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