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