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