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