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