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