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