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