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