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