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