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