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