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