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