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