PackageManager.java revision c7d62f02b8acfd0a6b31f8544ec2c07e780fe4bb
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.IntDef; 20import android.annotation.NonNull; 21import android.annotation.SdkConstant; 22import android.annotation.SdkConstant.SdkConstantType; 23import android.annotation.SystemApi; 24import android.app.PackageDeleteObserver; 25import android.app.PackageInstallObserver; 26import android.content.ComponentName; 27import android.content.Context; 28import android.content.Intent; 29import android.content.IntentFilter; 30import android.content.IntentSender; 31import android.content.pm.PackageParser.PackageParserException; 32import android.content.res.Resources; 33import android.content.res.XmlResourceParser; 34import android.graphics.Rect; 35import android.graphics.drawable.Drawable; 36import android.net.Uri; 37import android.os.Bundle; 38import android.os.Environment; 39import android.os.RemoteException; 40import android.os.UserHandle; 41import android.util.AndroidException; 42 43import java.io.File; 44import java.lang.annotation.Retention; 45import java.lang.annotation.RetentionPolicy; 46import java.util.List; 47 48/** 49 * Class for retrieving various kinds of information related to the application 50 * packages that are currently installed on the device. 51 * 52 * You can find this class through {@link Context#getPackageManager}. 53 */ 54public abstract class PackageManager { 55 56 /** 57 * This exception is thrown when a given package, application, or component 58 * name cannot be found. 59 */ 60 public static class NameNotFoundException extends AndroidException { 61 public NameNotFoundException() { 62 } 63 64 public NameNotFoundException(String name) { 65 super(name); 66 } 67 } 68 69 /** 70 * {@link PackageInfo} flag: return information about 71 * activities in the package in {@link PackageInfo#activities}. 72 */ 73 public static final int GET_ACTIVITIES = 0x00000001; 74 75 /** 76 * {@link PackageInfo} flag: return information about 77 * intent receivers in the package in 78 * {@link PackageInfo#receivers}. 79 */ 80 public static final int GET_RECEIVERS = 0x00000002; 81 82 /** 83 * {@link PackageInfo} flag: return information about 84 * services in the package in {@link PackageInfo#services}. 85 */ 86 public static final int GET_SERVICES = 0x00000004; 87 88 /** 89 * {@link PackageInfo} flag: return information about 90 * content providers in the package in 91 * {@link PackageInfo#providers}. 92 */ 93 public static final int GET_PROVIDERS = 0x00000008; 94 95 /** 96 * {@link PackageInfo} flag: return information about 97 * instrumentation in the package in 98 * {@link PackageInfo#instrumentation}. 99 */ 100 public static final int GET_INSTRUMENTATION = 0x00000010; 101 102 /** 103 * {@link PackageInfo} flag: return information about the 104 * intent filters supported by the activity. 105 */ 106 public static final int GET_INTENT_FILTERS = 0x00000020; 107 108 /** 109 * {@link PackageInfo} flag: return information about the 110 * signatures included in the package. 111 */ 112 public static final int GET_SIGNATURES = 0x00000040; 113 114 /** 115 * {@link ResolveInfo} flag: return the IntentFilter that 116 * was matched for a particular ResolveInfo in 117 * {@link ResolveInfo#filter}. 118 */ 119 public static final int GET_RESOLVED_FILTER = 0x00000040; 120 121 /** 122 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData} 123 * data {@link android.os.Bundle}s that are associated with a component. 124 * This applies for any API returning a ComponentInfo subclass. 125 */ 126 public static final int GET_META_DATA = 0x00000080; 127 128 /** 129 * {@link PackageInfo} flag: return the 130 * {@link PackageInfo#gids group ids} that are associated with an 131 * application. 132 * This applies for any API returning a PackageInfo class, either 133 * directly or nested inside of another. 134 */ 135 public static final int GET_GIDS = 0x00000100; 136 137 /** 138 * {@link PackageInfo} flag: include disabled components in the returned info. 139 */ 140 public static final int GET_DISABLED_COMPONENTS = 0x00000200; 141 142 /** 143 * {@link ApplicationInfo} flag: return the 144 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries} 145 * that are associated with an application. 146 * This applies for any API returning an ApplicationInfo class, either 147 * directly or nested inside of another. 148 */ 149 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400; 150 151 /** 152 * {@link ProviderInfo} flag: return the 153 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns} 154 * that are associated with a content provider. 155 * This applies for any API returning a ProviderInfo class, either 156 * directly or nested inside of another. 157 */ 158 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800; 159 /** 160 * {@link PackageInfo} flag: return information about 161 * permissions in the package in 162 * {@link PackageInfo#permissions}. 163 */ 164 public static final int GET_PERMISSIONS = 0x00001000; 165 166 /** 167 * Flag parameter to retrieve some information about all applications (even 168 * uninstalled ones) which have data directories. This state could have 169 * resulted if applications have been deleted with flag 170 * {@code DONT_DELETE_DATA} with a possibility of being replaced or 171 * reinstalled in future. 172 * <p> 173 * Note: this flag may cause less information about currently installed 174 * applications to be returned. 175 */ 176 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000; 177 178 /** 179 * {@link PackageInfo} flag: return information about 180 * hardware preferences in 181 * {@link PackageInfo#configPreferences PackageInfo.configPreferences}, 182 * and requested features in {@link PackageInfo#reqFeatures} and 183 * {@link PackageInfo#featureGroups}. 184 */ 185 public static final int GET_CONFIGURATIONS = 0x00004000; 186 187 /** 188 * {@link PackageInfo} flag: include disabled components which are in 189 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED} 190 * in the returned info. Note that if you set this flag, applications 191 * that are in this disabled state will be reported as enabled. 192 */ 193 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000; 194 195 /** 196 * Resolution and querying flag: if set, only filters that support the 197 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for 198 * matching. This is a synonym for including the CATEGORY_DEFAULT in your 199 * supplied Intent. 200 */ 201 public static final int MATCH_DEFAULT_ONLY = 0x00010000; 202 203 /** 204 * Resolution and querying flag: do not resolve intents cross-profile. 205 * @hide 206 */ 207 public static final int NO_CROSS_PROFILE = 0x00020000; 208 209 /** 210 * Flag for {@link addCrossProfileIntentFilter}: if this flag is set: 211 * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current 212 * profile will be skipped. 213 * Only activities in the target user can respond to the intent. 214 * @hide 215 */ 216 public static final int SKIP_CURRENT_PROFILE = 0x00000002; 217 218 /** @hide */ 219 @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED}) 220 @Retention(RetentionPolicy.SOURCE) 221 public @interface PermissionResult {} 222 223 /** 224 * Permission check result: this is returned by {@link #checkPermission} 225 * if the permission has been granted to the given package. 226 */ 227 public static final int PERMISSION_GRANTED = 0; 228 229 /** 230 * Permission check result: this is returned by {@link #checkPermission} 231 * if the permission has not been granted to the given package. 232 */ 233 public static final int PERMISSION_DENIED = -1; 234 235 /** 236 * Signature check result: this is returned by {@link #checkSignatures} 237 * if all signatures on the two packages match. 238 */ 239 public static final int SIGNATURE_MATCH = 0; 240 241 /** 242 * Signature check result: this is returned by {@link #checkSignatures} 243 * if neither of the two packages is signed. 244 */ 245 public static final int SIGNATURE_NEITHER_SIGNED = 1; 246 247 /** 248 * Signature check result: this is returned by {@link #checkSignatures} 249 * if the first package is not signed but the second is. 250 */ 251 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1; 252 253 /** 254 * Signature check result: this is returned by {@link #checkSignatures} 255 * if the second package is not signed but the first is. 256 */ 257 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2; 258 259 /** 260 * Signature check result: this is returned by {@link #checkSignatures} 261 * if not all signatures on both packages match. 262 */ 263 public static final int SIGNATURE_NO_MATCH = -3; 264 265 /** 266 * Signature check result: this is returned by {@link #checkSignatures} 267 * if either of the packages are not valid. 268 */ 269 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4; 270 271 /** 272 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 273 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 274 * component or application is in its default enabled state (as specified 275 * in its manifest). 276 */ 277 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; 278 279 /** 280 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 281 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 282 * component or application has been explictily enabled, regardless of 283 * what it has specified in its manifest. 284 */ 285 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1; 286 287 /** 288 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 289 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 290 * component or application has been explicitly disabled, regardless of 291 * what it has specified in its manifest. 292 */ 293 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; 294 295 /** 296 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The 297 * user has explicitly disabled the application, regardless of what it has 298 * specified in its manifest. Because this is due to the user's request, 299 * they may re-enable it if desired through the appropriate system UI. This 300 * option currently <strong>cannot</strong> be used with 301 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 302 */ 303 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3; 304 305 /** 306 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This 307 * application should be considered, until the point where the user actually 308 * wants to use it. This means that it will not normally show up to the user 309 * (such as in the launcher), but various parts of the user interface can 310 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow 311 * the user to select it (as for example an IME, device admin, etc). Such code, 312 * once the user has selected the app, should at that point also make it enabled. 313 * This option currently <strong>can not</strong> be used with 314 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 315 */ 316 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4; 317 318 /** 319 * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to 320 * indicate that this package should be installed as forward locked, i.e. only the app itself 321 * should have access to its code and non-resource assets. 322 * @hide 323 */ 324 public static final int INSTALL_FORWARD_LOCK = 0x00000001; 325 326 /** 327 * Flag parameter for {@link #installPackage} to indicate that you want to replace an already 328 * installed package, if one exists. 329 * @hide 330 */ 331 public static final int INSTALL_REPLACE_EXISTING = 0x00000002; 332 333 /** 334 * Flag parameter for {@link #installPackage} to indicate that you want to 335 * allow test packages (those that have set android:testOnly in their 336 * manifest) to be installed. 337 * @hide 338 */ 339 public static final int INSTALL_ALLOW_TEST = 0x00000004; 340 341 /** 342 * Flag parameter for {@link #installPackage} to indicate that this 343 * package has to be installed on the sdcard. 344 * @hide 345 */ 346 public static final int INSTALL_EXTERNAL = 0x00000008; 347 348 /** 349 * Flag parameter for {@link #installPackage} to indicate that this package 350 * has to be installed on the sdcard. 351 * @hide 352 */ 353 public static final int INSTALL_INTERNAL = 0x00000010; 354 355 /** 356 * Flag parameter for {@link #installPackage} to indicate that this install 357 * was initiated via ADB. 358 * 359 * @hide 360 */ 361 public static final int INSTALL_FROM_ADB = 0x00000020; 362 363 /** 364 * Flag parameter for {@link #installPackage} to indicate that this install 365 * should immediately be visible to all users. 366 * 367 * @hide 368 */ 369 public static final int INSTALL_ALL_USERS = 0x00000040; 370 371 /** 372 * Flag parameter for {@link #installPackage} to indicate that it is okay 373 * to install an update to an app where the newly installed app has a lower 374 * version code than the currently installed app. 375 * 376 * @hide 377 */ 378 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080; 379 380 /** 381 * Flag parameter for 382 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate 383 * that you don't want to kill the app containing the component. Be careful when you set this 384 * since changing component states can make the containing application's behavior unpredictable. 385 */ 386 public static final int DONT_KILL_APP = 0x00000001; 387 388 /** 389 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 390 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success. 391 * @hide 392 */ 393 @SystemApi 394 public static final int INSTALL_SUCCEEDED = 1; 395 396 /** 397 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 398 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is 399 * already installed. 400 * @hide 401 */ 402 @SystemApi 403 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1; 404 405 /** 406 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 407 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive 408 * file is invalid. 409 * @hide 410 */ 411 @SystemApi 412 public static final int INSTALL_FAILED_INVALID_APK = -2; 413 414 /** 415 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 416 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in 417 * is invalid. 418 * @hide 419 */ 420 @SystemApi 421 public static final int INSTALL_FAILED_INVALID_URI = -3; 422 423 /** 424 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 425 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager 426 * service found that the device didn't have enough storage space to install the app. 427 * @hide 428 */ 429 @SystemApi 430 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; 431 432 /** 433 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 434 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a 435 * package is already installed with the same name. 436 * @hide 437 */ 438 @SystemApi 439 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; 440 441 /** 442 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 443 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 444 * the requested shared user does not exist. 445 * @hide 446 */ 447 @SystemApi 448 public static final int INSTALL_FAILED_NO_SHARED_USER = -6; 449 450 /** 451 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 452 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 453 * a previously installed package of the same name has a different signature 454 * than the new package (and the old package's data was not removed). 455 * @hide 456 */ 457 @SystemApi 458 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; 459 460 /** 461 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 462 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 463 * the new package is requested a shared user which is already installed on the 464 * device and does not have matching signature. 465 * @hide 466 */ 467 @SystemApi 468 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; 469 470 /** 471 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 472 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 473 * the new package uses a shared library that is not available. 474 * @hide 475 */ 476 @SystemApi 477 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; 478 479 /** 480 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 481 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 482 * the new package uses a shared library that is not available. 483 * @hide 484 */ 485 @SystemApi 486 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; 487 488 /** 489 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 490 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 491 * the new package failed while optimizing and validating its dex files, 492 * either because there was not enough storage or the validation failed. 493 * @hide 494 */ 495 @SystemApi 496 public static final int INSTALL_FAILED_DEXOPT = -11; 497 498 /** 499 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 500 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 501 * the new package failed because the current SDK version is older than 502 * that required by the package. 503 * @hide 504 */ 505 @SystemApi 506 public static final int INSTALL_FAILED_OLDER_SDK = -12; 507 508 /** 509 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 510 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 511 * the new package failed because it contains a content provider with the 512 * same authority as a provider already installed in the system. 513 * @hide 514 */ 515 @SystemApi 516 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; 517 518 /** 519 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 520 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 521 * the new package failed because the current SDK version is newer than 522 * that required by the package. 523 * @hide 524 */ 525 @SystemApi 526 public static final int INSTALL_FAILED_NEWER_SDK = -14; 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 failed because it has specified that it is a test-only 532 * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST} 533 * flag. 534 * @hide 535 */ 536 @SystemApi 537 public static final int INSTALL_FAILED_TEST_ONLY = -15; 538 539 /** 540 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 541 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 542 * the package being installed contains native code, but none that is 543 * compatible with the device's CPU_ABI. 544 * @hide 545 */ 546 @SystemApi 547 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; 548 549 /** 550 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 551 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 552 * the new package uses a feature that is not available. 553 * @hide 554 */ 555 @SystemApi 556 public static final int INSTALL_FAILED_MISSING_FEATURE = -17; 557 558 // ------ Errors related to sdcard 559 /** 560 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 561 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 562 * a secure container mount point couldn't be accessed on external media. 563 * @hide 564 */ 565 @SystemApi 566 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18; 567 568 /** 569 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 570 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 571 * the new package couldn't be installed in the specified install 572 * location. 573 * @hide 574 */ 575 @SystemApi 576 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; 577 578 /** 579 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 580 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 581 * the new package couldn't be installed in the specified install 582 * location because the media is not available. 583 * @hide 584 */ 585 @SystemApi 586 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; 587 588 /** 589 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 590 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 591 * the new package couldn't be installed because the verification timed out. 592 * @hide 593 */ 594 @SystemApi 595 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21; 596 597 /** 598 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 599 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 600 * the new package couldn't be installed because the verification did not succeed. 601 * @hide 602 */ 603 @SystemApi 604 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22; 605 606 /** 607 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 608 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 609 * the package changed from what the calling program expected. 610 * @hide 611 */ 612 @SystemApi 613 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; 614 615 /** 616 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 617 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 618 * the new package is assigned a different UID than it previously held. 619 * @hide 620 */ 621 public static final int INSTALL_FAILED_UID_CHANGED = -24; 622 623 /** 624 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 625 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 626 * the new package has an older version code than the currently installed package. 627 * @hide 628 */ 629 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25; 630 631 /** 632 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 633 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 634 * if the parser was given a path that is not a file, or does not end with the expected 635 * '.apk' extension. 636 * @hide 637 */ 638 @SystemApi 639 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100; 640 641 /** 642 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 643 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 644 * if the parser was unable to retrieve the AndroidManifest.xml file. 645 * @hide 646 */ 647 @SystemApi 648 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; 649 650 /** 651 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 652 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 653 * if the parser encountered an unexpected exception. 654 * @hide 655 */ 656 @SystemApi 657 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; 658 659 /** 660 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 661 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 662 * if the parser did not find any certificates in the .apk. 663 * @hide 664 */ 665 @SystemApi 666 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; 667 668 /** 669 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 670 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 671 * if the parser found inconsistent certificates on the files in the .apk. 672 * @hide 673 */ 674 @SystemApi 675 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; 676 677 /** 678 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 679 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 680 * if the parser encountered a CertificateEncodingException in one of the 681 * files in the .apk. 682 * @hide 683 */ 684 @SystemApi 685 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; 686 687 /** 688 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 689 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 690 * if the parser encountered a bad or missing package name in the manifest. 691 * @hide 692 */ 693 @SystemApi 694 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; 695 696 /** 697 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 698 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 699 * if the parser encountered a bad shared user id name in the manifest. 700 * @hide 701 */ 702 @SystemApi 703 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; 704 705 /** 706 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 707 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 708 * if the parser encountered some structural problem in the manifest. 709 * @hide 710 */ 711 @SystemApi 712 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; 713 714 /** 715 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 716 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 717 * if the parser did not find any actionable tags (instrumentation or application) 718 * in the manifest. 719 * @hide 720 */ 721 @SystemApi 722 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; 723 724 /** 725 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 726 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 727 * if the system failed to install the package because of system issues. 728 * @hide 729 */ 730 @SystemApi 731 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110; 732 733 /** 734 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 735 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 736 * if the system failed to install the package because the user is restricted from installing 737 * apps. 738 * @hide 739 */ 740 public static final int INSTALL_FAILED_USER_RESTRICTED = -111; 741 742 /** 743 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 744 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 745 * if the system failed to install the package because it is attempting to define a 746 * permission that is already defined by some existing package. 747 * 748 * <p>The package name of the app which has already defined the permission is passed to 749 * a {@link PackageInstallObserver}, if any, as the {@link #EXTRA_EXISTING_PACKAGE} 750 * string extra; and the name of the permission being redefined is passed in the 751 * {@link #EXTRA_EXISTING_PERMISSION} string extra. 752 * @hide 753 */ 754 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112; 755 756 /** 757 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 758 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 759 * if the system failed to install the package because its packaged native code did not 760 * match any of the ABIs supported by the system. 761 * 762 * @hide 763 */ 764 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113; 765 766 /** 767 * Internal return code for NativeLibraryHelper methods to indicate that the package 768 * being processed did not contain any native code. This is placed here only so that 769 * it can belong to the same value space as the other install failure codes. 770 * 771 * @hide 772 */ 773 public static final int NO_NATIVE_LIBRARIES = -114; 774 775 /** {@hide} */ 776 public static final int INSTALL_FAILED_ABORTED = -115; 777 778 /** 779 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the 780 * package's data directory. 781 * 782 * @hide 783 */ 784 public static final int DELETE_KEEP_DATA = 0x00000001; 785 786 /** 787 * Flag parameter for {@link #deletePackage} to indicate that you want the 788 * package deleted for all users. 789 * 790 * @hide 791 */ 792 public static final int DELETE_ALL_USERS = 0x00000002; 793 794 /** 795 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling 796 * uninstall on a system that has been updated, then don't do the normal process 797 * of uninstalling the update and rolling back to the older system version (which 798 * needs to happen for all users); instead, just mark the app as uninstalled for 799 * the current user. 800 * 801 * @hide 802 */ 803 public static final int DELETE_SYSTEM_APP = 0x00000004; 804 805 /** 806 * Return code for when package deletion succeeds. This is passed to the 807 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 808 * succeeded in deleting the package. 809 * 810 * @hide 811 */ 812 public static final int DELETE_SUCCEEDED = 1; 813 814 /** 815 * Deletion failed return code: this is passed to the 816 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 817 * failed to delete the package for an unspecified reason. 818 * 819 * @hide 820 */ 821 public static final int DELETE_FAILED_INTERNAL_ERROR = -1; 822 823 /** 824 * Deletion failed return code: this is passed to the 825 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 826 * failed to delete the package because it is the active DevicePolicy 827 * manager. 828 * 829 * @hide 830 */ 831 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; 832 833 /** 834 * Deletion failed return code: this is passed to the 835 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 836 * failed to delete the package since the user is restricted. 837 * 838 * @hide 839 */ 840 public static final int DELETE_FAILED_USER_RESTRICTED = -3; 841 842 /** 843 * Deletion failed return code: this is passed to the 844 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 845 * failed to delete the package because a profile 846 * or device owner has marked the package as uninstallable. 847 * 848 * @hide 849 */ 850 public static final int DELETE_FAILED_OWNER_BLOCKED = -4; 851 852 /** {@hide} */ 853 public static final int DELETE_FAILED_ABORTED = -5; 854 855 /** 856 * Return code that is passed to the {@link IPackageMoveObserver} by 857 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the 858 * package has been successfully moved by the system. 859 * 860 * @hide 861 */ 862 public static final int MOVE_SUCCEEDED = 1; 863 /** 864 * Error code that is passed to the {@link IPackageMoveObserver} by 865 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 866 * when the package hasn't been successfully moved by the system 867 * because of insufficient memory on specified media. 868 * @hide 869 */ 870 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1; 871 872 /** 873 * Error code that is passed to the {@link IPackageMoveObserver} by 874 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 875 * if the specified package doesn't exist. 876 * @hide 877 */ 878 public static final int MOVE_FAILED_DOESNT_EXIST = -2; 879 880 /** 881 * Error code that is passed to the {@link IPackageMoveObserver} by 882 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 883 * if the specified package cannot be moved since its a system package. 884 * @hide 885 */ 886 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3; 887 888 /** 889 * Error code that is passed to the {@link IPackageMoveObserver} by 890 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 891 * if the specified package cannot be moved since its forward locked. 892 * @hide 893 */ 894 public static final int MOVE_FAILED_FORWARD_LOCKED = -4; 895 896 /** 897 * Error code that is passed to the {@link IPackageMoveObserver} by 898 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 899 * if the specified package cannot be moved to the specified location. 900 * @hide 901 */ 902 public static final int MOVE_FAILED_INVALID_LOCATION = -5; 903 904 /** 905 * Error code that is passed to the {@link IPackageMoveObserver} by 906 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 907 * if the specified package cannot be moved to the specified location. 908 * @hide 909 */ 910 public static final int MOVE_FAILED_INTERNAL_ERROR = -6; 911 912 /** 913 * Error code that is passed to the {@link IPackageMoveObserver} by 914 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the 915 * specified package already has an operation pending in the 916 * {@link PackageHandler} queue. 917 * 918 * @hide 919 */ 920 public static final int MOVE_FAILED_OPERATION_PENDING = -7; 921 922 /** 923 * Flag parameter for {@link #movePackage} to indicate that 924 * the package should be moved to internal storage if its 925 * been installed on external media. 926 * @hide 927 */ 928 public static final int MOVE_INTERNAL = 0x00000001; 929 930 /** 931 * Flag parameter for {@link #movePackage} to indicate that 932 * the package should be moved to external media. 933 * @hide 934 */ 935 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; 936 937 /** 938 * Usable by the required verifier as the {@code verificationCode} argument 939 * for {@link PackageManager#verifyPendingInstall} to indicate that it will 940 * allow the installation to proceed without any of the optional verifiers 941 * needing to vote. 942 * 943 * @hide 944 */ 945 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2; 946 947 /** 948 * Used as the {@code verificationCode} argument for 949 * {@link PackageManager#verifyPendingInstall} to indicate that the calling 950 * package verifier allows the installation to proceed. 951 */ 952 public static final int VERIFICATION_ALLOW = 1; 953 954 /** 955 * Used as the {@code verificationCode} argument for 956 * {@link PackageManager#verifyPendingInstall} to indicate the calling 957 * package verifier does not vote to allow the installation to proceed. 958 */ 959 public static final int VERIFICATION_REJECT = -1; 960 961 /** 962 * Can be used as the {@code millisecondsToDelay} argument for 963 * {@link PackageManager#extendVerificationTimeout}. This is the 964 * maximum time {@code PackageManager} waits for the verification 965 * agent to return (in milliseconds). 966 */ 967 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000; 968 969 /** 970 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's 971 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or 972 * lag in sound input or output. 973 */ 974 @SdkConstant(SdkConstantType.FEATURE) 975 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency"; 976 977 /** 978 * Feature for {@link #getSystemAvailableFeatures} and 979 * {@link #hasSystemFeature}: The device is capable of communicating with 980 * other devices via Bluetooth. 981 */ 982 @SdkConstant(SdkConstantType.FEATURE) 983 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 984 985 /** 986 * Feature for {@link #getSystemAvailableFeatures} and 987 * {@link #hasSystemFeature}: The device is capable of communicating with 988 * other devices via Bluetooth Low Energy radio. 989 */ 990 @SdkConstant(SdkConstantType.FEATURE) 991 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le"; 992 993 /** 994 * Feature for {@link #getSystemAvailableFeatures} and 995 * {@link #hasSystemFeature}: The device has a camera facing away 996 * from the screen. 997 */ 998 @SdkConstant(SdkConstantType.FEATURE) 999 public static final String FEATURE_CAMERA = "android.hardware.camera"; 1000 1001 /** 1002 * Feature for {@link #getSystemAvailableFeatures} and 1003 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 1004 */ 1005 @SdkConstant(SdkConstantType.FEATURE) 1006 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 1007 1008 /** 1009 * Feature for {@link #getSystemAvailableFeatures} and 1010 * {@link #hasSystemFeature}: The device has at least one camera pointing in 1011 * some direction, or can support an external camera being connected to it. 1012 */ 1013 @SdkConstant(SdkConstantType.FEATURE) 1014 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any"; 1015 1016 /** 1017 * Feature for {@link #getSystemAvailableFeatures} and 1018 * {@link #hasSystemFeature}: The device can support having an external camera connected to it. 1019 * The external camera may not always be connected or available to applications to use. 1020 */ 1021 @SdkConstant(SdkConstantType.FEATURE) 1022 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external"; 1023 1024 /** 1025 * Feature for {@link #getSystemAvailableFeatures} and 1026 * {@link #hasSystemFeature}: The device's camera supports flash. 1027 */ 1028 @SdkConstant(SdkConstantType.FEATURE) 1029 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 1030 1031 /** 1032 * Feature for {@link #getSystemAvailableFeatures} and 1033 * {@link #hasSystemFeature}: The device has a front facing camera. 1034 */ 1035 @SdkConstant(SdkConstantType.FEATURE) 1036 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 1037 1038 /** 1039 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1040 * of the cameras on the device supports the 1041 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware} 1042 * capability level. 1043 */ 1044 @SdkConstant(SdkConstantType.FEATURE) 1045 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full"; 1046 1047 /** 1048 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1049 * of the cameras on the device supports the 1050 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor} 1051 * capability level. 1052 */ 1053 @SdkConstant(SdkConstantType.FEATURE) 1054 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR = 1055 "android.hardware.camera.capability.manual_sensor"; 1056 1057 /** 1058 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1059 * of the cameras on the device supports the 1060 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing} 1061 * capability level. 1062 */ 1063 @SdkConstant(SdkConstantType.FEATURE) 1064 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING = 1065 "android.hardware.camera.capability.manual_post_processing"; 1066 1067 /** 1068 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1069 * of the cameras on the device supports the 1070 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW} 1071 * capability level. 1072 */ 1073 @SdkConstant(SdkConstantType.FEATURE) 1074 public static final String FEATURE_CAMERA_CAPABILITY_RAW = 1075 "android.hardware.camera.capability.raw"; 1076 1077 /** 1078 * Feature for {@link #getSystemAvailableFeatures} and 1079 * {@link #hasSystemFeature}: The device is capable of communicating with 1080 * consumer IR devices. 1081 */ 1082 @SdkConstant(SdkConstantType.FEATURE) 1083 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir"; 1084 1085 /** 1086 * Feature for {@link #getSystemAvailableFeatures} and 1087 * {@link #hasSystemFeature}: The device supports one or more methods of 1088 * reporting current location. 1089 */ 1090 @SdkConstant(SdkConstantType.FEATURE) 1091 public static final String FEATURE_LOCATION = "android.hardware.location"; 1092 1093 /** 1094 * Feature for {@link #getSystemAvailableFeatures} and 1095 * {@link #hasSystemFeature}: The device has a Global Positioning System 1096 * receiver and can report precise location. 1097 */ 1098 @SdkConstant(SdkConstantType.FEATURE) 1099 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 1100 1101 /** 1102 * Feature for {@link #getSystemAvailableFeatures} and 1103 * {@link #hasSystemFeature}: The device can report location with coarse 1104 * accuracy using a network-based geolocation system. 1105 */ 1106 @SdkConstant(SdkConstantType.FEATURE) 1107 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 1108 1109 /** 1110 * Feature for {@link #getSystemAvailableFeatures} and 1111 * {@link #hasSystemFeature}: The device can record audio via a 1112 * microphone. 1113 */ 1114 @SdkConstant(SdkConstantType.FEATURE) 1115 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 1116 1117 /** 1118 * Feature for {@link #getSystemAvailableFeatures} and 1119 * {@link #hasSystemFeature}: The device can communicate using Near-Field 1120 * Communications (NFC). 1121 */ 1122 @SdkConstant(SdkConstantType.FEATURE) 1123 public static final String FEATURE_NFC = "android.hardware.nfc"; 1124 1125 /** 1126 * Feature for {@link #getSystemAvailableFeatures} and 1127 * {@link #hasSystemFeature}: The device supports host- 1128 * based NFC card emulation. 1129 * 1130 * TODO remove when depending apps have moved to new constant. 1131 * @hide 1132 * @deprecated 1133 */ 1134 @Deprecated 1135 @SdkConstant(SdkConstantType.FEATURE) 1136 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce"; 1137 1138 /** 1139 * Feature for {@link #getSystemAvailableFeatures} and 1140 * {@link #hasSystemFeature}: The device supports host- 1141 * based NFC card emulation. 1142 */ 1143 @SdkConstant(SdkConstantType.FEATURE) 1144 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; 1145 1146 /** 1147 * Feature for {@link #getSystemAvailableFeatures} and 1148 * {@link #hasSystemFeature}: The device supports the OpenGL ES 1149 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 1150 * Android Extension Pack</a>. 1151 */ 1152 @SdkConstant(SdkConstantType.FEATURE) 1153 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 1154 1155 /** 1156 * Feature for {@link #getSystemAvailableFeatures} and 1157 * {@link #hasSystemFeature}: The device includes an accelerometer. 1158 */ 1159 @SdkConstant(SdkConstantType.FEATURE) 1160 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 1161 1162 /** 1163 * Feature for {@link #getSystemAvailableFeatures} and 1164 * {@link #hasSystemFeature}: The device includes a barometer (air 1165 * pressure sensor.) 1166 */ 1167 @SdkConstant(SdkConstantType.FEATURE) 1168 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 1169 1170 /** 1171 * Feature for {@link #getSystemAvailableFeatures} and 1172 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 1173 */ 1174 @SdkConstant(SdkConstantType.FEATURE) 1175 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 1176 1177 /** 1178 * Feature for {@link #getSystemAvailableFeatures} and 1179 * {@link #hasSystemFeature}: The device includes a gyroscope. 1180 */ 1181 @SdkConstant(SdkConstantType.FEATURE) 1182 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 1183 1184 /** 1185 * Feature for {@link #getSystemAvailableFeatures} and 1186 * {@link #hasSystemFeature}: The device includes a light sensor. 1187 */ 1188 @SdkConstant(SdkConstantType.FEATURE) 1189 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 1190 1191 /** 1192 * Feature for {@link #getSystemAvailableFeatures} and 1193 * {@link #hasSystemFeature}: The device includes a proximity sensor. 1194 */ 1195 @SdkConstant(SdkConstantType.FEATURE) 1196 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 1197 1198 /** 1199 * Feature for {@link #getSystemAvailableFeatures} and 1200 * {@link #hasSystemFeature}: The device includes a hardware step counter. 1201 */ 1202 @SdkConstant(SdkConstantType.FEATURE) 1203 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 1204 1205 /** 1206 * Feature for {@link #getSystemAvailableFeatures} and 1207 * {@link #hasSystemFeature}: The device includes a hardware step detector. 1208 */ 1209 @SdkConstant(SdkConstantType.FEATURE) 1210 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 1211 1212 /** 1213 * Feature for {@link #getSystemAvailableFeatures} and 1214 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 1215 */ 1216 @SdkConstant(SdkConstantType.FEATURE) 1217 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 1218 1219 /** 1220 * Feature for {@link #getSystemAvailableFeatures} and 1221 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocargiogram. 1222 */ 1223 @SdkConstant(SdkConstantType.FEATURE) 1224 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 1225 "android.hardware.sensor.heartrate.ecg"; 1226 1227 /** 1228 * Feature for {@link #getSystemAvailableFeatures} and 1229 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 1230 */ 1231 @SdkConstant(SdkConstantType.FEATURE) 1232 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 1233 "android.hardware.sensor.relative_humidity"; 1234 1235 /** 1236 * Feature for {@link #getSystemAvailableFeatures} and 1237 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 1238 */ 1239 @SdkConstant(SdkConstantType.FEATURE) 1240 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 1241 "android.hardware.sensor.ambient_temperature"; 1242 1243 /** 1244 * Feature for {@link #getSystemAvailableFeatures} and 1245 * {@link #hasSystemFeature}: The device has a telephony radio with data 1246 * communication support. 1247 */ 1248 @SdkConstant(SdkConstantType.FEATURE) 1249 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 1250 1251 /** 1252 * Feature for {@link #getSystemAvailableFeatures} and 1253 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 1254 */ 1255 @SdkConstant(SdkConstantType.FEATURE) 1256 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 1257 1258 /** 1259 * Feature for {@link #getSystemAvailableFeatures} and 1260 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 1261 */ 1262 @SdkConstant(SdkConstantType.FEATURE) 1263 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 1264 1265 /** 1266 * Feature for {@link #getSystemAvailableFeatures} and 1267 * {@link #hasSystemFeature}: The device supports connecting to USB devices 1268 * as the USB host. 1269 */ 1270 @SdkConstant(SdkConstantType.FEATURE) 1271 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 1272 1273 /** 1274 * Feature for {@link #getSystemAvailableFeatures} and 1275 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 1276 */ 1277 @SdkConstant(SdkConstantType.FEATURE) 1278 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 1279 1280 /** 1281 * Feature for {@link #getSystemAvailableFeatures} and 1282 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 1283 */ 1284 @SdkConstant(SdkConstantType.FEATURE) 1285 public static final String FEATURE_SIP = "android.software.sip"; 1286 1287 /** 1288 * Feature for {@link #getSystemAvailableFeatures} and 1289 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 1290 */ 1291 @SdkConstant(SdkConstantType.FEATURE) 1292 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 1293 1294 /** 1295 * Feature for {@link #getSystemAvailableFeatures} and 1296 * {@link #hasSystemFeature}: The device's display has a touch screen. 1297 */ 1298 @SdkConstant(SdkConstantType.FEATURE) 1299 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 1300 1301 1302 /** 1303 * Feature for {@link #getSystemAvailableFeatures} and 1304 * {@link #hasSystemFeature}: The device's touch screen supports 1305 * multitouch sufficient for basic two-finger gesture detection. 1306 */ 1307 @SdkConstant(SdkConstantType.FEATURE) 1308 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 1309 1310 /** 1311 * Feature for {@link #getSystemAvailableFeatures} and 1312 * {@link #hasSystemFeature}: The device's touch screen is capable of 1313 * tracking two or more fingers fully independently. 1314 */ 1315 @SdkConstant(SdkConstantType.FEATURE) 1316 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 1317 1318 /** 1319 * Feature for {@link #getSystemAvailableFeatures} and 1320 * {@link #hasSystemFeature}: The device's touch screen is capable of 1321 * tracking a full hand of fingers fully independently -- that is, 5 or 1322 * more simultaneous independent pointers. 1323 */ 1324 @SdkConstant(SdkConstantType.FEATURE) 1325 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 1326 1327 /** 1328 * Feature for {@link #getSystemAvailableFeatures} and 1329 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1330 * does support touch emulation for basic events. For instance, the 1331 * device might use a mouse or remote control to drive a cursor, and 1332 * emulate basic touch pointer events like down, up, drag, etc. All 1333 * devices that support android.hardware.touchscreen or a sub-feature are 1334 * presumed to also support faketouch. 1335 */ 1336 @SdkConstant(SdkConstantType.FEATURE) 1337 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 1338 1339 /** 1340 * Feature for {@link #getSystemAvailableFeatures} and 1341 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1342 * does support touch emulation for basic events that supports distinct 1343 * tracking of two or more fingers. This is an extension of 1344 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1345 * that unlike a distinct multitouch screen as defined by 1346 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 1347 * devices will not actually provide full two-finger gestures since the 1348 * input is being transformed to cursor movement on the screen. That is, 1349 * single finger gestures will move a cursor; two-finger swipes will 1350 * result in single-finger touch events; other two-finger gestures will 1351 * result in the corresponding two-finger touch event. 1352 */ 1353 @SdkConstant(SdkConstantType.FEATURE) 1354 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 1355 1356 /** 1357 * Feature for {@link #getSystemAvailableFeatures} and 1358 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1359 * does support touch emulation for basic events that supports tracking 1360 * a hand of fingers (5 or more fingers) fully independently. 1361 * This is an extension of 1362 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1363 * that unlike a multitouch screen as defined by 1364 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 1365 * gestures can be detected due to the limitations described for 1366 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 1367 */ 1368 @SdkConstant(SdkConstantType.FEATURE) 1369 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 1370 1371 /** 1372 * Feature for {@link #getSystemAvailableFeatures} and 1373 * {@link #hasSystemFeature}: The device supports portrait orientation 1374 * screens. For backwards compatibility, you can assume that if neither 1375 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 1376 * both portrait and landscape. 1377 */ 1378 @SdkConstant(SdkConstantType.FEATURE) 1379 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 1380 1381 /** 1382 * Feature for {@link #getSystemAvailableFeatures} and 1383 * {@link #hasSystemFeature}: The device supports landscape orientation 1384 * screens. For backwards compatibility, you can assume that if neither 1385 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 1386 * both portrait and landscape. 1387 */ 1388 @SdkConstant(SdkConstantType.FEATURE) 1389 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 1390 1391 /** 1392 * Feature for {@link #getSystemAvailableFeatures} and 1393 * {@link #hasSystemFeature}: The device supports live wallpapers. 1394 */ 1395 @SdkConstant(SdkConstantType.FEATURE) 1396 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 1397 /** 1398 * Feature for {@link #getSystemAvailableFeatures} and 1399 * {@link #hasSystemFeature}: The device supports app widgets. 1400 */ 1401 @SdkConstant(SdkConstantType.FEATURE) 1402 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 1403 1404 /** 1405 * @hide 1406 * Feature for {@link #getSystemAvailableFeatures} and 1407 * {@link #hasSystemFeature}: The device supports 1408 * {@link android.service.voice.VoiceInteractionService} and 1409 * {@link android.app.VoiceInteractor}. 1410 */ 1411 @SdkConstant(SdkConstantType.FEATURE) 1412 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 1413 1414 1415 /** 1416 * Feature for {@link #getSystemAvailableFeatures} and 1417 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 1418 * by third party applications. 1419 */ 1420 @SdkConstant(SdkConstantType.FEATURE) 1421 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 1422 1423 /** 1424 * Feature for {@link #getSystemAvailableFeatures} and 1425 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 1426 * with the {@link android.inputmethodservice.InputMethodService} API. 1427 */ 1428 @SdkConstant(SdkConstantType.FEATURE) 1429 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 1430 1431 /** 1432 * Feature for {@link #getSystemAvailableFeatures} and 1433 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 1434 */ 1435 @SdkConstant(SdkConstantType.FEATURE) 1436 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 1437 1438 /** 1439 * Feature for {@link #getSystemAvailableFeatures} and 1440 * {@link #hasSystemFeature}: The device supports leanback UI. This is 1441 * typically used in a living room television experience, but is a software 1442 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 1443 * feature will use resources associated with the "television" UI mode. 1444 */ 1445 @SdkConstant(SdkConstantType.FEATURE) 1446 public static final String FEATURE_LEANBACK = "android.software.leanback"; 1447 1448 /** 1449 * Feature for {@link #getSystemAvailableFeatures} and 1450 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 1451 * applications designed for this experience should be run, though this is 1452 * not enforced by the system. 1453 * @hide 1454 */ 1455 @SdkConstant(SdkConstantType.FEATURE) 1456 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 1457 1458 /** 1459 * Feature for {@link #getSystemAvailableFeatures} and 1460 * {@link #hasSystemFeature}: The device supports live TV and can display 1461 * contents from TV inputs implemented with the 1462 * {@link android.media.tv.TvInputService} API. 1463 */ 1464 @SdkConstant(SdkConstantType.FEATURE) 1465 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 1466 1467 /** 1468 * Feature for {@link #getSystemAvailableFeatures} and 1469 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 1470 */ 1471 @SdkConstant(SdkConstantType.FEATURE) 1472 public static final String FEATURE_WIFI = "android.hardware.wifi"; 1473 1474 /** 1475 * Feature for {@link #getSystemAvailableFeatures} and 1476 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 1477 */ 1478 @SdkConstant(SdkConstantType.FEATURE) 1479 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 1480 1481 /** 1482 * Feature for {@link #getSystemAvailableFeatures} and 1483 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1484 * on a television. Television here is defined to be a typical living 1485 * room television experience: displayed on a big screen, where the user 1486 * is sitting far away from it, and the dominant form of input will be 1487 * something like a DPAD, not through touch or mouse. 1488 * @deprecated use {@link #FEATURE_LEANBACK} instead. 1489 */ 1490 @Deprecated 1491 @SdkConstant(SdkConstantType.FEATURE) 1492 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 1493 1494 /** 1495 * Feature for {@link #getSystemAvailableFeatures} and 1496 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1497 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 1498 * the wrist. The user is very close when interacting with the device. 1499 */ 1500 @SdkConstant(SdkConstantType.FEATURE) 1501 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 1502 1503 /** 1504 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1505 * The device supports printing. 1506 */ 1507 @SdkConstant(SdkConstantType.FEATURE) 1508 public static final String FEATURE_PRINTING = "android.software.print"; 1509 1510 /** 1511 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1512 * The device can perform backup and restore operations on installed applications. 1513 */ 1514 @SdkConstant(SdkConstantType.FEATURE) 1515 public static final String FEATURE_BACKUP = "android.software.backup"; 1516 1517 /** 1518 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1519 * The device supports managed profiles for enterprise users. 1520 */ 1521 @SdkConstant(SdkConstantType.FEATURE) 1522 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_profiles"; 1523 1524 /** 1525 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1526 * The device has a full implementation of the android.webkit.* APIs. Devices 1527 * lacking this feature will not have a functioning WebView implementation. 1528 */ 1529 @SdkConstant(SdkConstantType.FEATURE) 1530 public static final String FEATURE_WEBVIEW = "android.software.webview"; 1531 1532 /** 1533 * Feature for {@link #getSystemAvailableFeatures} and 1534 * {@link #hasSystemFeature}: This device supports ethernet. 1535 * @hide 1536 */ 1537 @SdkConstant(SdkConstantType.FEATURE) 1538 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 1539 1540 /** 1541 * Feature for {@link #getSystemAvailableFeatures} and 1542 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 1543 * @hide 1544 */ 1545 @SdkConstant(SdkConstantType.FEATURE) 1546 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 1547 1548 /** 1549 * Action to external storage service to clean out removed apps. 1550 * @hide 1551 */ 1552 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 1553 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 1554 1555 /** 1556 * Extra field name for the URI to a verification file. Passed to a package 1557 * verifier. 1558 * 1559 * @hide 1560 */ 1561 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 1562 1563 /** 1564 * Extra field name for the ID of a package pending verification. Passed to 1565 * a package verifier and is used to call back to 1566 * {@link PackageManager#verifyPendingInstall(int, int)} 1567 */ 1568 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 1569 1570 /** 1571 * Extra field name for the package identifier which is trying to install 1572 * the package. 1573 * 1574 * @hide 1575 */ 1576 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 1577 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 1578 1579 /** 1580 * Extra field name for the requested install flags for a package pending 1581 * verification. Passed to a package verifier. 1582 * 1583 * @hide 1584 */ 1585 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 1586 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 1587 1588 /** 1589 * Extra field name for the uid of who is requesting to install 1590 * the package. 1591 * 1592 * @hide 1593 */ 1594 public static final String EXTRA_VERIFICATION_INSTALLER_UID 1595 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 1596 1597 /** 1598 * Extra field name for the package name of a package pending verification. 1599 * 1600 * @hide 1601 */ 1602 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 1603 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 1604 /** 1605 * Extra field name for the result of a verification, either 1606 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 1607 * Passed to package verifiers after a package is verified. 1608 */ 1609 public static final String EXTRA_VERIFICATION_RESULT 1610 = "android.content.pm.extra.VERIFICATION_RESULT"; 1611 1612 /** 1613 * Extra field name for the version code of a package pending verification. 1614 * 1615 * @hide 1616 */ 1617 public static final String EXTRA_VERIFICATION_VERSION_CODE 1618 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 1619 1620 /** 1621 * The action used to request that the user approve a permission request 1622 * from the application. 1623 * 1624 * @hide 1625 */ 1626 public static final String ACTION_REQUEST_PERMISSION 1627 = "android.content.pm.action.REQUEST_PERMISSION"; 1628 1629 /** 1630 * Extra field name for the list of permissions, which the user must approve. 1631 * 1632 * @hide 1633 */ 1634 public static final String EXTRA_REQUEST_PERMISSION_PERMISSION_LIST 1635 = "android.content.pm.extra.PERMISSION_LIST"; 1636 1637 /** 1638 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 1639 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 1640 * the existing definition for the permission. 1641 * @hide 1642 */ 1643 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 1644 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 1645 1646 /** 1647 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 1648 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 1649 * being redundantly defined by the package being installed. 1650 * @hide 1651 */ 1652 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 1653 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 1654 1655 /** 1656 * Retrieve overall information about an application package that is 1657 * installed on the system. 1658 * <p> 1659 * Throws {@link NameNotFoundException} if a package with the given name can 1660 * not be found on the system. 1661 * 1662 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1663 * desired package. 1664 * @param flags Additional option flags. Use any combination of 1665 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS}, 1666 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION}, 1667 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 1668 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 1669 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to 1670 * modify the data returned. 1671 * @return Returns a PackageInfo object containing information about the 1672 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the 1673 * package is not found in the list of installed applications, the 1674 * package information is retrieved from the list of uninstalled 1675 * applications (which includes installed applications as well as 1676 * applications with data directory i.e. applications which had been 1677 * deleted with {@code DONT_DELETE_DATA} flag set). 1678 * @see #GET_ACTIVITIES 1679 * @see #GET_GIDS 1680 * @see #GET_CONFIGURATIONS 1681 * @see #GET_INSTRUMENTATION 1682 * @see #GET_PERMISSIONS 1683 * @see #GET_PROVIDERS 1684 * @see #GET_RECEIVERS 1685 * @see #GET_SERVICES 1686 * @see #GET_SIGNATURES 1687 * @see #GET_UNINSTALLED_PACKAGES 1688 */ 1689 public abstract PackageInfo getPackageInfo(String packageName, int flags) 1690 throws NameNotFoundException; 1691 1692 /** 1693 * Map from the current package names in use on the device to whatever 1694 * the current canonical name of that package is. 1695 * @param names Array of current names to be mapped. 1696 * @return Returns an array of the same size as the original, containing 1697 * the canonical name for each package. 1698 */ 1699 public abstract String[] currentToCanonicalPackageNames(String[] names); 1700 1701 /** 1702 * Map from a packages canonical name to the current name in use on the device. 1703 * @param names Array of new names to be mapped. 1704 * @return Returns an array of the same size as the original, containing 1705 * the current name for each package. 1706 */ 1707 public abstract String[] canonicalToCurrentPackageNames(String[] names); 1708 1709 /** 1710 * Returns a "good" intent to launch a front-door activity in a package. 1711 * This is used, for example, to implement an "open" button when browsing 1712 * through packages. The current implementation looks first for a main 1713 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 1714 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 1715 * <code>null</code> if neither are found. 1716 * 1717 * @param packageName The name of the package to inspect. 1718 * 1719 * @return A fully-qualified {@link Intent} that can be used to launch the 1720 * main activity in the package. Returns <code>null</code> if the package 1721 * does not contain such an activity, or if <em>packageName</em> is not 1722 * recognized. 1723 */ 1724 public abstract Intent getLaunchIntentForPackage(String packageName); 1725 1726 /** 1727 * Return a "good" intent to launch a front-door Leanback activity in a 1728 * package, for use for example to implement an "open" button when browsing 1729 * through packages. The current implementation will look for a main 1730 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 1731 * return null if no main leanback activities are found. 1732 * <p> 1733 * Throws {@link NameNotFoundException} if a package with the given name 1734 * cannot be found on the system. 1735 * 1736 * @param packageName The name of the package to inspect. 1737 * @return Returns either a fully-qualified Intent that can be used to launch 1738 * the main Leanback activity in the package, or null if the package 1739 * does not contain such an activity. 1740 */ 1741 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName); 1742 1743 /** 1744 * Return an array of all of the secondary group-ids that have been assigned 1745 * to a package. 1746 * <p> 1747 * Throws {@link NameNotFoundException} if a package with the given name 1748 * cannot be found on the system. 1749 * 1750 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1751 * desired package. 1752 * @return Returns an int array of the assigned gids, or null if there are 1753 * none. 1754 */ 1755 public abstract int[] getPackageGids(String packageName) 1756 throws NameNotFoundException; 1757 1758 /** 1759 * @hide Return the uid associated with the given package name for the 1760 * given user. 1761 * 1762 * <p>Throws {@link NameNotFoundException} if a package with the given 1763 * name can not be found on the system. 1764 * 1765 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1766 * desired package. 1767 * @param userHandle The user handle identifier to look up the package under. 1768 * 1769 * @return Returns an integer uid who owns the given package name. 1770 */ 1771 public abstract int getPackageUid(String packageName, int userHandle) 1772 throws NameNotFoundException; 1773 1774 /** 1775 * Retrieve all of the information we know about a particular permission. 1776 * 1777 * <p>Throws {@link NameNotFoundException} if a permission with the given 1778 * name cannot be found on the system. 1779 * 1780 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 1781 * of the permission you are interested in. 1782 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1783 * retrieve any meta-data associated with the permission. 1784 * 1785 * @return Returns a {@link PermissionInfo} containing information about the 1786 * permission. 1787 */ 1788 public abstract PermissionInfo getPermissionInfo(String name, int flags) 1789 throws NameNotFoundException; 1790 1791 /** 1792 * Query for all of the permissions associated with a particular group. 1793 * 1794 * <p>Throws {@link NameNotFoundException} if the given group does not 1795 * exist. 1796 * 1797 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 1798 * of the permission group you are interested in. Use null to 1799 * find all of the permissions not associated with a group. 1800 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1801 * retrieve any meta-data associated with the permissions. 1802 * 1803 * @return Returns a list of {@link PermissionInfo} containing information 1804 * about all of the permissions in the given group. 1805 */ 1806 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 1807 int flags) throws NameNotFoundException; 1808 1809 /** 1810 * Retrieve all of the information we know about a particular group of 1811 * permissions. 1812 * 1813 * <p>Throws {@link NameNotFoundException} if a permission group with the given 1814 * name cannot be found on the system. 1815 * 1816 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 1817 * of the permission you are interested in. 1818 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1819 * retrieve any meta-data associated with the permission group. 1820 * 1821 * @return Returns a {@link PermissionGroupInfo} containing information 1822 * about the permission. 1823 */ 1824 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 1825 int flags) throws NameNotFoundException; 1826 1827 /** 1828 * Retrieve all of the known permission groups in the system. 1829 * 1830 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1831 * retrieve any meta-data associated with the permission group. 1832 * 1833 * @return Returns a list of {@link PermissionGroupInfo} containing 1834 * information about all of the known permission groups. 1835 */ 1836 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags); 1837 1838 /** 1839 * Retrieve all of the information we know about a particular 1840 * package/application. 1841 * 1842 * <p>Throws {@link NameNotFoundException} if an application with the given 1843 * package name cannot be found on the system. 1844 * 1845 * @param packageName The full name (i.e. com.google.apps.contacts) of an 1846 * application. 1847 * @param flags Additional option flags. Use any combination of 1848 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1849 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1850 * 1851 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing 1852 * information about the package. 1853 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 1854 * found in the list of installed applications, 1855 * the application information is retrieved from the 1856 * list of uninstalled applications(which includes 1857 * installed applications as well as applications 1858 * with data directory ie applications which had been 1859 * deleted with {@code DONT_DELETE_DATA} flag set). 1860 * 1861 * @see #GET_META_DATA 1862 * @see #GET_SHARED_LIBRARY_FILES 1863 * @see #GET_UNINSTALLED_PACKAGES 1864 */ 1865 public abstract ApplicationInfo getApplicationInfo(String packageName, 1866 int flags) throws NameNotFoundException; 1867 1868 /** 1869 * Retrieve all of the information we know about a particular activity 1870 * class. 1871 * 1872 * <p>Throws {@link NameNotFoundException} if an activity with the given 1873 * class name cannot be found on the system. 1874 * 1875 * @param component The full component name (i.e. 1876 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity 1877 * class. 1878 * @param flags Additional option flags. Use any combination of 1879 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1880 * to modify the data (in ApplicationInfo) returned. 1881 * 1882 * @return {@link ActivityInfo} containing information about the activity. 1883 * 1884 * @see #GET_INTENT_FILTERS 1885 * @see #GET_META_DATA 1886 * @see #GET_SHARED_LIBRARY_FILES 1887 */ 1888 public abstract ActivityInfo getActivityInfo(ComponentName component, 1889 int flags) throws NameNotFoundException; 1890 1891 /** 1892 * Retrieve all of the information we know about a particular receiver 1893 * class. 1894 * 1895 * <p>Throws {@link NameNotFoundException} if a receiver with the given 1896 * class name cannot be found on the system. 1897 * 1898 * @param component The full component name (i.e. 1899 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver 1900 * class. 1901 * @param flags Additional option flags. Use any combination of 1902 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1903 * to modify the data returned. 1904 * 1905 * @return {@link ActivityInfo} containing information about the receiver. 1906 * 1907 * @see #GET_INTENT_FILTERS 1908 * @see #GET_META_DATA 1909 * @see #GET_SHARED_LIBRARY_FILES 1910 */ 1911 public abstract ActivityInfo getReceiverInfo(ComponentName component, 1912 int flags) throws NameNotFoundException; 1913 1914 /** 1915 * Retrieve all of the information we know about a particular service 1916 * class. 1917 * 1918 * <p>Throws {@link NameNotFoundException} if a service with the given 1919 * class name cannot be found on the system. 1920 * 1921 * @param component The full component name (i.e. 1922 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service 1923 * class. 1924 * @param flags Additional option flags. Use any combination of 1925 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1926 * to modify the data returned. 1927 * 1928 * @return ServiceInfo containing information about the service. 1929 * 1930 * @see #GET_META_DATA 1931 * @see #GET_SHARED_LIBRARY_FILES 1932 */ 1933 public abstract ServiceInfo getServiceInfo(ComponentName component, 1934 int flags) throws NameNotFoundException; 1935 1936 /** 1937 * Retrieve all of the information we know about a particular content 1938 * provider class. 1939 * 1940 * <p>Throws {@link NameNotFoundException} if a provider with the given 1941 * class name cannot be found on the system. 1942 * 1943 * @param component The full component name (i.e. 1944 * com.google.providers.media/com.google.providers.media.MediaProvider) of a 1945 * ContentProvider class. 1946 * @param flags Additional option flags. Use any combination of 1947 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1948 * to modify the data returned. 1949 * 1950 * @return ProviderInfo containing information about the service. 1951 * 1952 * @see #GET_META_DATA 1953 * @see #GET_SHARED_LIBRARY_FILES 1954 */ 1955 public abstract ProviderInfo getProviderInfo(ComponentName component, 1956 int flags) throws NameNotFoundException; 1957 1958 /** 1959 * Return a List of all packages that are installed 1960 * on the device. 1961 * 1962 * @param flags Additional option flags. Use any combination of 1963 * {@link #GET_ACTIVITIES}, 1964 * {@link #GET_GIDS}, 1965 * {@link #GET_CONFIGURATIONS}, 1966 * {@link #GET_INSTRUMENTATION}, 1967 * {@link #GET_PERMISSIONS}, 1968 * {@link #GET_PROVIDERS}, 1969 * {@link #GET_RECEIVERS}, 1970 * {@link #GET_SERVICES}, 1971 * {@link #GET_SIGNATURES}, 1972 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1973 * 1974 * @return A List of PackageInfo objects, one for each package that is 1975 * installed on the device. In the unlikely case of there being no 1976 * installed packages, an empty list is returned. 1977 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1978 * applications including those deleted with {@code DONT_DELETE_DATA} 1979 * (partially installed apps with data directory) will be returned. 1980 * 1981 * @see #GET_ACTIVITIES 1982 * @see #GET_GIDS 1983 * @see #GET_CONFIGURATIONS 1984 * @see #GET_INSTRUMENTATION 1985 * @see #GET_PERMISSIONS 1986 * @see #GET_PROVIDERS 1987 * @see #GET_RECEIVERS 1988 * @see #GET_SERVICES 1989 * @see #GET_SIGNATURES 1990 * @see #GET_UNINSTALLED_PACKAGES 1991 */ 1992 public abstract List<PackageInfo> getInstalledPackages(int flags); 1993 1994 /** 1995 * Return a List of all installed packages that are currently 1996 * holding any of the given permissions. 1997 * 1998 * @param flags Additional option flags. Use any combination of 1999 * {@link #GET_ACTIVITIES}, 2000 * {@link #GET_GIDS}, 2001 * {@link #GET_CONFIGURATIONS}, 2002 * {@link #GET_INSTRUMENTATION}, 2003 * {@link #GET_PERMISSIONS}, 2004 * {@link #GET_PROVIDERS}, 2005 * {@link #GET_RECEIVERS}, 2006 * {@link #GET_SERVICES}, 2007 * {@link #GET_SIGNATURES}, 2008 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2009 * 2010 * @return Returns a List of PackageInfo objects, one for each installed 2011 * application that is holding any of the permissions that were provided. 2012 * 2013 * @see #GET_ACTIVITIES 2014 * @see #GET_GIDS 2015 * @see #GET_CONFIGURATIONS 2016 * @see #GET_INSTRUMENTATION 2017 * @see #GET_PERMISSIONS 2018 * @see #GET_PROVIDERS 2019 * @see #GET_RECEIVERS 2020 * @see #GET_SERVICES 2021 * @see #GET_SIGNATURES 2022 * @see #GET_UNINSTALLED_PACKAGES 2023 */ 2024 public abstract List<PackageInfo> getPackagesHoldingPermissions( 2025 String[] permissions, int flags); 2026 2027 /** 2028 * Return a List of all packages that are installed on the device, for a specific user. 2029 * Requesting a list of installed packages for another user 2030 * will require the permission INTERACT_ACROSS_USERS_FULL. 2031 * @param flags Additional option flags. Use any combination of 2032 * {@link #GET_ACTIVITIES}, 2033 * {@link #GET_GIDS}, 2034 * {@link #GET_CONFIGURATIONS}, 2035 * {@link #GET_INSTRUMENTATION}, 2036 * {@link #GET_PERMISSIONS}, 2037 * {@link #GET_PROVIDERS}, 2038 * {@link #GET_RECEIVERS}, 2039 * {@link #GET_SERVICES}, 2040 * {@link #GET_SIGNATURES}, 2041 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2042 * @param userId The user for whom the installed packages are to be listed 2043 * 2044 * @return A List of PackageInfo objects, one for each package that is 2045 * installed on the device. In the unlikely case of there being no 2046 * installed packages, an empty list is returned. 2047 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2048 * applications including those deleted with {@code DONT_DELETE_DATA} 2049 * (partially installed apps with data directory) will be returned. 2050 * 2051 * @see #GET_ACTIVITIES 2052 * @see #GET_GIDS 2053 * @see #GET_CONFIGURATIONS 2054 * @see #GET_INSTRUMENTATION 2055 * @see #GET_PERMISSIONS 2056 * @see #GET_PROVIDERS 2057 * @see #GET_RECEIVERS 2058 * @see #GET_SERVICES 2059 * @see #GET_SIGNATURES 2060 * @see #GET_UNINSTALLED_PACKAGES 2061 * 2062 * @hide 2063 */ 2064 public abstract List<PackageInfo> getInstalledPackages(int flags, int userId); 2065 2066 /** 2067 * Check whether a particular package has been granted a particular 2068 * permission. 2069 * 2070 * @param permName The name of the permission you are checking for, 2071 * @param pkgName The name of the package you are checking against. 2072 * 2073 * @return If the package has the permission, PERMISSION_GRANTED is 2074 * returned. If it does not have the permission, PERMISSION_DENIED 2075 * is returned. 2076 * 2077 * @see #PERMISSION_GRANTED 2078 * @see #PERMISSION_DENIED 2079 */ 2080 public abstract int checkPermission(String permName, String pkgName); 2081 2082 /** 2083 * Add a new dynamic permission to the system. For this to work, your 2084 * package must have defined a permission tree through the 2085 * {@link android.R.styleable#AndroidManifestPermissionTree 2086 * <permission-tree>} tag in its manifest. A package can only add 2087 * permissions to trees that were defined by either its own package or 2088 * another with the same user id; a permission is in a tree if it 2089 * matches the name of the permission tree + ".": for example, 2090 * "com.foo.bar" is a member of the permission tree "com.foo". 2091 * 2092 * <p>It is good to make your permission tree name descriptive, because you 2093 * are taking possession of that entire set of permission names. Thus, it 2094 * must be under a domain you control, with a suffix that will not match 2095 * any normal permissions that may be declared in any applications that 2096 * are part of that domain. 2097 * 2098 * <p>New permissions must be added before 2099 * any .apks are installed that use those permissions. Permissions you 2100 * add through this method are remembered across reboots of the device. 2101 * If the given permission already exists, the info you supply here 2102 * will be used to update it. 2103 * 2104 * @param info Description of the permission to be added. 2105 * 2106 * @return Returns true if a new permission was created, false if an 2107 * existing one was updated. 2108 * 2109 * @throws SecurityException if you are not allowed to add the 2110 * given permission name. 2111 * 2112 * @see #removePermission(String) 2113 */ 2114 public abstract boolean addPermission(PermissionInfo info); 2115 2116 /** 2117 * Like {@link #addPermission(PermissionInfo)} but asynchronously 2118 * persists the package manager state after returning from the call, 2119 * allowing it to return quicker and batch a series of adds at the 2120 * expense of no guarantee the added permission will be retained if 2121 * the device is rebooted before it is written. 2122 */ 2123 public abstract boolean addPermissionAsync(PermissionInfo info); 2124 2125 /** 2126 * Removes a permission that was previously added with 2127 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 2128 * -- you are only allowed to remove permissions that you are allowed 2129 * to add. 2130 * 2131 * @param name The name of the permission to remove. 2132 * 2133 * @throws SecurityException if you are not allowed to remove the 2134 * given permission name. 2135 * 2136 * @see #addPermission(PermissionInfo) 2137 */ 2138 public abstract void removePermission(String name); 2139 2140 /** 2141 * Returns an {@link Intent} suitable for passing to {@code startActivityForResult} 2142 * which prompts the user to grant {@code permissions} to this application. 2143 * @hide 2144 * 2145 * @throws NullPointerException if {@code permissions} is {@code null}. 2146 * @throws IllegalArgumentException if {@code permissions} contains {@code null}. 2147 */ 2148 public Intent buildPermissionRequestIntent(String... permissions) { 2149 if (permissions == null) { 2150 throw new NullPointerException("permissions cannot be null"); 2151 } 2152 for (String permission : permissions) { 2153 if (permission == null) { 2154 throw new IllegalArgumentException("permissions cannot contain null"); 2155 } 2156 } 2157 2158 Intent i = new Intent(ACTION_REQUEST_PERMISSION); 2159 i.putExtra(EXTRA_REQUEST_PERMISSION_PERMISSION_LIST, permissions); 2160 i.setPackage("com.android.packageinstaller"); 2161 return i; 2162 } 2163 2164 /** 2165 * Grant a permission to an application which the application does not 2166 * already have. The permission must have been requested by the application, 2167 * but as an optional permission. If the application is not allowed to 2168 * hold the permission, a SecurityException is thrown. 2169 * @hide 2170 * 2171 * @param packageName The name of the package that the permission will be 2172 * granted to. 2173 * @param permissionName The name of the permission. 2174 */ 2175 public abstract void grantPermission(String packageName, String permissionName); 2176 2177 /** 2178 * Revoke a permission that was previously granted by {@link #grantPermission}. 2179 * @hide 2180 * 2181 * @param packageName The name of the package that the permission will be 2182 * granted to. 2183 * @param permissionName The name of the permission. 2184 */ 2185 public abstract void revokePermission(String packageName, String permissionName); 2186 2187 /** 2188 * Compare the signatures of two packages to determine if the same 2189 * signature appears in both of them. If they do contain the same 2190 * signature, then they are allowed special privileges when working 2191 * with each other: they can share the same user-id, run instrumentation 2192 * against each other, etc. 2193 * 2194 * @param pkg1 First package name whose signature will be compared. 2195 * @param pkg2 Second package name whose signature will be compared. 2196 * 2197 * @return Returns an integer indicating whether all signatures on the 2198 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2199 * all signatures match or < 0 if there is not a match ({@link 2200 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2201 * 2202 * @see #checkSignatures(int, int) 2203 * @see #SIGNATURE_MATCH 2204 * @see #SIGNATURE_NO_MATCH 2205 * @see #SIGNATURE_UNKNOWN_PACKAGE 2206 */ 2207 public abstract int checkSignatures(String pkg1, String pkg2); 2208 2209 /** 2210 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 2211 * the two packages to be checked. This can be useful, for example, 2212 * when doing the check in an IPC, where the UID is the only identity 2213 * available. It is functionally identical to determining the package 2214 * associated with the UIDs and checking their signatures. 2215 * 2216 * @param uid1 First UID whose signature will be compared. 2217 * @param uid2 Second UID whose signature will be compared. 2218 * 2219 * @return Returns an integer indicating whether all signatures on the 2220 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2221 * all signatures match or < 0 if there is not a match ({@link 2222 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2223 * 2224 * @see #checkSignatures(String, String) 2225 * @see #SIGNATURE_MATCH 2226 * @see #SIGNATURE_NO_MATCH 2227 * @see #SIGNATURE_UNKNOWN_PACKAGE 2228 */ 2229 public abstract int checkSignatures(int uid1, int uid2); 2230 2231 /** 2232 * Retrieve the names of all packages that are associated with a particular 2233 * user id. In most cases, this will be a single package name, the package 2234 * that has been assigned that user id. Where there are multiple packages 2235 * sharing the same user id through the "sharedUserId" mechanism, all 2236 * packages with that id will be returned. 2237 * 2238 * @param uid The user id for which you would like to retrieve the 2239 * associated packages. 2240 * 2241 * @return Returns an array of one or more packages assigned to the user 2242 * id, or null if there are no known packages with the given id. 2243 */ 2244 public abstract String[] getPackagesForUid(int uid); 2245 2246 /** 2247 * Retrieve the official name associated with a user id. This name is 2248 * guaranteed to never change, though it is possibly for the underlying 2249 * user id to be changed. That is, if you are storing information about 2250 * user ids in persistent storage, you should use the string returned 2251 * by this function instead of the raw user-id. 2252 * 2253 * @param uid The user id for which you would like to retrieve a name. 2254 * @return Returns a unique name for the given user id, or null if the 2255 * user id is not currently assigned. 2256 */ 2257 public abstract String getNameForUid(int uid); 2258 2259 /** 2260 * Return the user id associated with a shared user name. Multiple 2261 * applications can specify a shared user name in their manifest and thus 2262 * end up using a common uid. This might be used for new applications 2263 * that use an existing shared user name and need to know the uid of the 2264 * shared user. 2265 * 2266 * @param sharedUserName The shared user name whose uid is to be retrieved. 2267 * @return Returns the uid associated with the shared user, or NameNotFoundException 2268 * if the shared user name is not being used by any installed packages 2269 * @hide 2270 */ 2271 public abstract int getUidForSharedUser(String sharedUserName) 2272 throws NameNotFoundException; 2273 2274 /** 2275 * Return a List of all application packages that are installed on the 2276 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 2277 * applications including those deleted with {@code DONT_DELETE_DATA} (partially 2278 * installed apps with data directory) will be returned. 2279 * 2280 * @param flags Additional option flags. Use any combination of 2281 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2282 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2283 * 2284 * @return Returns a List of ApplicationInfo objects, one for each application that 2285 * is installed on the device. In the unlikely case of there being 2286 * no installed applications, an empty list is returned. 2287 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2288 * applications including those deleted with {@code DONT_DELETE_DATA} 2289 * (partially installed apps with data directory) will be returned. 2290 * 2291 * @see #GET_META_DATA 2292 * @see #GET_SHARED_LIBRARY_FILES 2293 * @see #GET_UNINSTALLED_PACKAGES 2294 */ 2295 public abstract List<ApplicationInfo> getInstalledApplications(int flags); 2296 2297 /** 2298 * Get a list of shared libraries that are available on the 2299 * system. 2300 * 2301 * @return An array of shared library names that are 2302 * available on the system, or null if none are installed. 2303 * 2304 */ 2305 public abstract String[] getSystemSharedLibraryNames(); 2306 2307 /** 2308 * Get a list of features that are available on the 2309 * system. 2310 * 2311 * @return An array of FeatureInfo classes describing the features 2312 * that are available on the system, or null if there are none(!!). 2313 */ 2314 public abstract FeatureInfo[] getSystemAvailableFeatures(); 2315 2316 /** 2317 * Check whether the given feature name is one of the available 2318 * features as returned by {@link #getSystemAvailableFeatures()}. 2319 * 2320 * @return Returns true if the devices supports the feature, else 2321 * false. 2322 */ 2323 public abstract boolean hasSystemFeature(String name); 2324 2325 /** 2326 * Determine the best action to perform for a given Intent. This is how 2327 * {@link Intent#resolveActivity} finds an activity if a class has not 2328 * been explicitly specified. 2329 * 2330 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 2331 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 2332 * only flag. You need to do so to resolve the activity in the same way 2333 * that {@link android.content.Context#startActivity(Intent)} and 2334 * {@link android.content.Intent#resolveActivity(PackageManager) 2335 * Intent.resolveActivity(PackageManager)} do.</p> 2336 * 2337 * @param intent An intent containing all of the desired specification 2338 * (action, data, type, category, and/or component). 2339 * @param flags Additional option flags. The most important is 2340 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2341 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2342 * 2343 * @return Returns a ResolveInfo containing the final activity intent that 2344 * was determined to be the best action. Returns null if no 2345 * matching activity was found. If multiple matching activities are 2346 * found and there is no default set, returns a ResolveInfo 2347 * containing something else, such as the activity resolver. 2348 * 2349 * @see #MATCH_DEFAULT_ONLY 2350 * @see #GET_INTENT_FILTERS 2351 * @see #GET_RESOLVED_FILTER 2352 */ 2353 public abstract ResolveInfo resolveActivity(Intent intent, int flags); 2354 2355 /** 2356 * Determine the best action to perform for a given Intent for a given user. This 2357 * is how {@link Intent#resolveActivity} finds an activity if a class has not 2358 * been explicitly specified. 2359 * 2360 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 2361 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 2362 * only flag. You need to do so to resolve the activity in the same way 2363 * that {@link android.content.Context#startActivity(Intent)} and 2364 * {@link android.content.Intent#resolveActivity(PackageManager) 2365 * Intent.resolveActivity(PackageManager)} do.</p> 2366 * 2367 * @param intent An intent containing all of the desired specification 2368 * (action, data, type, category, and/or component). 2369 * @param flags Additional option flags. The most important is 2370 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2371 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2372 * @param userId The user id. 2373 * 2374 * @return Returns a ResolveInfo containing the final activity intent that 2375 * was determined to be the best action. Returns null if no 2376 * matching activity was found. If multiple matching activities are 2377 * found and there is no default set, returns a ResolveInfo 2378 * containing something else, such as the activity resolver. 2379 * 2380 * @see #MATCH_DEFAULT_ONLY 2381 * @see #GET_INTENT_FILTERS 2382 * @see #GET_RESOLVED_FILTER 2383 * 2384 * @hide 2385 */ 2386 public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId); 2387 2388 /** 2389 * Retrieve all activities that can be performed for the given intent. 2390 * 2391 * @param intent The desired intent as per resolveActivity(). 2392 * @param flags Additional option flags. The most important is 2393 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2394 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2395 * 2396 * @return A List<ResolveInfo> containing one entry for each matching 2397 * Activity. These are ordered from best to worst match -- that 2398 * is, the first item in the list is what is returned by 2399 * {@link #resolveActivity}. If there are no matching activities, an empty 2400 * list is returned. 2401 * 2402 * @see #MATCH_DEFAULT_ONLY 2403 * @see #GET_INTENT_FILTERS 2404 * @see #GET_RESOLVED_FILTER 2405 */ 2406 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 2407 int flags); 2408 2409 /** 2410 * Retrieve all activities that can be performed for the given intent, for a specific user. 2411 * 2412 * @param intent The desired intent as per resolveActivity(). 2413 * @param flags Additional option flags. The most important is 2414 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2415 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2416 * 2417 * @return A List<ResolveInfo> containing one entry for each matching 2418 * Activity. These are ordered from best to worst match -- that 2419 * is, the first item in the list is what is returned by 2420 * {@link #resolveActivity}. If there are no matching activities, an empty 2421 * list is returned. 2422 * 2423 * @see #MATCH_DEFAULT_ONLY 2424 * @see #GET_INTENT_FILTERS 2425 * @see #GET_RESOLVED_FILTER 2426 * @see #NO_CROSS_PROFILE 2427 * @hide 2428 */ 2429 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 2430 int flags, int userId); 2431 2432 2433 /** 2434 * Retrieve a set of activities that should be presented to the user as 2435 * similar options. This is like {@link #queryIntentActivities}, except it 2436 * also allows you to supply a list of more explicit Intents that you would 2437 * like to resolve to particular options, and takes care of returning the 2438 * final ResolveInfo list in a reasonable order, with no duplicates, based 2439 * on those inputs. 2440 * 2441 * @param caller The class name of the activity that is making the 2442 * request. This activity will never appear in the output 2443 * list. Can be null. 2444 * @param specifics An array of Intents that should be resolved to the 2445 * first specific results. Can be null. 2446 * @param intent The desired intent as per resolveActivity(). 2447 * @param flags Additional option flags. The most important is 2448 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2449 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2450 * 2451 * @return A List<ResolveInfo> containing one entry for each matching 2452 * Activity. These are ordered first by all of the intents resolved 2453 * in <var>specifics</var> and then any additional activities that 2454 * can handle <var>intent</var> but did not get included by one of 2455 * the <var>specifics</var> intents. If there are no matching 2456 * activities, an empty list is returned. 2457 * 2458 * @see #MATCH_DEFAULT_ONLY 2459 * @see #GET_INTENT_FILTERS 2460 * @see #GET_RESOLVED_FILTER 2461 */ 2462 public abstract List<ResolveInfo> queryIntentActivityOptions( 2463 ComponentName caller, Intent[] specifics, Intent intent, int flags); 2464 2465 /** 2466 * Retrieve all receivers that can handle a broadcast of the given intent. 2467 * 2468 * @param intent The desired intent as per resolveActivity(). 2469 * @param flags Additional option flags. 2470 * 2471 * @return A List<ResolveInfo> containing one entry for each matching 2472 * Receiver. These are ordered from first to last in priority. If 2473 * there are no matching receivers, an empty list is returned. 2474 * 2475 * @see #MATCH_DEFAULT_ONLY 2476 * @see #GET_INTENT_FILTERS 2477 * @see #GET_RESOLVED_FILTER 2478 */ 2479 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 2480 int flags); 2481 2482 /** 2483 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific 2484 * user. 2485 * 2486 * @param intent The desired intent as per resolveActivity(). 2487 * @param flags Additional option flags. 2488 * @param userId The userId of the user being queried. 2489 * 2490 * @return A List<ResolveInfo> containing one entry for each matching 2491 * Receiver. These are ordered from first to last in priority. If 2492 * there are no matching receivers, an empty list is returned. 2493 * 2494 * @see #MATCH_DEFAULT_ONLY 2495 * @see #GET_INTENT_FILTERS 2496 * @see #GET_RESOLVED_FILTER 2497 * @hide 2498 */ 2499 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 2500 int flags, int userId); 2501 2502 /** 2503 * Determine the best service to handle for a given Intent. 2504 * 2505 * @param intent An intent containing all of the desired specification 2506 * (action, data, type, category, and/or component). 2507 * @param flags Additional option flags. 2508 * 2509 * @return Returns a ResolveInfo containing the final service intent that 2510 * was determined to be the best action. Returns null if no 2511 * matching service was found. 2512 * 2513 * @see #GET_INTENT_FILTERS 2514 * @see #GET_RESOLVED_FILTER 2515 */ 2516 public abstract ResolveInfo resolveService(Intent intent, int flags); 2517 2518 /** 2519 * Retrieve all services that can match the given intent. 2520 * 2521 * @param intent The desired intent as per resolveService(). 2522 * @param flags Additional option flags. 2523 * 2524 * @return A List<ResolveInfo> containing one entry for each matching 2525 * ServiceInfo. These are ordered from best to worst match -- that 2526 * is, the first item in the list is what is returned by 2527 * resolveService(). If there are no matching services, an empty 2528 * list is returned. 2529 * 2530 * @see #GET_INTENT_FILTERS 2531 * @see #GET_RESOLVED_FILTER 2532 */ 2533 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 2534 int flags); 2535 2536 /** 2537 * Retrieve all services that can match the given intent for a given user. 2538 * 2539 * @param intent The desired intent as per resolveService(). 2540 * @param flags Additional option flags. 2541 * @param userId The user id. 2542 * 2543 * @return A List<ResolveInfo> containing one entry for each matching 2544 * ServiceInfo. These are ordered from best to worst match -- that 2545 * is, the first item in the list is what is returned by 2546 * resolveService(). If there are no matching services, an empty 2547 * list is returned. 2548 * 2549 * @see #GET_INTENT_FILTERS 2550 * @see #GET_RESOLVED_FILTER 2551 * 2552 * @hide 2553 */ 2554 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 2555 int flags, int userId); 2556 2557 /** {@hide} */ 2558 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 2559 Intent intent, int flags, int userId); 2560 2561 /** 2562 * Retrieve all providers that can match the given intent. 2563 * 2564 * @param intent An intent containing all of the desired specification 2565 * (action, data, type, category, and/or component). 2566 * @param flags Additional option flags. 2567 * @return A List<ResolveInfo> containing one entry for each matching 2568 * ProviderInfo. These are ordered from best to worst match. If 2569 * there are no matching providers, an empty list is returned. 2570 * @see #GET_INTENT_FILTERS 2571 * @see #GET_RESOLVED_FILTER 2572 */ 2573 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags); 2574 2575 /** 2576 * Find a single content provider by its base path name. 2577 * 2578 * @param name The name of the provider to find. 2579 * @param flags Additional option flags. Currently should always be 0. 2580 * 2581 * @return ContentProviderInfo Information about the provider, if found, 2582 * else null. 2583 */ 2584 public abstract ProviderInfo resolveContentProvider(String name, 2585 int flags); 2586 2587 /** 2588 * Find a single content provider by its base path name. 2589 * 2590 * @param name The name of the provider to find. 2591 * @param flags Additional option flags. Currently should always be 0. 2592 * @param userId The user id. 2593 * 2594 * @return ContentProviderInfo Information about the provider, if found, 2595 * else null. 2596 * @hide 2597 */ 2598 public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId); 2599 2600 /** 2601 * Retrieve content provider information. 2602 * 2603 * <p><em>Note: unlike most other methods, an empty result set is indicated 2604 * by a null return instead of an empty list.</em> 2605 * 2606 * @param processName If non-null, limits the returned providers to only 2607 * those that are hosted by the given process. If null, 2608 * all content providers are returned. 2609 * @param uid If <var>processName</var> is non-null, this is the required 2610 * uid owning the requested content providers. 2611 * @param flags Additional option flags. Currently should always be 0. 2612 * 2613 * @return A List<ContentProviderInfo> containing one entry for each 2614 * content provider either patching <var>processName</var> or, if 2615 * <var>processName</var> is null, all known content providers. 2616 * <em>If there are no matching providers, null is returned.</em> 2617 */ 2618 public abstract List<ProviderInfo> queryContentProviders( 2619 String processName, int uid, int flags); 2620 2621 /** 2622 * Retrieve all of the information we know about a particular 2623 * instrumentation class. 2624 * 2625 * <p>Throws {@link NameNotFoundException} if instrumentation with the 2626 * given class name cannot be found on the system. 2627 * 2628 * @param className The full name (i.e. 2629 * com.google.apps.contacts.InstrumentList) of an 2630 * Instrumentation class. 2631 * @param flags Additional option flags. Currently should always be 0. 2632 * 2633 * @return InstrumentationInfo containing information about the 2634 * instrumentation. 2635 */ 2636 public abstract InstrumentationInfo getInstrumentationInfo( 2637 ComponentName className, int flags) throws NameNotFoundException; 2638 2639 /** 2640 * Retrieve information about available instrumentation code. May be used 2641 * to retrieve either all instrumentation code, or only the code targeting 2642 * a particular package. 2643 * 2644 * @param targetPackage If null, all instrumentation is returned; only the 2645 * instrumentation targeting this package name is 2646 * returned. 2647 * @param flags Additional option flags. Currently should always be 0. 2648 * 2649 * @return A List<InstrumentationInfo> containing one entry for each 2650 * matching available Instrumentation. Returns an empty list if 2651 * there is no instrumentation available for the given package. 2652 */ 2653 public abstract List<InstrumentationInfo> queryInstrumentation( 2654 String targetPackage, int flags); 2655 2656 /** 2657 * Retrieve an image from a package. This is a low-level API used by 2658 * the various package manager info structures (such as 2659 * {@link ComponentInfo} to implement retrieval of their associated 2660 * icon. 2661 * 2662 * @param packageName The name of the package that this icon is coming from. 2663 * Cannot be null. 2664 * @param resid The resource identifier of the desired image. Cannot be 0. 2665 * @param appInfo Overall information about <var>packageName</var>. This 2666 * may be null, in which case the application information will be retrieved 2667 * for you if needed; if you already have this information around, it can 2668 * be much more efficient to supply it here. 2669 * 2670 * @return Returns a Drawable holding the requested image. Returns null if 2671 * an image could not be found for any reason. 2672 */ 2673 public abstract Drawable getDrawable(String packageName, int resid, 2674 ApplicationInfo appInfo); 2675 2676 /** 2677 * Retrieve the icon associated with an activity. Given the full name of 2678 * an activity, retrieves the information about it and calls 2679 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 2680 * If the activity cannot be found, NameNotFoundException is thrown. 2681 * 2682 * @param activityName Name of the activity whose icon is to be retrieved. 2683 * 2684 * @return Returns the image of the icon, or the default activity icon if 2685 * it could not be found. Does not return null. 2686 * @throws NameNotFoundException Thrown if the resources for the given 2687 * activity could not be loaded. 2688 * 2689 * @see #getActivityIcon(Intent) 2690 */ 2691 public abstract Drawable getActivityIcon(ComponentName activityName) 2692 throws NameNotFoundException; 2693 2694 /** 2695 * Retrieve the icon associated with an Intent. If intent.getClassName() is 2696 * set, this simply returns the result of 2697 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 2698 * component and returns the icon associated with the resolved component. 2699 * If intent.getClassName() cannot be found or the Intent cannot be resolved 2700 * to a component, NameNotFoundException is thrown. 2701 * 2702 * @param intent The intent for which you would like to retrieve an icon. 2703 * 2704 * @return Returns the image of the icon, or the default activity icon if 2705 * it could not be found. Does not return null. 2706 * @throws NameNotFoundException Thrown if the resources for application 2707 * matching the given intent could not be loaded. 2708 * 2709 * @see #getActivityIcon(ComponentName) 2710 */ 2711 public abstract Drawable getActivityIcon(Intent intent) 2712 throws NameNotFoundException; 2713 2714 /** 2715 * Retrieve the banner associated with an activity. Given the full name of 2716 * an activity, retrieves the information about it and calls 2717 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 2718 * banner. If the activity cannot be found, NameNotFoundException is thrown. 2719 * 2720 * @param activityName Name of the activity whose banner is to be retrieved. 2721 * @return Returns the image of the banner, or null if the activity has no 2722 * banner specified. 2723 * @throws NameNotFoundException Thrown if the resources for the given 2724 * activity could not be loaded. 2725 * @see #getActivityBanner(Intent) 2726 */ 2727 public abstract Drawable getActivityBanner(ComponentName activityName) 2728 throws NameNotFoundException; 2729 2730 /** 2731 * Retrieve the banner associated with an Intent. If intent.getClassName() 2732 * is set, this simply returns the result of 2733 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 2734 * intent's component and returns the banner associated with the resolved 2735 * component. If intent.getClassName() cannot be found or the Intent cannot 2736 * be resolved to a component, NameNotFoundException is thrown. 2737 * 2738 * @param intent The intent for which you would like to retrieve a banner. 2739 * @return Returns the image of the banner, or null if the activity has no 2740 * banner specified. 2741 * @throws NameNotFoundException Thrown if the resources for application 2742 * matching the given intent could not be loaded. 2743 * @see #getActivityBanner(ComponentName) 2744 */ 2745 public abstract Drawable getActivityBanner(Intent intent) 2746 throws NameNotFoundException; 2747 2748 /** 2749 * Return the generic icon for an activity that is used when no specific 2750 * icon is defined. 2751 * 2752 * @return Drawable Image of the icon. 2753 */ 2754 public abstract Drawable getDefaultActivityIcon(); 2755 2756 /** 2757 * Retrieve the icon associated with an application. If it has not defined 2758 * an icon, the default app icon is returned. Does not return null. 2759 * 2760 * @param info Information about application being queried. 2761 * 2762 * @return Returns the image of the icon, or the default application icon 2763 * if it could not be found. 2764 * 2765 * @see #getApplicationIcon(String) 2766 */ 2767 public abstract Drawable getApplicationIcon(ApplicationInfo info); 2768 2769 /** 2770 * Retrieve the icon associated with an application. Given the name of the 2771 * application's package, retrieves the information about it and calls 2772 * getApplicationIcon() to return its icon. If the application cannot be 2773 * found, NameNotFoundException is thrown. 2774 * 2775 * @param packageName Name of the package whose application icon is to be 2776 * retrieved. 2777 * 2778 * @return Returns the image of the icon, or the default application icon 2779 * if it could not be found. Does not return null. 2780 * @throws NameNotFoundException Thrown if the resources for the given 2781 * application could not be loaded. 2782 * 2783 * @see #getApplicationIcon(ApplicationInfo) 2784 */ 2785 public abstract Drawable getApplicationIcon(String packageName) 2786 throws NameNotFoundException; 2787 2788 /** 2789 * Retrieve the banner associated with an application. 2790 * 2791 * @param info Information about application being queried. 2792 * @return Returns the image of the banner or null if the application has no 2793 * banner specified. 2794 * @see #getApplicationBanner(String) 2795 */ 2796 public abstract Drawable getApplicationBanner(ApplicationInfo info); 2797 2798 /** 2799 * Retrieve the banner associated with an application. Given the name of the 2800 * application's package, retrieves the information about it and calls 2801 * getApplicationIcon() to return its banner. If the application cannot be 2802 * found, NameNotFoundException is thrown. 2803 * 2804 * @param packageName Name of the package whose application banner is to be 2805 * retrieved. 2806 * @return Returns the image of the banner or null if the application has no 2807 * banner specified. 2808 * @throws NameNotFoundException Thrown if the resources for the given 2809 * application could not be loaded. 2810 * @see #getApplicationBanner(ApplicationInfo) 2811 */ 2812 public abstract Drawable getApplicationBanner(String packageName) 2813 throws NameNotFoundException; 2814 2815 /** 2816 * Retrieve the logo associated with an activity. Given the full name of an 2817 * activity, retrieves the information about it and calls 2818 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 2819 * logo. If the activity cannot be found, NameNotFoundException is thrown. 2820 * 2821 * @param activityName Name of the activity whose logo is to be retrieved. 2822 * @return Returns the image of the logo or null if the activity has no logo 2823 * specified. 2824 * @throws NameNotFoundException Thrown if the resources for the given 2825 * activity could not be loaded. 2826 * @see #getActivityLogo(Intent) 2827 */ 2828 public abstract Drawable getActivityLogo(ComponentName activityName) 2829 throws NameNotFoundException; 2830 2831 /** 2832 * Retrieve the logo associated with an Intent. If intent.getClassName() is 2833 * set, this simply returns the result of 2834 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 2835 * component and returns the logo associated with the resolved component. 2836 * If intent.getClassName() cannot be found or the Intent cannot be resolved 2837 * to a component, NameNotFoundException is thrown. 2838 * 2839 * @param intent The intent for which you would like to retrieve a logo. 2840 * 2841 * @return Returns the image of the logo, or null if the activity has no 2842 * logo specified. 2843 * 2844 * @throws NameNotFoundException Thrown if the resources for application 2845 * matching the given intent could not be loaded. 2846 * 2847 * @see #getActivityLogo(ComponentName) 2848 */ 2849 public abstract Drawable getActivityLogo(Intent intent) 2850 throws NameNotFoundException; 2851 2852 /** 2853 * Retrieve the logo associated with an application. If it has not specified 2854 * a logo, this method returns null. 2855 * 2856 * @param info Information about application being queried. 2857 * 2858 * @return Returns the image of the logo, or null if no logo is specified 2859 * by the application. 2860 * 2861 * @see #getApplicationLogo(String) 2862 */ 2863 public abstract Drawable getApplicationLogo(ApplicationInfo info); 2864 2865 /** 2866 * Retrieve the logo associated with an application. Given the name of the 2867 * application's package, retrieves the information about it and calls 2868 * getApplicationLogo() to return its logo. If the application cannot be 2869 * found, NameNotFoundException is thrown. 2870 * 2871 * @param packageName Name of the package whose application logo is to be 2872 * retrieved. 2873 * 2874 * @return Returns the image of the logo, or null if no application logo 2875 * has been specified. 2876 * 2877 * @throws NameNotFoundException Thrown if the resources for the given 2878 * application could not be loaded. 2879 * 2880 * @see #getApplicationLogo(ApplicationInfo) 2881 */ 2882 public abstract Drawable getApplicationLogo(String packageName) 2883 throws NameNotFoundException; 2884 2885 /** 2886 * If the target user is a managed profile of the calling user or the caller 2887 * is itself a managed profile, then this returns a badged copy of the given 2888 * icon to be able to distinguish it from the original icon. For badging an 2889 * arbitrary drawable use {@link #getUserBadgedDrawableForDensity( 2890 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 2891 * <p> 2892 * If the original drawable is a BitmapDrawable and the backing bitmap is 2893 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 2894 * is performed in place and the original drawable is returned. 2895 * </p> 2896 * 2897 * @param icon The icon to badge. 2898 * @param user The target user. 2899 * @return A drawable that combines the original icon and a badge as 2900 * determined by the system. 2901 */ 2902 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 2903 2904 /** 2905 * If the target user is a managed profile of the calling user or the caller 2906 * is itself a managed profile, then this returns a badged copy of the given 2907 * drawable allowing the user to distinguish it from the original drawable. 2908 * The caller can specify the location in the bounds of the drawable to be 2909 * badged where the badge should be applied as well as the density of the 2910 * badge to be used. 2911 * <p> 2912 * If the original drawable is a BitmapDrawable and the backing bitmap is 2913 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading 2914 * is performed in place and the original drawable is returned. 2915 * </p> 2916 * 2917 * @param drawable The drawable to badge. 2918 * @param user The target user. 2919 * @param badgeLocation Where in the bounds of the badged drawable to place 2920 * the badge. If not provided, the badge is applied on top of the entire 2921 * drawable being badged. 2922 * @param badgeDensity The optional desired density for the badge as per 2923 * {@link android.util.DisplayMetrics#densityDpi}. If not provided, 2924 * the density of the display is used. 2925 * @return A drawable that combines the original drawable and a badge as 2926 * determined by the system. 2927 */ 2928 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 2929 UserHandle user, Rect badgeLocation, int badgeDensity); 2930 2931 /** 2932 * If the target user is a managed profile of the calling user or the caller 2933 * is itself a managed profile, then this returns a drawable to use as a small 2934 * icon to include in a view to distinguish it from the original icon. 2935 * 2936 * @param user The target user. 2937 * @param density The optional desired density for the badge as per 2938 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 2939 * the density of the current display is used. 2940 * @return the drawable or null if no drawable is required. 2941 * @hide 2942 */ 2943 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 2944 2945 /** 2946 * If the target user is a managed profile of the calling user or the caller 2947 * is itself a managed profile, then this returns a copy of the label with 2948 * badging for accessibility services like talkback. E.g. passing in "Email" 2949 * and it might return "Work Email" for Email in the work profile. 2950 * 2951 * @param label The label to change. 2952 * @param user The target user. 2953 * @return A label that combines the original label and a badge as 2954 * determined by the system. 2955 */ 2956 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 2957 2958 /** 2959 * Retrieve text from a package. This is a low-level API used by 2960 * the various package manager info structures (such as 2961 * {@link ComponentInfo} to implement retrieval of their associated 2962 * labels and other text. 2963 * 2964 * @param packageName The name of the package that this text is coming from. 2965 * Cannot be null. 2966 * @param resid The resource identifier of the desired text. Cannot be 0. 2967 * @param appInfo Overall information about <var>packageName</var>. This 2968 * may be null, in which case the application information will be retrieved 2969 * for you if needed; if you already have this information around, it can 2970 * be much more efficient to supply it here. 2971 * 2972 * @return Returns a CharSequence holding the requested text. Returns null 2973 * if the text could not be found for any reason. 2974 */ 2975 public abstract CharSequence getText(String packageName, int resid, 2976 ApplicationInfo appInfo); 2977 2978 /** 2979 * Retrieve an XML file from a package. This is a low-level API used to 2980 * retrieve XML meta data. 2981 * 2982 * @param packageName The name of the package that this xml is coming from. 2983 * Cannot be null. 2984 * @param resid The resource identifier of the desired xml. Cannot be 0. 2985 * @param appInfo Overall information about <var>packageName</var>. This 2986 * may be null, in which case the application information will be retrieved 2987 * for you if needed; if you already have this information around, it can 2988 * be much more efficient to supply it here. 2989 * 2990 * @return Returns an XmlPullParser allowing you to parse out the XML 2991 * data. Returns null if the xml resource could not be found for any 2992 * reason. 2993 */ 2994 public abstract XmlResourceParser getXml(String packageName, int resid, 2995 ApplicationInfo appInfo); 2996 2997 /** 2998 * Return the label to use for this application. 2999 * 3000 * @return Returns the label associated with this application, or null if 3001 * it could not be found for any reason. 3002 * @param info The application to get the label of. 3003 */ 3004 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 3005 3006 /** 3007 * Retrieve the resources associated with an activity. Given the full 3008 * name of an activity, retrieves the information about it and calls 3009 * getResources() to return its application's resources. If the activity 3010 * cannot be found, NameNotFoundException is thrown. 3011 * 3012 * @param activityName Name of the activity whose resources are to be 3013 * retrieved. 3014 * 3015 * @return Returns the application's Resources. 3016 * @throws NameNotFoundException Thrown if the resources for the given 3017 * application could not be loaded. 3018 * 3019 * @see #getResourcesForApplication(ApplicationInfo) 3020 */ 3021 public abstract Resources getResourcesForActivity(ComponentName activityName) 3022 throws NameNotFoundException; 3023 3024 /** 3025 * Retrieve the resources for an application. Throws NameNotFoundException 3026 * if the package is no longer installed. 3027 * 3028 * @param app Information about the desired application. 3029 * 3030 * @return Returns the application's Resources. 3031 * @throws NameNotFoundException Thrown if the resources for the given 3032 * application could not be loaded (most likely because it was uninstalled). 3033 */ 3034 public abstract Resources getResourcesForApplication(ApplicationInfo app) 3035 throws NameNotFoundException; 3036 3037 /** 3038 * Retrieve the resources associated with an application. Given the full 3039 * package name of an application, retrieves the information about it and 3040 * calls getResources() to return its application's resources. If the 3041 * appPackageName cannot be found, NameNotFoundException is thrown. 3042 * 3043 * @param appPackageName Package name of the application whose resources 3044 * are to be retrieved. 3045 * 3046 * @return Returns the application's Resources. 3047 * @throws NameNotFoundException Thrown if the resources for the given 3048 * application could not be loaded. 3049 * 3050 * @see #getResourcesForApplication(ApplicationInfo) 3051 */ 3052 public abstract Resources getResourcesForApplication(String appPackageName) 3053 throws NameNotFoundException; 3054 3055 /** @hide */ 3056 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId) 3057 throws NameNotFoundException; 3058 3059 /** 3060 * Retrieve overall information about an application package defined 3061 * in a package archive file 3062 * 3063 * @param archiveFilePath The path to the archive file 3064 * @param flags Additional option flags. Use any combination of 3065 * {@link #GET_ACTIVITIES}, 3066 * {@link #GET_GIDS}, 3067 * {@link #GET_CONFIGURATIONS}, 3068 * {@link #GET_INSTRUMENTATION}, 3069 * {@link #GET_PERMISSIONS}, 3070 * {@link #GET_PROVIDERS}, 3071 * {@link #GET_RECEIVERS}, 3072 * {@link #GET_SERVICES}, 3073 * {@link #GET_SIGNATURES}, to modify the data returned. 3074 * 3075 * @return Returns the information about the package. Returns 3076 * null if the package could not be successfully parsed. 3077 * 3078 * @see #GET_ACTIVITIES 3079 * @see #GET_GIDS 3080 * @see #GET_CONFIGURATIONS 3081 * @see #GET_INSTRUMENTATION 3082 * @see #GET_PERMISSIONS 3083 * @see #GET_PROVIDERS 3084 * @see #GET_RECEIVERS 3085 * @see #GET_SERVICES 3086 * @see #GET_SIGNATURES 3087 * 3088 */ 3089 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { 3090 final PackageParser parser = new PackageParser(); 3091 final File apkFile = new File(archiveFilePath); 3092 try { 3093 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 3094 if ((flags & GET_SIGNATURES) != 0) { 3095 parser.collectCertificates(pkg, 0); 3096 parser.collectManifestDigest(pkg); 3097 } 3098 PackageUserState state = new PackageUserState(); 3099 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 3100 } catch (PackageParserException e) { 3101 return null; 3102 } 3103 } 3104 3105 /** 3106 * @hide Install a package. Since this may take a little while, the result 3107 * will be posted back to the given observer. An installation will 3108 * fail if the calling context lacks the 3109 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if 3110 * the package named in the package file's manifest is already 3111 * installed, or if there's no space available on the device. 3112 * @param packageURI The location of the package file to install. This can 3113 * be a 'file:' or a 'content:' URI. 3114 * @param observer An observer callback to get notified when the package 3115 * installation is complete. 3116 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3117 * will be called when that happens. This parameter must not be 3118 * null. 3119 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3120 * {@link #INSTALL_REPLACE_EXISTING}, 3121 * {@link #INSTALL_ALLOW_TEST}. 3122 * @param installerPackageName Optional package name of the application that 3123 * is performing the installation. This identifies which market 3124 * the package came from. 3125 * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int, 3126 * String)} instead. This method will continue to be supported 3127 * but the older observer interface will not get additional 3128 * failure details. 3129 */ 3130 // @SystemApi 3131 public abstract void installPackage( 3132 Uri packageURI, IPackageInstallObserver observer, int flags, 3133 String installerPackageName); 3134 3135 /** 3136 * Similar to 3137 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3138 * with an extra verification file provided. 3139 * 3140 * @param packageURI The location of the package file to install. This can 3141 * be a 'file:' or a 'content:' URI. 3142 * @param observer An observer callback to get notified when the package 3143 * installation is complete. 3144 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3145 * will be called when that happens. This parameter must not be 3146 * null. 3147 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3148 * {@link #INSTALL_REPLACE_EXISTING}, 3149 * {@link #INSTALL_ALLOW_TEST}. 3150 * @param installerPackageName Optional package name of the application that 3151 * is performing the installation. This identifies which market 3152 * the package came from. 3153 * @param verificationURI The location of the supplementary verification 3154 * file. This can be a 'file:' or a 'content:' URI. May be 3155 * {@code null}. 3156 * @param manifestDigest an object that holds the digest of the package 3157 * which can be used to verify ownership. May be {@code null}. 3158 * @param encryptionParams if the package to be installed is encrypted, 3159 * these parameters describing the encryption and authentication 3160 * used. May be {@code null}. 3161 * @hide 3162 * @deprecated Use {@link #installPackageWithVerification(Uri, 3163 * PackageInstallObserver, int, String, Uri, ManifestDigest, 3164 * ContainerEncryptionParams)} instead. This method will 3165 * continue to be supported but the older observer interface 3166 * will not get additional failure details. 3167 */ 3168 // @SystemApi 3169 public abstract void installPackageWithVerification(Uri packageURI, 3170 IPackageInstallObserver observer, int flags, String installerPackageName, 3171 Uri verificationURI, ManifestDigest manifestDigest, 3172 ContainerEncryptionParams encryptionParams); 3173 3174 /** 3175 * Similar to 3176 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3177 * with an extra verification information provided. 3178 * 3179 * @param packageURI The location of the package file to install. This can 3180 * be a 'file:' or a 'content:' URI. 3181 * @param observer An observer callback to get notified when the package 3182 * installation is complete. 3183 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3184 * will be called when that happens. This parameter must not be 3185 * null. 3186 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3187 * {@link #INSTALL_REPLACE_EXISTING}, 3188 * {@link #INSTALL_ALLOW_TEST}. 3189 * @param installerPackageName Optional package name of the application that 3190 * is performing the installation. This identifies which market 3191 * the package came from. 3192 * @param verificationParams an object that holds signal information to 3193 * assist verification. May be {@code null}. 3194 * @param encryptionParams if the package to be installed is encrypted, 3195 * these parameters describing the encryption and authentication 3196 * used. May be {@code null}. 3197 * @hide 3198 * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri, 3199 * PackageInstallObserver, int, String, VerificationParams, 3200 * ContainerEncryptionParams)} instead. This method will 3201 * continue to be supported but the older observer interface 3202 * will not get additional failure details. 3203 */ 3204 @Deprecated 3205 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 3206 IPackageInstallObserver observer, int flags, String installerPackageName, 3207 VerificationParams verificationParams, 3208 ContainerEncryptionParams encryptionParams); 3209 3210 // Package-install variants that take the new, expanded form of observer interface. 3211 // Note that these *also* take the original observer type and will redundantly 3212 // report the same information to that observer if supplied; but it is not required. 3213 3214 /** 3215 * @hide 3216 * 3217 * Install a package. Since this may take a little while, the result will 3218 * be posted back to the given observer. An installation will fail if the calling context 3219 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the 3220 * package named in the package file's manifest is already installed, or if there's no space 3221 * available on the device. 3222 * 3223 * @param packageURI The location of the package file to install. This can be a 'file:' or a 3224 * 'content:' URI. 3225 * @param observer An observer callback to get notified when the package installation is 3226 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3227 * called when that happens. This parameter must not be null. 3228 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3229 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3230 * @param installerPackageName Optional package name of the application that is performing the 3231 * installation. This identifies which market the package came from. 3232 */ 3233 public abstract void installPackage( 3234 Uri packageURI, PackageInstallObserver observer, 3235 int flags, String installerPackageName); 3236 3237 /** 3238 * Similar to 3239 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3240 * with an extra verification file provided. 3241 * 3242 * @param packageURI The location of the package file to install. This can 3243 * be a 'file:' or a 'content:' URI. 3244 * @param observer An observer callback to get notified when the package installation is 3245 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3246 * called when that happens. This parameter must not be null. 3247 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3248 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3249 * @param installerPackageName Optional package name of the application that 3250 * is performing the installation. This identifies which market 3251 * the package came from. 3252 * @param verificationURI The location of the supplementary verification 3253 * file. This can be a 'file:' or a 'content:' URI. May be 3254 * {@code null}. 3255 * @param manifestDigest an object that holds the digest of the package 3256 * which can be used to verify ownership. May be {@code null}. 3257 * @param encryptionParams if the package to be installed is encrypted, 3258 * these parameters describing the encryption and authentication 3259 * used. May be {@code null}. 3260 * @hide 3261 */ 3262 public abstract void installPackageWithVerification(Uri packageURI, 3263 PackageInstallObserver observer, int flags, String installerPackageName, 3264 Uri verificationURI, ManifestDigest manifestDigest, 3265 ContainerEncryptionParams encryptionParams); 3266 3267 /** 3268 * Similar to 3269 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3270 * with an extra verification information provided. 3271 * 3272 * @param packageURI The location of the package file to install. This can 3273 * be a 'file:' or a 'content:' URI. 3274 * @param observer An observer callback to get notified when the package installation is 3275 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3276 * called when that happens. This parameter must not be null. 3277 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3278 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3279 * @param installerPackageName Optional package name of the application that 3280 * is performing the installation. This identifies which market 3281 * the package came from. 3282 * @param verificationParams an object that holds signal information to 3283 * assist verification. May be {@code null}. 3284 * @param encryptionParams if the package to be installed is encrypted, 3285 * these parameters describing the encryption and authentication 3286 * used. May be {@code null}. 3287 * 3288 * @hide 3289 */ 3290 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 3291 PackageInstallObserver observer, int flags, String installerPackageName, 3292 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams); 3293 3294 /** 3295 * If there is already an application with the given package name installed 3296 * on the system for other users, also install it for the calling user. 3297 * @hide 3298 */ 3299 // @SystemApi 3300 public abstract int installExistingPackage(String packageName) 3301 throws NameNotFoundException; 3302 3303 /** 3304 * Allows a package listening to the 3305 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 3306 * broadcast} to respond to the package manager. The response must include 3307 * the {@code verificationCode} which is one of 3308 * {@link PackageManager#VERIFICATION_ALLOW} or 3309 * {@link PackageManager#VERIFICATION_REJECT}. 3310 * 3311 * @param id pending package identifier as passed via the 3312 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 3313 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 3314 * or {@link PackageManager#VERIFICATION_REJECT}. 3315 * @throws SecurityException if the caller does not have the 3316 * PACKAGE_VERIFICATION_AGENT permission. 3317 */ 3318 public abstract void verifyPendingInstall(int id, int verificationCode); 3319 3320 /** 3321 * Allows a package listening to the 3322 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 3323 * broadcast} to extend the default timeout for a response and declare what 3324 * action to perform after the timeout occurs. The response must include 3325 * the {@code verificationCodeAtTimeout} which is one of 3326 * {@link PackageManager#VERIFICATION_ALLOW} or 3327 * {@link PackageManager#VERIFICATION_REJECT}. 3328 * 3329 * This method may only be called once per package id. Additional calls 3330 * will have no effect. 3331 * 3332 * @param id pending package identifier as passed via the 3333 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 3334 * @param verificationCodeAtTimeout either 3335 * {@link PackageManager#VERIFICATION_ALLOW} or 3336 * {@link PackageManager#VERIFICATION_REJECT}. If 3337 * {@code verificationCodeAtTimeout} is neither 3338 * {@link PackageManager#VERIFICATION_ALLOW} or 3339 * {@link PackageManager#VERIFICATION_REJECT}, then 3340 * {@code verificationCodeAtTimeout} will default to 3341 * {@link PackageManager#VERIFICATION_REJECT}. 3342 * @param millisecondsToDelay the amount of time requested for the timeout. 3343 * Must be positive and less than 3344 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 3345 * {@code millisecondsToDelay} is out of bounds, 3346 * {@code millisecondsToDelay} will be set to the closest in 3347 * bounds value; namely, 0 or 3348 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 3349 * @throws SecurityException if the caller does not have the 3350 * PACKAGE_VERIFICATION_AGENT permission. 3351 */ 3352 public abstract void extendVerificationTimeout(int id, 3353 int verificationCodeAtTimeout, long millisecondsToDelay); 3354 3355 /** 3356 * Change the installer associated with a given package. There are limitations 3357 * on how the installer package can be changed; in particular: 3358 * <ul> 3359 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 3360 * is not signed with the same certificate as the calling application. 3361 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 3362 * has an installer package, and that installer package is not signed with 3363 * the same certificate as the calling application. 3364 * </ul> 3365 * 3366 * @param targetPackage The installed package whose installer will be changed. 3367 * @param installerPackageName The package name of the new installer. May be 3368 * null to clear the association. 3369 */ 3370 public abstract void setInstallerPackageName(String targetPackage, 3371 String installerPackageName); 3372 3373 /** 3374 * Attempts to delete a package. Since this may take a little while, the result will 3375 * be posted back to the given observer. A deletion will fail if the calling context 3376 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 3377 * named package cannot be found, or if the named package is a "system package". 3378 * (TODO: include pointer to documentation on "system packages") 3379 * 3380 * @param packageName The name of the package to delete 3381 * @param observer An observer callback to get notified when the package deletion is 3382 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 3383 * called when that happens. observer may be null to indicate that no callback is desired. 3384 * @param flags - possible values: {@link #DELETE_KEEP_DATA}, 3385 * {@link #DELETE_ALL_USERS}. 3386 * 3387 * @hide 3388 */ 3389 // @SystemApi 3390 public abstract void deletePackage( 3391 String packageName, IPackageDeleteObserver observer, int flags); 3392 3393 /** 3394 * Retrieve the package name of the application that installed a package. This identifies 3395 * which market the package came from. 3396 * 3397 * @param packageName The name of the package to query 3398 */ 3399 public abstract String getInstallerPackageName(String packageName); 3400 3401 /** 3402 * Attempts to clear the user data directory of an application. 3403 * Since this may take a little while, the result will 3404 * be posted back to the given observer. A deletion will fail if the 3405 * named package cannot be found, or if the named package is a "system package". 3406 * 3407 * @param packageName The name of the package 3408 * @param observer An observer callback to get notified when the operation is finished 3409 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 3410 * will be called when that happens. observer may be null to indicate that 3411 * no callback is desired. 3412 * 3413 * @hide 3414 */ 3415 public abstract void clearApplicationUserData(String packageName, 3416 IPackageDataObserver observer); 3417 /** 3418 * Attempts to delete the cache files associated with an application. 3419 * Since this may take a little while, the result will 3420 * be posted back to the given observer. A deletion will fail if the calling context 3421 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 3422 * named package cannot be found, or if the named package is a "system package". 3423 * 3424 * @param packageName The name of the package to delete 3425 * @param observer An observer callback to get notified when the cache file deletion 3426 * is complete. 3427 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 3428 * will be called when that happens. observer may be null to indicate that 3429 * no callback is desired. 3430 * 3431 * @hide 3432 */ 3433 public abstract void deleteApplicationCacheFiles(String packageName, 3434 IPackageDataObserver observer); 3435 3436 /** 3437 * Free storage by deleting LRU sorted list of cache files across 3438 * all applications. If the currently available free storage 3439 * on the device is greater than or equal to the requested 3440 * free storage, no cache files are cleared. If the currently 3441 * available storage on the device is less than the requested 3442 * free storage, some or all of the cache files across 3443 * all applications are deleted (based on last accessed time) 3444 * to increase the free storage space on the device to 3445 * the requested value. There is no guarantee that clearing all 3446 * the cache files from all applications will clear up 3447 * enough storage to achieve the desired value. 3448 * @param freeStorageSize The number of bytes of storage to be 3449 * freed by the system. Say if freeStorageSize is XX, 3450 * and the current free storage is YY, 3451 * if XX is less than YY, just return. if not free XX-YY number 3452 * of bytes if possible. 3453 * @param observer call back used to notify when 3454 * the operation is completed 3455 * 3456 * @hide 3457 */ 3458 // @SystemApi 3459 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer); 3460 3461 /** 3462 * Free storage by deleting LRU sorted list of cache files across 3463 * all applications. If the currently available free storage 3464 * on the device is greater than or equal to the requested 3465 * free storage, no cache files are cleared. If the currently 3466 * available storage on the device is less than the requested 3467 * free storage, some or all of the cache files across 3468 * all applications are deleted (based on last accessed time) 3469 * to increase the free storage space on the device to 3470 * the requested value. There is no guarantee that clearing all 3471 * the cache files from all applications will clear up 3472 * enough storage to achieve the desired value. 3473 * @param freeStorageSize The number of bytes of storage to be 3474 * freed by the system. Say if freeStorageSize is XX, 3475 * and the current free storage is YY, 3476 * if XX is less than YY, just return. if not free XX-YY number 3477 * of bytes if possible. 3478 * @param pi IntentSender call back used to 3479 * notify when the operation is completed.May be null 3480 * to indicate that no call back is desired. 3481 * 3482 * @hide 3483 */ 3484 public abstract void freeStorage(long freeStorageSize, IntentSender pi); 3485 3486 /** 3487 * Retrieve the size information for a package. 3488 * Since this may take a little while, the result will 3489 * be posted back to the given observer. The calling context 3490 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 3491 * 3492 * @param packageName The name of the package whose size information is to be retrieved 3493 * @param userHandle The user whose size information should be retrieved. 3494 * @param observer An observer callback to get notified when the operation 3495 * is complete. 3496 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 3497 * The observer's callback is invoked with a PackageStats object(containing the 3498 * code, data and cache sizes of the package) and a boolean value representing 3499 * the status of the operation. observer may be null to indicate that 3500 * no callback is desired. 3501 * 3502 * @hide 3503 */ 3504 public abstract void getPackageSizeInfo(String packageName, int userHandle, 3505 IPackageStatsObserver observer); 3506 3507 /** 3508 * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but 3509 * returns the size for the calling user. 3510 * 3511 * @hide 3512 */ 3513 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 3514 getPackageSizeInfo(packageName, UserHandle.myUserId(), observer); 3515 } 3516 3517 /** 3518 * @deprecated This function no longer does anything; it was an old 3519 * approach to managing preferred activities, which has been superseded 3520 * by (and conflicts with) the modern activity-based preferences. 3521 */ 3522 @Deprecated 3523 public abstract void addPackageToPreferred(String packageName); 3524 3525 /** 3526 * @deprecated This function no longer does anything; it was an old 3527 * approach to managing preferred activities, which has been superseded 3528 * by (and conflicts with) the modern activity-based preferences. 3529 */ 3530 @Deprecated 3531 public abstract void removePackageFromPreferred(String packageName); 3532 3533 /** 3534 * Retrieve the list of all currently configured preferred packages. The 3535 * first package on the list is the most preferred, the last is the 3536 * least preferred. 3537 * 3538 * @param flags Additional option flags. Use any combination of 3539 * {@link #GET_ACTIVITIES}, 3540 * {@link #GET_GIDS}, 3541 * {@link #GET_CONFIGURATIONS}, 3542 * {@link #GET_INSTRUMENTATION}, 3543 * {@link #GET_PERMISSIONS}, 3544 * {@link #GET_PROVIDERS}, 3545 * {@link #GET_RECEIVERS}, 3546 * {@link #GET_SERVICES}, 3547 * {@link #GET_SIGNATURES}, to modify the data returned. 3548 * 3549 * @return Returns a list of PackageInfo objects describing each 3550 * preferred application, in order of preference. 3551 * 3552 * @see #GET_ACTIVITIES 3553 * @see #GET_GIDS 3554 * @see #GET_CONFIGURATIONS 3555 * @see #GET_INSTRUMENTATION 3556 * @see #GET_PERMISSIONS 3557 * @see #GET_PROVIDERS 3558 * @see #GET_RECEIVERS 3559 * @see #GET_SERVICES 3560 * @see #GET_SIGNATURES 3561 */ 3562 public abstract List<PackageInfo> getPreferredPackages(int flags); 3563 3564 /** 3565 * @deprecated This is a protected API that should not have been available 3566 * to third party applications. It is the platform's responsibility for 3567 * assigning preferred activities and this cannot be directly modified. 3568 * 3569 * Add a new preferred activity mapping to the system. This will be used 3570 * to automatically select the given activity component when 3571 * {@link Context#startActivity(Intent) Context.startActivity()} finds 3572 * multiple matching activities and also matches the given filter. 3573 * 3574 * @param filter The set of intents under which this activity will be 3575 * made preferred. 3576 * @param match The IntentFilter match category that this preference 3577 * applies to. 3578 * @param set The set of activities that the user was picking from when 3579 * this preference was made. 3580 * @param activity The component name of the activity that is to be 3581 * preferred. 3582 */ 3583 @Deprecated 3584 public abstract void addPreferredActivity(IntentFilter filter, int match, 3585 ComponentName[] set, ComponentName activity); 3586 3587 /** 3588 * Same as {@link #addPreferredActivity(IntentFilter, int, 3589 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 3590 to. 3591 * @hide 3592 */ 3593 public void addPreferredActivity(IntentFilter filter, int match, 3594 ComponentName[] set, ComponentName activity, int userId) { 3595 throw new RuntimeException("Not implemented. Must override in a subclass."); 3596 } 3597 3598 /** 3599 * @deprecated This is a protected API that should not have been available 3600 * to third party applications. It is the platform's responsibility for 3601 * assigning preferred activities and this cannot be directly modified. 3602 * 3603 * Replaces an existing preferred activity mapping to the system, and if that were not present 3604 * adds a new preferred activity. This will be used 3605 * to automatically select the given activity component when 3606 * {@link Context#startActivity(Intent) Context.startActivity()} finds 3607 * multiple matching activities and also matches the given filter. 3608 * 3609 * @param filter The set of intents under which this activity will be 3610 * made preferred. 3611 * @param match The IntentFilter match category that this preference 3612 * applies to. 3613 * @param set The set of activities that the user was picking from when 3614 * this preference was made. 3615 * @param activity The component name of the activity that is to be 3616 * preferred. 3617 * @hide 3618 */ 3619 @Deprecated 3620 public abstract void replacePreferredActivity(IntentFilter filter, int match, 3621 ComponentName[] set, ComponentName activity); 3622 3623 /** 3624 * @hide 3625 */ 3626 @Deprecated 3627 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 3628 ComponentName[] set, ComponentName activity, int userId) { 3629 throw new RuntimeException("Not implemented. Must override in a subclass."); 3630 } 3631 3632 /** 3633 * Remove all preferred activity mappings, previously added with 3634 * {@link #addPreferredActivity}, from the 3635 * system whose activities are implemented in the given package name. 3636 * An application can only clear its own package(s). 3637 * 3638 * @param packageName The name of the package whose preferred activity 3639 * mappings are to be removed. 3640 */ 3641 public abstract void clearPackagePreferredActivities(String packageName); 3642 3643 /** 3644 * Retrieve all preferred activities, previously added with 3645 * {@link #addPreferredActivity}, that are 3646 * currently registered with the system. 3647 * 3648 * @param outFilters A list in which to place the filters of all of the 3649 * preferred activities, or null for none. 3650 * @param outActivities A list in which to place the component names of 3651 * all of the preferred activities, or null for none. 3652 * @param packageName An option package in which you would like to limit 3653 * the list. If null, all activities will be returned; if non-null, only 3654 * those activities in the given package are returned. 3655 * 3656 * @return Returns the total number of registered preferred activities 3657 * (the number of distinct IntentFilter records, not the number of unique 3658 * activity components) that were found. 3659 */ 3660 public abstract int getPreferredActivities(List<IntentFilter> outFilters, 3661 List<ComponentName> outActivities, String packageName); 3662 3663 /** 3664 * Ask for the set of available 'home' activities and the current explicit 3665 * default, if any. 3666 * @hide 3667 */ 3668 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 3669 3670 /** 3671 * Set the enabled setting for a package component (activity, receiver, service, provider). 3672 * This setting will override any enabled state which may have been set by the component in its 3673 * manifest. 3674 * 3675 * @param componentName The component to enable 3676 * @param newState The new enabled state for the component. The legal values for this state 3677 * are: 3678 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 3679 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 3680 * and 3681 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 3682 * The last one removes the setting, thereby restoring the component's state to 3683 * whatever was set in it's manifest (or enabled, by default). 3684 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 3685 */ 3686 public abstract void setComponentEnabledSetting(ComponentName componentName, 3687 int newState, int flags); 3688 3689 3690 /** 3691 * Return the enabled setting for a package component (activity, 3692 * receiver, service, provider). This returns the last value set by 3693 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 3694 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 3695 * the value originally specified in the manifest has not been modified. 3696 * 3697 * @param componentName The component to retrieve. 3698 * @return Returns the current enabled state for the component. May 3699 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 3700 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 3701 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 3702 * component's enabled state is based on the original information in 3703 * the manifest as found in {@link ComponentInfo}. 3704 */ 3705 public abstract int getComponentEnabledSetting(ComponentName componentName); 3706 3707 /** 3708 * Set the enabled setting for an application 3709 * This setting will override any enabled state which may have been set by the application in 3710 * its manifest. It also overrides the enabled state set in the manifest for any of the 3711 * application's components. It does not override any enabled state set by 3712 * {@link #setComponentEnabledSetting} for any of the application's components. 3713 * 3714 * @param packageName The package name of the application to enable 3715 * @param newState The new enabled state for the component. The legal values for this state 3716 * are: 3717 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 3718 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 3719 * and 3720 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 3721 * The last one removes the setting, thereby restoring the applications's state to 3722 * whatever was set in its manifest (or enabled, by default). 3723 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 3724 */ 3725 public abstract void setApplicationEnabledSetting(String packageName, 3726 int newState, int flags); 3727 3728 /** 3729 * Return the enabled setting for an application. This returns 3730 * the last value set by 3731 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 3732 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 3733 * the value originally specified in the manifest has not been modified. 3734 * 3735 * @param packageName The package name of the application to retrieve. 3736 * @return Returns the current enabled state for the application. May 3737 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 3738 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 3739 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 3740 * application's enabled state is based on the original information in 3741 * the manifest as found in {@link ComponentInfo}. 3742 * @throws IllegalArgumentException if the named package does not exist. 3743 */ 3744 public abstract int getApplicationEnabledSetting(String packageName); 3745 3746 /** 3747 * Puts the package in a hidden state, which is almost like an uninstalled state, 3748 * making the package unavailable, but it doesn't remove the data or the actual 3749 * package file. Application can be unhidden by either resetting the hidden state 3750 * or by installing it, such as with {@link #installExistingPackage(String)} 3751 * @hide 3752 */ 3753 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 3754 UserHandle userHandle); 3755 3756 /** 3757 * Returns the hidden state of a package. 3758 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 3759 * @hide 3760 */ 3761 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 3762 UserHandle userHandle); 3763 3764 /** 3765 * Return whether the device has been booted into safe mode. 3766 */ 3767 public abstract boolean isSafeMode(); 3768 3769 /** 3770 * Return the {@link KeySet} associated with the String alias for this 3771 * application. 3772 * 3773 * @param alias The alias for a given {@link KeySet} as defined in the 3774 * application's AndroidManifest.xml. 3775 * @hide 3776 */ 3777 public abstract KeySet getKeySetByAlias(String packageName, String alias); 3778 3779 /** Return the signing {@link KeySet} for this application. 3780 * @hide 3781 */ 3782 public abstract KeySet getSigningKeySet(String packageName); 3783 3784 /** 3785 * Return whether the package denoted by packageName has been signed by all 3786 * of the keys specified by the {@link KeySet} ks. This will return true if 3787 * the package has been signed by additional keys (a superset) as well. 3788 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 3789 * @hide 3790 */ 3791 public abstract boolean isSignedBy(String packageName, KeySet ks); 3792 3793 /** 3794 * Return whether the package denoted by packageName has been signed by all 3795 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 3796 * {@link #isSignedBy(String packageName, KeySet ks)}. 3797 * @hide 3798 */ 3799 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 3800 3801 /** 3802 * Attempts to move package resources from internal to external media or vice versa. 3803 * Since this may take a little while, the result will 3804 * be posted back to the given observer. This call may fail if the calling context 3805 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the 3806 * named package cannot be found, or if the named package is a "system package". 3807 * 3808 * @param packageName The name of the package to delete 3809 * @param observer An observer callback to get notified when the package move is 3810 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be 3811 * called when that happens. observer may be null to indicate that no callback is desired. 3812 * @param flags To indicate install location {@link #MOVE_INTERNAL} or 3813 * {@link #MOVE_EXTERNAL_MEDIA} 3814 * 3815 * @hide 3816 */ 3817 public abstract void movePackage( 3818 String packageName, IPackageMoveObserver observer, int flags); 3819 3820 /** 3821 * Returns the device identity that verifiers can use to associate their scheme to a particular 3822 * device. This should not be used by anything other than a package verifier. 3823 * 3824 * @return identity that uniquely identifies current device 3825 * @hide 3826 */ 3827 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 3828 3829 /** 3830 * Return interface that offers the ability to install, upgrade, and remove 3831 * applications on the device. 3832 */ 3833 public abstract @NonNull PackageInstaller getPackageInstaller(); 3834 3835 /** 3836 * Returns the data directory for a particular user and package, given the uid of the package. 3837 * @param uid uid of the package, including the userId and appId 3838 * @param packageName name of the package 3839 * @return the user-specific data directory for the package 3840 * @hide 3841 */ 3842 public static String getDataDirForUser(int userId, String packageName) { 3843 // TODO: This should be shared with Installer's knowledge of user directory 3844 return Environment.getDataDirectory().toString() + "/user/" + userId 3845 + "/" + packageName; 3846 } 3847 3848 /** 3849 * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the 3850 * user with id sourceUserId can also be be resolved by activities in the user with id 3851 * targetUserId if they match the specified intent filter. 3852 * @param filter The {@link IntentFilter} the intent has to match 3853 * @param sourceUserId The source user id. 3854 * @param targetUserId The target user id. 3855 * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE} 3856 * @hide 3857 */ 3858 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 3859 int targetUserId, int flags); 3860 3861 /** 3862 * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their 3863 * source, and have been set by the app calling this method. 3864 * @param sourceUserId The source user id. 3865 * @hide 3866 */ 3867 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 3868 3869 /** 3870 * Forwards all intents for {@link packageName} for user {@link sourceUserId} to user 3871 * {@link targetUserId}. 3872 * @hide 3873 */ 3874 public abstract void addCrossProfileIntentsForPackage(String packageName, 3875 int sourceUserId, int targetUserId); 3876 3877 /** 3878 * Removes all intents for {@link packageName} for user {@link sourceUserId} to user 3879 * {@link targetUserId}. 3880 * @hide 3881 */ 3882 public abstract void removeCrossProfileIntentsForPackage(String packageName, 3883 int sourceUserId, int targetUserId); 3884 3885 /** 3886 * @hide 3887 */ 3888 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 3889 3890 /** {@hide} */ 3891 public abstract boolean isPackageAvailable(String packageName); 3892 3893 /** {@hide} */ 3894 public static String installStatusToString(int status, String msg) { 3895 final String str = installStatusToString(status); 3896 if (msg != null) { 3897 return str + ": " + msg; 3898 } else { 3899 return str; 3900 } 3901 } 3902 3903 /** {@hide} */ 3904 public static String installStatusToString(int status) { 3905 switch (status) { 3906 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 3907 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 3908 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 3909 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 3910 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 3911 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 3912 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 3913 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 3914 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 3915 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 3916 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 3917 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 3918 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 3919 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 3920 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 3921 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 3922 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 3923 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 3924 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 3925 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 3926 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 3927 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 3928 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 3929 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 3930 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 3931 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 3932 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 3933 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 3934 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 3935 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 3936 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 3937 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 3938 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 3939 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 3940 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 3941 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 3942 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 3943 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 3944 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 3945 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 3946 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 3947 default: return Integer.toString(status); 3948 } 3949 } 3950 3951 /** {@hide} */ 3952 public static int installStatusToPublicStatus(int status) { 3953 switch (status) { 3954 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 3955 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3956 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 3957 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 3958 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 3959 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3960 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3961 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3962 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3963 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3964 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3965 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 3966 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3967 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3968 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3969 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 3970 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3971 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3972 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 3973 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 3974 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 3975 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 3976 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 3977 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 3978 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 3979 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 3980 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 3981 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 3982 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 3983 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 3984 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 3985 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 3986 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 3987 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 3988 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 3989 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 3990 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 3991 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3992 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3993 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3994 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 3995 default: return PackageInstaller.STATUS_FAILURE; 3996 } 3997 } 3998 3999 /** {@hide} */ 4000 public static String deleteStatusToString(int status, String msg) { 4001 final String str = deleteStatusToString(status); 4002 if (msg != null) { 4003 return str + ": " + msg; 4004 } else { 4005 return str; 4006 } 4007 } 4008 4009 /** {@hide} */ 4010 public static String deleteStatusToString(int status) { 4011 switch (status) { 4012 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 4013 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 4014 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 4015 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 4016 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 4017 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 4018 default: return Integer.toString(status); 4019 } 4020 } 4021 4022 /** {@hide} */ 4023 public static int deleteStatusToPublicStatus(int status) { 4024 switch (status) { 4025 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 4026 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 4027 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 4028 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 4029 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 4030 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 4031 default: return PackageInstaller.STATUS_FAILURE; 4032 } 4033 } 4034 4035 /** {@hide} */ 4036 public static class LegacyPackageInstallObserver extends PackageInstallObserver { 4037 private final IPackageInstallObserver mLegacy; 4038 4039 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { 4040 mLegacy = legacy; 4041 } 4042 4043 @Override 4044 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 4045 Bundle extras) { 4046 if (mLegacy == null) return; 4047 try { 4048 mLegacy.packageInstalled(basePackageName, returnCode); 4049 } catch (RemoteException ignored) { 4050 } 4051 } 4052 } 4053 4054 /** {@hide} */ 4055 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 4056 private final IPackageDeleteObserver mLegacy; 4057 4058 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 4059 mLegacy = legacy; 4060 } 4061 4062 @Override 4063 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 4064 if (mLegacy == null) return; 4065 try { 4066 mLegacy.packageDeleted(basePackageName, returnCode); 4067 } catch (RemoteException ignored) { 4068 } 4069 } 4070 } 4071} 4072