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