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