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