PackageManager.java revision 1ab7689ce8a4164a86cf472fa028d7b0f18f696f
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 is capable of communicating with 979 * other devices via Bluetooth. 980 */ 981 @SdkConstant(SdkConstantType.FEATURE) 982 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 983 984 /** 985 * Feature for {@link #getSystemAvailableFeatures} and 986 * {@link #hasSystemFeature}: The device is capable of communicating with 987 * other devices via Bluetooth Low Energy radio. 988 */ 989 @SdkConstant(SdkConstantType.FEATURE) 990 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le"; 991 992 /** 993 * Feature for {@link #getSystemAvailableFeatures} and 994 * {@link #hasSystemFeature}: The device has a camera facing away 995 * from the screen. 996 */ 997 @SdkConstant(SdkConstantType.FEATURE) 998 public static final String FEATURE_CAMERA = "android.hardware.camera"; 999 1000 /** 1001 * Feature for {@link #getSystemAvailableFeatures} and 1002 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 1003 */ 1004 @SdkConstant(SdkConstantType.FEATURE) 1005 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 1006 1007 /** 1008 * Feature for {@link #getSystemAvailableFeatures} and 1009 * {@link #hasSystemFeature}: The device has at least one camera pointing in 1010 * some direction, or can support an external camera being connected to it. 1011 */ 1012 @SdkConstant(SdkConstantType.FEATURE) 1013 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any"; 1014 1015 /** 1016 * Feature for {@link #getSystemAvailableFeatures} and 1017 * {@link #hasSystemFeature}: The device can support having an external camera connected to it. 1018 * The external camera may not always be connected or available to applications to use. 1019 */ 1020 @SdkConstant(SdkConstantType.FEATURE) 1021 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external"; 1022 1023 /** 1024 * Feature for {@link #getSystemAvailableFeatures} and 1025 * {@link #hasSystemFeature}: The device's camera supports flash. 1026 */ 1027 @SdkConstant(SdkConstantType.FEATURE) 1028 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 1029 1030 /** 1031 * Feature for {@link #getSystemAvailableFeatures} and 1032 * {@link #hasSystemFeature}: The device has a front facing camera. 1033 */ 1034 @SdkConstant(SdkConstantType.FEATURE) 1035 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 1036 1037 /** 1038 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1039 * of the cameras on the device supports the 1040 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware} 1041 * capability level. 1042 */ 1043 @SdkConstant(SdkConstantType.FEATURE) 1044 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full"; 1045 1046 /** 1047 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1048 * of the cameras on the device supports the 1049 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor} 1050 * capability level. 1051 */ 1052 @SdkConstant(SdkConstantType.FEATURE) 1053 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR = 1054 "android.hardware.camera.capability.manual_sensor"; 1055 1056 /** 1057 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1058 * of the cameras on the device supports the 1059 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing} 1060 * capability level. 1061 */ 1062 @SdkConstant(SdkConstantType.FEATURE) 1063 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING = 1064 "android.hardware.camera.capability.manual_post_processing"; 1065 1066 /** 1067 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1068 * of the cameras on the device supports the 1069 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW} 1070 * capability level. 1071 */ 1072 @SdkConstant(SdkConstantType.FEATURE) 1073 public static final String FEATURE_CAMERA_CAPABILITY_RAW = 1074 "android.hardware.camera.capability.raw"; 1075 1076 /** 1077 * Feature for {@link #getSystemAvailableFeatures} and 1078 * {@link #hasSystemFeature}: The device is capable of communicating with 1079 * consumer IR devices. 1080 */ 1081 @SdkConstant(SdkConstantType.FEATURE) 1082 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir"; 1083 1084 /** 1085 * Feature for {@link #getSystemAvailableFeatures} and 1086 * {@link #hasSystemFeature}: The device supports one or more methods of 1087 * reporting current location. 1088 */ 1089 @SdkConstant(SdkConstantType.FEATURE) 1090 public static final String FEATURE_LOCATION = "android.hardware.location"; 1091 1092 /** 1093 * Feature for {@link #getSystemAvailableFeatures} and 1094 * {@link #hasSystemFeature}: The device has a Global Positioning System 1095 * receiver and can report precise location. 1096 */ 1097 @SdkConstant(SdkConstantType.FEATURE) 1098 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 1099 1100 /** 1101 * Feature for {@link #getSystemAvailableFeatures} and 1102 * {@link #hasSystemFeature}: The device can report location with coarse 1103 * accuracy using a network-based geolocation system. 1104 */ 1105 @SdkConstant(SdkConstantType.FEATURE) 1106 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 1107 1108 /** 1109 * Feature for {@link #getSystemAvailableFeatures} and 1110 * {@link #hasSystemFeature}: The device can record audio via a 1111 * microphone. 1112 */ 1113 @SdkConstant(SdkConstantType.FEATURE) 1114 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 1115 1116 /** 1117 * Feature for {@link #getSystemAvailableFeatures} and 1118 * {@link #hasSystemFeature}: The device can communicate using Near-Field 1119 * Communications (NFC). 1120 */ 1121 @SdkConstant(SdkConstantType.FEATURE) 1122 public static final String FEATURE_NFC = "android.hardware.nfc"; 1123 1124 /** 1125 * Feature for {@link #getSystemAvailableFeatures} and 1126 * {@link #hasSystemFeature}: The device supports host- 1127 * based NFC card emulation. 1128 * 1129 * TODO remove when depending apps have moved to new constant. 1130 * @hide 1131 * @deprecated 1132 */ 1133 @Deprecated 1134 @SdkConstant(SdkConstantType.FEATURE) 1135 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce"; 1136 1137 /** 1138 * Feature for {@link #getSystemAvailableFeatures} and 1139 * {@link #hasSystemFeature}: The device supports host- 1140 * based NFC card emulation. 1141 */ 1142 @SdkConstant(SdkConstantType.FEATURE) 1143 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; 1144 1145 /** 1146 * Feature for {@link #getSystemAvailableFeatures} and 1147 * {@link #hasSystemFeature}: The device supports the OpenGL ES 1148 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 1149 * Android Extension Pack</a>. 1150 */ 1151 @SdkConstant(SdkConstantType.FEATURE) 1152 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 1153 1154 /** 1155 * Feature for {@link #getSystemAvailableFeatures} and 1156 * {@link #hasSystemFeature}: The device includes an accelerometer. 1157 */ 1158 @SdkConstant(SdkConstantType.FEATURE) 1159 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 1160 1161 /** 1162 * Feature for {@link #getSystemAvailableFeatures} and 1163 * {@link #hasSystemFeature}: The device includes a barometer (air 1164 * pressure sensor.) 1165 */ 1166 @SdkConstant(SdkConstantType.FEATURE) 1167 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 1168 1169 /** 1170 * Feature for {@link #getSystemAvailableFeatures} and 1171 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 1172 */ 1173 @SdkConstant(SdkConstantType.FEATURE) 1174 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 1175 1176 /** 1177 * Feature for {@link #getSystemAvailableFeatures} and 1178 * {@link #hasSystemFeature}: The device includes a gyroscope. 1179 */ 1180 @SdkConstant(SdkConstantType.FEATURE) 1181 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 1182 1183 /** 1184 * Feature for {@link #getSystemAvailableFeatures} and 1185 * {@link #hasSystemFeature}: The device includes a light sensor. 1186 */ 1187 @SdkConstant(SdkConstantType.FEATURE) 1188 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 1189 1190 /** 1191 * Feature for {@link #getSystemAvailableFeatures} and 1192 * {@link #hasSystemFeature}: The device includes a proximity sensor. 1193 */ 1194 @SdkConstant(SdkConstantType.FEATURE) 1195 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 1196 1197 /** 1198 * Feature for {@link #getSystemAvailableFeatures} and 1199 * {@link #hasSystemFeature}: The device includes a hardware step counter. 1200 */ 1201 @SdkConstant(SdkConstantType.FEATURE) 1202 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 1203 1204 /** 1205 * Feature for {@link #getSystemAvailableFeatures} and 1206 * {@link #hasSystemFeature}: The device includes a hardware step detector. 1207 */ 1208 @SdkConstant(SdkConstantType.FEATURE) 1209 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 1210 1211 /** 1212 * Feature for {@link #getSystemAvailableFeatures} and 1213 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 1214 */ 1215 @SdkConstant(SdkConstantType.FEATURE) 1216 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 1217 1218 /** 1219 * Feature for {@link #getSystemAvailableFeatures} and 1220 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocargiogram. 1221 */ 1222 @SdkConstant(SdkConstantType.FEATURE) 1223 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 1224 "android.hardware.sensor.heartrate.ecg"; 1225 1226 /** 1227 * Feature for {@link #getSystemAvailableFeatures} and 1228 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 1229 */ 1230 @SdkConstant(SdkConstantType.FEATURE) 1231 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 1232 "android.hardware.sensor.relative_humidity"; 1233 1234 /** 1235 * Feature for {@link #getSystemAvailableFeatures} and 1236 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 1237 */ 1238 @SdkConstant(SdkConstantType.FEATURE) 1239 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 1240 "android.hardware.sensor.ambient_temperature"; 1241 1242 /** 1243 * Feature for {@link #getSystemAvailableFeatures} and 1244 * {@link #hasSystemFeature}: The device has a telephony radio with data 1245 * communication support. 1246 */ 1247 @SdkConstant(SdkConstantType.FEATURE) 1248 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 1249 1250 /** 1251 * Feature for {@link #getSystemAvailableFeatures} and 1252 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 1253 */ 1254 @SdkConstant(SdkConstantType.FEATURE) 1255 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 1256 1257 /** 1258 * Feature for {@link #getSystemAvailableFeatures} and 1259 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 1260 */ 1261 @SdkConstant(SdkConstantType.FEATURE) 1262 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 1263 1264 /** 1265 * Feature for {@link #getSystemAvailableFeatures} and 1266 * {@link #hasSystemFeature}: The device supports connecting to USB devices 1267 * as the USB host. 1268 */ 1269 @SdkConstant(SdkConstantType.FEATURE) 1270 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 1271 1272 /** 1273 * Feature for {@link #getSystemAvailableFeatures} and 1274 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 1275 */ 1276 @SdkConstant(SdkConstantType.FEATURE) 1277 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 1278 1279 /** 1280 * Feature for {@link #getSystemAvailableFeatures} and 1281 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 1282 */ 1283 @SdkConstant(SdkConstantType.FEATURE) 1284 public static final String FEATURE_SIP = "android.software.sip"; 1285 1286 /** 1287 * Feature for {@link #getSystemAvailableFeatures} and 1288 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 1289 */ 1290 @SdkConstant(SdkConstantType.FEATURE) 1291 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 1292 1293 /** 1294 * Feature for {@link #getSystemAvailableFeatures} and 1295 * {@link #hasSystemFeature}: The device's display has a touch screen. 1296 */ 1297 @SdkConstant(SdkConstantType.FEATURE) 1298 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 1299 1300 1301 /** 1302 * Feature for {@link #getSystemAvailableFeatures} and 1303 * {@link #hasSystemFeature}: The device's touch screen supports 1304 * multitouch sufficient for basic two-finger gesture detection. 1305 */ 1306 @SdkConstant(SdkConstantType.FEATURE) 1307 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 1308 1309 /** 1310 * Feature for {@link #getSystemAvailableFeatures} and 1311 * {@link #hasSystemFeature}: The device's touch screen is capable of 1312 * tracking two or more fingers fully independently. 1313 */ 1314 @SdkConstant(SdkConstantType.FEATURE) 1315 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 1316 1317 /** 1318 * Feature for {@link #getSystemAvailableFeatures} and 1319 * {@link #hasSystemFeature}: The device's touch screen is capable of 1320 * tracking a full hand of fingers fully independently -- that is, 5 or 1321 * more simultaneous independent pointers. 1322 */ 1323 @SdkConstant(SdkConstantType.FEATURE) 1324 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 1325 1326 /** 1327 * Feature for {@link #getSystemAvailableFeatures} and 1328 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1329 * does support touch emulation for basic events. For instance, the 1330 * device might use a mouse or remote control to drive a cursor, and 1331 * emulate basic touch pointer events like down, up, drag, etc. All 1332 * devices that support android.hardware.touchscreen or a sub-feature are 1333 * presumed to also support faketouch. 1334 */ 1335 @SdkConstant(SdkConstantType.FEATURE) 1336 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 1337 1338 /** 1339 * Feature for {@link #getSystemAvailableFeatures} and 1340 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1341 * does support touch emulation for basic events that supports distinct 1342 * tracking of two or more fingers. This is an extension of 1343 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1344 * that unlike a distinct multitouch screen as defined by 1345 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 1346 * devices will not actually provide full two-finger gestures since the 1347 * input is being transformed to cursor movement on the screen. That is, 1348 * single finger gestures will move a cursor; two-finger swipes will 1349 * result in single-finger touch events; other two-finger gestures will 1350 * result in the corresponding two-finger touch event. 1351 */ 1352 @SdkConstant(SdkConstantType.FEATURE) 1353 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 1354 1355 /** 1356 * Feature for {@link #getSystemAvailableFeatures} and 1357 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1358 * does support touch emulation for basic events that supports tracking 1359 * a hand of fingers (5 or more fingers) fully independently. 1360 * This is an extension of 1361 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1362 * that unlike a multitouch screen as defined by 1363 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 1364 * gestures can be detected due to the limitations described for 1365 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 1366 */ 1367 @SdkConstant(SdkConstantType.FEATURE) 1368 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 1369 1370 /** 1371 * Feature for {@link #getSystemAvailableFeatures} and 1372 * {@link #hasSystemFeature}: The device supports portrait orientation 1373 * screens. For backwards compatibility, you can assume that if neither 1374 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 1375 * both portrait and landscape. 1376 */ 1377 @SdkConstant(SdkConstantType.FEATURE) 1378 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 1379 1380 /** 1381 * Feature for {@link #getSystemAvailableFeatures} and 1382 * {@link #hasSystemFeature}: The device supports landscape orientation 1383 * screens. For backwards compatibility, you can assume that if neither 1384 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 1385 * both portrait and landscape. 1386 */ 1387 @SdkConstant(SdkConstantType.FEATURE) 1388 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 1389 1390 /** 1391 * Feature for {@link #getSystemAvailableFeatures} and 1392 * {@link #hasSystemFeature}: The device supports live wallpapers. 1393 */ 1394 @SdkConstant(SdkConstantType.FEATURE) 1395 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 1396 /** 1397 * Feature for {@link #getSystemAvailableFeatures} and 1398 * {@link #hasSystemFeature}: The device supports app widgets. 1399 */ 1400 @SdkConstant(SdkConstantType.FEATURE) 1401 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 1402 1403 /** 1404 * @hide 1405 * Feature for {@link #getSystemAvailableFeatures} and 1406 * {@link #hasSystemFeature}: The device supports 1407 * {@link android.service.voice.VoiceInteractionService} and 1408 * {@link android.app.VoiceInteractor}. 1409 */ 1410 @SdkConstant(SdkConstantType.FEATURE) 1411 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 1412 1413 1414 /** 1415 * Feature for {@link #getSystemAvailableFeatures} and 1416 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 1417 * by third party applications. 1418 */ 1419 @SdkConstant(SdkConstantType.FEATURE) 1420 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 1421 1422 /** 1423 * Feature for {@link #getSystemAvailableFeatures} and 1424 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 1425 * with the {@link android.inputmethodservice.InputMethodService} API. 1426 */ 1427 @SdkConstant(SdkConstantType.FEATURE) 1428 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 1429 1430 /** 1431 * Feature for {@link #getSystemAvailableFeatures} and 1432 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 1433 */ 1434 @SdkConstant(SdkConstantType.FEATURE) 1435 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 1436 1437 /** 1438 * Feature for {@link #getSystemAvailableFeatures} and 1439 * {@link #hasSystemFeature}: The device supports leanback UI. This is 1440 * typically used in a living room television experience, but is a software 1441 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 1442 * feature will use resources associated with the "television" UI mode. 1443 */ 1444 @SdkConstant(SdkConstantType.FEATURE) 1445 public static final String FEATURE_LEANBACK = "android.software.leanback"; 1446 1447 /** 1448 * Feature for {@link #getSystemAvailableFeatures} and 1449 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 1450 * applications designed for this experience should be run, though this is 1451 * not enforced by the system. 1452 * @hide 1453 */ 1454 @SdkConstant(SdkConstantType.FEATURE) 1455 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 1456 1457 /** 1458 * Feature for {@link #getSystemAvailableFeatures} and 1459 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 1460 */ 1461 @SdkConstant(SdkConstantType.FEATURE) 1462 public static final String FEATURE_WIFI = "android.hardware.wifi"; 1463 1464 /** 1465 * Feature for {@link #getSystemAvailableFeatures} and 1466 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 1467 */ 1468 @SdkConstant(SdkConstantType.FEATURE) 1469 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 1470 1471 /** 1472 * Feature for {@link #getSystemAvailableFeatures} and 1473 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1474 * on a television. Television here is defined to be a typical living 1475 * room television experience: displayed on a big screen, where the user 1476 * is sitting far away from it, and the dominant form of input will be 1477 * something like a DPAD, not through touch or mouse. 1478 * @deprecated use {@link #FEATURE_LEANBACK} instead. 1479 */ 1480 @Deprecated 1481 @SdkConstant(SdkConstantType.FEATURE) 1482 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 1483 1484 /** 1485 * Feature for {@link #getSystemAvailableFeatures} and 1486 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1487 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 1488 * the wrist. The user is very close when interacting with the device. 1489 */ 1490 @SdkConstant(SdkConstantType.FEATURE) 1491 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 1492 1493 /** 1494 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1495 * The device supports printing. 1496 */ 1497 @SdkConstant(SdkConstantType.FEATURE) 1498 public static final String FEATURE_PRINTING = "android.software.print"; 1499 1500 /** 1501 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1502 * The device can perform backup and restore operations on installed applications. 1503 */ 1504 @SdkConstant(SdkConstantType.FEATURE) 1505 public static final String FEATURE_BACKUP = "android.software.backup"; 1506 1507 /** 1508 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1509 * The device supports managed profiles for enterprise users. 1510 */ 1511 @SdkConstant(SdkConstantType.FEATURE) 1512 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_profiles"; 1513 1514 /** 1515 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1516 * The device has a full implementation of the android.webkit.* APIs. Devices 1517 * lacking this feature will not have a functioning WebView implementation. 1518 */ 1519 @SdkConstant(SdkConstantType.FEATURE) 1520 public static final String FEATURE_WEBVIEW = "android.software.webview"; 1521 1522 /** 1523 * Feature for {@link #getSystemAvailableFeatures} and 1524 * {@link #hasSystemFeature}: This device supports ethernet. 1525 * @hide 1526 */ 1527 @SdkConstant(SdkConstantType.FEATURE) 1528 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 1529 1530 /** 1531 * Feature for {@link #getSystemAvailableFeatures} and 1532 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 1533 * @hide 1534 */ 1535 @SdkConstant(SdkConstantType.FEATURE) 1536 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 1537 1538 /** 1539 * Action to external storage service to clean out removed apps. 1540 * @hide 1541 */ 1542 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 1543 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 1544 1545 /** 1546 * Extra field name for the URI to a verification file. Passed to a package 1547 * verifier. 1548 * 1549 * @hide 1550 */ 1551 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 1552 1553 /** 1554 * Extra field name for the ID of a package pending verification. Passed to 1555 * a package verifier and is used to call back to 1556 * {@link PackageManager#verifyPendingInstall(int, int)} 1557 */ 1558 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 1559 1560 /** 1561 * Extra field name for the package identifier which is trying to install 1562 * the package. 1563 * 1564 * @hide 1565 */ 1566 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 1567 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 1568 1569 /** 1570 * Extra field name for the requested install flags for a package pending 1571 * verification. Passed to a package verifier. 1572 * 1573 * @hide 1574 */ 1575 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 1576 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 1577 1578 /** 1579 * Extra field name for the uid of who is requesting to install 1580 * the package. 1581 * 1582 * @hide 1583 */ 1584 public static final String EXTRA_VERIFICATION_INSTALLER_UID 1585 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 1586 1587 /** 1588 * Extra field name for the package name of a package pending verification. 1589 * 1590 * @hide 1591 */ 1592 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 1593 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 1594 /** 1595 * Extra field name for the result of a verification, either 1596 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 1597 * Passed to package verifiers after a package is verified. 1598 */ 1599 public static final String EXTRA_VERIFICATION_RESULT 1600 = "android.content.pm.extra.VERIFICATION_RESULT"; 1601 1602 /** 1603 * Extra field name for the version code of a package pending verification. 1604 * 1605 * @hide 1606 */ 1607 public static final String EXTRA_VERIFICATION_VERSION_CODE 1608 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 1609 1610 /** 1611 * The action used to request that the user approve a permission request 1612 * from the application. 1613 * 1614 * @hide 1615 */ 1616 public static final String ACTION_REQUEST_PERMISSION 1617 = "android.content.pm.action.REQUEST_PERMISSION"; 1618 1619 /** 1620 * Extra field name for the list of permissions, which the user must approve. 1621 * 1622 * @hide 1623 */ 1624 public static final String EXTRA_REQUEST_PERMISSION_PERMISSION_LIST 1625 = "android.content.pm.extra.PERMISSION_LIST"; 1626 1627 /** 1628 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 1629 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 1630 * the existing definition for the permission. 1631 * @hide 1632 */ 1633 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 1634 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 1635 1636 /** 1637 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 1638 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 1639 * being redundantly defined by the package being installed. 1640 * @hide 1641 */ 1642 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 1643 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 1644 1645 /** 1646 * Retrieve overall information about an application package that is 1647 * installed on the system. 1648 * <p> 1649 * Throws {@link NameNotFoundException} if a package with the given name can 1650 * not be found on the system. 1651 * 1652 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1653 * desired package. 1654 * @param flags Additional option flags. Use any combination of 1655 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS}, 1656 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION}, 1657 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 1658 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 1659 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to 1660 * modify the data returned. 1661 * @return Returns a PackageInfo object containing information about the 1662 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the 1663 * package is not found in the list of installed applications, the 1664 * package information is retrieved from the list of uninstalled 1665 * applications (which includes installed applications as well as 1666 * applications with data directory i.e. applications which had been 1667 * deleted with {@code DONT_DELETE_DATA} flag set). 1668 * @see #GET_ACTIVITIES 1669 * @see #GET_GIDS 1670 * @see #GET_CONFIGURATIONS 1671 * @see #GET_INSTRUMENTATION 1672 * @see #GET_PERMISSIONS 1673 * @see #GET_PROVIDERS 1674 * @see #GET_RECEIVERS 1675 * @see #GET_SERVICES 1676 * @see #GET_SIGNATURES 1677 * @see #GET_UNINSTALLED_PACKAGES 1678 */ 1679 public abstract PackageInfo getPackageInfo(String packageName, int flags) 1680 throws NameNotFoundException; 1681 1682 /** 1683 * Map from the current package names in use on the device to whatever 1684 * the current canonical name of that package is. 1685 * @param names Array of current names to be mapped. 1686 * @return Returns an array of the same size as the original, containing 1687 * the canonical name for each package. 1688 */ 1689 public abstract String[] currentToCanonicalPackageNames(String[] names); 1690 1691 /** 1692 * Map from a packages canonical name to the current name in use on the device. 1693 * @param names Array of new names to be mapped. 1694 * @return Returns an array of the same size as the original, containing 1695 * the current name for each package. 1696 */ 1697 public abstract String[] canonicalToCurrentPackageNames(String[] names); 1698 1699 /** 1700 * Returns a "good" intent to launch a front-door activity in a package. 1701 * This is used, for example, to implement an "open" button when browsing 1702 * through packages. The current implementation looks first for a main 1703 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 1704 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 1705 * <code>null</code> if neither are found. 1706 * 1707 * @param packageName The name of the package to inspect. 1708 * 1709 * @return A fully-qualified {@link Intent} that can be used to launch the 1710 * main activity in the package. Returns <code>null</code> if the package 1711 * does not contain such an activity, or if <em>packageName</em> is not 1712 * recognized. 1713 */ 1714 public abstract Intent getLaunchIntentForPackage(String packageName); 1715 1716 /** 1717 * Return a "good" intent to launch a front-door Leanback activity in a 1718 * package, for use for example to implement an "open" button when browsing 1719 * through packages. The current implementation will look for a main 1720 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 1721 * return null if no main leanback activities are found. 1722 * <p> 1723 * Throws {@link NameNotFoundException} if a package with the given name 1724 * cannot be found on the system. 1725 * 1726 * @param packageName The name of the package to inspect. 1727 * @return Returns either a fully-qualified Intent that can be used to launch 1728 * the main Leanback activity in the package, or null if the package 1729 * does not contain such an activity. 1730 */ 1731 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName); 1732 1733 /** 1734 * Return an array of all of the secondary group-ids that have been assigned 1735 * to a package. 1736 * <p> 1737 * Throws {@link NameNotFoundException} if a package with the given name 1738 * cannot be found on the system. 1739 * 1740 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1741 * desired package. 1742 * @return Returns an int array of the assigned gids, or null if there are 1743 * none. 1744 */ 1745 public abstract int[] getPackageGids(String packageName) 1746 throws NameNotFoundException; 1747 1748 /** 1749 * @hide Return the uid associated with the given package name for the 1750 * given user. 1751 * 1752 * <p>Throws {@link NameNotFoundException} if a package with the given 1753 * name can not be found on the system. 1754 * 1755 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1756 * desired package. 1757 * @param userHandle The user handle identifier to look up the package under. 1758 * 1759 * @return Returns an integer uid who owns the given package name. 1760 */ 1761 public abstract int getPackageUid(String packageName, int userHandle) 1762 throws NameNotFoundException; 1763 1764 /** 1765 * Retrieve all of the information we know about a particular permission. 1766 * 1767 * <p>Throws {@link NameNotFoundException} if a permission with the given 1768 * name cannot be found on the system. 1769 * 1770 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 1771 * of the permission you are interested in. 1772 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1773 * retrieve any meta-data associated with the permission. 1774 * 1775 * @return Returns a {@link PermissionInfo} containing information about the 1776 * permission. 1777 */ 1778 public abstract PermissionInfo getPermissionInfo(String name, int flags) 1779 throws NameNotFoundException; 1780 1781 /** 1782 * Query for all of the permissions associated with a particular group. 1783 * 1784 * <p>Throws {@link NameNotFoundException} if the given group does not 1785 * exist. 1786 * 1787 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 1788 * of the permission group you are interested in. Use null to 1789 * find all of the permissions not associated with a group. 1790 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1791 * retrieve any meta-data associated with the permissions. 1792 * 1793 * @return Returns a list of {@link PermissionInfo} containing information 1794 * about all of the permissions in the given group. 1795 */ 1796 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 1797 int flags) throws NameNotFoundException; 1798 1799 /** 1800 * Retrieve all of the information we know about a particular group of 1801 * permissions. 1802 * 1803 * <p>Throws {@link NameNotFoundException} if a permission group with the given 1804 * name cannot be found on the system. 1805 * 1806 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 1807 * of the permission you are interested in. 1808 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1809 * retrieve any meta-data associated with the permission group. 1810 * 1811 * @return Returns a {@link PermissionGroupInfo} containing information 1812 * about the permission. 1813 */ 1814 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 1815 int flags) throws NameNotFoundException; 1816 1817 /** 1818 * Retrieve all of the known permission groups in the system. 1819 * 1820 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1821 * retrieve any meta-data associated with the permission group. 1822 * 1823 * @return Returns a list of {@link PermissionGroupInfo} containing 1824 * information about all of the known permission groups. 1825 */ 1826 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags); 1827 1828 /** 1829 * Retrieve all of the information we know about a particular 1830 * package/application. 1831 * 1832 * <p>Throws {@link NameNotFoundException} if an application with the given 1833 * package name cannot be found on the system. 1834 * 1835 * @param packageName The full name (i.e. com.google.apps.contacts) of an 1836 * application. 1837 * @param flags Additional option flags. Use any combination of 1838 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1839 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1840 * 1841 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing 1842 * information about the package. 1843 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 1844 * found in the list of installed applications, 1845 * the application information is retrieved from the 1846 * list of uninstalled applications(which includes 1847 * installed applications as well as applications 1848 * with data directory ie applications which had been 1849 * deleted with {@code DONT_DELETE_DATA} flag set). 1850 * 1851 * @see #GET_META_DATA 1852 * @see #GET_SHARED_LIBRARY_FILES 1853 * @see #GET_UNINSTALLED_PACKAGES 1854 */ 1855 public abstract ApplicationInfo getApplicationInfo(String packageName, 1856 int flags) throws NameNotFoundException; 1857 1858 /** 1859 * Retrieve all of the information we know about a particular activity 1860 * class. 1861 * 1862 * <p>Throws {@link NameNotFoundException} if an activity with the given 1863 * class name cannot be found on the system. 1864 * 1865 * @param component The full component name (i.e. 1866 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity 1867 * class. 1868 * @param flags Additional option flags. Use any combination of 1869 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1870 * to modify the data (in ApplicationInfo) returned. 1871 * 1872 * @return {@link ActivityInfo} containing information about the activity. 1873 * 1874 * @see #GET_INTENT_FILTERS 1875 * @see #GET_META_DATA 1876 * @see #GET_SHARED_LIBRARY_FILES 1877 */ 1878 public abstract ActivityInfo getActivityInfo(ComponentName component, 1879 int flags) throws NameNotFoundException; 1880 1881 /** 1882 * Retrieve all of the information we know about a particular receiver 1883 * class. 1884 * 1885 * <p>Throws {@link NameNotFoundException} if a receiver with the given 1886 * class name cannot be found on the system. 1887 * 1888 * @param component The full component name (i.e. 1889 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver 1890 * class. 1891 * @param flags Additional option flags. Use any combination of 1892 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1893 * to modify the data returned. 1894 * 1895 * @return {@link ActivityInfo} containing information about the receiver. 1896 * 1897 * @see #GET_INTENT_FILTERS 1898 * @see #GET_META_DATA 1899 * @see #GET_SHARED_LIBRARY_FILES 1900 */ 1901 public abstract ActivityInfo getReceiverInfo(ComponentName component, 1902 int flags) throws NameNotFoundException; 1903 1904 /** 1905 * Retrieve all of the information we know about a particular service 1906 * class. 1907 * 1908 * <p>Throws {@link NameNotFoundException} if a service with the given 1909 * class name cannot be found on the system. 1910 * 1911 * @param component The full component name (i.e. 1912 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service 1913 * class. 1914 * @param flags Additional option flags. Use any combination of 1915 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1916 * to modify the data returned. 1917 * 1918 * @return ServiceInfo containing information about the service. 1919 * 1920 * @see #GET_META_DATA 1921 * @see #GET_SHARED_LIBRARY_FILES 1922 */ 1923 public abstract ServiceInfo getServiceInfo(ComponentName component, 1924 int flags) throws NameNotFoundException; 1925 1926 /** 1927 * Retrieve all of the information we know about a particular content 1928 * provider class. 1929 * 1930 * <p>Throws {@link NameNotFoundException} if a provider with the given 1931 * class name cannot be found on the system. 1932 * 1933 * @param component The full component name (i.e. 1934 * com.google.providers.media/com.google.providers.media.MediaProvider) of a 1935 * ContentProvider class. 1936 * @param flags Additional option flags. Use any combination of 1937 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 1938 * to modify the data returned. 1939 * 1940 * @return ProviderInfo containing information about the service. 1941 * 1942 * @see #GET_META_DATA 1943 * @see #GET_SHARED_LIBRARY_FILES 1944 */ 1945 public abstract ProviderInfo getProviderInfo(ComponentName component, 1946 int flags) throws NameNotFoundException; 1947 1948 /** 1949 * Return a List of all packages that are installed 1950 * on the device. 1951 * 1952 * @param flags Additional option flags. Use any combination of 1953 * {@link #GET_ACTIVITIES}, 1954 * {@link #GET_GIDS}, 1955 * {@link #GET_CONFIGURATIONS}, 1956 * {@link #GET_INSTRUMENTATION}, 1957 * {@link #GET_PERMISSIONS}, 1958 * {@link #GET_PROVIDERS}, 1959 * {@link #GET_RECEIVERS}, 1960 * {@link #GET_SERVICES}, 1961 * {@link #GET_SIGNATURES}, 1962 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1963 * 1964 * @return A List of PackageInfo objects, one for each package that is 1965 * installed on the device. In the unlikely case of there being no 1966 * installed packages, an empty list is returned. 1967 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 1968 * applications including those deleted with {@code DONT_DELETE_DATA} 1969 * (partially installed apps with data directory) will be returned. 1970 * 1971 * @see #GET_ACTIVITIES 1972 * @see #GET_GIDS 1973 * @see #GET_CONFIGURATIONS 1974 * @see #GET_INSTRUMENTATION 1975 * @see #GET_PERMISSIONS 1976 * @see #GET_PROVIDERS 1977 * @see #GET_RECEIVERS 1978 * @see #GET_SERVICES 1979 * @see #GET_SIGNATURES 1980 * @see #GET_UNINSTALLED_PACKAGES 1981 */ 1982 public abstract List<PackageInfo> getInstalledPackages(int flags); 1983 1984 /** 1985 * Return a List of all installed packages that are currently 1986 * holding any of the given permissions. 1987 * 1988 * @param flags Additional option flags. Use any combination of 1989 * {@link #GET_ACTIVITIES}, 1990 * {@link #GET_GIDS}, 1991 * {@link #GET_CONFIGURATIONS}, 1992 * {@link #GET_INSTRUMENTATION}, 1993 * {@link #GET_PERMISSIONS}, 1994 * {@link #GET_PROVIDERS}, 1995 * {@link #GET_RECEIVERS}, 1996 * {@link #GET_SERVICES}, 1997 * {@link #GET_SIGNATURES}, 1998 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 1999 * 2000 * @return Returns a List of PackageInfo objects, one for each installed 2001 * application that is holding any of the permissions that were provided. 2002 * 2003 * @see #GET_ACTIVITIES 2004 * @see #GET_GIDS 2005 * @see #GET_CONFIGURATIONS 2006 * @see #GET_INSTRUMENTATION 2007 * @see #GET_PERMISSIONS 2008 * @see #GET_PROVIDERS 2009 * @see #GET_RECEIVERS 2010 * @see #GET_SERVICES 2011 * @see #GET_SIGNATURES 2012 * @see #GET_UNINSTALLED_PACKAGES 2013 */ 2014 public abstract List<PackageInfo> getPackagesHoldingPermissions( 2015 String[] permissions, int flags); 2016 2017 /** 2018 * Return a List of all packages that are installed on the device, for a specific user. 2019 * Requesting a list of installed packages for another user 2020 * will require the permission INTERACT_ACROSS_USERS_FULL. 2021 * @param flags Additional option flags. Use any combination of 2022 * {@link #GET_ACTIVITIES}, 2023 * {@link #GET_GIDS}, 2024 * {@link #GET_CONFIGURATIONS}, 2025 * {@link #GET_INSTRUMENTATION}, 2026 * {@link #GET_PERMISSIONS}, 2027 * {@link #GET_PROVIDERS}, 2028 * {@link #GET_RECEIVERS}, 2029 * {@link #GET_SERVICES}, 2030 * {@link #GET_SIGNATURES}, 2031 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2032 * @param userId The user for whom the installed packages are to be listed 2033 * 2034 * @return A List of PackageInfo objects, one for each package that is 2035 * installed on the device. In the unlikely case of there being no 2036 * installed packages, an empty list is returned. 2037 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2038 * applications including those deleted with {@code DONT_DELETE_DATA} 2039 * (partially installed apps with data directory) will be returned. 2040 * 2041 * @see #GET_ACTIVITIES 2042 * @see #GET_GIDS 2043 * @see #GET_CONFIGURATIONS 2044 * @see #GET_INSTRUMENTATION 2045 * @see #GET_PERMISSIONS 2046 * @see #GET_PROVIDERS 2047 * @see #GET_RECEIVERS 2048 * @see #GET_SERVICES 2049 * @see #GET_SIGNATURES 2050 * @see #GET_UNINSTALLED_PACKAGES 2051 * 2052 * @hide 2053 */ 2054 public abstract List<PackageInfo> getInstalledPackages(int flags, int userId); 2055 2056 /** 2057 * Check whether a particular package has been granted a particular 2058 * permission. 2059 * 2060 * @param permName The name of the permission you are checking for, 2061 * @param pkgName The name of the package you are checking against. 2062 * 2063 * @return If the package has the permission, PERMISSION_GRANTED is 2064 * returned. If it does not have the permission, PERMISSION_DENIED 2065 * is returned. 2066 * 2067 * @see #PERMISSION_GRANTED 2068 * @see #PERMISSION_DENIED 2069 */ 2070 public abstract int checkPermission(String permName, String pkgName); 2071 2072 /** 2073 * Add a new dynamic permission to the system. For this to work, your 2074 * package must have defined a permission tree through the 2075 * {@link android.R.styleable#AndroidManifestPermissionTree 2076 * <permission-tree>} tag in its manifest. A package can only add 2077 * permissions to trees that were defined by either its own package or 2078 * another with the same user id; a permission is in a tree if it 2079 * matches the name of the permission tree + ".": for example, 2080 * "com.foo.bar" is a member of the permission tree "com.foo". 2081 * 2082 * <p>It is good to make your permission tree name descriptive, because you 2083 * are taking possession of that entire set of permission names. Thus, it 2084 * must be under a domain you control, with a suffix that will not match 2085 * any normal permissions that may be declared in any applications that 2086 * are part of that domain. 2087 * 2088 * <p>New permissions must be added before 2089 * any .apks are installed that use those permissions. Permissions you 2090 * add through this method are remembered across reboots of the device. 2091 * If the given permission already exists, the info you supply here 2092 * will be used to update it. 2093 * 2094 * @param info Description of the permission to be added. 2095 * 2096 * @return Returns true if a new permission was created, false if an 2097 * existing one was updated. 2098 * 2099 * @throws SecurityException if you are not allowed to add the 2100 * given permission name. 2101 * 2102 * @see #removePermission(String) 2103 */ 2104 public abstract boolean addPermission(PermissionInfo info); 2105 2106 /** 2107 * Like {@link #addPermission(PermissionInfo)} but asynchronously 2108 * persists the package manager state after returning from the call, 2109 * allowing it to return quicker and batch a series of adds at the 2110 * expense of no guarantee the added permission will be retained if 2111 * the device is rebooted before it is written. 2112 */ 2113 public abstract boolean addPermissionAsync(PermissionInfo info); 2114 2115 /** 2116 * Removes a permission that was previously added with 2117 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 2118 * -- you are only allowed to remove permissions that you are allowed 2119 * to add. 2120 * 2121 * @param name The name of the permission to remove. 2122 * 2123 * @throws SecurityException if you are not allowed to remove the 2124 * given permission name. 2125 * 2126 * @see #addPermission(PermissionInfo) 2127 */ 2128 public abstract void removePermission(String name); 2129 2130 /** 2131 * Returns an {@link Intent} suitable for passing to {@code startActivityForResult} 2132 * which prompts the user to grant {@code permissions} to this application. 2133 * @hide 2134 * 2135 * @throws NullPointerException if {@code permissions} is {@code null}. 2136 * @throws IllegalArgumentException if {@code permissions} contains {@code null}. 2137 */ 2138 public Intent buildPermissionRequestIntent(String... permissions) { 2139 if (permissions == null) { 2140 throw new NullPointerException("permissions cannot be null"); 2141 } 2142 for (String permission : permissions) { 2143 if (permission == null) { 2144 throw new IllegalArgumentException("permissions cannot contain null"); 2145 } 2146 } 2147 2148 Intent i = new Intent(ACTION_REQUEST_PERMISSION); 2149 i.putExtra(EXTRA_REQUEST_PERMISSION_PERMISSION_LIST, permissions); 2150 i.setPackage("com.android.packageinstaller"); 2151 return i; 2152 } 2153 2154 /** 2155 * Grant a permission to an application which the application does not 2156 * already have. The permission must have been requested by the application, 2157 * but as an optional permission. If the application is not allowed to 2158 * hold the permission, a SecurityException is thrown. 2159 * @hide 2160 * 2161 * @param packageName The name of the package that the permission will be 2162 * granted to. 2163 * @param permissionName The name of the permission. 2164 */ 2165 public abstract void grantPermission(String packageName, String permissionName); 2166 2167 /** 2168 * Revoke a permission that was previously granted by {@link #grantPermission}. 2169 * @hide 2170 * 2171 * @param packageName The name of the package that the permission will be 2172 * granted to. 2173 * @param permissionName The name of the permission. 2174 */ 2175 public abstract void revokePermission(String packageName, String permissionName); 2176 2177 /** 2178 * Compare the signatures of two packages to determine if the same 2179 * signature appears in both of them. If they do contain the same 2180 * signature, then they are allowed special privileges when working 2181 * with each other: they can share the same user-id, run instrumentation 2182 * against each other, etc. 2183 * 2184 * @param pkg1 First package name whose signature will be compared. 2185 * @param pkg2 Second package name whose signature will be compared. 2186 * 2187 * @return Returns an integer indicating whether all signatures on the 2188 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2189 * all signatures match or < 0 if there is not a match ({@link 2190 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2191 * 2192 * @see #checkSignatures(int, int) 2193 * @see #SIGNATURE_MATCH 2194 * @see #SIGNATURE_NO_MATCH 2195 * @see #SIGNATURE_UNKNOWN_PACKAGE 2196 */ 2197 public abstract int checkSignatures(String pkg1, String pkg2); 2198 2199 /** 2200 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 2201 * the two packages to be checked. This can be useful, for example, 2202 * when doing the check in an IPC, where the UID is the only identity 2203 * available. It is functionally identical to determining the package 2204 * associated with the UIDs and checking their signatures. 2205 * 2206 * @param uid1 First UID whose signature will be compared. 2207 * @param uid2 Second UID whose signature will be compared. 2208 * 2209 * @return Returns an integer indicating whether all signatures on the 2210 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2211 * all signatures match or < 0 if there is not a match ({@link 2212 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2213 * 2214 * @see #checkSignatures(String, String) 2215 * @see #SIGNATURE_MATCH 2216 * @see #SIGNATURE_NO_MATCH 2217 * @see #SIGNATURE_UNKNOWN_PACKAGE 2218 */ 2219 public abstract int checkSignatures(int uid1, int uid2); 2220 2221 /** 2222 * Retrieve the names of all packages that are associated with a particular 2223 * user id. In most cases, this will be a single package name, the package 2224 * that has been assigned that user id. Where there are multiple packages 2225 * sharing the same user id through the "sharedUserId" mechanism, all 2226 * packages with that id will be returned. 2227 * 2228 * @param uid The user id for which you would like to retrieve the 2229 * associated packages. 2230 * 2231 * @return Returns an array of one or more packages assigned to the user 2232 * id, or null if there are no known packages with the given id. 2233 */ 2234 public abstract String[] getPackagesForUid(int uid); 2235 2236 /** 2237 * Retrieve the official name associated with a user id. This name is 2238 * guaranteed to never change, though it is possibly for the underlying 2239 * user id to be changed. That is, if you are storing information about 2240 * user ids in persistent storage, you should use the string returned 2241 * by this function instead of the raw user-id. 2242 * 2243 * @param uid The user id for which you would like to retrieve a name. 2244 * @return Returns a unique name for the given user id, or null if the 2245 * user id is not currently assigned. 2246 */ 2247 public abstract String getNameForUid(int uid); 2248 2249 /** 2250 * Return the user id associated with a shared user name. Multiple 2251 * applications can specify a shared user name in their manifest and thus 2252 * end up using a common uid. This might be used for new applications 2253 * that use an existing shared user name and need to know the uid of the 2254 * shared user. 2255 * 2256 * @param sharedUserName The shared user name whose uid is to be retrieved. 2257 * @return Returns the uid associated with the shared user, or NameNotFoundException 2258 * if the shared user name is not being used by any installed packages 2259 * @hide 2260 */ 2261 public abstract int getUidForSharedUser(String sharedUserName) 2262 throws NameNotFoundException; 2263 2264 /** 2265 * Return a List of all application packages that are installed on the 2266 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 2267 * applications including those deleted with {@code DONT_DELETE_DATA} (partially 2268 * installed apps with data directory) will be returned. 2269 * 2270 * @param flags Additional option flags. Use any combination of 2271 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2272 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2273 * 2274 * @return Returns a List of ApplicationInfo objects, one for each application that 2275 * is installed on the device. In the unlikely case of there being 2276 * no installed applications, an empty list is returned. 2277 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2278 * applications including those deleted with {@code DONT_DELETE_DATA} 2279 * (partially installed apps with data directory) will be returned. 2280 * 2281 * @see #GET_META_DATA 2282 * @see #GET_SHARED_LIBRARY_FILES 2283 * @see #GET_UNINSTALLED_PACKAGES 2284 */ 2285 public abstract List<ApplicationInfo> getInstalledApplications(int flags); 2286 2287 /** 2288 * Get a list of shared libraries that are available on the 2289 * system. 2290 * 2291 * @return An array of shared library names that are 2292 * available on the system, or null if none are installed. 2293 * 2294 */ 2295 public abstract String[] getSystemSharedLibraryNames(); 2296 2297 /** 2298 * Get a list of features that are available on the 2299 * system. 2300 * 2301 * @return An array of FeatureInfo classes describing the features 2302 * that are available on the system, or null if there are none(!!). 2303 */ 2304 public abstract FeatureInfo[] getSystemAvailableFeatures(); 2305 2306 /** 2307 * Check whether the given feature name is one of the available 2308 * features as returned by {@link #getSystemAvailableFeatures()}. 2309 * 2310 * @return Returns true if the devices supports the feature, else 2311 * false. 2312 */ 2313 public abstract boolean hasSystemFeature(String name); 2314 2315 /** 2316 * Determine the best action to perform for a given Intent. This is how 2317 * {@link Intent#resolveActivity} finds an activity if a class has not 2318 * been explicitly specified. 2319 * 2320 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 2321 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 2322 * only flag. You need to do so to resolve the activity in the same way 2323 * that {@link android.content.Context#startActivity(Intent)} and 2324 * {@link android.content.Intent#resolveActivity(PackageManager) 2325 * Intent.resolveActivity(PackageManager)} do.</p> 2326 * 2327 * @param intent An intent containing all of the desired specification 2328 * (action, data, type, category, and/or component). 2329 * @param flags Additional option flags. The most important is 2330 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2331 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2332 * 2333 * @return Returns a ResolveInfo containing the final activity intent that 2334 * was determined to be the best action. Returns null if no 2335 * matching activity was found. If multiple matching activities are 2336 * found and there is no default set, returns a ResolveInfo 2337 * containing something else, such as the activity resolver. 2338 * 2339 * @see #MATCH_DEFAULT_ONLY 2340 * @see #GET_INTENT_FILTERS 2341 * @see #GET_RESOLVED_FILTER 2342 */ 2343 public abstract ResolveInfo resolveActivity(Intent intent, int flags); 2344 2345 /** 2346 * Determine the best action to perform for a given Intent for a given user. This 2347 * is how {@link Intent#resolveActivity} finds an activity if a class has not 2348 * been explicitly specified. 2349 * 2350 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 2351 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 2352 * only flag. You need to do so to resolve the activity in the same way 2353 * that {@link android.content.Context#startActivity(Intent)} and 2354 * {@link android.content.Intent#resolveActivity(PackageManager) 2355 * Intent.resolveActivity(PackageManager)} do.</p> 2356 * 2357 * @param intent An intent containing all of the desired specification 2358 * (action, data, type, category, and/or component). 2359 * @param flags Additional option flags. The most important is 2360 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2361 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2362 * @param userId The user id. 2363 * 2364 * @return Returns a ResolveInfo containing the final activity intent that 2365 * was determined to be the best action. Returns null if no 2366 * matching activity was found. If multiple matching activities are 2367 * found and there is no default set, returns a ResolveInfo 2368 * containing something else, such as the activity resolver. 2369 * 2370 * @see #MATCH_DEFAULT_ONLY 2371 * @see #GET_INTENT_FILTERS 2372 * @see #GET_RESOLVED_FILTER 2373 * 2374 * @hide 2375 */ 2376 public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId); 2377 2378 /** 2379 * Retrieve all activities that can be performed for the given intent. 2380 * 2381 * @param intent The desired intent as per resolveActivity(). 2382 * @param flags Additional option flags. The most important is 2383 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2384 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2385 * 2386 * @return A List<ResolveInfo> containing one entry for each matching 2387 * Activity. These are ordered from best to worst match -- that 2388 * is, the first item in the list is what is returned by 2389 * {@link #resolveActivity}. If there are no matching activities, an empty 2390 * list is returned. 2391 * 2392 * @see #MATCH_DEFAULT_ONLY 2393 * @see #GET_INTENT_FILTERS 2394 * @see #GET_RESOLVED_FILTER 2395 */ 2396 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 2397 int flags); 2398 2399 /** 2400 * Retrieve all activities that can be performed for the given intent, for a specific user. 2401 * 2402 * @param intent The desired intent as per resolveActivity(). 2403 * @param flags Additional option flags. The most important is 2404 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2405 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2406 * 2407 * @return A List<ResolveInfo> containing one entry for each matching 2408 * Activity. These are ordered from best to worst match -- that 2409 * is, the first item in the list is what is returned by 2410 * {@link #resolveActivity}. If there are no matching activities, an empty 2411 * list is returned. 2412 * 2413 * @see #MATCH_DEFAULT_ONLY 2414 * @see #GET_INTENT_FILTERS 2415 * @see #GET_RESOLVED_FILTER 2416 * @see #NO_CROSS_PROFILE 2417 * @hide 2418 */ 2419 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 2420 int flags, int userId); 2421 2422 2423 /** 2424 * Retrieve a set of activities that should be presented to the user as 2425 * similar options. This is like {@link #queryIntentActivities}, except it 2426 * also allows you to supply a list of more explicit Intents that you would 2427 * like to resolve to particular options, and takes care of returning the 2428 * final ResolveInfo list in a reasonable order, with no duplicates, based 2429 * on those inputs. 2430 * 2431 * @param caller The class name of the activity that is making the 2432 * request. This activity will never appear in the output 2433 * list. Can be null. 2434 * @param specifics An array of Intents that should be resolved to the 2435 * first specific results. Can be null. 2436 * @param intent The desired intent as per resolveActivity(). 2437 * @param flags Additional option flags. The most important is 2438 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2439 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2440 * 2441 * @return A List<ResolveInfo> containing one entry for each matching 2442 * Activity. These are ordered first by all of the intents resolved 2443 * in <var>specifics</var> and then any additional activities that 2444 * can handle <var>intent</var> but did not get included by one of 2445 * the <var>specifics</var> intents. If there are no matching 2446 * activities, an empty list is returned. 2447 * 2448 * @see #MATCH_DEFAULT_ONLY 2449 * @see #GET_INTENT_FILTERS 2450 * @see #GET_RESOLVED_FILTER 2451 */ 2452 public abstract List<ResolveInfo> queryIntentActivityOptions( 2453 ComponentName caller, Intent[] specifics, Intent intent, int flags); 2454 2455 /** 2456 * Retrieve all receivers that can handle a broadcast of the given intent. 2457 * 2458 * @param intent The desired intent as per resolveActivity(). 2459 * @param flags Additional option flags. 2460 * 2461 * @return A List<ResolveInfo> containing one entry for each matching 2462 * Receiver. These are ordered from first to last in priority. If 2463 * there are no matching receivers, 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> queryBroadcastReceivers(Intent intent, 2470 int flags); 2471 2472 /** 2473 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific 2474 * user. 2475 * 2476 * @param intent The desired intent as per resolveActivity(). 2477 * @param flags Additional option flags. 2478 * @param userId The userId of the user being queried. 2479 * 2480 * @return A List<ResolveInfo> containing one entry for each matching 2481 * Receiver. These are ordered from first to last in priority. If 2482 * there are no matching receivers, an empty list is returned. 2483 * 2484 * @see #MATCH_DEFAULT_ONLY 2485 * @see #GET_INTENT_FILTERS 2486 * @see #GET_RESOLVED_FILTER 2487 * @hide 2488 */ 2489 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 2490 int flags, int userId); 2491 2492 /** 2493 * Determine the best service to handle for a given Intent. 2494 * 2495 * @param intent An intent containing all of the desired specification 2496 * (action, data, type, category, and/or component). 2497 * @param flags Additional option flags. 2498 * 2499 * @return Returns a ResolveInfo containing the final service intent that 2500 * was determined to be the best action. Returns null if no 2501 * matching service was found. 2502 * 2503 * @see #GET_INTENT_FILTERS 2504 * @see #GET_RESOLVED_FILTER 2505 */ 2506 public abstract ResolveInfo resolveService(Intent intent, int flags); 2507 2508 /** 2509 * Retrieve all services that can match the given intent. 2510 * 2511 * @param intent The desired intent as per resolveService(). 2512 * @param flags Additional option flags. 2513 * 2514 * @return A List<ResolveInfo> containing one entry for each matching 2515 * ServiceInfo. These are ordered from best to worst match -- that 2516 * is, the first item in the list is what is returned by 2517 * resolveService(). If there are no matching services, an empty 2518 * list is returned. 2519 * 2520 * @see #GET_INTENT_FILTERS 2521 * @see #GET_RESOLVED_FILTER 2522 */ 2523 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 2524 int flags); 2525 2526 /** 2527 * Retrieve all services that can match the given intent for a given user. 2528 * 2529 * @param intent The desired intent as per resolveService(). 2530 * @param flags Additional option flags. 2531 * @param userId The user id. 2532 * 2533 * @return A List<ResolveInfo> containing one entry for each matching 2534 * ServiceInfo. These are ordered from best to worst match -- that 2535 * is, the first item in the list is what is returned by 2536 * resolveService(). If there are no matching services, an empty 2537 * list is returned. 2538 * 2539 * @see #GET_INTENT_FILTERS 2540 * @see #GET_RESOLVED_FILTER 2541 * 2542 * @hide 2543 */ 2544 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 2545 int flags, int userId); 2546 2547 /** {@hide} */ 2548 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 2549 Intent intent, int flags, int userId); 2550 2551 /** 2552 * Retrieve all providers that can match the given intent. 2553 * 2554 * @param intent An intent containing all of the desired specification 2555 * (action, data, type, category, and/or component). 2556 * @param flags Additional option flags. 2557 * @return A List<ResolveInfo> containing one entry for each matching 2558 * ProviderInfo. These are ordered from best to worst match. If 2559 * there are no matching providers, an empty list is returned. 2560 * @see #GET_INTENT_FILTERS 2561 * @see #GET_RESOLVED_FILTER 2562 */ 2563 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags); 2564 2565 /** 2566 * Find a single content provider by its base path name. 2567 * 2568 * @param name The name of the provider to find. 2569 * @param flags Additional option flags. Currently should always be 0. 2570 * 2571 * @return ContentProviderInfo Information about the provider, if found, 2572 * else null. 2573 */ 2574 public abstract ProviderInfo resolveContentProvider(String name, 2575 int flags); 2576 2577 /** 2578 * Find a single content provider by its base path name. 2579 * 2580 * @param name The name of the provider to find. 2581 * @param flags Additional option flags. Currently should always be 0. 2582 * @param userId The user id. 2583 * 2584 * @return ContentProviderInfo Information about the provider, if found, 2585 * else null. 2586 * @hide 2587 */ 2588 public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId); 2589 2590 /** 2591 * Retrieve content provider information. 2592 * 2593 * <p><em>Note: unlike most other methods, an empty result set is indicated 2594 * by a null return instead of an empty list.</em> 2595 * 2596 * @param processName If non-null, limits the returned providers to only 2597 * those that are hosted by the given process. If null, 2598 * all content providers are returned. 2599 * @param uid If <var>processName</var> is non-null, this is the required 2600 * uid owning the requested content providers. 2601 * @param flags Additional option flags. Currently should always be 0. 2602 * 2603 * @return A List<ContentProviderInfo> containing one entry for each 2604 * content provider either patching <var>processName</var> or, if 2605 * <var>processName</var> is null, all known content providers. 2606 * <em>If there are no matching providers, null is returned.</em> 2607 */ 2608 public abstract List<ProviderInfo> queryContentProviders( 2609 String processName, int uid, int flags); 2610 2611 /** 2612 * Retrieve all of the information we know about a particular 2613 * instrumentation class. 2614 * 2615 * <p>Throws {@link NameNotFoundException} if instrumentation with the 2616 * given class name cannot be found on the system. 2617 * 2618 * @param className The full name (i.e. 2619 * com.google.apps.contacts.InstrumentList) of an 2620 * Instrumentation class. 2621 * @param flags Additional option flags. Currently should always be 0. 2622 * 2623 * @return InstrumentationInfo containing information about the 2624 * instrumentation. 2625 */ 2626 public abstract InstrumentationInfo getInstrumentationInfo( 2627 ComponentName className, int flags) throws NameNotFoundException; 2628 2629 /** 2630 * Retrieve information about available instrumentation code. May be used 2631 * to retrieve either all instrumentation code, or only the code targeting 2632 * a particular package. 2633 * 2634 * @param targetPackage If null, all instrumentation is returned; only the 2635 * instrumentation targeting this package name is 2636 * returned. 2637 * @param flags Additional option flags. Currently should always be 0. 2638 * 2639 * @return A List<InstrumentationInfo> containing one entry for each 2640 * matching available Instrumentation. Returns an empty list if 2641 * there is no instrumentation available for the given package. 2642 */ 2643 public abstract List<InstrumentationInfo> queryInstrumentation( 2644 String targetPackage, int flags); 2645 2646 /** 2647 * Retrieve an image from a package. This is a low-level API used by 2648 * the various package manager info structures (such as 2649 * {@link ComponentInfo} to implement retrieval of their associated 2650 * icon. 2651 * 2652 * @param packageName The name of the package that this icon is coming from. 2653 * Cannot be null. 2654 * @param resid The resource identifier of the desired image. Cannot be 0. 2655 * @param appInfo Overall information about <var>packageName</var>. This 2656 * may be null, in which case the application information will be retrieved 2657 * for you if needed; if you already have this information around, it can 2658 * be much more efficient to supply it here. 2659 * 2660 * @return Returns a Drawable holding the requested image. Returns null if 2661 * an image could not be found for any reason. 2662 */ 2663 public abstract Drawable getDrawable(String packageName, int resid, 2664 ApplicationInfo appInfo); 2665 2666 /** 2667 * Retrieve the icon associated with an activity. Given the full name of 2668 * an activity, retrieves the information about it and calls 2669 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 2670 * If the activity cannot be found, NameNotFoundException is thrown. 2671 * 2672 * @param activityName Name of the activity whose icon is to be retrieved. 2673 * 2674 * @return Returns the image of the icon, or the default activity icon if 2675 * it could not be found. Does not return null. 2676 * @throws NameNotFoundException Thrown if the resources for the given 2677 * activity could not be loaded. 2678 * 2679 * @see #getActivityIcon(Intent) 2680 */ 2681 public abstract Drawable getActivityIcon(ComponentName activityName) 2682 throws NameNotFoundException; 2683 2684 /** 2685 * Retrieve the icon associated with an Intent. If intent.getClassName() is 2686 * set, this simply returns the result of 2687 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 2688 * component and returns the icon associated with the resolved component. 2689 * If intent.getClassName() cannot be found or the Intent cannot be resolved 2690 * to a component, NameNotFoundException is thrown. 2691 * 2692 * @param intent The intent for which you would like to retrieve an icon. 2693 * 2694 * @return Returns the image of the icon, or the default activity icon if 2695 * it could not be found. Does not return null. 2696 * @throws NameNotFoundException Thrown if the resources for application 2697 * matching the given intent could not be loaded. 2698 * 2699 * @see #getActivityIcon(ComponentName) 2700 */ 2701 public abstract Drawable getActivityIcon(Intent intent) 2702 throws NameNotFoundException; 2703 2704 /** 2705 * Retrieve the banner associated with an activity. Given the full name of 2706 * an activity, retrieves the information about it and calls 2707 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 2708 * banner. If the activity cannot be found, NameNotFoundException is thrown. 2709 * 2710 * @param activityName Name of the activity whose banner is to be retrieved. 2711 * @return Returns the image of the banner, or null if the activity has no 2712 * banner specified. 2713 * @throws NameNotFoundException Thrown if the resources for the given 2714 * activity could not be loaded. 2715 * @see #getActivityBanner(Intent) 2716 */ 2717 public abstract Drawable getActivityBanner(ComponentName activityName) 2718 throws NameNotFoundException; 2719 2720 /** 2721 * Retrieve the banner associated with an Intent. If intent.getClassName() 2722 * is set, this simply returns the result of 2723 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 2724 * intent's component and returns the banner associated with the resolved 2725 * component. If intent.getClassName() cannot be found or the Intent cannot 2726 * be resolved to a component, NameNotFoundException is thrown. 2727 * 2728 * @param intent The intent for which you would like to retrieve a banner. 2729 * @return Returns the image of the banner, or null if the activity has no 2730 * banner specified. 2731 * @throws NameNotFoundException Thrown if the resources for application 2732 * matching the given intent could not be loaded. 2733 * @see #getActivityBanner(ComponentName) 2734 */ 2735 public abstract Drawable getActivityBanner(Intent intent) 2736 throws NameNotFoundException; 2737 2738 /** 2739 * Return the generic icon for an activity that is used when no specific 2740 * icon is defined. 2741 * 2742 * @return Drawable Image of the icon. 2743 */ 2744 public abstract Drawable getDefaultActivityIcon(); 2745 2746 /** 2747 * Retrieve the icon associated with an application. If it has not defined 2748 * an icon, the default app icon is returned. Does not return null. 2749 * 2750 * @param info Information about application being queried. 2751 * 2752 * @return Returns the image of the icon, or the default application icon 2753 * if it could not be found. 2754 * 2755 * @see #getApplicationIcon(String) 2756 */ 2757 public abstract Drawable getApplicationIcon(ApplicationInfo info); 2758 2759 /** 2760 * Retrieve the icon associated with an application. Given the name of the 2761 * application's package, retrieves the information about it and calls 2762 * getApplicationIcon() to return its icon. If the application cannot be 2763 * found, NameNotFoundException is thrown. 2764 * 2765 * @param packageName Name of the package whose application icon is to be 2766 * retrieved. 2767 * 2768 * @return Returns the image of the icon, or the default application icon 2769 * if it could not be found. Does not return null. 2770 * @throws NameNotFoundException Thrown if the resources for the given 2771 * application could not be loaded. 2772 * 2773 * @see #getApplicationIcon(ApplicationInfo) 2774 */ 2775 public abstract Drawable getApplicationIcon(String packageName) 2776 throws NameNotFoundException; 2777 2778 /** 2779 * Retrieve the banner associated with an application. 2780 * 2781 * @param info Information about application being queried. 2782 * @return Returns the image of the banner or null if the application has no 2783 * banner specified. 2784 * @see #getApplicationBanner(String) 2785 */ 2786 public abstract Drawable getApplicationBanner(ApplicationInfo info); 2787 2788 /** 2789 * Retrieve the banner associated with an application. Given the name of the 2790 * application's package, retrieves the information about it and calls 2791 * getApplicationIcon() to return its banner. If the application cannot be 2792 * found, NameNotFoundException is thrown. 2793 * 2794 * @param packageName Name of the package whose application banner is to be 2795 * retrieved. 2796 * @return Returns the image of the banner or null if the application has no 2797 * banner specified. 2798 * @throws NameNotFoundException Thrown if the resources for the given 2799 * application could not be loaded. 2800 * @see #getApplicationBanner(ApplicationInfo) 2801 */ 2802 public abstract Drawable getApplicationBanner(String packageName) 2803 throws NameNotFoundException; 2804 2805 /** 2806 * Retrieve the logo associated with an activity. Given the full name of an 2807 * activity, retrieves the information about it and calls 2808 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 2809 * logo. If the activity cannot be found, NameNotFoundException is thrown. 2810 * 2811 * @param activityName Name of the activity whose logo is to be retrieved. 2812 * @return Returns the image of the logo or null if the activity has no logo 2813 * specified. 2814 * @throws NameNotFoundException Thrown if the resources for the given 2815 * activity could not be loaded. 2816 * @see #getActivityLogo(Intent) 2817 */ 2818 public abstract Drawable getActivityLogo(ComponentName activityName) 2819 throws NameNotFoundException; 2820 2821 /** 2822 * Retrieve the logo associated with an Intent. If intent.getClassName() is 2823 * set, this simply returns the result of 2824 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 2825 * component and returns the logo associated with the resolved component. 2826 * If intent.getClassName() cannot be found or the Intent cannot be resolved 2827 * to a component, NameNotFoundException is thrown. 2828 * 2829 * @param intent The intent for which you would like to retrieve a logo. 2830 * 2831 * @return Returns the image of the logo, or null if the activity has no 2832 * logo specified. 2833 * 2834 * @throws NameNotFoundException Thrown if the resources for application 2835 * matching the given intent could not be loaded. 2836 * 2837 * @see #getActivityLogo(ComponentName) 2838 */ 2839 public abstract Drawable getActivityLogo(Intent intent) 2840 throws NameNotFoundException; 2841 2842 /** 2843 * Retrieve the logo associated with an application. If it has not specified 2844 * a logo, this method returns null. 2845 * 2846 * @param info Information about application being queried. 2847 * 2848 * @return Returns the image of the logo, or null if no logo is specified 2849 * by the application. 2850 * 2851 * @see #getApplicationLogo(String) 2852 */ 2853 public abstract Drawable getApplicationLogo(ApplicationInfo info); 2854 2855 /** 2856 * Retrieve the logo associated with an application. Given the name of the 2857 * application's package, retrieves the information about it and calls 2858 * getApplicationLogo() to return its logo. If the application cannot be 2859 * found, NameNotFoundException is thrown. 2860 * 2861 * @param packageName Name of the package whose application logo is to be 2862 * retrieved. 2863 * 2864 * @return Returns the image of the logo, or null if no application logo 2865 * has been specified. 2866 * 2867 * @throws NameNotFoundException Thrown if the resources for the given 2868 * application could not be loaded. 2869 * 2870 * @see #getApplicationLogo(ApplicationInfo) 2871 */ 2872 public abstract Drawable getApplicationLogo(String packageName) 2873 throws NameNotFoundException; 2874 2875 /** 2876 * Retrieve text from a package. This is a low-level API used by 2877 * the various package manager info structures (such as 2878 * {@link ComponentInfo} to implement retrieval of their associated 2879 * labels and other text. 2880 * 2881 * @param packageName The name of the package that this text is coming from. 2882 * Cannot be null. 2883 * @param resid The resource identifier of the desired text. Cannot be 0. 2884 * @param appInfo Overall information about <var>packageName</var>. This 2885 * may be null, in which case the application information will be retrieved 2886 * for you if needed; if you already have this information around, it can 2887 * be much more efficient to supply it here. 2888 * 2889 * @return Returns a CharSequence holding the requested text. Returns null 2890 * if the text could not be found for any reason. 2891 */ 2892 public abstract CharSequence getText(String packageName, int resid, 2893 ApplicationInfo appInfo); 2894 2895 /** 2896 * Retrieve an XML file from a package. This is a low-level API used to 2897 * retrieve XML meta data. 2898 * 2899 * @param packageName The name of the package that this xml is coming from. 2900 * Cannot be null. 2901 * @param resid The resource identifier of the desired xml. Cannot be 0. 2902 * @param appInfo Overall information about <var>packageName</var>. This 2903 * may be null, in which case the application information will be retrieved 2904 * for you if needed; if you already have this information around, it can 2905 * be much more efficient to supply it here. 2906 * 2907 * @return Returns an XmlPullParser allowing you to parse out the XML 2908 * data. Returns null if the xml resource could not be found for any 2909 * reason. 2910 */ 2911 public abstract XmlResourceParser getXml(String packageName, int resid, 2912 ApplicationInfo appInfo); 2913 2914 /** 2915 * Return the label to use for this application. 2916 * 2917 * @return Returns the label associated with this application, or null if 2918 * it could not be found for any reason. 2919 * @param info The application to get the label of. 2920 */ 2921 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 2922 2923 /** 2924 * Retrieve the resources associated with an activity. Given the full 2925 * name of an activity, retrieves the information about it and calls 2926 * getResources() to return its application's resources. If the activity 2927 * cannot be found, NameNotFoundException is thrown. 2928 * 2929 * @param activityName Name of the activity whose resources are to be 2930 * retrieved. 2931 * 2932 * @return Returns the application's Resources. 2933 * @throws NameNotFoundException Thrown if the resources for the given 2934 * application could not be loaded. 2935 * 2936 * @see #getResourcesForApplication(ApplicationInfo) 2937 */ 2938 public abstract Resources getResourcesForActivity(ComponentName activityName) 2939 throws NameNotFoundException; 2940 2941 /** 2942 * Retrieve the resources for an application. Throws NameNotFoundException 2943 * if the package is no longer installed. 2944 * 2945 * @param app Information about the desired application. 2946 * 2947 * @return Returns the application's Resources. 2948 * @throws NameNotFoundException Thrown if the resources for the given 2949 * application could not be loaded (most likely because it was uninstalled). 2950 */ 2951 public abstract Resources getResourcesForApplication(ApplicationInfo app) 2952 throws NameNotFoundException; 2953 2954 /** 2955 * Retrieve the resources associated with an application. Given the full 2956 * package name of an application, retrieves the information about it and 2957 * calls getResources() to return its application's resources. If the 2958 * appPackageName cannot be found, NameNotFoundException is thrown. 2959 * 2960 * @param appPackageName Package name of the application whose resources 2961 * are to be retrieved. 2962 * 2963 * @return Returns the application's Resources. 2964 * @throws NameNotFoundException Thrown if the resources for the given 2965 * application could not be loaded. 2966 * 2967 * @see #getResourcesForApplication(ApplicationInfo) 2968 */ 2969 public abstract Resources getResourcesForApplication(String appPackageName) 2970 throws NameNotFoundException; 2971 2972 /** @hide */ 2973 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId) 2974 throws NameNotFoundException; 2975 2976 /** 2977 * Retrieve overall information about an application package defined 2978 * in a package archive file 2979 * 2980 * @param archiveFilePath The path to the archive file 2981 * @param flags Additional option flags. Use any combination of 2982 * {@link #GET_ACTIVITIES}, 2983 * {@link #GET_GIDS}, 2984 * {@link #GET_CONFIGURATIONS}, 2985 * {@link #GET_INSTRUMENTATION}, 2986 * {@link #GET_PERMISSIONS}, 2987 * {@link #GET_PROVIDERS}, 2988 * {@link #GET_RECEIVERS}, 2989 * {@link #GET_SERVICES}, 2990 * {@link #GET_SIGNATURES}, to modify the data returned. 2991 * 2992 * @return Returns the information about the package. Returns 2993 * null if the package could not be successfully parsed. 2994 * 2995 * @see #GET_ACTIVITIES 2996 * @see #GET_GIDS 2997 * @see #GET_CONFIGURATIONS 2998 * @see #GET_INSTRUMENTATION 2999 * @see #GET_PERMISSIONS 3000 * @see #GET_PROVIDERS 3001 * @see #GET_RECEIVERS 3002 * @see #GET_SERVICES 3003 * @see #GET_SIGNATURES 3004 * 3005 */ 3006 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { 3007 final PackageParser parser = new PackageParser(); 3008 final File apkFile = new File(archiveFilePath); 3009 try { 3010 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 3011 if ((flags & GET_SIGNATURES) != 0) { 3012 parser.collectCertificates(pkg, 0); 3013 parser.collectManifestDigest(pkg); 3014 } 3015 PackageUserState state = new PackageUserState(); 3016 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 3017 } catch (PackageParserException e) { 3018 return null; 3019 } 3020 } 3021 3022 /** 3023 * @hide Install a package. Since this may take a little while, the result 3024 * will be posted back to the given observer. An installation will 3025 * fail if the calling context lacks the 3026 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if 3027 * the package named in the package file's manifest is already 3028 * installed, or if there's no space available on the device. 3029 * @param packageURI The location of the package file to install. This can 3030 * be a 'file:' or a 'content:' URI. 3031 * @param observer An observer callback to get notified when the package 3032 * installation is complete. 3033 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3034 * will be called when that happens. This parameter must not be 3035 * null. 3036 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3037 * {@link #INSTALL_REPLACE_EXISTING}, 3038 * {@link #INSTALL_ALLOW_TEST}. 3039 * @param installerPackageName Optional package name of the application that 3040 * is performing the installation. This identifies which market 3041 * the package came from. 3042 * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int, 3043 * String)} instead. This method will continue to be supported 3044 * but the older observer interface will not get additional 3045 * failure details. 3046 */ 3047 // @SystemApi 3048 public abstract void installPackage( 3049 Uri packageURI, IPackageInstallObserver observer, int flags, 3050 String installerPackageName); 3051 3052 /** 3053 * Similar to 3054 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3055 * with an extra verification file provided. 3056 * 3057 * @param packageURI The location of the package file to install. This can 3058 * be a 'file:' or a 'content:' URI. 3059 * @param observer An observer callback to get notified when the package 3060 * installation is complete. 3061 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3062 * will be called when that happens. This parameter must not be 3063 * null. 3064 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3065 * {@link #INSTALL_REPLACE_EXISTING}, 3066 * {@link #INSTALL_ALLOW_TEST}. 3067 * @param installerPackageName Optional package name of the application that 3068 * is performing the installation. This identifies which market 3069 * the package came from. 3070 * @param verificationURI The location of the supplementary verification 3071 * file. This can be a 'file:' or a 'content:' URI. May be 3072 * {@code null}. 3073 * @param manifestDigest an object that holds the digest of the package 3074 * which can be used to verify ownership. May be {@code null}. 3075 * @param encryptionParams if the package to be installed is encrypted, 3076 * these parameters describing the encryption and authentication 3077 * used. May be {@code null}. 3078 * @hide 3079 * @deprecated Use {@link #installPackageWithVerification(Uri, 3080 * PackageInstallObserver, int, String, Uri, ManifestDigest, 3081 * ContainerEncryptionParams)} instead. This method will 3082 * continue to be supported but the older observer interface 3083 * will not get additional failure details. 3084 */ 3085 // @SystemApi 3086 public abstract void installPackageWithVerification(Uri packageURI, 3087 IPackageInstallObserver observer, int flags, String installerPackageName, 3088 Uri verificationURI, ManifestDigest manifestDigest, 3089 ContainerEncryptionParams encryptionParams); 3090 3091 /** 3092 * Similar to 3093 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3094 * with an extra verification information provided. 3095 * 3096 * @param packageURI The location of the package file to install. This can 3097 * be a 'file:' or a 'content:' URI. 3098 * @param observer An observer callback to get notified when the package 3099 * installation is complete. 3100 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3101 * will be called when that happens. This parameter must not be 3102 * null. 3103 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3104 * {@link #INSTALL_REPLACE_EXISTING}, 3105 * {@link #INSTALL_ALLOW_TEST}. 3106 * @param installerPackageName Optional package name of the application that 3107 * is performing the installation. This identifies which market 3108 * the package came from. 3109 * @param verificationParams an object that holds signal information to 3110 * assist verification. May be {@code null}. 3111 * @param encryptionParams if the package to be installed is encrypted, 3112 * these parameters describing the encryption and authentication 3113 * used. May be {@code null}. 3114 * @hide 3115 * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri, 3116 * PackageInstallObserver, int, String, VerificationParams, 3117 * ContainerEncryptionParams)} instead. This method will 3118 * continue to be supported but the older observer interface 3119 * will not get additional failure details. 3120 */ 3121 @Deprecated 3122 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 3123 IPackageInstallObserver observer, int flags, String installerPackageName, 3124 VerificationParams verificationParams, 3125 ContainerEncryptionParams encryptionParams); 3126 3127 // Package-install variants that take the new, expanded form of observer interface. 3128 // Note that these *also* take the original observer type and will redundantly 3129 // report the same information to that observer if supplied; but it is not required. 3130 3131 /** 3132 * @hide 3133 * 3134 * Install a package. Since this may take a little while, the result will 3135 * be posted back to the given observer. An installation will fail if the calling context 3136 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the 3137 * package named in the package file's manifest is already installed, or if there's no space 3138 * available on the device. 3139 * 3140 * @param packageURI The location of the package file to install. This can be a 'file:' or a 3141 * 'content:' URI. 3142 * @param observer An observer callback to get notified when the package installation is 3143 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3144 * called when that happens. This parameter must not be null. 3145 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3146 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3147 * @param installerPackageName Optional package name of the application that is performing the 3148 * installation. This identifies which market the package came from. 3149 */ 3150 public abstract void installPackage( 3151 Uri packageURI, PackageInstallObserver observer, 3152 int flags, String installerPackageName); 3153 3154 /** 3155 * Similar to 3156 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3157 * with an extra verification file provided. 3158 * 3159 * @param packageURI The location of the package file to install. This can 3160 * be a 'file:' or a 'content:' URI. 3161 * @param observer An observer callback to get notified when the package installation is 3162 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3163 * called when that happens. This parameter must not be null. 3164 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3165 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3166 * @param installerPackageName Optional package name of the application that 3167 * is performing the installation. This identifies which market 3168 * the package came from. 3169 * @param verificationURI The location of the supplementary verification 3170 * file. This can be a 'file:' or a 'content:' URI. May be 3171 * {@code null}. 3172 * @param manifestDigest an object that holds the digest of the package 3173 * which can be used to verify ownership. May be {@code null}. 3174 * @param encryptionParams if the package to be installed is encrypted, 3175 * these parameters describing the encryption and authentication 3176 * used. May be {@code null}. 3177 * @hide 3178 */ 3179 public abstract void installPackageWithVerification(Uri packageURI, 3180 PackageInstallObserver observer, int flags, String installerPackageName, 3181 Uri verificationURI, ManifestDigest manifestDigest, 3182 ContainerEncryptionParams encryptionParams); 3183 3184 /** 3185 * Similar to 3186 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3187 * with an extra verification information provided. 3188 * 3189 * @param packageURI The location of the package file to install. This can 3190 * be a 'file:' or a 'content:' URI. 3191 * @param observer An observer callback to get notified when the package installation is 3192 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3193 * called when that happens. This parameter must not be null. 3194 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3195 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3196 * @param installerPackageName Optional package name of the application that 3197 * is performing the installation. This identifies which market 3198 * the package came from. 3199 * @param verificationParams an object that holds signal information to 3200 * assist verification. May be {@code null}. 3201 * @param encryptionParams if the package to be installed is encrypted, 3202 * these parameters describing the encryption and authentication 3203 * used. May be {@code null}. 3204 * 3205 * @hide 3206 */ 3207 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 3208 PackageInstallObserver observer, int flags, String installerPackageName, 3209 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams); 3210 3211 /** 3212 * If there is already an application with the given package name installed 3213 * on the system for other users, also install it for the calling user. 3214 * @hide 3215 */ 3216 // @SystemApi 3217 public abstract int installExistingPackage(String packageName) 3218 throws NameNotFoundException; 3219 3220 /** 3221 * Allows a package listening to the 3222 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 3223 * broadcast} to respond to the package manager. The response must include 3224 * the {@code verificationCode} which is one of 3225 * {@link PackageManager#VERIFICATION_ALLOW} or 3226 * {@link PackageManager#VERIFICATION_REJECT}. 3227 * 3228 * @param id pending package identifier as passed via the 3229 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 3230 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 3231 * or {@link PackageManager#VERIFICATION_REJECT}. 3232 * @throws SecurityException if the caller does not have the 3233 * PACKAGE_VERIFICATION_AGENT permission. 3234 */ 3235 public abstract void verifyPendingInstall(int id, int verificationCode); 3236 3237 /** 3238 * Allows a package listening to the 3239 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 3240 * broadcast} to extend the default timeout for a response and declare what 3241 * action to perform after the timeout occurs. The response must include 3242 * the {@code verificationCodeAtTimeout} which is one of 3243 * {@link PackageManager#VERIFICATION_ALLOW} or 3244 * {@link PackageManager#VERIFICATION_REJECT}. 3245 * 3246 * This method may only be called once per package id. Additional calls 3247 * will have no effect. 3248 * 3249 * @param id pending package identifier as passed via the 3250 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 3251 * @param verificationCodeAtTimeout either 3252 * {@link PackageManager#VERIFICATION_ALLOW} or 3253 * {@link PackageManager#VERIFICATION_REJECT}. If 3254 * {@code verificationCodeAtTimeout} is neither 3255 * {@link PackageManager#VERIFICATION_ALLOW} or 3256 * {@link PackageManager#VERIFICATION_REJECT}, then 3257 * {@code verificationCodeAtTimeout} will default to 3258 * {@link PackageManager#VERIFICATION_REJECT}. 3259 * @param millisecondsToDelay the amount of time requested for the timeout. 3260 * Must be positive and less than 3261 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 3262 * {@code millisecondsToDelay} is out of bounds, 3263 * {@code millisecondsToDelay} will be set to the closest in 3264 * bounds value; namely, 0 or 3265 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 3266 * @throws SecurityException if the caller does not have the 3267 * PACKAGE_VERIFICATION_AGENT permission. 3268 */ 3269 public abstract void extendVerificationTimeout(int id, 3270 int verificationCodeAtTimeout, long millisecondsToDelay); 3271 3272 /** 3273 * Change the installer associated with a given package. There are limitations 3274 * on how the installer package can be changed; in particular: 3275 * <ul> 3276 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 3277 * is not signed with the same certificate as the calling application. 3278 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 3279 * has an installer package, and that installer package is not signed with 3280 * the same certificate as the calling application. 3281 * </ul> 3282 * 3283 * @param targetPackage The installed package whose installer will be changed. 3284 * @param installerPackageName The package name of the new installer. May be 3285 * null to clear the association. 3286 */ 3287 public abstract void setInstallerPackageName(String targetPackage, 3288 String installerPackageName); 3289 3290 /** 3291 * Attempts to delete a package. Since this may take a little while, the result will 3292 * be posted back to the given observer. A deletion will fail if the calling context 3293 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 3294 * named package cannot be found, or if the named package is a "system package". 3295 * (TODO: include pointer to documentation on "system packages") 3296 * 3297 * @param packageName The name of the package to delete 3298 * @param observer An observer callback to get notified when the package deletion is 3299 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 3300 * called when that happens. observer may be null to indicate that no callback is desired. 3301 * @param flags - possible values: {@link #DELETE_KEEP_DATA}, 3302 * {@link #DELETE_ALL_USERS}. 3303 * 3304 * @hide 3305 */ 3306 // @SystemApi 3307 public abstract void deletePackage( 3308 String packageName, IPackageDeleteObserver observer, int flags); 3309 3310 /** 3311 * Retrieve the package name of the application that installed a package. This identifies 3312 * which market the package came from. 3313 * 3314 * @param packageName The name of the package to query 3315 */ 3316 public abstract String getInstallerPackageName(String packageName); 3317 3318 /** 3319 * Attempts to clear the user data directory of an application. 3320 * Since this may take a little while, the result will 3321 * be posted back to the given observer. A deletion will fail if the 3322 * named package cannot be found, or if the named package is a "system package". 3323 * 3324 * @param packageName The name of the package 3325 * @param observer An observer callback to get notified when the operation is finished 3326 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 3327 * will be called when that happens. observer may be null to indicate that 3328 * no callback is desired. 3329 * 3330 * @hide 3331 */ 3332 public abstract void clearApplicationUserData(String packageName, 3333 IPackageDataObserver observer); 3334 /** 3335 * Attempts to delete the cache files associated with an application. 3336 * Since this may take a little while, the result will 3337 * be posted back to the given observer. A deletion will fail if the calling context 3338 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, 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 to delete 3342 * @param observer An observer callback to get notified when the cache file deletion 3343 * is complete. 3344 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 3345 * will be called when that happens. observer may be null to indicate that 3346 * no callback is desired. 3347 * 3348 * @hide 3349 */ 3350 public abstract void deleteApplicationCacheFiles(String packageName, 3351 IPackageDataObserver observer); 3352 3353 /** 3354 * Free storage by deleting LRU sorted list of cache files across 3355 * all applications. If the currently available free storage 3356 * on the device is greater than or equal to the requested 3357 * free storage, no cache files are cleared. If the currently 3358 * available storage on the device is less than the requested 3359 * free storage, some or all of the cache files across 3360 * all applications are deleted (based on last accessed time) 3361 * to increase the free storage space on the device to 3362 * the requested value. There is no guarantee that clearing all 3363 * the cache files from all applications will clear up 3364 * enough storage to achieve the desired value. 3365 * @param freeStorageSize The number of bytes of storage to be 3366 * freed by the system. Say if freeStorageSize is XX, 3367 * and the current free storage is YY, 3368 * if XX is less than YY, just return. if not free XX-YY number 3369 * of bytes if possible. 3370 * @param observer call back used to notify when 3371 * the operation is completed 3372 * 3373 * @hide 3374 */ 3375 // @SystemApi 3376 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer); 3377 3378 /** 3379 * Free storage by deleting LRU sorted list of cache files across 3380 * all applications. If the currently available free storage 3381 * on the device is greater than or equal to the requested 3382 * free storage, no cache files are cleared. If the currently 3383 * available storage on the device is less than the requested 3384 * free storage, some or all of the cache files across 3385 * all applications are deleted (based on last accessed time) 3386 * to increase the free storage space on the device to 3387 * the requested value. There is no guarantee that clearing all 3388 * the cache files from all applications will clear up 3389 * enough storage to achieve the desired value. 3390 * @param freeStorageSize The number of bytes of storage to be 3391 * freed by the system. Say if freeStorageSize is XX, 3392 * and the current free storage is YY, 3393 * if XX is less than YY, just return. if not free XX-YY number 3394 * of bytes if possible. 3395 * @param pi IntentSender call back used to 3396 * notify when the operation is completed.May be null 3397 * to indicate that no call back is desired. 3398 * 3399 * @hide 3400 */ 3401 public abstract void freeStorage(long freeStorageSize, IntentSender pi); 3402 3403 /** 3404 * Retrieve the size information for a package. 3405 * Since this may take a little while, the result will 3406 * be posted back to the given observer. The calling context 3407 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 3408 * 3409 * @param packageName The name of the package whose size information is to be retrieved 3410 * @param userHandle The user whose size information should be retrieved. 3411 * @param observer An observer callback to get notified when the operation 3412 * is complete. 3413 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 3414 * The observer's callback is invoked with a PackageStats object(containing the 3415 * code, data and cache sizes of the package) and a boolean value representing 3416 * the status of the operation. observer may be null to indicate that 3417 * no callback is desired. 3418 * 3419 * @hide 3420 */ 3421 public abstract void getPackageSizeInfo(String packageName, int userHandle, 3422 IPackageStatsObserver observer); 3423 3424 /** 3425 * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but 3426 * returns the size for the calling user. 3427 * 3428 * @hide 3429 */ 3430 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 3431 getPackageSizeInfo(packageName, UserHandle.myUserId(), observer); 3432 } 3433 3434 /** 3435 * @deprecated This function no longer does anything; it was an old 3436 * approach to managing preferred activities, which has been superseded 3437 * by (and conflicts with) the modern activity-based preferences. 3438 */ 3439 @Deprecated 3440 public abstract void addPackageToPreferred(String packageName); 3441 3442 /** 3443 * @deprecated This function no longer does anything; it was an old 3444 * approach to managing preferred activities, which has been superseded 3445 * by (and conflicts with) the modern activity-based preferences. 3446 */ 3447 @Deprecated 3448 public abstract void removePackageFromPreferred(String packageName); 3449 3450 /** 3451 * Retrieve the list of all currently configured preferred packages. The 3452 * first package on the list is the most preferred, the last is the 3453 * least preferred. 3454 * 3455 * @param flags Additional option flags. Use any combination of 3456 * {@link #GET_ACTIVITIES}, 3457 * {@link #GET_GIDS}, 3458 * {@link #GET_CONFIGURATIONS}, 3459 * {@link #GET_INSTRUMENTATION}, 3460 * {@link #GET_PERMISSIONS}, 3461 * {@link #GET_PROVIDERS}, 3462 * {@link #GET_RECEIVERS}, 3463 * {@link #GET_SERVICES}, 3464 * {@link #GET_SIGNATURES}, to modify the data returned. 3465 * 3466 * @return Returns a list of PackageInfo objects describing each 3467 * preferred application, in order of preference. 3468 * 3469 * @see #GET_ACTIVITIES 3470 * @see #GET_GIDS 3471 * @see #GET_CONFIGURATIONS 3472 * @see #GET_INSTRUMENTATION 3473 * @see #GET_PERMISSIONS 3474 * @see #GET_PROVIDERS 3475 * @see #GET_RECEIVERS 3476 * @see #GET_SERVICES 3477 * @see #GET_SIGNATURES 3478 */ 3479 public abstract List<PackageInfo> getPreferredPackages(int flags); 3480 3481 /** 3482 * @deprecated This is a protected API that should not have been available 3483 * to third party applications. It is the platform's responsibility for 3484 * assigning preferred activities and this cannot be directly modified. 3485 * 3486 * Add a new preferred activity mapping to the system. This will be used 3487 * to automatically select the given activity component when 3488 * {@link Context#startActivity(Intent) Context.startActivity()} finds 3489 * multiple matching activities and also matches the given filter. 3490 * 3491 * @param filter The set of intents under which this activity will be 3492 * made preferred. 3493 * @param match The IntentFilter match category that this preference 3494 * applies to. 3495 * @param set The set of activities that the user was picking from when 3496 * this preference was made. 3497 * @param activity The component name of the activity that is to be 3498 * preferred. 3499 */ 3500 @Deprecated 3501 public abstract void addPreferredActivity(IntentFilter filter, int match, 3502 ComponentName[] set, ComponentName activity); 3503 3504 /** 3505 * Same as {@link #addPreferredActivity(IntentFilter, int, 3506 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 3507 to. 3508 * @hide 3509 */ 3510 public void addPreferredActivity(IntentFilter filter, int match, 3511 ComponentName[] set, ComponentName activity, int userId) { 3512 throw new RuntimeException("Not implemented. Must override in a subclass."); 3513 } 3514 3515 /** 3516 * @deprecated This is a protected API that should not have been available 3517 * to third party applications. It is the platform's responsibility for 3518 * assigning preferred activities and this cannot be directly modified. 3519 * 3520 * Replaces an existing preferred activity mapping to the system, and if that were not present 3521 * adds a new preferred activity. This will be used 3522 * to automatically select the given activity component when 3523 * {@link Context#startActivity(Intent) Context.startActivity()} finds 3524 * multiple matching activities and also matches the given filter. 3525 * 3526 * @param filter The set of intents under which this activity will be 3527 * made preferred. 3528 * @param match The IntentFilter match category that this preference 3529 * applies to. 3530 * @param set The set of activities that the user was picking from when 3531 * this preference was made. 3532 * @param activity The component name of the activity that is to be 3533 * preferred. 3534 * @hide 3535 */ 3536 @Deprecated 3537 public abstract void replacePreferredActivity(IntentFilter filter, int match, 3538 ComponentName[] set, ComponentName activity); 3539 3540 /** 3541 * @hide 3542 */ 3543 @Deprecated 3544 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 3545 ComponentName[] set, ComponentName activity, int userId) { 3546 throw new RuntimeException("Not implemented. Must override in a subclass."); 3547 } 3548 3549 /** 3550 * Remove all preferred activity mappings, previously added with 3551 * {@link #addPreferredActivity}, from the 3552 * system whose activities are implemented in the given package name. 3553 * An application can only clear its own package(s). 3554 * 3555 * @param packageName The name of the package whose preferred activity 3556 * mappings are to be removed. 3557 */ 3558 public abstract void clearPackagePreferredActivities(String packageName); 3559 3560 /** 3561 * Retrieve all preferred activities, previously added with 3562 * {@link #addPreferredActivity}, that are 3563 * currently registered with the system. 3564 * 3565 * @param outFilters A list in which to place the filters of all of the 3566 * preferred activities, or null for none. 3567 * @param outActivities A list in which to place the component names of 3568 * all of the preferred activities, or null for none. 3569 * @param packageName An option package in which you would like to limit 3570 * the list. If null, all activities will be returned; if non-null, only 3571 * those activities in the given package are returned. 3572 * 3573 * @return Returns the total number of registered preferred activities 3574 * (the number of distinct IntentFilter records, not the number of unique 3575 * activity components) that were found. 3576 */ 3577 public abstract int getPreferredActivities(List<IntentFilter> outFilters, 3578 List<ComponentName> outActivities, String packageName); 3579 3580 /** 3581 * Ask for the set of available 'home' activities and the current explicit 3582 * default, if any. 3583 * @hide 3584 */ 3585 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 3586 3587 /** 3588 * Set the enabled setting for a package component (activity, receiver, service, provider). 3589 * This setting will override any enabled state which may have been set by the component in its 3590 * manifest. 3591 * 3592 * @param componentName The component to enable 3593 * @param newState The new enabled state for the component. The legal values for this state 3594 * are: 3595 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 3596 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 3597 * and 3598 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 3599 * The last one removes the setting, thereby restoring the component's state to 3600 * whatever was set in it's manifest (or enabled, by default). 3601 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 3602 */ 3603 public abstract void setComponentEnabledSetting(ComponentName componentName, 3604 int newState, int flags); 3605 3606 3607 /** 3608 * Return the enabled setting for a package component (activity, 3609 * receiver, service, provider). This returns the last value set by 3610 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 3611 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 3612 * the value originally specified in the manifest has not been modified. 3613 * 3614 * @param componentName The component to retrieve. 3615 * @return Returns the current enabled state for the component. May 3616 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 3617 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 3618 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 3619 * component's enabled state is based on the original information in 3620 * the manifest as found in {@link ComponentInfo}. 3621 */ 3622 public abstract int getComponentEnabledSetting(ComponentName componentName); 3623 3624 /** 3625 * Set the enabled setting for an application 3626 * This setting will override any enabled state which may have been set by the application in 3627 * its manifest. It also overrides the enabled state set in the manifest for any of the 3628 * application's components. It does not override any enabled state set by 3629 * {@link #setComponentEnabledSetting} for any of the application's components. 3630 * 3631 * @param packageName The package name of the application to enable 3632 * @param newState The new enabled state for the component. The legal values for this state 3633 * are: 3634 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 3635 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 3636 * and 3637 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 3638 * The last one removes the setting, thereby restoring the applications's state to 3639 * whatever was set in its manifest (or enabled, by default). 3640 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 3641 */ 3642 public abstract void setApplicationEnabledSetting(String packageName, 3643 int newState, int flags); 3644 3645 /** 3646 * Return the enabled setting for an application. This returns 3647 * the last value set by 3648 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 3649 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 3650 * the value originally specified in the manifest has not been modified. 3651 * 3652 * @param packageName The package name of the application to retrieve. 3653 * @return Returns the current enabled state for the application. May 3654 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 3655 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 3656 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 3657 * application's enabled state is based on the original information in 3658 * the manifest as found in {@link ComponentInfo}. 3659 * @throws IllegalArgumentException if the named package does not exist. 3660 */ 3661 public abstract int getApplicationEnabledSetting(String packageName); 3662 3663 /** 3664 * Puts the package in a hidden state, which is almost like an uninstalled state, 3665 * making the package unavailable, but it doesn't remove the data or the actual 3666 * package file. Application can be unhidden by either resetting the hidden state 3667 * or by installing it, such as with {@link #installExistingPackage(String)} 3668 * @hide 3669 */ 3670 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 3671 UserHandle userHandle); 3672 3673 /** 3674 * Returns the hidden state of a package. 3675 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 3676 * @hide 3677 */ 3678 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 3679 UserHandle userHandle); 3680 3681 /** 3682 * Return whether the device has been booted into safe mode. 3683 */ 3684 public abstract boolean isSafeMode(); 3685 3686 /** 3687 * Return the {@link KeySet} associated with the String alias for this 3688 * application. 3689 * 3690 * @param alias The alias for a given {@link KeySet} as defined in the 3691 * application's AndroidManifest.xml. 3692 */ 3693 public abstract KeySet getKeySetByAlias(String packageName, String alias); 3694 3695 /** Return the signing {@link KeySet} for this application. */ 3696 public abstract KeySet getSigningKeySet(String packageName); 3697 3698 /** 3699 * Return whether the package denoted by packageName has been signed by all 3700 * of the keys specified by the {@link KeySet} ks. This will return true if 3701 * the package has been signed by additional keys (a superset) as well. 3702 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 3703 */ 3704 public abstract boolean isSignedBy(String packageName, KeySet ks); 3705 3706 /** 3707 * Return whether the package denoted by packageName has been signed by all 3708 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 3709 * {@link #isSignedBy(String packageName, KeySet ks)}. 3710 */ 3711 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 3712 3713 /** 3714 * Attempts to move package resources from internal to external media or vice versa. 3715 * Since this may take a little while, the result will 3716 * be posted back to the given observer. This call may fail if the calling context 3717 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the 3718 * named package cannot be found, or if the named package is a "system package". 3719 * 3720 * @param packageName The name of the package to delete 3721 * @param observer An observer callback to get notified when the package move is 3722 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be 3723 * called when that happens. observer may be null to indicate that no callback is desired. 3724 * @param flags To indicate install location {@link #MOVE_INTERNAL} or 3725 * {@link #MOVE_EXTERNAL_MEDIA} 3726 * 3727 * @hide 3728 */ 3729 public abstract void movePackage( 3730 String packageName, IPackageMoveObserver observer, int flags); 3731 3732 /** 3733 * Returns the device identity that verifiers can use to associate their scheme to a particular 3734 * device. This should not be used by anything other than a package verifier. 3735 * 3736 * @return identity that uniquely identifies current device 3737 * @hide 3738 */ 3739 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 3740 3741 /** 3742 * Return interface that offers the ability to install, upgrade, and remove 3743 * applications on the device. 3744 */ 3745 public abstract @NonNull PackageInstaller getPackageInstaller(); 3746 3747 /** 3748 * Returns the data directory for a particular user and package, given the uid of the package. 3749 * @param uid uid of the package, including the userId and appId 3750 * @param packageName name of the package 3751 * @return the user-specific data directory for the package 3752 * @hide 3753 */ 3754 public static String getDataDirForUser(int userId, String packageName) { 3755 // TODO: This should be shared with Installer's knowledge of user directory 3756 return Environment.getDataDirectory().toString() + "/user/" + userId 3757 + "/" + packageName; 3758 } 3759 3760 /** 3761 * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the 3762 * user with id sourceUserId can also be be resolved by activities in the user with id 3763 * targetUserId if they match the specified intent filter. 3764 * @param filter The {@link IntentFilter} the intent has to match 3765 * @param sourceUserId The source user id. 3766 * @param targetUserId The target user id. 3767 * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE} 3768 * @hide 3769 */ 3770 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 3771 int targetUserId, int flags); 3772 3773 /** 3774 * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their 3775 * source, and have been set by the app calling this method. 3776 * @param sourceUserId The source user id. 3777 * @hide 3778 */ 3779 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 3780 3781 /** 3782 * Forwards all intents for {@link packageName} for user {@link sourceUserId} to user 3783 * {@link targetUserId}. 3784 * @hide 3785 */ 3786 public abstract void addCrossProfileIntentsForPackage(String packageName, 3787 int sourceUserId, int targetUserId); 3788 3789 /** 3790 * Removes all intents for {@link packageName} for user {@link sourceUserId} to user 3791 * {@link targetUserId}. 3792 * @hide 3793 */ 3794 public abstract void removeCrossProfileIntentsForPackage(String packageName, 3795 int sourceUserId, int targetUserId); 3796 3797 /** 3798 * @hide 3799 */ 3800 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 3801 3802 /** {@hide} */ 3803 public abstract boolean isPackageAvailable(String packageName); 3804 3805 /** {@hide} */ 3806 public static String installStatusToString(int status, String msg) { 3807 final String str = installStatusToString(status); 3808 if (msg != null) { 3809 return str + ": " + msg; 3810 } else { 3811 return str; 3812 } 3813 } 3814 3815 /** {@hide} */ 3816 public static String installStatusToString(int status) { 3817 switch (status) { 3818 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 3819 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 3820 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 3821 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 3822 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 3823 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 3824 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 3825 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 3826 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 3827 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 3828 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 3829 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 3830 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 3831 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 3832 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 3833 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 3834 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 3835 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 3836 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 3837 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 3838 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 3839 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 3840 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 3841 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 3842 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 3843 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 3844 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 3845 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 3846 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 3847 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 3848 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 3849 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 3850 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 3851 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 3852 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 3853 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 3854 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 3855 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 3856 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 3857 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 3858 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 3859 default: return Integer.toString(status); 3860 } 3861 } 3862 3863 /** {@hide} */ 3864 public static int installStatusToPublicStatus(int status) { 3865 switch (status) { 3866 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 3867 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3868 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 3869 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 3870 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 3871 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3872 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3873 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3874 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3875 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3876 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3877 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 3878 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3879 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3880 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3881 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 3882 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3883 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3884 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 3885 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 3886 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 3887 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 3888 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 3889 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 3890 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 3891 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 3892 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 3893 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 3894 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 3895 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 3896 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 3897 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 3898 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 3899 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 3900 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 3901 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 3902 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 3903 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3904 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 3905 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 3906 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 3907 default: return PackageInstaller.STATUS_FAILURE; 3908 } 3909 } 3910 3911 /** {@hide} */ 3912 public static String deleteStatusToString(int status, String msg) { 3913 final String str = deleteStatusToString(status); 3914 if (msg != null) { 3915 return str + ": " + msg; 3916 } else { 3917 return str; 3918 } 3919 } 3920 3921 /** {@hide} */ 3922 public static String deleteStatusToString(int status) { 3923 switch (status) { 3924 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 3925 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 3926 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 3927 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 3928 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 3929 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 3930 default: return Integer.toString(status); 3931 } 3932 } 3933 3934 /** {@hide} */ 3935 public static int deleteStatusToPublicStatus(int status) { 3936 switch (status) { 3937 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 3938 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 3939 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 3940 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 3941 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 3942 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 3943 default: return PackageInstaller.STATUS_FAILURE; 3944 } 3945 } 3946 3947 /** {@hide} */ 3948 public static class LegacyPackageInstallObserver extends PackageInstallObserver { 3949 private final IPackageInstallObserver mLegacy; 3950 3951 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { 3952 mLegacy = legacy; 3953 } 3954 3955 @Override 3956 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 3957 Bundle extras) { 3958 if (mLegacy == null) return; 3959 try { 3960 mLegacy.packageInstalled(basePackageName, returnCode); 3961 } catch (RemoteException ignored) { 3962 } 3963 } 3964 } 3965 3966 /** {@hide} */ 3967 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 3968 private final IPackageDeleteObserver mLegacy; 3969 3970 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 3971 mLegacy = legacy; 3972 } 3973 3974 @Override 3975 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 3976 if (mLegacy == null) return; 3977 try { 3978 mLegacy.packageDeleted(basePackageName, returnCode); 3979 } catch (RemoteException ignored) { 3980 } 3981 } 3982 } 3983} 3984