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