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