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