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