PackageManager.java revision b9f3674c11ed9c89b80a69f728cbc5f540b2ecde
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.CheckResult; 20import android.annotation.DrawableRes; 21import android.annotation.IntDef; 22import android.annotation.NonNull; 23import android.annotation.SdkConstant; 24import android.annotation.SdkConstant.SdkConstantType; 25import android.annotation.StringRes; 26import android.annotation.SystemApi; 27import android.annotation.XmlRes; 28import android.app.PackageDeleteObserver; 29import android.app.PackageInstallObserver; 30import android.app.admin.DevicePolicyManager; 31import android.content.ComponentName; 32import android.content.Context; 33import android.content.Intent; 34import android.content.IntentFilter; 35import android.content.IntentSender; 36import android.content.pm.PackageParser.PackageParserException; 37import android.content.res.Resources; 38import android.content.res.XmlResourceParser; 39import android.graphics.Rect; 40import android.graphics.drawable.Drawable; 41import android.net.Uri; 42import android.os.Bundle; 43import android.os.Environment; 44import android.os.RemoteException; 45import android.os.UserHandle; 46import android.os.storage.VolumeInfo; 47import android.text.TextUtils; 48import android.util.AndroidException; 49 50import com.android.internal.util.ArrayUtils; 51 52import java.io.File; 53import java.lang.annotation.Retention; 54import java.lang.annotation.RetentionPolicy; 55import java.util.List; 56 57/** 58 * Class for retrieving various kinds of information related to the application 59 * packages that are currently installed on the device. 60 * 61 * You can find this class through {@link Context#getPackageManager}. 62 */ 63public abstract class PackageManager { 64 65 /** 66 * This exception is thrown when a given package, application, or component 67 * name cannot be found. 68 */ 69 public static class NameNotFoundException extends AndroidException { 70 public NameNotFoundException() { 71 } 72 73 public NameNotFoundException(String name) { 74 super(name); 75 } 76 } 77 78 /** 79 * {@link PackageInfo} flag: return information about 80 * activities in the package in {@link PackageInfo#activities}. 81 */ 82 public static final int GET_ACTIVITIES = 0x00000001; 83 84 /** 85 * {@link PackageInfo} flag: return information about 86 * intent receivers in the package in 87 * {@link PackageInfo#receivers}. 88 */ 89 public static final int GET_RECEIVERS = 0x00000002; 90 91 /** 92 * {@link PackageInfo} flag: return information about 93 * services in the package in {@link PackageInfo#services}. 94 */ 95 public static final int GET_SERVICES = 0x00000004; 96 97 /** 98 * {@link PackageInfo} flag: return information about 99 * content providers in the package in 100 * {@link PackageInfo#providers}. 101 */ 102 public static final int GET_PROVIDERS = 0x00000008; 103 104 /** 105 * {@link PackageInfo} flag: return information about 106 * instrumentation in the package in 107 * {@link PackageInfo#instrumentation}. 108 */ 109 public static final int GET_INSTRUMENTATION = 0x00000010; 110 111 /** 112 * {@link PackageInfo} flag: return information about the 113 * intent filters supported by the activity. 114 */ 115 public static final int GET_INTENT_FILTERS = 0x00000020; 116 117 /** 118 * {@link PackageInfo} flag: return information about the 119 * signatures included in the package. 120 */ 121 public static final int GET_SIGNATURES = 0x00000040; 122 123 /** 124 * {@link ResolveInfo} flag: return the IntentFilter that 125 * was matched for a particular ResolveInfo in 126 * {@link ResolveInfo#filter}. 127 */ 128 public static final int GET_RESOLVED_FILTER = 0x00000040; 129 130 /** 131 * {@link ComponentInfo} flag: return the {@link ComponentInfo#metaData} 132 * data {@link android.os.Bundle}s that are associated with a component. 133 * This applies for any API returning a ComponentInfo subclass. 134 */ 135 public static final int GET_META_DATA = 0x00000080; 136 137 /** 138 * {@link PackageInfo} flag: return the 139 * {@link PackageInfo#gids group ids} that are associated with an 140 * application. 141 * This applies for any API returning a PackageInfo class, either 142 * directly or nested inside of another. 143 */ 144 public static final int GET_GIDS = 0x00000100; 145 146 /** 147 * {@link PackageInfo} flag: include disabled components in the returned info. 148 */ 149 public static final int GET_DISABLED_COMPONENTS = 0x00000200; 150 151 /** 152 * {@link ApplicationInfo} flag: return the 153 * {@link ApplicationInfo#sharedLibraryFiles paths to the shared libraries} 154 * that are associated with an application. 155 * This applies for any API returning an ApplicationInfo class, either 156 * directly or nested inside of another. 157 */ 158 public static final int GET_SHARED_LIBRARY_FILES = 0x00000400; 159 160 /** 161 * {@link ProviderInfo} flag: return the 162 * {@link ProviderInfo#uriPermissionPatterns URI permission patterns} 163 * that are associated with a content provider. 164 * This applies for any API returning a ProviderInfo class, either 165 * directly or nested inside of another. 166 */ 167 public static final int GET_URI_PERMISSION_PATTERNS = 0x00000800; 168 /** 169 * {@link PackageInfo} flag: return information about 170 * permissions in the package in 171 * {@link PackageInfo#permissions}. 172 */ 173 public static final int GET_PERMISSIONS = 0x00001000; 174 175 /** 176 * Flag parameter to retrieve some information about all applications (even 177 * uninstalled ones) which have data directories. This state could have 178 * resulted if applications have been deleted with flag 179 * {@code DONT_DELETE_DATA} with a possibility of being replaced or 180 * reinstalled in future. 181 * <p> 182 * Note: this flag may cause less information about currently installed 183 * applications to be returned. 184 */ 185 public static final int GET_UNINSTALLED_PACKAGES = 0x00002000; 186 187 /** 188 * {@link PackageInfo} flag: return information about 189 * hardware preferences in 190 * {@link PackageInfo#configPreferences PackageInfo.configPreferences}, 191 * and requested features in {@link PackageInfo#reqFeatures} and 192 * {@link PackageInfo#featureGroups}. 193 */ 194 public static final int GET_CONFIGURATIONS = 0x00004000; 195 196 /** 197 * {@link PackageInfo} flag: include disabled components which are in 198 * that state only because of {@link #COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED} 199 * in the returned info. Note that if you set this flag, applications 200 * that are in this disabled state will be reported as enabled. 201 */ 202 public static final int GET_DISABLED_UNTIL_USED_COMPONENTS = 0x00008000; 203 204 /** 205 * Resolution and querying flag: if set, only filters that support the 206 * {@link android.content.Intent#CATEGORY_DEFAULT} will be considered for 207 * matching. This is a synonym for including the CATEGORY_DEFAULT in your 208 * supplied Intent. 209 */ 210 public static final int MATCH_DEFAULT_ONLY = 0x00010000; 211 212 /** 213 * Flag for {@link addCrossProfileIntentFilter}: if this flag is set: 214 * when resolving an intent that matches the {@link CrossProfileIntentFilter}, the current 215 * profile will be skipped. 216 * Only activities in the target user can respond to the intent. 217 * @hide 218 */ 219 public static final int SKIP_CURRENT_PROFILE = 0x00000002; 220 221 /** @hide */ 222 @IntDef({PERMISSION_GRANTED, PERMISSION_DENIED}) 223 @Retention(RetentionPolicy.SOURCE) 224 public @interface PermissionResult {} 225 226 /** 227 * Permission check result: this is returned by {@link #checkPermission} 228 * if the permission has been granted to the given package. 229 */ 230 public static final int PERMISSION_GRANTED = 0; 231 232 /** 233 * Permission check result: this is returned by {@link #checkPermission} 234 * if the permission has not been granted to the given package. 235 */ 236 public static final int PERMISSION_DENIED = -1; 237 238 /** 239 * Signature check result: this is returned by {@link #checkSignatures} 240 * if all signatures on the two packages match. 241 */ 242 public static final int SIGNATURE_MATCH = 0; 243 244 /** 245 * Signature check result: this is returned by {@link #checkSignatures} 246 * if neither of the two packages is signed. 247 */ 248 public static final int SIGNATURE_NEITHER_SIGNED = 1; 249 250 /** 251 * Signature check result: this is returned by {@link #checkSignatures} 252 * if the first package is not signed but the second is. 253 */ 254 public static final int SIGNATURE_FIRST_NOT_SIGNED = -1; 255 256 /** 257 * Signature check result: this is returned by {@link #checkSignatures} 258 * if the second package is not signed but the first is. 259 */ 260 public static final int SIGNATURE_SECOND_NOT_SIGNED = -2; 261 262 /** 263 * Signature check result: this is returned by {@link #checkSignatures} 264 * if not all signatures on both packages match. 265 */ 266 public static final int SIGNATURE_NO_MATCH = -3; 267 268 /** 269 * Signature check result: this is returned by {@link #checkSignatures} 270 * if either of the packages are not valid. 271 */ 272 public static final int SIGNATURE_UNKNOWN_PACKAGE = -4; 273 274 /** 275 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 276 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 277 * component or application is in its default enabled state (as specified 278 * in its manifest). 279 */ 280 public static final int COMPONENT_ENABLED_STATE_DEFAULT = 0; 281 282 /** 283 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 284 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 285 * component or application has been explictily enabled, regardless of 286 * what it has specified in its manifest. 287 */ 288 public static final int COMPONENT_ENABLED_STATE_ENABLED = 1; 289 290 /** 291 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} 292 * and {@link #setComponentEnabledSetting(ComponentName, int, int)}: This 293 * component or application has been explicitly disabled, regardless of 294 * what it has specified in its manifest. 295 */ 296 public static final int COMPONENT_ENABLED_STATE_DISABLED = 2; 297 298 /** 299 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: The 300 * user has explicitly disabled the application, regardless of what it has 301 * specified in its manifest. Because this is due to the user's request, 302 * they may re-enable it if desired through the appropriate system UI. This 303 * option currently <strong>cannot</strong> be used with 304 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 305 */ 306 public static final int COMPONENT_ENABLED_STATE_DISABLED_USER = 3; 307 308 /** 309 * Flag for {@link #setApplicationEnabledSetting(String, int, int)} only: This 310 * application should be considered, until the point where the user actually 311 * wants to use it. This means that it will not normally show up to the user 312 * (such as in the launcher), but various parts of the user interface can 313 * use {@link #GET_DISABLED_UNTIL_USED_COMPONENTS} to still see it and allow 314 * the user to select it (as for example an IME, device admin, etc). Such code, 315 * once the user has selected the app, should at that point also make it enabled. 316 * This option currently <strong>can not</strong> be used with 317 * {@link #setComponentEnabledSetting(ComponentName, int, int)}. 318 */ 319 public static final int COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED = 4; 320 321 /** 322 * Flag parameter for {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} to 323 * indicate that this package should be installed as forward locked, i.e. only the app itself 324 * should have access to its code and non-resource assets. 325 * @hide 326 */ 327 public static final int INSTALL_FORWARD_LOCK = 0x00000001; 328 329 /** 330 * Flag parameter for {@link #installPackage} to indicate that you want to replace an already 331 * installed package, if one exists. 332 * @hide 333 */ 334 public static final int INSTALL_REPLACE_EXISTING = 0x00000002; 335 336 /** 337 * Flag parameter for {@link #installPackage} to indicate that you want to 338 * allow test packages (those that have set android:testOnly in their 339 * manifest) to be installed. 340 * @hide 341 */ 342 public static final int INSTALL_ALLOW_TEST = 0x00000004; 343 344 /** 345 * Flag parameter for {@link #installPackage} to indicate that this package 346 * must be installed to an ASEC on a {@link VolumeInfo#TYPE_PUBLIC}. 347 * 348 * @hide 349 */ 350 public static final int INSTALL_EXTERNAL = 0x00000008; 351 352 /** 353 * Flag parameter for {@link #installPackage} to indicate that this package 354 * must be installed to internal storage. 355 * 356 * @hide 357 */ 358 public static final int INSTALL_INTERNAL = 0x00000010; 359 360 /** 361 * Flag parameter for {@link #installPackage} to indicate that this install 362 * was initiated via ADB. 363 * 364 * @hide 365 */ 366 public static final int INSTALL_FROM_ADB = 0x00000020; 367 368 /** 369 * Flag parameter for {@link #installPackage} to indicate that this install 370 * should immediately be visible to all users. 371 * 372 * @hide 373 */ 374 public static final int INSTALL_ALL_USERS = 0x00000040; 375 376 /** 377 * Flag parameter for {@link #installPackage} to indicate that it is okay 378 * to install an update to an app where the newly installed app has a lower 379 * version code than the currently installed app. 380 * 381 * @hide 382 */ 383 public static final int INSTALL_ALLOW_DOWNGRADE = 0x00000080; 384 385 /** 386 * Flag parameter for {@link #installPackage} to indicate that all runtime 387 * permissions should be granted to the package. If {@link #INSTALL_ALL_USERS} 388 * is set the runtime permissions will be granted to all users, otherwise 389 * only to the owner. 390 * 391 * @hide 392 */ 393 public static final int INSTALL_GRANT_RUNTIME_PERMISSIONS = 0x00000100; 394 395 /** 396 * Flag parameter for 397 * {@link #setComponentEnabledSetting(android.content.ComponentName, int, int)} to indicate 398 * that you don't want to kill the app containing the component. Be careful when you set this 399 * since changing component states can make the containing application's behavior unpredictable. 400 */ 401 public static final int DONT_KILL_APP = 0x00000001; 402 403 /** 404 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 405 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} on success. 406 * @hide 407 */ 408 @SystemApi 409 public static final int INSTALL_SUCCEEDED = 1; 410 411 /** 412 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 413 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package is 414 * already installed. 415 * @hide 416 */ 417 @SystemApi 418 public static final int INSTALL_FAILED_ALREADY_EXISTS = -1; 419 420 /** 421 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 422 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package archive 423 * file is invalid. 424 * @hide 425 */ 426 @SystemApi 427 public static final int INSTALL_FAILED_INVALID_APK = -2; 428 429 /** 430 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 431 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the URI passed in 432 * is invalid. 433 * @hide 434 */ 435 @SystemApi 436 public static final int INSTALL_FAILED_INVALID_URI = -3; 437 438 /** 439 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 440 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if the package manager 441 * service found that the device didn't have enough storage space to install the app. 442 * @hide 443 */ 444 @SystemApi 445 public static final int INSTALL_FAILED_INSUFFICIENT_STORAGE = -4; 446 447 /** 448 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 449 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if a 450 * package is already installed with the same name. 451 * @hide 452 */ 453 @SystemApi 454 public static final int INSTALL_FAILED_DUPLICATE_PACKAGE = -5; 455 456 /** 457 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 458 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 459 * the requested shared user does not exist. 460 * @hide 461 */ 462 @SystemApi 463 public static final int INSTALL_FAILED_NO_SHARED_USER = -6; 464 465 /** 466 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 467 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 468 * a previously installed package of the same name has a different signature 469 * than the new package (and the old package's data was not removed). 470 * @hide 471 */ 472 @SystemApi 473 public static final int INSTALL_FAILED_UPDATE_INCOMPATIBLE = -7; 474 475 /** 476 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 477 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 478 * the new package is requested a shared user which is already installed on the 479 * device and does not have matching signature. 480 * @hide 481 */ 482 @SystemApi 483 public static final int INSTALL_FAILED_SHARED_USER_INCOMPATIBLE = -8; 484 485 /** 486 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 487 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 488 * the new package uses a shared library that is not available. 489 * @hide 490 */ 491 @SystemApi 492 public static final int INSTALL_FAILED_MISSING_SHARED_LIBRARY = -9; 493 494 /** 495 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 496 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 497 * the new package uses a shared library that is not available. 498 * @hide 499 */ 500 @SystemApi 501 public static final int INSTALL_FAILED_REPLACE_COULDNT_DELETE = -10; 502 503 /** 504 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 505 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 506 * the new package failed while optimizing and validating its dex files, 507 * either because there was not enough storage or the validation failed. 508 * @hide 509 */ 510 @SystemApi 511 public static final int INSTALL_FAILED_DEXOPT = -11; 512 513 /** 514 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 515 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 516 * the new package failed because the current SDK version is older than 517 * that required by the package. 518 * @hide 519 */ 520 @SystemApi 521 public static final int INSTALL_FAILED_OLDER_SDK = -12; 522 523 /** 524 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 525 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 526 * the new package failed because it contains a content provider with the 527 * same authority as a provider already installed in the system. 528 * @hide 529 */ 530 @SystemApi 531 public static final int INSTALL_FAILED_CONFLICTING_PROVIDER = -13; 532 533 /** 534 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 535 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 536 * the new package failed because the current SDK version is newer than 537 * that required by the package. 538 * @hide 539 */ 540 @SystemApi 541 public static final int INSTALL_FAILED_NEWER_SDK = -14; 542 543 /** 544 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 545 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 546 * the new package failed because it has specified that it is a test-only 547 * package and the caller has not supplied the {@link #INSTALL_ALLOW_TEST} 548 * flag. 549 * @hide 550 */ 551 @SystemApi 552 public static final int INSTALL_FAILED_TEST_ONLY = -15; 553 554 /** 555 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 556 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 557 * the package being installed contains native code, but none that is 558 * compatible with the device's CPU_ABI. 559 * @hide 560 */ 561 @SystemApi 562 public static final int INSTALL_FAILED_CPU_ABI_INCOMPATIBLE = -16; 563 564 /** 565 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 566 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 567 * the new package uses a feature that is not available. 568 * @hide 569 */ 570 @SystemApi 571 public static final int INSTALL_FAILED_MISSING_FEATURE = -17; 572 573 // ------ Errors related to sdcard 574 /** 575 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 576 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 577 * a secure container mount point couldn't be accessed on external media. 578 * @hide 579 */ 580 @SystemApi 581 public static final int INSTALL_FAILED_CONTAINER_ERROR = -18; 582 583 /** 584 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 585 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 586 * the new package couldn't be installed in the specified install 587 * location. 588 * @hide 589 */ 590 @SystemApi 591 public static final int INSTALL_FAILED_INVALID_INSTALL_LOCATION = -19; 592 593 /** 594 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 595 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 596 * the new package couldn't be installed in the specified install 597 * location because the media is not available. 598 * @hide 599 */ 600 @SystemApi 601 public static final int INSTALL_FAILED_MEDIA_UNAVAILABLE = -20; 602 603 /** 604 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 605 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 606 * the new package couldn't be installed because the verification timed out. 607 * @hide 608 */ 609 @SystemApi 610 public static final int INSTALL_FAILED_VERIFICATION_TIMEOUT = -21; 611 612 /** 613 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 614 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 615 * the new package couldn't be installed because the verification did not succeed. 616 * @hide 617 */ 618 @SystemApi 619 public static final int INSTALL_FAILED_VERIFICATION_FAILURE = -22; 620 621 /** 622 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 623 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 624 * the package changed from what the calling program expected. 625 * @hide 626 */ 627 @SystemApi 628 public static final int INSTALL_FAILED_PACKAGE_CHANGED = -23; 629 630 /** 631 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 632 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 633 * the new package is assigned a different UID than it previously held. 634 * @hide 635 */ 636 public static final int INSTALL_FAILED_UID_CHANGED = -24; 637 638 /** 639 * Installation return code: this is passed to the {@link IPackageInstallObserver} by 640 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} if 641 * the new package has an older version code than the currently installed package. 642 * @hide 643 */ 644 public static final int INSTALL_FAILED_VERSION_DOWNGRADE = -25; 645 646 /** 647 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 648 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 649 * if the parser was given a path that is not a file, or does not end with the expected 650 * '.apk' extension. 651 * @hide 652 */ 653 @SystemApi 654 public static final int INSTALL_PARSE_FAILED_NOT_APK = -100; 655 656 /** 657 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 658 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 659 * if the parser was unable to retrieve the AndroidManifest.xml file. 660 * @hide 661 */ 662 @SystemApi 663 public static final int INSTALL_PARSE_FAILED_BAD_MANIFEST = -101; 664 665 /** 666 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 667 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 668 * if the parser encountered an unexpected exception. 669 * @hide 670 */ 671 @SystemApi 672 public static final int INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION = -102; 673 674 /** 675 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 676 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 677 * if the parser did not find any certificates in the .apk. 678 * @hide 679 */ 680 @SystemApi 681 public static final int INSTALL_PARSE_FAILED_NO_CERTIFICATES = -103; 682 683 /** 684 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 685 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 686 * if the parser found inconsistent certificates on the files in the .apk. 687 * @hide 688 */ 689 @SystemApi 690 public static final int INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES = -104; 691 692 /** 693 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 694 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 695 * if the parser encountered a CertificateEncodingException in one of the 696 * files in the .apk. 697 * @hide 698 */ 699 @SystemApi 700 public static final int INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING = -105; 701 702 /** 703 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 704 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 705 * if the parser encountered a bad or missing package name in the manifest. 706 * @hide 707 */ 708 @SystemApi 709 public static final int INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME = -106; 710 711 /** 712 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 713 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 714 * if the parser encountered a bad shared user id name in the manifest. 715 * @hide 716 */ 717 @SystemApi 718 public static final int INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID = -107; 719 720 /** 721 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 722 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 723 * if the parser encountered some structural problem in the manifest. 724 * @hide 725 */ 726 @SystemApi 727 public static final int INSTALL_PARSE_FAILED_MANIFEST_MALFORMED = -108; 728 729 /** 730 * Installation parse return code: this is passed to the {@link IPackageInstallObserver} by 731 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 732 * if the parser did not find any actionable tags (instrumentation or application) 733 * in the manifest. 734 * @hide 735 */ 736 @SystemApi 737 public static final int INSTALL_PARSE_FAILED_MANIFEST_EMPTY = -109; 738 739 /** 740 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 741 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 742 * if the system failed to install the package because of system issues. 743 * @hide 744 */ 745 @SystemApi 746 public static final int INSTALL_FAILED_INTERNAL_ERROR = -110; 747 748 /** 749 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 750 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 751 * if the system failed to install the package because the user is restricted from installing 752 * apps. 753 * @hide 754 */ 755 public static final int INSTALL_FAILED_USER_RESTRICTED = -111; 756 757 /** 758 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 759 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 760 * if the system failed to install the package because it is attempting to define a 761 * permission that is already defined by some existing package. 762 * 763 * <p>The package name of the app which has already defined the permission is passed to 764 * a {@link PackageInstallObserver}, if any, as the {@link #EXTRA_EXISTING_PACKAGE} 765 * string extra; and the name of the permission being redefined is passed in the 766 * {@link #EXTRA_EXISTING_PERMISSION} string extra. 767 * @hide 768 */ 769 public static final int INSTALL_FAILED_DUPLICATE_PERMISSION = -112; 770 771 /** 772 * Installation failed return code: this is passed to the {@link IPackageInstallObserver} by 773 * {@link #installPackage(android.net.Uri, IPackageInstallObserver, int)} 774 * if the system failed to install the package because its packaged native code did not 775 * match any of the ABIs supported by the system. 776 * 777 * @hide 778 */ 779 public static final int INSTALL_FAILED_NO_MATCHING_ABIS = -113; 780 781 /** 782 * Internal return code for NativeLibraryHelper methods to indicate that the package 783 * being processed did not contain any native code. This is placed here only so that 784 * it can belong to the same value space as the other install failure codes. 785 * 786 * @hide 787 */ 788 public static final int NO_NATIVE_LIBRARIES = -114; 789 790 /** {@hide} */ 791 public static final int INSTALL_FAILED_ABORTED = -115; 792 793 /** 794 * Flag parameter for {@link #deletePackage} to indicate that you don't want to delete the 795 * package's data directory. 796 * 797 * @hide 798 */ 799 public static final int DELETE_KEEP_DATA = 0x00000001; 800 801 /** 802 * Flag parameter for {@link #deletePackage} to indicate that you want the 803 * package deleted for all users. 804 * 805 * @hide 806 */ 807 public static final int DELETE_ALL_USERS = 0x00000002; 808 809 /** 810 * Flag parameter for {@link #deletePackage} to indicate that, if you are calling 811 * uninstall on a system that has been updated, then don't do the normal process 812 * of uninstalling the update and rolling back to the older system version (which 813 * needs to happen for all users); instead, just mark the app as uninstalled for 814 * the current user. 815 * 816 * @hide 817 */ 818 public static final int DELETE_SYSTEM_APP = 0x00000004; 819 820 /** 821 * Return code for when package deletion succeeds. This is passed to the 822 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 823 * succeeded in deleting the package. 824 * 825 * @hide 826 */ 827 public static final int DELETE_SUCCEEDED = 1; 828 829 /** 830 * Deletion failed return code: this is passed to the 831 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 832 * failed to delete the package for an unspecified reason. 833 * 834 * @hide 835 */ 836 public static final int DELETE_FAILED_INTERNAL_ERROR = -1; 837 838 /** 839 * Deletion failed return code: this is passed to the 840 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 841 * failed to delete the package because it is the active DevicePolicy 842 * manager. 843 * 844 * @hide 845 */ 846 public static final int DELETE_FAILED_DEVICE_POLICY_MANAGER = -2; 847 848 /** 849 * Deletion failed return code: this is passed to the 850 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 851 * failed to delete the package since the user is restricted. 852 * 853 * @hide 854 */ 855 public static final int DELETE_FAILED_USER_RESTRICTED = -3; 856 857 /** 858 * Deletion failed return code: this is passed to the 859 * {@link IPackageDeleteObserver} by {@link #deletePackage()} if the system 860 * failed to delete the package because a profile 861 * or device owner has marked the package as uninstallable. 862 * 863 * @hide 864 */ 865 public static final int DELETE_FAILED_OWNER_BLOCKED = -4; 866 867 /** {@hide} */ 868 public static final int DELETE_FAILED_ABORTED = -5; 869 870 /** 871 * Return code that is passed to the {@link IPackageMoveObserver} by 872 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} when the 873 * package has been successfully moved by the system. 874 * 875 * @hide 876 */ 877 public static final int MOVE_SUCCEEDED = 1; 878 /** 879 * Error code that is passed to the {@link IPackageMoveObserver} by 880 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 881 * when the package hasn't been successfully moved by the system 882 * because of insufficient memory on specified media. 883 * @hide 884 */ 885 public static final int MOVE_FAILED_INSUFFICIENT_STORAGE = -1; 886 887 /** 888 * Error code that is passed to the {@link IPackageMoveObserver} by 889 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 890 * if the specified package doesn't exist. 891 * @hide 892 */ 893 public static final int MOVE_FAILED_DOESNT_EXIST = -2; 894 895 /** 896 * Error code that is passed to the {@link IPackageMoveObserver} by 897 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 898 * if the specified package cannot be moved since its a system package. 899 * @hide 900 */ 901 public static final int MOVE_FAILED_SYSTEM_PACKAGE = -3; 902 903 /** 904 * Error code that is passed to the {@link IPackageMoveObserver} by 905 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 906 * if the specified package cannot be moved since its forward locked. 907 * @hide 908 */ 909 public static final int MOVE_FAILED_FORWARD_LOCKED = -4; 910 911 /** 912 * Error code that is passed to the {@link IPackageMoveObserver} by 913 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 914 * if the specified package cannot be moved to the specified location. 915 * @hide 916 */ 917 public static final int MOVE_FAILED_INVALID_LOCATION = -5; 918 919 /** 920 * Error code that is passed to the {@link IPackageMoveObserver} by 921 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} 922 * if the specified package cannot be moved to the specified location. 923 * @hide 924 */ 925 public static final int MOVE_FAILED_INTERNAL_ERROR = -6; 926 927 /** 928 * Error code that is passed to the {@link IPackageMoveObserver} by 929 * {@link #movePackage(android.net.Uri, IPackageMoveObserver)} if the 930 * specified package already has an operation pending in the 931 * {@link PackageHandler} queue. 932 * 933 * @hide 934 */ 935 public static final int MOVE_FAILED_OPERATION_PENDING = -7; 936 937 /** 938 * Flag parameter for {@link #movePackage} to indicate that 939 * the package should be moved to internal storage if its 940 * been installed on external media. 941 * @hide 942 */ 943 public static final int MOVE_INTERNAL = 0x00000001; 944 945 /** 946 * Flag parameter for {@link #movePackage} to indicate that 947 * the package should be moved to external media. 948 * @hide 949 */ 950 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; 951 952 /** 953 * Usable by the required verifier as the {@code verificationCode} argument 954 * for {@link PackageManager#verifyPendingInstall} to indicate that it will 955 * allow the installation to proceed without any of the optional verifiers 956 * needing to vote. 957 * 958 * @hide 959 */ 960 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2; 961 962 /** 963 * Used as the {@code verificationCode} argument for 964 * {@link PackageManager#verifyPendingInstall} to indicate that the calling 965 * package verifier allows the installation to proceed. 966 */ 967 public static final int VERIFICATION_ALLOW = 1; 968 969 /** 970 * Used as the {@code verificationCode} argument for 971 * {@link PackageManager#verifyPendingInstall} to indicate the calling 972 * package verifier does not vote to allow the installation to proceed. 973 */ 974 public static final int VERIFICATION_REJECT = -1; 975 976 /** 977 * Used as the {@code verificationCode} argument for 978 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 979 * IntentFilter Verifier confirms that the IntentFilter is verified. 980 * 981 * @hide 982 */ 983 public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1; 984 985 /** 986 * Used as the {@code verificationCode} argument for 987 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 988 * IntentFilter Verifier confirms that the IntentFilter is NOT verified. 989 * 990 * @hide 991 */ 992 public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1; 993 994 /** 995 * Internal status code to indicate that an IntentFilter verification result is not specified. 996 * 997 * @hide 998 */ 999 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0; 1000 1001 /** 1002 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1003 * to indicate that the User will always be prompted the Intent Disambiguation Dialog if there 1004 * are two or more Intent resolved for the IntentFilter's domain(s). 1005 * 1006 * @hide 1007 */ 1008 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1; 1009 1010 /** 1011 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1012 * to indicate that the User will never be prompted the Intent Disambiguation Dialog if there 1013 * are two or more resolution of the Intent. The default App for the domain(s) specified in the 1014 * IntentFilter will also ALWAYS be used. 1015 * 1016 * @hide 1017 */ 1018 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2; 1019 1020 /** 1021 * Used as the {@code status} argument for {@link PackageManager#updateIntentVerificationStatus} 1022 * to indicate that the User may be prompted the Intent Disambiguation Dialog if there 1023 * are two or more Intent resolved. The default App for the domain(s) specified in the 1024 * IntentFilter will also NEVER be presented to the User. 1025 * 1026 * @hide 1027 */ 1028 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3; 1029 1030 /** 1031 * Can be used as the {@code millisecondsToDelay} argument for 1032 * {@link PackageManager#extendVerificationTimeout}. This is the 1033 * maximum time {@code PackageManager} waits for the verification 1034 * agent to return (in milliseconds). 1035 */ 1036 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000; 1037 1038 /** 1039 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's 1040 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or 1041 * lag in sound input or output. 1042 */ 1043 @SdkConstant(SdkConstantType.FEATURE) 1044 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency"; 1045 1046 /** 1047 * Feature for {@link #getSystemAvailableFeatures} and 1048 * {@link #hasSystemFeature}: The device includes at least one form of audio 1049 * output, such as speakers, audio jack or streaming over bluetooth 1050 */ 1051 @SdkConstant(SdkConstantType.FEATURE) 1052 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output"; 1053 1054 /** 1055 * Feature for {@link #getSystemAvailableFeatures} and 1056 * {@link #hasSystemFeature}: The device is capable of communicating with 1057 * other devices via Bluetooth. 1058 */ 1059 @SdkConstant(SdkConstantType.FEATURE) 1060 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 1061 1062 /** 1063 * Feature for {@link #getSystemAvailableFeatures} and 1064 * {@link #hasSystemFeature}: The device is capable of communicating with 1065 * other devices via Bluetooth Low Energy radio. 1066 */ 1067 @SdkConstant(SdkConstantType.FEATURE) 1068 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le"; 1069 1070 /** 1071 * Feature for {@link #getSystemAvailableFeatures} and 1072 * {@link #hasSystemFeature}: The device has a camera facing away 1073 * from the screen. 1074 */ 1075 @SdkConstant(SdkConstantType.FEATURE) 1076 public static final String FEATURE_CAMERA = "android.hardware.camera"; 1077 1078 /** 1079 * Feature for {@link #getSystemAvailableFeatures} and 1080 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 1081 */ 1082 @SdkConstant(SdkConstantType.FEATURE) 1083 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 1084 1085 /** 1086 * Feature for {@link #getSystemAvailableFeatures} and 1087 * {@link #hasSystemFeature}: The device has at least one camera pointing in 1088 * some direction, or can support an external camera being connected to it. 1089 */ 1090 @SdkConstant(SdkConstantType.FEATURE) 1091 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any"; 1092 1093 /** 1094 * Feature for {@link #getSystemAvailableFeatures} and 1095 * {@link #hasSystemFeature}: The device can support having an external camera connected to it. 1096 * The external camera may not always be connected or available to applications to use. 1097 */ 1098 @SdkConstant(SdkConstantType.FEATURE) 1099 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external"; 1100 1101 /** 1102 * Feature for {@link #getSystemAvailableFeatures} and 1103 * {@link #hasSystemFeature}: The device's camera supports flash. 1104 */ 1105 @SdkConstant(SdkConstantType.FEATURE) 1106 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 1107 1108 /** 1109 * Feature for {@link #getSystemAvailableFeatures} and 1110 * {@link #hasSystemFeature}: The device has a front facing camera. 1111 */ 1112 @SdkConstant(SdkConstantType.FEATURE) 1113 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 1114 1115 /** 1116 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1117 * of the cameras on the device supports the 1118 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware} 1119 * capability level. 1120 */ 1121 @SdkConstant(SdkConstantType.FEATURE) 1122 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full"; 1123 1124 /** 1125 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1126 * of the cameras on the device supports the 1127 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor} 1128 * capability level. 1129 */ 1130 @SdkConstant(SdkConstantType.FEATURE) 1131 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR = 1132 "android.hardware.camera.capability.manual_sensor"; 1133 1134 /** 1135 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1136 * of the cameras on the device supports the 1137 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing} 1138 * capability level. 1139 */ 1140 @SdkConstant(SdkConstantType.FEATURE) 1141 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING = 1142 "android.hardware.camera.capability.manual_post_processing"; 1143 1144 /** 1145 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1146 * of the cameras on the device supports the 1147 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW} 1148 * capability level. 1149 */ 1150 @SdkConstant(SdkConstantType.FEATURE) 1151 public static final String FEATURE_CAMERA_CAPABILITY_RAW = 1152 "android.hardware.camera.capability.raw"; 1153 1154 /** 1155 * Feature for {@link #getSystemAvailableFeatures} and 1156 * {@link #hasSystemFeature}: The device is capable of communicating with 1157 * consumer IR devices. 1158 */ 1159 @SdkConstant(SdkConstantType.FEATURE) 1160 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir"; 1161 1162 /** 1163 * Feature for {@link #getSystemAvailableFeatures} and 1164 * {@link #hasSystemFeature}: The device supports one or more methods of 1165 * reporting current location. 1166 */ 1167 @SdkConstant(SdkConstantType.FEATURE) 1168 public static final String FEATURE_LOCATION = "android.hardware.location"; 1169 1170 /** 1171 * Feature for {@link #getSystemAvailableFeatures} and 1172 * {@link #hasSystemFeature}: The device has a Global Positioning System 1173 * receiver and can report precise location. 1174 */ 1175 @SdkConstant(SdkConstantType.FEATURE) 1176 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 1177 1178 /** 1179 * Feature for {@link #getSystemAvailableFeatures} and 1180 * {@link #hasSystemFeature}: The device can report location with coarse 1181 * accuracy using a network-based geolocation system. 1182 */ 1183 @SdkConstant(SdkConstantType.FEATURE) 1184 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 1185 1186 /** 1187 * Feature for {@link #getSystemAvailableFeatures} and 1188 * {@link #hasSystemFeature}: The device can record audio via a 1189 * microphone. 1190 */ 1191 @SdkConstant(SdkConstantType.FEATURE) 1192 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 1193 1194 /** 1195 * Feature for {@link #getSystemAvailableFeatures} and 1196 * {@link #hasSystemFeature}: The device can communicate using Near-Field 1197 * Communications (NFC). 1198 */ 1199 @SdkConstant(SdkConstantType.FEATURE) 1200 public static final String FEATURE_NFC = "android.hardware.nfc"; 1201 1202 /** 1203 * Feature for {@link #getSystemAvailableFeatures} and 1204 * {@link #hasSystemFeature}: The device supports host- 1205 * based NFC card emulation. 1206 * 1207 * TODO remove when depending apps have moved to new constant. 1208 * @hide 1209 * @deprecated 1210 */ 1211 @Deprecated 1212 @SdkConstant(SdkConstantType.FEATURE) 1213 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce"; 1214 1215 /** 1216 * Feature for {@link #getSystemAvailableFeatures} and 1217 * {@link #hasSystemFeature}: The device supports host- 1218 * based NFC card emulation. 1219 */ 1220 @SdkConstant(SdkConstantType.FEATURE) 1221 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; 1222 1223 /** 1224 * Feature for {@link #getSystemAvailableFeatures} and 1225 * {@link #hasSystemFeature}: The device supports the OpenGL ES 1226 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 1227 * Android Extension Pack</a>. 1228 */ 1229 @SdkConstant(SdkConstantType.FEATURE) 1230 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 1231 1232 /** 1233 * Feature for {@link #getSystemAvailableFeatures} and 1234 * {@link #hasSystemFeature}: The device includes an accelerometer. 1235 */ 1236 @SdkConstant(SdkConstantType.FEATURE) 1237 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 1238 1239 /** 1240 * Feature for {@link #getSystemAvailableFeatures} and 1241 * {@link #hasSystemFeature}: The device includes a barometer (air 1242 * pressure sensor.) 1243 */ 1244 @SdkConstant(SdkConstantType.FEATURE) 1245 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 1246 1247 /** 1248 * Feature for {@link #getSystemAvailableFeatures} and 1249 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 1250 */ 1251 @SdkConstant(SdkConstantType.FEATURE) 1252 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 1253 1254 /** 1255 * Feature for {@link #getSystemAvailableFeatures} and 1256 * {@link #hasSystemFeature}: The device includes a gyroscope. 1257 */ 1258 @SdkConstant(SdkConstantType.FEATURE) 1259 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 1260 1261 /** 1262 * Feature for {@link #getSystemAvailableFeatures} and 1263 * {@link #hasSystemFeature}: The device includes a light sensor. 1264 */ 1265 @SdkConstant(SdkConstantType.FEATURE) 1266 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 1267 1268 /** 1269 * Feature for {@link #getSystemAvailableFeatures} and 1270 * {@link #hasSystemFeature}: The device includes a proximity sensor. 1271 */ 1272 @SdkConstant(SdkConstantType.FEATURE) 1273 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 1274 1275 /** 1276 * Feature for {@link #getSystemAvailableFeatures} and 1277 * {@link #hasSystemFeature}: The device includes a hardware step counter. 1278 */ 1279 @SdkConstant(SdkConstantType.FEATURE) 1280 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 1281 1282 /** 1283 * Feature for {@link #getSystemAvailableFeatures} and 1284 * {@link #hasSystemFeature}: The device includes a hardware step detector. 1285 */ 1286 @SdkConstant(SdkConstantType.FEATURE) 1287 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 1288 1289 /** 1290 * Feature for {@link #getSystemAvailableFeatures} and 1291 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 1292 */ 1293 @SdkConstant(SdkConstantType.FEATURE) 1294 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 1295 1296 /** 1297 * Feature for {@link #getSystemAvailableFeatures} and 1298 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocargiogram. 1299 */ 1300 @SdkConstant(SdkConstantType.FEATURE) 1301 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 1302 "android.hardware.sensor.heartrate.ecg"; 1303 1304 /** 1305 * Feature for {@link #getSystemAvailableFeatures} and 1306 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 1307 */ 1308 @SdkConstant(SdkConstantType.FEATURE) 1309 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 1310 "android.hardware.sensor.relative_humidity"; 1311 1312 /** 1313 * Feature for {@link #getSystemAvailableFeatures} and 1314 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 1315 */ 1316 @SdkConstant(SdkConstantType.FEATURE) 1317 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 1318 "android.hardware.sensor.ambient_temperature"; 1319 1320 /** 1321 * Feature for {@link #getSystemAvailableFeatures} and 1322 * {@link #hasSystemFeature}: The device has a telephony radio with data 1323 * communication support. 1324 */ 1325 @SdkConstant(SdkConstantType.FEATURE) 1326 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 1327 1328 /** 1329 * Feature for {@link #getSystemAvailableFeatures} and 1330 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 1331 */ 1332 @SdkConstant(SdkConstantType.FEATURE) 1333 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 1334 1335 /** 1336 * Feature for {@link #getSystemAvailableFeatures} and 1337 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 1338 */ 1339 @SdkConstant(SdkConstantType.FEATURE) 1340 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 1341 1342 /** 1343 * Feature for {@link #getSystemAvailableFeatures} and 1344 * {@link #hasSystemFeature}: The device supports connecting to USB devices 1345 * as the USB host. 1346 */ 1347 @SdkConstant(SdkConstantType.FEATURE) 1348 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 1349 1350 /** 1351 * Feature for {@link #getSystemAvailableFeatures} and 1352 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 1353 */ 1354 @SdkConstant(SdkConstantType.FEATURE) 1355 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 1356 1357 /** 1358 * Feature for {@link #getSystemAvailableFeatures} and 1359 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 1360 */ 1361 @SdkConstant(SdkConstantType.FEATURE) 1362 public static final String FEATURE_SIP = "android.software.sip"; 1363 1364 /** 1365 * Feature for {@link #getSystemAvailableFeatures} and 1366 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 1367 */ 1368 @SdkConstant(SdkConstantType.FEATURE) 1369 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 1370 1371 /** 1372 * Feature for {@link #getSystemAvailableFeatures} and 1373 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device. 1374 */ 1375 @SdkConstant(SdkConstantType.FEATURE) 1376 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice"; 1377 1378 /** 1379 * Feature for {@link #getSystemAvailableFeatures} and 1380 * {@link #hasSystemFeature}: The device's display has a touch screen. 1381 */ 1382 @SdkConstant(SdkConstantType.FEATURE) 1383 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 1384 1385 /** 1386 * Feature for {@link #getSystemAvailableFeatures} and 1387 * {@link #hasSystemFeature}: The device's touch screen supports 1388 * multitouch sufficient for basic two-finger gesture detection. 1389 */ 1390 @SdkConstant(SdkConstantType.FEATURE) 1391 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 1392 1393 /** 1394 * Feature for {@link #getSystemAvailableFeatures} and 1395 * {@link #hasSystemFeature}: The device's touch screen is capable of 1396 * tracking two or more fingers fully independently. 1397 */ 1398 @SdkConstant(SdkConstantType.FEATURE) 1399 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 1400 1401 /** 1402 * Feature for {@link #getSystemAvailableFeatures} and 1403 * {@link #hasSystemFeature}: The device's touch screen is capable of 1404 * tracking a full hand of fingers fully independently -- that is, 5 or 1405 * more simultaneous independent pointers. 1406 */ 1407 @SdkConstant(SdkConstantType.FEATURE) 1408 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 1409 1410 /** 1411 * Feature for {@link #getSystemAvailableFeatures} and 1412 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1413 * does support touch emulation for basic events. For instance, the 1414 * device might use a mouse or remote control to drive a cursor, and 1415 * emulate basic touch pointer events like down, up, drag, etc. All 1416 * devices that support android.hardware.touchscreen or a sub-feature are 1417 * presumed to also support faketouch. 1418 */ 1419 @SdkConstant(SdkConstantType.FEATURE) 1420 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 1421 1422 /** 1423 * Feature for {@link #getSystemAvailableFeatures} and 1424 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1425 * does support touch emulation for basic events that supports distinct 1426 * tracking of two or more fingers. This is an extension of 1427 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1428 * that unlike a distinct multitouch screen as defined by 1429 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 1430 * devices will not actually provide full two-finger gestures since the 1431 * input is being transformed to cursor movement on the screen. That is, 1432 * single finger gestures will move a cursor; two-finger swipes will 1433 * result in single-finger touch events; other two-finger gestures will 1434 * result in the corresponding two-finger touch event. 1435 */ 1436 @SdkConstant(SdkConstantType.FEATURE) 1437 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 1438 1439 /** 1440 * Feature for {@link #getSystemAvailableFeatures} and 1441 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1442 * does support touch emulation for basic events that supports tracking 1443 * a hand of fingers (5 or more fingers) fully independently. 1444 * This is an extension of 1445 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1446 * that unlike a multitouch screen as defined by 1447 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 1448 * gestures can be detected due to the limitations described for 1449 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 1450 */ 1451 @SdkConstant(SdkConstantType.FEATURE) 1452 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 1453 1454 /** 1455 * Feature for {@link #getSystemAvailableFeatures} and 1456 * {@link #hasSystemFeature}: The device supports portrait orientation 1457 * screens. For backwards compatibility, you can assume that if neither 1458 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 1459 * both portrait and landscape. 1460 */ 1461 @SdkConstant(SdkConstantType.FEATURE) 1462 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 1463 1464 /** 1465 * Feature for {@link #getSystemAvailableFeatures} and 1466 * {@link #hasSystemFeature}: The device supports landscape orientation 1467 * screens. For backwards compatibility, you can assume that if neither 1468 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 1469 * both portrait and landscape. 1470 */ 1471 @SdkConstant(SdkConstantType.FEATURE) 1472 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 1473 1474 /** 1475 * Feature for {@link #getSystemAvailableFeatures} and 1476 * {@link #hasSystemFeature}: The device supports live wallpapers. 1477 */ 1478 @SdkConstant(SdkConstantType.FEATURE) 1479 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 1480 /** 1481 * Feature for {@link #getSystemAvailableFeatures} and 1482 * {@link #hasSystemFeature}: The device supports app widgets. 1483 */ 1484 @SdkConstant(SdkConstantType.FEATURE) 1485 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 1486 1487 /** 1488 * @hide 1489 * Feature for {@link #getSystemAvailableFeatures} and 1490 * {@link #hasSystemFeature}: The device supports 1491 * {@link android.service.voice.VoiceInteractionService} and 1492 * {@link android.app.VoiceInteractor}. 1493 */ 1494 @SdkConstant(SdkConstantType.FEATURE) 1495 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 1496 1497 1498 /** 1499 * Feature for {@link #getSystemAvailableFeatures} and 1500 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 1501 * by third party applications. 1502 */ 1503 @SdkConstant(SdkConstantType.FEATURE) 1504 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 1505 1506 /** 1507 * Feature for {@link #getSystemAvailableFeatures} and 1508 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 1509 * with the {@link android.inputmethodservice.InputMethodService} API. 1510 */ 1511 @SdkConstant(SdkConstantType.FEATURE) 1512 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 1513 1514 /** 1515 * Feature for {@link #getSystemAvailableFeatures} and 1516 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 1517 */ 1518 @SdkConstant(SdkConstantType.FEATURE) 1519 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 1520 1521 /** 1522 * Feature for {@link #getSystemAvailableFeatures} and 1523 * {@link #hasSystemFeature}: The device supports leanback UI. This is 1524 * typically used in a living room television experience, but is a software 1525 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 1526 * feature will use resources associated with the "television" UI mode. 1527 */ 1528 @SdkConstant(SdkConstantType.FEATURE) 1529 public static final String FEATURE_LEANBACK = "android.software.leanback"; 1530 1531 /** 1532 * Feature for {@link #getSystemAvailableFeatures} and 1533 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 1534 * applications designed for this experience should be run, though this is 1535 * not enforced by the system. 1536 * @hide 1537 */ 1538 @SdkConstant(SdkConstantType.FEATURE) 1539 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 1540 1541 /** 1542 * Feature for {@link #getSystemAvailableFeatures} and 1543 * {@link #hasSystemFeature}: The device supports live TV and can display 1544 * contents from TV inputs implemented with the 1545 * {@link android.media.tv.TvInputService} API. 1546 */ 1547 @SdkConstant(SdkConstantType.FEATURE) 1548 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 1549 1550 /** 1551 * Feature for {@link #getSystemAvailableFeatures} and 1552 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 1553 */ 1554 @SdkConstant(SdkConstantType.FEATURE) 1555 public static final String FEATURE_WIFI = "android.hardware.wifi"; 1556 1557 /** 1558 * Feature for {@link #getSystemAvailableFeatures} and 1559 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 1560 */ 1561 @SdkConstant(SdkConstantType.FEATURE) 1562 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 1563 1564 /** 1565 * Feature for {@link #getSystemAvailableFeatures} and 1566 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1567 * on a television. Television here is defined to be a typical living 1568 * room television experience: displayed on a big screen, where the user 1569 * is sitting far away from it, and the dominant form of input will be 1570 * something like a DPAD, not through touch or mouse. 1571 * @deprecated use {@link #FEATURE_LEANBACK} instead. 1572 */ 1573 @Deprecated 1574 @SdkConstant(SdkConstantType.FEATURE) 1575 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 1576 1577 /** 1578 * Feature for {@link #getSystemAvailableFeatures} and 1579 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1580 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 1581 * the wrist. The user is very close when interacting with the device. 1582 */ 1583 @SdkConstant(SdkConstantType.FEATURE) 1584 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 1585 1586 /** 1587 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1588 * The device supports printing. 1589 */ 1590 @SdkConstant(SdkConstantType.FEATURE) 1591 public static final String FEATURE_PRINTING = "android.software.print"; 1592 1593 /** 1594 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1595 * The device can perform backup and restore operations on installed applications. 1596 */ 1597 @SdkConstant(SdkConstantType.FEATURE) 1598 public static final String FEATURE_BACKUP = "android.software.backup"; 1599 1600 /** 1601 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1602 * The device supports creating secondary users and managed profiles via 1603 * {@link DevicePolicyManager}. 1604 */ 1605 @SdkConstant(SdkConstantType.FEATURE) 1606 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 1607 1608 /** 1609 * @hide 1610 * TODO: Remove after dependencies updated b/17392243 1611 */ 1612 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 1613 1614 /** 1615 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1616 * The device supports verified boot. 1617 */ 1618 @SdkConstant(SdkConstantType.FEATURE) 1619 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 1620 1621 /** 1622 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1623 * The device supports secure removal of users. When a user is deleted the data associated 1624 * with that user is securely deleted and no longer available. 1625 */ 1626 @SdkConstant(SdkConstantType.FEATURE) 1627 public static final String FEATURE_SECURELY_REMOVES_USERS 1628 = "android.software.securely_removes_users"; 1629 1630 /** 1631 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1632 * The device has a full implementation of the android.webkit.* APIs. Devices 1633 * lacking this feature will not have a functioning WebView implementation. 1634 */ 1635 @SdkConstant(SdkConstantType.FEATURE) 1636 public static final String FEATURE_WEBVIEW = "android.software.webview"; 1637 1638 /** 1639 * Feature for {@link #getSystemAvailableFeatures} and 1640 * {@link #hasSystemFeature}: This device supports ethernet. 1641 * @hide 1642 */ 1643 @SdkConstant(SdkConstantType.FEATURE) 1644 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 1645 1646 /** 1647 * Feature for {@link #getSystemAvailableFeatures} and 1648 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 1649 * @hide 1650 */ 1651 @SdkConstant(SdkConstantType.FEATURE) 1652 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 1653 1654 /** 1655 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1656 * The device has all of the inputs necessary to be considered a compatible game controller, or 1657 * includes a compatible game controller in the box. 1658 */ 1659 @SdkConstant(SdkConstantType.FEATURE) 1660 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 1661 1662 /** 1663 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1664 * The device has a full implementation of the android.media.midi.* APIs. 1665 */ 1666 @SdkConstant(SdkConstantType.FEATURE) 1667 public static final String FEATURE_MIDI = "android.software.midi"; 1668 1669 /** 1670 * Action to external storage service to clean out removed apps. 1671 * @hide 1672 */ 1673 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 1674 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 1675 1676 /** 1677 * Extra field name for the URI to a verification file. Passed to a package 1678 * verifier. 1679 * 1680 * @hide 1681 */ 1682 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 1683 1684 /** 1685 * Extra field name for the ID of a package pending verification. Passed to 1686 * a package verifier and is used to call back to 1687 * {@link PackageManager#verifyPendingInstall(int, int)} 1688 */ 1689 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 1690 1691 /** 1692 * Extra field name for the package identifier which is trying to install 1693 * the package. 1694 * 1695 * @hide 1696 */ 1697 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 1698 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 1699 1700 /** 1701 * Extra field name for the requested install flags for a package pending 1702 * verification. Passed to a package verifier. 1703 * 1704 * @hide 1705 */ 1706 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 1707 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 1708 1709 /** 1710 * Extra field name for the uid of who is requesting to install 1711 * the package. 1712 * 1713 * @hide 1714 */ 1715 public static final String EXTRA_VERIFICATION_INSTALLER_UID 1716 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 1717 1718 /** 1719 * Extra field name for the package name of a package pending verification. 1720 * 1721 * @hide 1722 */ 1723 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 1724 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 1725 /** 1726 * Extra field name for the result of a verification, either 1727 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 1728 * Passed to package verifiers after a package is verified. 1729 */ 1730 public static final String EXTRA_VERIFICATION_RESULT 1731 = "android.content.pm.extra.VERIFICATION_RESULT"; 1732 1733 /** 1734 * Extra field name for the version code of a package pending verification. 1735 * 1736 * @hide 1737 */ 1738 public static final String EXTRA_VERIFICATION_VERSION_CODE 1739 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 1740 1741 /** 1742 * Extra field name for the ID of a intent filter pending verification. Passed to 1743 * an intent filter verifier and is used to call back to 1744 * {@link PackageManager#verifyIntentFilter(int, int)} 1745 * 1746 * @hide 1747 */ 1748 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 1749 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 1750 1751 /** 1752 * Extra field name for the scheme used for an intent filter pending verification. Passed to 1753 * an intent filter verifier and is used to construct the URI to verify against. 1754 * 1755 * Usually this is "https" 1756 * 1757 * @hide 1758 */ 1759 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 1760 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 1761 1762 /** 1763 * Extra field name for the host names to be used for an intent filter pending verification. 1764 * Passed to an intent filter verifier and is used to construct the URI to verify the 1765 * intent filter. 1766 * 1767 * This is a space delimited list of hosts. 1768 * 1769 * @hide 1770 */ 1771 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 1772 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 1773 1774 /** 1775 * Extra field name for the package name to be used for an intent filter pending verification. 1776 * Passed to an intent filter verifier and is used to check the verification responses coming 1777 * from the hosts. Each host response will need to include the package name of APK containing 1778 * the intent filter. 1779 * 1780 * @hide 1781 */ 1782 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 1783 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 1784 1785 /** 1786 * The action used to request that the user approve a permission request 1787 * from the application. 1788 * 1789 * @hide 1790 */ 1791 @SystemApi 1792 public static final String ACTION_REQUEST_PERMISSIONS = 1793 "android.content.pm.action.REQUEST_PERMISSIONS"; 1794 1795 /** 1796 * The component name handling runtime permission grants. 1797 * 1798 * @hide 1799 */ 1800 public static final String GRANT_PERMISSIONS_PACKAGE_NAME = 1801 "com.android.packageinstaller"; 1802 1803 /** 1804 * The names of the requested permissions. 1805 * <p> 1806 * <strong>Type:</strong> String[] 1807 * </p> 1808 * 1809 * @hide 1810 */ 1811 @SystemApi 1812 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 1813 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 1814 1815 /** 1816 * The results from the permissions request. 1817 * <p> 1818 * <strong>Type:</strong> int[] of #PermissionResult 1819 * </p> 1820 * 1821 * @hide 1822 */ 1823 @SystemApi 1824 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 1825 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 1826 1827 /** 1828 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 1829 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 1830 * the existing definition for the permission. 1831 * @hide 1832 */ 1833 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 1834 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 1835 1836 /** 1837 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 1838 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 1839 * being redundantly defined by the package being installed. 1840 * @hide 1841 */ 1842 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 1843 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 1844 1845 /** 1846 * Retrieve overall information about an application package that is 1847 * installed on the system. 1848 * <p> 1849 * Throws {@link NameNotFoundException} if a package with the given name can 1850 * not be found on the system. 1851 * 1852 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1853 * desired package. 1854 * @param flags Additional option flags. Use any combination of 1855 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS}, 1856 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION}, 1857 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 1858 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 1859 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to 1860 * modify the data returned. 1861 * @return Returns a PackageInfo object containing information about the 1862 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the 1863 * package is not found in the list of installed applications, the 1864 * package information is retrieved from the list of uninstalled 1865 * applications (which includes installed applications as well as 1866 * applications with data directory i.e. applications which had been 1867 * deleted with {@code DONT_DELETE_DATA} flag set). 1868 * @see #GET_ACTIVITIES 1869 * @see #GET_GIDS 1870 * @see #GET_CONFIGURATIONS 1871 * @see #GET_INSTRUMENTATION 1872 * @see #GET_PERMISSIONS 1873 * @see #GET_PROVIDERS 1874 * @see #GET_RECEIVERS 1875 * @see #GET_SERVICES 1876 * @see #GET_SIGNATURES 1877 * @see #GET_UNINSTALLED_PACKAGES 1878 */ 1879 public abstract PackageInfo getPackageInfo(String packageName, int flags) 1880 throws NameNotFoundException; 1881 1882 /** 1883 * Map from the current package names in use on the device to whatever 1884 * the current canonical name of that package is. 1885 * @param names Array of current names to be mapped. 1886 * @return Returns an array of the same size as the original, containing 1887 * the canonical name for each package. 1888 */ 1889 public abstract String[] currentToCanonicalPackageNames(String[] names); 1890 1891 /** 1892 * Map from a packages canonical name to the current name in use on the device. 1893 * @param names Array of new names to be mapped. 1894 * @return Returns an array of the same size as the original, containing 1895 * the current name for each package. 1896 */ 1897 public abstract String[] canonicalToCurrentPackageNames(String[] names); 1898 1899 /** 1900 * Returns a "good" intent to launch a front-door activity in a package. 1901 * This is used, for example, to implement an "open" button when browsing 1902 * through packages. The current implementation looks first for a main 1903 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 1904 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 1905 * <code>null</code> if neither are found. 1906 * 1907 * @param packageName The name of the package to inspect. 1908 * 1909 * @return A fully-qualified {@link Intent} that can be used to launch the 1910 * main activity in the package. Returns <code>null</code> if the package 1911 * does not contain such an activity, or if <em>packageName</em> is not 1912 * recognized. 1913 */ 1914 public abstract Intent getLaunchIntentForPackage(String packageName); 1915 1916 /** 1917 * Return a "good" intent to launch a front-door Leanback activity in a 1918 * package, for use for example to implement an "open" button when browsing 1919 * through packages. The current implementation will look for a main 1920 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 1921 * return null if no main leanback activities are found. 1922 * <p> 1923 * Throws {@link NameNotFoundException} if a package with the given name 1924 * cannot be found on the system. 1925 * 1926 * @param packageName The name of the package to inspect. 1927 * @return Returns either a fully-qualified Intent that can be used to launch 1928 * the main Leanback activity in the package, or null if the package 1929 * does not contain such an activity. 1930 */ 1931 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName); 1932 1933 /** 1934 * Return an array of all of the secondary group-ids that have been assigned 1935 * to a package. 1936 * <p> 1937 * Throws {@link NameNotFoundException} if a package with the given name 1938 * cannot be found on the system. 1939 * 1940 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1941 * desired package. 1942 * @return Returns an int array of the assigned gids, or null if there are 1943 * none. 1944 */ 1945 public abstract int[] getPackageGids(String packageName) 1946 throws NameNotFoundException; 1947 1948 /** 1949 * @hide Return the uid associated with the given package name for the 1950 * given user. 1951 * 1952 * <p>Throws {@link NameNotFoundException} if a package with the given 1953 * name can not be found on the system. 1954 * 1955 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1956 * desired package. 1957 * @param userHandle The user handle identifier to look up the package under. 1958 * 1959 * @return Returns an integer uid who owns the given package name. 1960 */ 1961 public abstract int getPackageUid(String packageName, int userHandle) 1962 throws NameNotFoundException; 1963 1964 /** 1965 * Retrieve all of the information we know about a particular permission. 1966 * 1967 * <p>Throws {@link NameNotFoundException} if a permission with the given 1968 * name cannot be found on the system. 1969 * 1970 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 1971 * of the permission you are interested in. 1972 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1973 * retrieve any meta-data associated with the permission. 1974 * 1975 * @return Returns a {@link PermissionInfo} containing information about the 1976 * permission. 1977 */ 1978 public abstract PermissionInfo getPermissionInfo(String name, int flags) 1979 throws NameNotFoundException; 1980 1981 /** 1982 * Query for all of the permissions associated with a particular group. 1983 * 1984 * <p>Throws {@link NameNotFoundException} if the given group does not 1985 * exist. 1986 * 1987 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 1988 * of the permission group you are interested in. Use null to 1989 * find all of the permissions not associated with a group. 1990 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 1991 * retrieve any meta-data associated with the permissions. 1992 * 1993 * @return Returns a list of {@link PermissionInfo} containing information 1994 * about all of the permissions in the given group. 1995 */ 1996 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 1997 int flags) throws NameNotFoundException; 1998 1999 /** 2000 * Retrieve all of the information we know about a particular group of 2001 * permissions. 2002 * 2003 * <p>Throws {@link NameNotFoundException} if a permission group with the given 2004 * name cannot be found on the system. 2005 * 2006 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 2007 * of the permission you are interested in. 2008 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2009 * retrieve any meta-data associated with the permission group. 2010 * 2011 * @return Returns a {@link PermissionGroupInfo} containing information 2012 * about the permission. 2013 */ 2014 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 2015 int flags) throws NameNotFoundException; 2016 2017 /** 2018 * Retrieve all of the known permission groups in the system. 2019 * 2020 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2021 * retrieve any meta-data associated with the permission group. 2022 * 2023 * @return Returns a list of {@link PermissionGroupInfo} containing 2024 * information about all of the known permission groups. 2025 */ 2026 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags); 2027 2028 /** 2029 * Retrieve all of the information we know about a particular 2030 * package/application. 2031 * 2032 * <p>Throws {@link NameNotFoundException} if an application with the given 2033 * package name cannot be found on the system. 2034 * 2035 * @param packageName The full name (i.e. com.google.apps.contacts) of an 2036 * application. 2037 * @param flags Additional option flags. Use any combination of 2038 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2039 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2040 * 2041 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing 2042 * information about the package. 2043 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 2044 * found in the list of installed applications, 2045 * the application information is retrieved from the 2046 * list of uninstalled applications(which includes 2047 * installed applications as well as applications 2048 * with data directory ie applications which had been 2049 * deleted with {@code DONT_DELETE_DATA} flag set). 2050 * 2051 * @see #GET_META_DATA 2052 * @see #GET_SHARED_LIBRARY_FILES 2053 * @see #GET_UNINSTALLED_PACKAGES 2054 */ 2055 public abstract ApplicationInfo getApplicationInfo(String packageName, 2056 int flags) throws NameNotFoundException; 2057 2058 /** 2059 * Retrieve all of the information we know about a particular activity 2060 * class. 2061 * 2062 * <p>Throws {@link NameNotFoundException} if an activity with the given 2063 * class name cannot be found on the system. 2064 * 2065 * @param component The full component name (i.e. 2066 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity 2067 * class. 2068 * @param flags Additional option flags. Use any combination of 2069 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2070 * to modify the data (in ApplicationInfo) returned. 2071 * 2072 * @return {@link ActivityInfo} containing information about the activity. 2073 * 2074 * @see #GET_INTENT_FILTERS 2075 * @see #GET_META_DATA 2076 * @see #GET_SHARED_LIBRARY_FILES 2077 */ 2078 public abstract ActivityInfo getActivityInfo(ComponentName component, 2079 int flags) throws NameNotFoundException; 2080 2081 /** 2082 * Retrieve all of the information we know about a particular receiver 2083 * class. 2084 * 2085 * <p>Throws {@link NameNotFoundException} if a receiver with the given 2086 * class name cannot be found on the system. 2087 * 2088 * @param component The full component name (i.e. 2089 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver 2090 * class. 2091 * @param flags Additional option flags. Use any combination of 2092 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2093 * to modify the data returned. 2094 * 2095 * @return {@link ActivityInfo} containing information about the receiver. 2096 * 2097 * @see #GET_INTENT_FILTERS 2098 * @see #GET_META_DATA 2099 * @see #GET_SHARED_LIBRARY_FILES 2100 */ 2101 public abstract ActivityInfo getReceiverInfo(ComponentName component, 2102 int flags) throws NameNotFoundException; 2103 2104 /** 2105 * Retrieve all of the information we know about a particular service 2106 * class. 2107 * 2108 * <p>Throws {@link NameNotFoundException} if a service with the given 2109 * class name cannot be found on the system. 2110 * 2111 * @param component The full component name (i.e. 2112 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service 2113 * class. 2114 * @param flags Additional option flags. Use any combination of 2115 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2116 * to modify the data returned. 2117 * 2118 * @return ServiceInfo containing information about the service. 2119 * 2120 * @see #GET_META_DATA 2121 * @see #GET_SHARED_LIBRARY_FILES 2122 */ 2123 public abstract ServiceInfo getServiceInfo(ComponentName component, 2124 int flags) throws NameNotFoundException; 2125 2126 /** 2127 * Retrieve all of the information we know about a particular content 2128 * provider class. 2129 * 2130 * <p>Throws {@link NameNotFoundException} if a provider with the given 2131 * class name cannot be found on the system. 2132 * 2133 * @param component The full component name (i.e. 2134 * com.google.providers.media/com.google.providers.media.MediaProvider) of a 2135 * ContentProvider class. 2136 * @param flags Additional option flags. Use any combination of 2137 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2138 * to modify the data returned. 2139 * 2140 * @return ProviderInfo containing information about the service. 2141 * 2142 * @see #GET_META_DATA 2143 * @see #GET_SHARED_LIBRARY_FILES 2144 */ 2145 public abstract ProviderInfo getProviderInfo(ComponentName component, 2146 int flags) throws NameNotFoundException; 2147 2148 /** 2149 * Return a List of all packages that are installed 2150 * on the device. 2151 * 2152 * @param flags Additional option flags. Use any combination of 2153 * {@link #GET_ACTIVITIES}, 2154 * {@link #GET_GIDS}, 2155 * {@link #GET_CONFIGURATIONS}, 2156 * {@link #GET_INSTRUMENTATION}, 2157 * {@link #GET_PERMISSIONS}, 2158 * {@link #GET_PROVIDERS}, 2159 * {@link #GET_RECEIVERS}, 2160 * {@link #GET_SERVICES}, 2161 * {@link #GET_SIGNATURES}, 2162 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2163 * 2164 * @return A List of PackageInfo objects, one for each package that is 2165 * installed on the device. In the unlikely case of there being no 2166 * installed packages, an empty list is returned. 2167 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2168 * applications including those deleted with {@code DONT_DELETE_DATA} 2169 * (partially installed apps with data directory) will be returned. 2170 * 2171 * @see #GET_ACTIVITIES 2172 * @see #GET_GIDS 2173 * @see #GET_CONFIGURATIONS 2174 * @see #GET_INSTRUMENTATION 2175 * @see #GET_PERMISSIONS 2176 * @see #GET_PROVIDERS 2177 * @see #GET_RECEIVERS 2178 * @see #GET_SERVICES 2179 * @see #GET_SIGNATURES 2180 * @see #GET_UNINSTALLED_PACKAGES 2181 */ 2182 public abstract List<PackageInfo> getInstalledPackages(int flags); 2183 2184 /** 2185 * Return a List of all installed packages that are currently 2186 * holding any of the given permissions. 2187 * 2188 * @param flags Additional option flags. Use any combination of 2189 * {@link #GET_ACTIVITIES}, 2190 * {@link #GET_GIDS}, 2191 * {@link #GET_CONFIGURATIONS}, 2192 * {@link #GET_INSTRUMENTATION}, 2193 * {@link #GET_PERMISSIONS}, 2194 * {@link #GET_PROVIDERS}, 2195 * {@link #GET_RECEIVERS}, 2196 * {@link #GET_SERVICES}, 2197 * {@link #GET_SIGNATURES}, 2198 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2199 * 2200 * @return Returns a List of PackageInfo objects, one for each installed 2201 * application that is holding any of the permissions that were provided. 2202 * 2203 * @see #GET_ACTIVITIES 2204 * @see #GET_GIDS 2205 * @see #GET_CONFIGURATIONS 2206 * @see #GET_INSTRUMENTATION 2207 * @see #GET_PERMISSIONS 2208 * @see #GET_PROVIDERS 2209 * @see #GET_RECEIVERS 2210 * @see #GET_SERVICES 2211 * @see #GET_SIGNATURES 2212 * @see #GET_UNINSTALLED_PACKAGES 2213 */ 2214 public abstract List<PackageInfo> getPackagesHoldingPermissions( 2215 String[] permissions, int flags); 2216 2217 /** 2218 * Return a List of all packages that are installed on the device, for a specific user. 2219 * Requesting a list of installed packages for another user 2220 * will require the permission INTERACT_ACROSS_USERS_FULL. 2221 * @param flags Additional option flags. Use any combination of 2222 * {@link #GET_ACTIVITIES}, 2223 * {@link #GET_GIDS}, 2224 * {@link #GET_CONFIGURATIONS}, 2225 * {@link #GET_INSTRUMENTATION}, 2226 * {@link #GET_PERMISSIONS}, 2227 * {@link #GET_PROVIDERS}, 2228 * {@link #GET_RECEIVERS}, 2229 * {@link #GET_SERVICES}, 2230 * {@link #GET_SIGNATURES}, 2231 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2232 * @param userId The user for whom the installed packages are to be listed 2233 * 2234 * @return A List of PackageInfo objects, one for each package that is 2235 * installed on the device. In the unlikely case of there being no 2236 * installed packages, an empty list is returned. 2237 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2238 * applications including those deleted with {@code DONT_DELETE_DATA} 2239 * (partially installed apps with data directory) will be returned. 2240 * 2241 * @see #GET_ACTIVITIES 2242 * @see #GET_GIDS 2243 * @see #GET_CONFIGURATIONS 2244 * @see #GET_INSTRUMENTATION 2245 * @see #GET_PERMISSIONS 2246 * @see #GET_PROVIDERS 2247 * @see #GET_RECEIVERS 2248 * @see #GET_SERVICES 2249 * @see #GET_SIGNATURES 2250 * @see #GET_UNINSTALLED_PACKAGES 2251 * 2252 * @hide 2253 */ 2254 public abstract List<PackageInfo> getInstalledPackages(int flags, int userId); 2255 2256 /** 2257 * Check whether a particular package has been granted a particular 2258 * permission. 2259 * 2260 * @param permName The name of the permission you are checking for, 2261 * @param pkgName The name of the package you are checking against. 2262 * 2263 * @return If the package has the permission, PERMISSION_GRANTED is 2264 * returned. If it does not have the permission, PERMISSION_DENIED 2265 * is returned. 2266 * 2267 * @see #PERMISSION_GRANTED 2268 * @see #PERMISSION_DENIED 2269 */ 2270 @CheckResult 2271 public abstract int checkPermission(String permName, String pkgName); 2272 2273 /** 2274 * Add a new dynamic permission to the system. For this to work, your 2275 * package must have defined a permission tree through the 2276 * {@link android.R.styleable#AndroidManifestPermissionTree 2277 * <permission-tree>} tag in its manifest. A package can only add 2278 * permissions to trees that were defined by either its own package or 2279 * another with the same user id; a permission is in a tree if it 2280 * matches the name of the permission tree + ".": for example, 2281 * "com.foo.bar" is a member of the permission tree "com.foo". 2282 * 2283 * <p>It is good to make your permission tree name descriptive, because you 2284 * are taking possession of that entire set of permission names. Thus, it 2285 * must be under a domain you control, with a suffix that will not match 2286 * any normal permissions that may be declared in any applications that 2287 * are part of that domain. 2288 * 2289 * <p>New permissions must be added before 2290 * any .apks are installed that use those permissions. Permissions you 2291 * add through this method are remembered across reboots of the device. 2292 * If the given permission already exists, the info you supply here 2293 * will be used to update it. 2294 * 2295 * @param info Description of the permission to be added. 2296 * 2297 * @return Returns true if a new permission was created, false if an 2298 * existing one was updated. 2299 * 2300 * @throws SecurityException if you are not allowed to add the 2301 * given permission name. 2302 * 2303 * @see #removePermission(String) 2304 */ 2305 public abstract boolean addPermission(PermissionInfo info); 2306 2307 /** 2308 * Like {@link #addPermission(PermissionInfo)} but asynchronously 2309 * persists the package manager state after returning from the call, 2310 * allowing it to return quicker and batch a series of adds at the 2311 * expense of no guarantee the added permission will be retained if 2312 * the device is rebooted before it is written. 2313 */ 2314 public abstract boolean addPermissionAsync(PermissionInfo info); 2315 2316 /** 2317 * Removes a permission that was previously added with 2318 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 2319 * -- you are only allowed to remove permissions that you are allowed 2320 * to add. 2321 * 2322 * @param name The name of the permission to remove. 2323 * 2324 * @throws SecurityException if you are not allowed to remove the 2325 * given permission name. 2326 * 2327 * @see #addPermission(PermissionInfo) 2328 */ 2329 public abstract void removePermission(String name); 2330 2331 /** 2332 * Grant a runtime permission to an application which the application does not 2333 * already have. The permission must have been requested by the application. 2334 * If the application is not allowed to hold the permission, a {@link 2335 * java.lang.SecurityException} is thrown. 2336 * <p> 2337 * <strong>Note: </strong>Using this API requires holding 2338 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is 2339 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 2340 * </p> 2341 * 2342 * @param packageName The package to which to grant the permission. 2343 * @param permissionName The permission name to grant. 2344 * @param user The user for which to grant the permission. 2345 * 2346 * @see #revokePermission(String, String, android.os.UserHandle) 2347 * 2348 * @hide 2349 */ 2350 @SystemApi 2351 public abstract void grantPermission(@NonNull String packageName, 2352 @NonNull String permissionName, @NonNull UserHandle user); 2353 2354 /** 2355 * Revoke a runtime permission that was previously granted by {@link 2356 * #grantPermission(String, String, android.os.UserHandle)}. The permission 2357 * must have been requested by and granted to the application. If the 2358 * application is not allowed to hold the permission, a {@link 2359 * java.lang.SecurityException} is thrown. 2360 * <p> 2361 * <strong>Note: </strong>Using this API requires holding 2362 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is 2363 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 2364 * </p> 2365 * 2366 * @param packageName The package from which to revoke the permission. 2367 * @param permissionName The permission name to revoke. 2368 * @param user The user for which to revoke the permission. 2369 * 2370 * @see #grantPermission(String, String, android.os.UserHandle) 2371 * 2372 * @hide 2373 */ 2374 @SystemApi 2375 public abstract void revokePermission(@NonNull String packageName, 2376 @NonNull String permissionName, @NonNull UserHandle user); 2377 2378 /** 2379 * Returns an {@link android.content.Intent} suitable for passing to 2380 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 2381 * which prompts the user to grant permissions to this application. 2382 * 2383 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 2384 * 2385 * @hide 2386 */ 2387 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 2388 if (ArrayUtils.isEmpty(permissions)) { 2389 throw new NullPointerException("permission cannot be null or empty"); 2390 } 2391 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 2392 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 2393 intent.setPackage(GRANT_PERMISSIONS_PACKAGE_NAME); 2394 return intent; 2395 } 2396 2397 /** 2398 * Compare the signatures of two packages to determine if the same 2399 * signature appears in both of them. If they do contain the same 2400 * signature, then they are allowed special privileges when working 2401 * with each other: they can share the same user-id, run instrumentation 2402 * against each other, etc. 2403 * 2404 * @param pkg1 First package name whose signature will be compared. 2405 * @param pkg2 Second package name whose signature will be compared. 2406 * 2407 * @return Returns an integer indicating whether all signatures on the 2408 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2409 * all signatures match or < 0 if there is not a match ({@link 2410 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2411 * 2412 * @see #checkSignatures(int, int) 2413 * @see #SIGNATURE_MATCH 2414 * @see #SIGNATURE_NO_MATCH 2415 * @see #SIGNATURE_UNKNOWN_PACKAGE 2416 */ 2417 @CheckResult 2418 public abstract int checkSignatures(String pkg1, String pkg2); 2419 2420 /** 2421 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 2422 * the two packages to be checked. This can be useful, for example, 2423 * when doing the check in an IPC, where the UID is the only identity 2424 * available. It is functionally identical to determining the package 2425 * associated with the UIDs and checking their signatures. 2426 * 2427 * @param uid1 First UID whose signature will be compared. 2428 * @param uid2 Second UID whose signature will be compared. 2429 * 2430 * @return Returns an integer indicating whether all signatures on the 2431 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2432 * all signatures match or < 0 if there is not a match ({@link 2433 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2434 * 2435 * @see #checkSignatures(String, String) 2436 * @see #SIGNATURE_MATCH 2437 * @see #SIGNATURE_NO_MATCH 2438 * @see #SIGNATURE_UNKNOWN_PACKAGE 2439 */ 2440 @CheckResult 2441 public abstract int checkSignatures(int uid1, int uid2); 2442 2443 /** 2444 * Retrieve the names of all packages that are associated with a particular 2445 * user id. In most cases, this will be a single package name, the package 2446 * that has been assigned that user id. Where there are multiple packages 2447 * sharing the same user id through the "sharedUserId" mechanism, all 2448 * packages with that id will be returned. 2449 * 2450 * @param uid The user id for which you would like to retrieve the 2451 * associated packages. 2452 * 2453 * @return Returns an array of one or more packages assigned to the user 2454 * id, or null if there are no known packages with the given id. 2455 */ 2456 public abstract String[] getPackagesForUid(int uid); 2457 2458 /** 2459 * Retrieve the official name associated with a user id. This name is 2460 * guaranteed to never change, though it is possibly for the underlying 2461 * user id to be changed. That is, if you are storing information about 2462 * user ids in persistent storage, you should use the string returned 2463 * by this function instead of the raw user-id. 2464 * 2465 * @param uid The user id for which you would like to retrieve a name. 2466 * @return Returns a unique name for the given user id, or null if the 2467 * user id is not currently assigned. 2468 */ 2469 public abstract String getNameForUid(int uid); 2470 2471 /** 2472 * Return the user id associated with a shared user name. Multiple 2473 * applications can specify a shared user name in their manifest and thus 2474 * end up using a common uid. This might be used for new applications 2475 * that use an existing shared user name and need to know the uid of the 2476 * shared user. 2477 * 2478 * @param sharedUserName The shared user name whose uid is to be retrieved. 2479 * @return Returns the uid associated with the shared user, or NameNotFoundException 2480 * if the shared user name is not being used by any installed packages 2481 * @hide 2482 */ 2483 public abstract int getUidForSharedUser(String sharedUserName) 2484 throws NameNotFoundException; 2485 2486 /** 2487 * Return a List of all application packages that are installed on the 2488 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 2489 * applications including those deleted with {@code DONT_DELETE_DATA} (partially 2490 * installed apps with data directory) will be returned. 2491 * 2492 * @param flags Additional option flags. Use any combination of 2493 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2494 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2495 * 2496 * @return Returns a List of ApplicationInfo objects, one for each application that 2497 * is installed on the device. In the unlikely case of there being 2498 * no installed applications, an empty list is returned. 2499 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2500 * applications including those deleted with {@code DONT_DELETE_DATA} 2501 * (partially installed apps with data directory) will be returned. 2502 * 2503 * @see #GET_META_DATA 2504 * @see #GET_SHARED_LIBRARY_FILES 2505 * @see #GET_UNINSTALLED_PACKAGES 2506 */ 2507 public abstract List<ApplicationInfo> getInstalledApplications(int flags); 2508 2509 /** 2510 * Get a list of shared libraries that are available on the 2511 * system. 2512 * 2513 * @return An array of shared library names that are 2514 * available on the system, or null if none are installed. 2515 * 2516 */ 2517 public abstract String[] getSystemSharedLibraryNames(); 2518 2519 /** 2520 * Get a list of features that are available on the 2521 * system. 2522 * 2523 * @return An array of FeatureInfo classes describing the features 2524 * that are available on the system, or null if there are none(!!). 2525 */ 2526 public abstract FeatureInfo[] getSystemAvailableFeatures(); 2527 2528 /** 2529 * Check whether the given feature name is one of the available 2530 * features as returned by {@link #getSystemAvailableFeatures()}. 2531 * 2532 * @return Returns true if the devices supports the feature, else 2533 * false. 2534 */ 2535 public abstract boolean hasSystemFeature(String name); 2536 2537 /** 2538 * Determine the best action to perform for a given Intent. This is how 2539 * {@link Intent#resolveActivity} finds an activity if a class has not 2540 * been explicitly specified. 2541 * 2542 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 2543 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 2544 * only flag. You need to do so to resolve the activity in the same way 2545 * that {@link android.content.Context#startActivity(Intent)} and 2546 * {@link android.content.Intent#resolveActivity(PackageManager) 2547 * Intent.resolveActivity(PackageManager)} do.</p> 2548 * 2549 * @param intent An intent containing all of the desired specification 2550 * (action, data, type, category, and/or component). 2551 * @param flags Additional option flags. The most important is 2552 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2553 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2554 * 2555 * @return Returns a ResolveInfo containing the final activity intent that 2556 * was determined to be the best action. Returns null if no 2557 * matching activity was found. If multiple matching activities are 2558 * found and there is no default set, returns a ResolveInfo 2559 * containing something else, such as the activity resolver. 2560 * 2561 * @see #MATCH_DEFAULT_ONLY 2562 * @see #GET_INTENT_FILTERS 2563 * @see #GET_RESOLVED_FILTER 2564 */ 2565 public abstract ResolveInfo resolveActivity(Intent intent, int flags); 2566 2567 /** 2568 * Determine the best action to perform for a given Intent for a given user. This 2569 * is how {@link Intent#resolveActivity} finds an activity if a class has not 2570 * been explicitly specified. 2571 * 2572 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 2573 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 2574 * only flag. You need to do so to resolve the activity in the same way 2575 * that {@link android.content.Context#startActivity(Intent)} and 2576 * {@link android.content.Intent#resolveActivity(PackageManager) 2577 * Intent.resolveActivity(PackageManager)} do.</p> 2578 * 2579 * @param intent An intent containing all of the desired specification 2580 * (action, data, type, category, and/or component). 2581 * @param flags Additional option flags. The most important is 2582 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2583 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2584 * @param userId The user id. 2585 * 2586 * @return Returns a ResolveInfo containing the final activity intent that 2587 * was determined to be the best action. Returns null if no 2588 * matching activity was found. If multiple matching activities are 2589 * found and there is no default set, returns a ResolveInfo 2590 * containing something else, such as the activity resolver. 2591 * 2592 * @see #MATCH_DEFAULT_ONLY 2593 * @see #GET_INTENT_FILTERS 2594 * @see #GET_RESOLVED_FILTER 2595 * 2596 * @hide 2597 */ 2598 public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId); 2599 2600 /** 2601 * Retrieve all activities that can be performed for the given intent. 2602 * 2603 * @param intent The desired intent as per resolveActivity(). 2604 * @param flags Additional option flags. The most important is 2605 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2606 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2607 * 2608 * @return A List<ResolveInfo> containing one entry for each matching 2609 * Activity. These are ordered from best to worst match -- that 2610 * is, the first item in the list is what is returned by 2611 * {@link #resolveActivity}. If there are no matching activities, an empty 2612 * list is returned. 2613 * 2614 * @see #MATCH_DEFAULT_ONLY 2615 * @see #GET_INTENT_FILTERS 2616 * @see #GET_RESOLVED_FILTER 2617 */ 2618 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 2619 int flags); 2620 2621 /** 2622 * Retrieve all activities that can be performed for the given intent, for a specific user. 2623 * 2624 * @param intent The desired intent as per resolveActivity(). 2625 * @param flags Additional option flags. The most important is 2626 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2627 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2628 * 2629 * @return A List<ResolveInfo> containing one entry for each matching 2630 * Activity. These are ordered from best to worst match -- that 2631 * is, the first item in the list is what is returned by 2632 * {@link #resolveActivity}. If there are no matching activities, an empty 2633 * list is returned. 2634 * 2635 * @see #MATCH_DEFAULT_ONLY 2636 * @see #GET_INTENT_FILTERS 2637 * @see #GET_RESOLVED_FILTER 2638 * @hide 2639 */ 2640 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 2641 int flags, int userId); 2642 2643 2644 /** 2645 * Retrieve a set of activities that should be presented to the user as 2646 * similar options. This is like {@link #queryIntentActivities}, except it 2647 * also allows you to supply a list of more explicit Intents that you would 2648 * like to resolve to particular options, and takes care of returning the 2649 * final ResolveInfo list in a reasonable order, with no duplicates, based 2650 * on those inputs. 2651 * 2652 * @param caller The class name of the activity that is making the 2653 * request. This activity will never appear in the output 2654 * list. Can be null. 2655 * @param specifics An array of Intents that should be resolved to the 2656 * first specific results. Can be null. 2657 * @param intent The desired intent as per resolveActivity(). 2658 * @param flags Additional option flags. The most important is 2659 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2660 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2661 * 2662 * @return A List<ResolveInfo> containing one entry for each matching 2663 * Activity. These are ordered first by all of the intents resolved 2664 * in <var>specifics</var> and then any additional activities that 2665 * can handle <var>intent</var> but did not get included by one of 2666 * the <var>specifics</var> intents. If there are no matching 2667 * activities, an empty list is returned. 2668 * 2669 * @see #MATCH_DEFAULT_ONLY 2670 * @see #GET_INTENT_FILTERS 2671 * @see #GET_RESOLVED_FILTER 2672 */ 2673 public abstract List<ResolveInfo> queryIntentActivityOptions( 2674 ComponentName caller, Intent[] specifics, Intent intent, int flags); 2675 2676 /** 2677 * Retrieve all receivers that can handle a broadcast of the given intent. 2678 * 2679 * @param intent The desired intent as per resolveActivity(). 2680 * @param flags Additional option flags. 2681 * 2682 * @return A List<ResolveInfo> containing one entry for each matching 2683 * Receiver. These are ordered from first to last in priority. If 2684 * there are no matching receivers, an empty list is returned. 2685 * 2686 * @see #MATCH_DEFAULT_ONLY 2687 * @see #GET_INTENT_FILTERS 2688 * @see #GET_RESOLVED_FILTER 2689 */ 2690 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 2691 int flags); 2692 2693 /** 2694 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific 2695 * user. 2696 * 2697 * @param intent The desired intent as per resolveActivity(). 2698 * @param flags Additional option flags. 2699 * @param userId The userId of the user being queried. 2700 * 2701 * @return A List<ResolveInfo> containing one entry for each matching 2702 * Receiver. These are ordered from first to last in priority. If 2703 * there are no matching receivers, an empty list is returned. 2704 * 2705 * @see #MATCH_DEFAULT_ONLY 2706 * @see #GET_INTENT_FILTERS 2707 * @see #GET_RESOLVED_FILTER 2708 * @hide 2709 */ 2710 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 2711 int flags, int userId); 2712 2713 /** 2714 * Determine the best service to handle for a given Intent. 2715 * 2716 * @param intent An intent containing all of the desired specification 2717 * (action, data, type, category, and/or component). 2718 * @param flags Additional option flags. 2719 * 2720 * @return Returns a ResolveInfo containing the final service intent that 2721 * was determined to be the best action. Returns null if no 2722 * matching service was found. 2723 * 2724 * @see #GET_INTENT_FILTERS 2725 * @see #GET_RESOLVED_FILTER 2726 */ 2727 public abstract ResolveInfo resolveService(Intent intent, int flags); 2728 2729 /** 2730 * Retrieve all services that can match the given intent. 2731 * 2732 * @param intent The desired intent as per resolveService(). 2733 * @param flags Additional option flags. 2734 * 2735 * @return A List<ResolveInfo> containing one entry for each matching 2736 * ServiceInfo. These are ordered from best to worst match -- that 2737 * is, the first item in the list is what is returned by 2738 * resolveService(). If there are no matching services, an empty 2739 * list is returned. 2740 * 2741 * @see #GET_INTENT_FILTERS 2742 * @see #GET_RESOLVED_FILTER 2743 */ 2744 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 2745 int flags); 2746 2747 /** 2748 * Retrieve all services that can match the given intent for a given user. 2749 * 2750 * @param intent The desired intent as per resolveService(). 2751 * @param flags Additional option flags. 2752 * @param userId The user id. 2753 * 2754 * @return A List<ResolveInfo> containing one entry for each matching 2755 * ServiceInfo. These are ordered from best to worst match -- that 2756 * is, the first item in the list is what is returned by 2757 * resolveService(). If there are no matching services, an empty 2758 * list is returned. 2759 * 2760 * @see #GET_INTENT_FILTERS 2761 * @see #GET_RESOLVED_FILTER 2762 * 2763 * @hide 2764 */ 2765 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 2766 int flags, int userId); 2767 2768 /** {@hide} */ 2769 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 2770 Intent intent, int flags, int userId); 2771 2772 /** 2773 * Retrieve all providers that can match the given intent. 2774 * 2775 * @param intent An intent containing all of the desired specification 2776 * (action, data, type, category, and/or component). 2777 * @param flags Additional option flags. 2778 * @return A List<ResolveInfo> containing one entry for each matching 2779 * ProviderInfo. These are ordered from best to worst match. If 2780 * there are no matching providers, an empty list is returned. 2781 * @see #GET_INTENT_FILTERS 2782 * @see #GET_RESOLVED_FILTER 2783 */ 2784 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags); 2785 2786 /** 2787 * Find a single content provider by its base path name. 2788 * 2789 * @param name The name of the provider to find. 2790 * @param flags Additional option flags. Currently should always be 0. 2791 * 2792 * @return ContentProviderInfo Information about the provider, if found, 2793 * else null. 2794 */ 2795 public abstract ProviderInfo resolveContentProvider(String name, 2796 int flags); 2797 2798 /** 2799 * Find a single content provider by its base path name. 2800 * 2801 * @param name The name of the provider to find. 2802 * @param flags Additional option flags. Currently should always be 0. 2803 * @param userId The user id. 2804 * 2805 * @return ContentProviderInfo Information about the provider, if found, 2806 * else null. 2807 * @hide 2808 */ 2809 public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId); 2810 2811 /** 2812 * Retrieve content provider information. 2813 * 2814 * <p><em>Note: unlike most other methods, an empty result set is indicated 2815 * by a null return instead of an empty list.</em> 2816 * 2817 * @param processName If non-null, limits the returned providers to only 2818 * those that are hosted by the given process. If null, 2819 * all content providers are returned. 2820 * @param uid If <var>processName</var> is non-null, this is the required 2821 * uid owning the requested content providers. 2822 * @param flags Additional option flags. Currently should always be 0. 2823 * 2824 * @return A List<ContentProviderInfo> containing one entry for each 2825 * content provider either patching <var>processName</var> or, if 2826 * <var>processName</var> is null, all known content providers. 2827 * <em>If there are no matching providers, null is returned.</em> 2828 */ 2829 public abstract List<ProviderInfo> queryContentProviders( 2830 String processName, int uid, int flags); 2831 2832 /** 2833 * Retrieve all of the information we know about a particular 2834 * instrumentation class. 2835 * 2836 * <p>Throws {@link NameNotFoundException} if instrumentation with the 2837 * given class name cannot be found on the system. 2838 * 2839 * @param className The full name (i.e. 2840 * com.google.apps.contacts.InstrumentList) of an 2841 * Instrumentation class. 2842 * @param flags Additional option flags. Currently should always be 0. 2843 * 2844 * @return InstrumentationInfo containing information about the 2845 * instrumentation. 2846 */ 2847 public abstract InstrumentationInfo getInstrumentationInfo( 2848 ComponentName className, int flags) throws NameNotFoundException; 2849 2850 /** 2851 * Retrieve information about available instrumentation code. May be used 2852 * to retrieve either all instrumentation code, or only the code targeting 2853 * a particular package. 2854 * 2855 * @param targetPackage If null, all instrumentation is returned; only the 2856 * instrumentation targeting this package name is 2857 * returned. 2858 * @param flags Additional option flags. Currently should always be 0. 2859 * 2860 * @return A List<InstrumentationInfo> containing one entry for each 2861 * matching available Instrumentation. Returns an empty list if 2862 * there is no instrumentation available for the given package. 2863 */ 2864 public abstract List<InstrumentationInfo> queryInstrumentation( 2865 String targetPackage, int flags); 2866 2867 /** 2868 * Retrieve an image from a package. This is a low-level API used by 2869 * the various package manager info structures (such as 2870 * {@link ComponentInfo} to implement retrieval of their associated 2871 * icon. 2872 * 2873 * @param packageName The name of the package that this icon is coming from. 2874 * Cannot be null. 2875 * @param resid The resource identifier of the desired image. Cannot be 0. 2876 * @param appInfo Overall information about <var>packageName</var>. This 2877 * may be null, in which case the application information will be retrieved 2878 * for you if needed; if you already have this information around, it can 2879 * be much more efficient to supply it here. 2880 * 2881 * @return Returns a Drawable holding the requested image. Returns null if 2882 * an image could not be found for any reason. 2883 */ 2884 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid, 2885 ApplicationInfo appInfo); 2886 2887 /** 2888 * Retrieve the icon associated with an activity. Given the full name of 2889 * an activity, retrieves the information about it and calls 2890 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 2891 * If the activity cannot be found, NameNotFoundException is thrown. 2892 * 2893 * @param activityName Name of the activity whose icon is to be retrieved. 2894 * 2895 * @return Returns the image of the icon, or the default activity icon if 2896 * it could not be found. Does not return null. 2897 * @throws NameNotFoundException Thrown if the resources for the given 2898 * activity could not be loaded. 2899 * 2900 * @see #getActivityIcon(Intent) 2901 */ 2902 public abstract Drawable getActivityIcon(ComponentName activityName) 2903 throws NameNotFoundException; 2904 2905 /** 2906 * Retrieve the icon associated with an Intent. If intent.getClassName() is 2907 * set, this simply returns the result of 2908 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 2909 * component and returns the icon associated with the resolved component. 2910 * If intent.getClassName() cannot be found or the Intent cannot be resolved 2911 * to a component, NameNotFoundException is thrown. 2912 * 2913 * @param intent The intent for which you would like to retrieve an icon. 2914 * 2915 * @return Returns the image of the icon, or the default activity icon if 2916 * it could not be found. Does not return null. 2917 * @throws NameNotFoundException Thrown if the resources for application 2918 * matching the given intent could not be loaded. 2919 * 2920 * @see #getActivityIcon(ComponentName) 2921 */ 2922 public abstract Drawable getActivityIcon(Intent intent) 2923 throws NameNotFoundException; 2924 2925 /** 2926 * Retrieve the banner associated with an activity. Given the full name of 2927 * an activity, retrieves the information about it and calls 2928 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 2929 * banner. If the activity cannot be found, NameNotFoundException is thrown. 2930 * 2931 * @param activityName Name of the activity whose banner is to be retrieved. 2932 * @return Returns the image of the banner, or null if the activity has no 2933 * banner specified. 2934 * @throws NameNotFoundException Thrown if the resources for the given 2935 * activity could not be loaded. 2936 * @see #getActivityBanner(Intent) 2937 */ 2938 public abstract Drawable getActivityBanner(ComponentName activityName) 2939 throws NameNotFoundException; 2940 2941 /** 2942 * Retrieve the banner associated with an Intent. If intent.getClassName() 2943 * is set, this simply returns the result of 2944 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 2945 * intent's component and returns the banner associated with the resolved 2946 * component. If intent.getClassName() cannot be found or the Intent cannot 2947 * be resolved to a component, NameNotFoundException is thrown. 2948 * 2949 * @param intent The intent for which you would like to retrieve a banner. 2950 * @return Returns the image of the banner, or null if the activity has no 2951 * banner specified. 2952 * @throws NameNotFoundException Thrown if the resources for application 2953 * matching the given intent could not be loaded. 2954 * @see #getActivityBanner(ComponentName) 2955 */ 2956 public abstract Drawable getActivityBanner(Intent intent) 2957 throws NameNotFoundException; 2958 2959 /** 2960 * Return the generic icon for an activity that is used when no specific 2961 * icon is defined. 2962 * 2963 * @return Drawable Image of the icon. 2964 */ 2965 public abstract Drawable getDefaultActivityIcon(); 2966 2967 /** 2968 * Retrieve the icon associated with an application. If it has not defined 2969 * an icon, the default app icon is returned. Does not return null. 2970 * 2971 * @param info Information about application being queried. 2972 * 2973 * @return Returns the image of the icon, or the default application icon 2974 * if it could not be found. 2975 * 2976 * @see #getApplicationIcon(String) 2977 */ 2978 public abstract Drawable getApplicationIcon(ApplicationInfo info); 2979 2980 /** 2981 * Retrieve the icon associated with an application. Given the name of the 2982 * application's package, retrieves the information about it and calls 2983 * getApplicationIcon() to return its icon. If the application cannot be 2984 * found, NameNotFoundException is thrown. 2985 * 2986 * @param packageName Name of the package whose application icon is to be 2987 * retrieved. 2988 * 2989 * @return Returns the image of the icon, or the default application icon 2990 * if it could not be found. Does not return null. 2991 * @throws NameNotFoundException Thrown if the resources for the given 2992 * application could not be loaded. 2993 * 2994 * @see #getApplicationIcon(ApplicationInfo) 2995 */ 2996 public abstract Drawable getApplicationIcon(String packageName) 2997 throws NameNotFoundException; 2998 2999 /** 3000 * Retrieve the banner associated with an application. 3001 * 3002 * @param info Information about application being queried. 3003 * @return Returns the image of the banner or null if the application has no 3004 * banner specified. 3005 * @see #getApplicationBanner(String) 3006 */ 3007 public abstract Drawable getApplicationBanner(ApplicationInfo info); 3008 3009 /** 3010 * Retrieve the banner associated with an application. Given the name of the 3011 * application's package, retrieves the information about it and calls 3012 * getApplicationIcon() to return its banner. If the application cannot be 3013 * found, NameNotFoundException is thrown. 3014 * 3015 * @param packageName Name of the package whose application banner is to be 3016 * retrieved. 3017 * @return Returns the image of the banner or null if the application has no 3018 * banner specified. 3019 * @throws NameNotFoundException Thrown if the resources for the given 3020 * application could not be loaded. 3021 * @see #getApplicationBanner(ApplicationInfo) 3022 */ 3023 public abstract Drawable getApplicationBanner(String packageName) 3024 throws NameNotFoundException; 3025 3026 /** 3027 * Retrieve the logo associated with an activity. Given the full name of an 3028 * activity, retrieves the information about it and calls 3029 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 3030 * logo. If the activity cannot be found, NameNotFoundException is thrown. 3031 * 3032 * @param activityName Name of the activity whose logo is to be retrieved. 3033 * @return Returns the image of the logo or null if the activity has no logo 3034 * specified. 3035 * @throws NameNotFoundException Thrown if the resources for the given 3036 * activity could not be loaded. 3037 * @see #getActivityLogo(Intent) 3038 */ 3039 public abstract Drawable getActivityLogo(ComponentName activityName) 3040 throws NameNotFoundException; 3041 3042 /** 3043 * Retrieve the logo associated with an Intent. If intent.getClassName() is 3044 * set, this simply returns the result of 3045 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 3046 * component and returns the logo associated with the resolved component. 3047 * If intent.getClassName() cannot be found or the Intent cannot be resolved 3048 * to a component, NameNotFoundException is thrown. 3049 * 3050 * @param intent The intent for which you would like to retrieve a logo. 3051 * 3052 * @return Returns the image of the logo, or null if the activity has no 3053 * logo specified. 3054 * 3055 * @throws NameNotFoundException Thrown if the resources for application 3056 * matching the given intent could not be loaded. 3057 * 3058 * @see #getActivityLogo(ComponentName) 3059 */ 3060 public abstract Drawable getActivityLogo(Intent intent) 3061 throws NameNotFoundException; 3062 3063 /** 3064 * Retrieve the logo associated with an application. If it has not specified 3065 * a logo, this method returns null. 3066 * 3067 * @param info Information about application being queried. 3068 * 3069 * @return Returns the image of the logo, or null if no logo is specified 3070 * by the application. 3071 * 3072 * @see #getApplicationLogo(String) 3073 */ 3074 public abstract Drawable getApplicationLogo(ApplicationInfo info); 3075 3076 /** 3077 * Retrieve the logo associated with an application. Given the name of the 3078 * application's package, retrieves the information about it and calls 3079 * getApplicationLogo() to return its logo. If the application cannot be 3080 * found, NameNotFoundException is thrown. 3081 * 3082 * @param packageName Name of the package whose application logo is to be 3083 * retrieved. 3084 * 3085 * @return Returns the image of the logo, or null if no application logo 3086 * has been specified. 3087 * 3088 * @throws NameNotFoundException Thrown if the resources for the given 3089 * application could not be loaded. 3090 * 3091 * @see #getApplicationLogo(ApplicationInfo) 3092 */ 3093 public abstract Drawable getApplicationLogo(String packageName) 3094 throws NameNotFoundException; 3095 3096 /** 3097 * If the target user is a managed profile of the calling user or the caller 3098 * is itself a managed profile, then this returns a badged copy of the given 3099 * icon to be able to distinguish it from the original icon. For badging an 3100 * arbitrary drawable use {@link #getUserBadgedDrawableForDensity( 3101 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 3102 * <p> 3103 * If the original drawable is a BitmapDrawable and the backing bitmap is 3104 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 3105 * is performed in place and the original drawable is returned. 3106 * </p> 3107 * 3108 * @param icon The icon to badge. 3109 * @param user The target user. 3110 * @return A drawable that combines the original icon and a badge as 3111 * determined by the system. 3112 */ 3113 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 3114 3115 /** 3116 * If the target user is a managed profile of the calling user or the caller 3117 * is itself a managed profile, then this returns a badged copy of the given 3118 * drawable allowing the user to distinguish it from the original drawable. 3119 * The caller can specify the location in the bounds of the drawable to be 3120 * badged where the badge should be applied as well as the density of the 3121 * badge to be used. 3122 * <p> 3123 * If the original drawable is a BitmapDrawable and the backing bitmap is 3124 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading 3125 * is performed in place and the original drawable is returned. 3126 * </p> 3127 * 3128 * @param drawable The drawable to badge. 3129 * @param user The target user. 3130 * @param badgeLocation Where in the bounds of the badged drawable to place 3131 * the badge. If not provided, the badge is applied on top of the entire 3132 * drawable being badged. 3133 * @param badgeDensity The optional desired density for the badge as per 3134 * {@link android.util.DisplayMetrics#densityDpi}. If not provided, 3135 * the density of the display is used. 3136 * @return A drawable that combines the original drawable and a badge as 3137 * determined by the system. 3138 */ 3139 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 3140 UserHandle user, Rect badgeLocation, int badgeDensity); 3141 3142 /** 3143 * If the target user is a managed profile of the calling user or the caller 3144 * is itself a managed profile, then this returns a drawable to use as a small 3145 * icon to include in a view to distinguish it from the original icon. 3146 * 3147 * @param user The target user. 3148 * @param density The optional desired density for the badge as per 3149 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 3150 * the density of the current display is used. 3151 * @return the drawable or null if no drawable is required. 3152 * @hide 3153 */ 3154 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 3155 3156 /** 3157 * If the target user is a managed profile of the calling user or the caller 3158 * is itself a managed profile, then this returns a copy of the label with 3159 * badging for accessibility services like talkback. E.g. passing in "Email" 3160 * and it might return "Work Email" for Email in the work profile. 3161 * 3162 * @param label The label to change. 3163 * @param user The target user. 3164 * @return A label that combines the original label and a badge as 3165 * determined by the system. 3166 */ 3167 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 3168 3169 /** 3170 * Retrieve text from a package. This is a low-level API used by 3171 * the various package manager info structures (such as 3172 * {@link ComponentInfo} to implement retrieval of their associated 3173 * labels and other text. 3174 * 3175 * @param packageName The name of the package that this text is coming from. 3176 * Cannot be null. 3177 * @param resid The resource identifier of the desired text. Cannot be 0. 3178 * @param appInfo Overall information about <var>packageName</var>. This 3179 * may be null, in which case the application information will be retrieved 3180 * for you if needed; if you already have this information around, it can 3181 * be much more efficient to supply it here. 3182 * 3183 * @return Returns a CharSequence holding the requested text. Returns null 3184 * if the text could not be found for any reason. 3185 */ 3186 public abstract CharSequence getText(String packageName, @StringRes int resid, 3187 ApplicationInfo appInfo); 3188 3189 /** 3190 * Retrieve an XML file from a package. This is a low-level API used to 3191 * retrieve XML meta data. 3192 * 3193 * @param packageName The name of the package that this xml is coming from. 3194 * Cannot be null. 3195 * @param resid The resource identifier of the desired xml. Cannot be 0. 3196 * @param appInfo Overall information about <var>packageName</var>. This 3197 * may be null, in which case the application information will be retrieved 3198 * for you if needed; if you already have this information around, it can 3199 * be much more efficient to supply it here. 3200 * 3201 * @return Returns an XmlPullParser allowing you to parse out the XML 3202 * data. Returns null if the xml resource could not be found for any 3203 * reason. 3204 */ 3205 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid, 3206 ApplicationInfo appInfo); 3207 3208 /** 3209 * Return the label to use for this application. 3210 * 3211 * @return Returns the label associated with this application, or null if 3212 * it could not be found for any reason. 3213 * @param info The application to get the label of. 3214 */ 3215 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 3216 3217 /** 3218 * Retrieve the resources associated with an activity. Given the full 3219 * name of an activity, retrieves the information about it and calls 3220 * getResources() to return its application's resources. If the activity 3221 * cannot be found, NameNotFoundException is thrown. 3222 * 3223 * @param activityName Name of the activity whose resources are to be 3224 * retrieved. 3225 * 3226 * @return Returns the application's Resources. 3227 * @throws NameNotFoundException Thrown if the resources for the given 3228 * application could not be loaded. 3229 * 3230 * @see #getResourcesForApplication(ApplicationInfo) 3231 */ 3232 public abstract Resources getResourcesForActivity(ComponentName activityName) 3233 throws NameNotFoundException; 3234 3235 /** 3236 * Retrieve the resources for an application. Throws NameNotFoundException 3237 * if the package is no longer installed. 3238 * 3239 * @param app Information about the desired application. 3240 * 3241 * @return Returns the application's Resources. 3242 * @throws NameNotFoundException Thrown if the resources for the given 3243 * application could not be loaded (most likely because it was uninstalled). 3244 */ 3245 public abstract Resources getResourcesForApplication(ApplicationInfo app) 3246 throws NameNotFoundException; 3247 3248 /** 3249 * Retrieve the resources associated with an application. Given the full 3250 * package name of an application, retrieves the information about it and 3251 * calls getResources() to return its application's resources. If the 3252 * appPackageName cannot be found, NameNotFoundException is thrown. 3253 * 3254 * @param appPackageName Package name of the application whose resources 3255 * are to be retrieved. 3256 * 3257 * @return Returns the application's Resources. 3258 * @throws NameNotFoundException Thrown if the resources for the given 3259 * application could not be loaded. 3260 * 3261 * @see #getResourcesForApplication(ApplicationInfo) 3262 */ 3263 public abstract Resources getResourcesForApplication(String appPackageName) 3264 throws NameNotFoundException; 3265 3266 /** @hide */ 3267 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId) 3268 throws NameNotFoundException; 3269 3270 /** 3271 * Retrieve overall information about an application package defined 3272 * in a package archive file 3273 * 3274 * @param archiveFilePath The path to the archive file 3275 * @param flags Additional option flags. Use any combination of 3276 * {@link #GET_ACTIVITIES}, 3277 * {@link #GET_GIDS}, 3278 * {@link #GET_CONFIGURATIONS}, 3279 * {@link #GET_INSTRUMENTATION}, 3280 * {@link #GET_PERMISSIONS}, 3281 * {@link #GET_PROVIDERS}, 3282 * {@link #GET_RECEIVERS}, 3283 * {@link #GET_SERVICES}, 3284 * {@link #GET_SIGNATURES}, to modify the data returned. 3285 * 3286 * @return Returns the information about the package. Returns 3287 * null if the package could not be successfully parsed. 3288 * 3289 * @see #GET_ACTIVITIES 3290 * @see #GET_GIDS 3291 * @see #GET_CONFIGURATIONS 3292 * @see #GET_INSTRUMENTATION 3293 * @see #GET_PERMISSIONS 3294 * @see #GET_PROVIDERS 3295 * @see #GET_RECEIVERS 3296 * @see #GET_SERVICES 3297 * @see #GET_SIGNATURES 3298 * 3299 */ 3300 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { 3301 final PackageParser parser = new PackageParser(); 3302 final File apkFile = new File(archiveFilePath); 3303 try { 3304 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 3305 if ((flags & GET_SIGNATURES) != 0) { 3306 parser.collectCertificates(pkg, 0); 3307 parser.collectManifestDigest(pkg); 3308 } 3309 PackageUserState state = new PackageUserState(); 3310 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 3311 } catch (PackageParserException e) { 3312 return null; 3313 } 3314 } 3315 3316 /** 3317 * @hide Install a package. Since this may take a little while, the result 3318 * will be posted back to the given observer. An installation will 3319 * fail if the calling context lacks the 3320 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if 3321 * the package named in the package file's manifest is already 3322 * installed, or if there's no space available on the device. 3323 * @param packageURI The location of the package file to install. This can 3324 * be a 'file:' or a 'content:' URI. 3325 * @param observer An observer callback to get notified when the package 3326 * installation is complete. 3327 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3328 * will be called when that happens. This parameter must not be 3329 * null. 3330 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3331 * {@link #INSTALL_REPLACE_EXISTING}, 3332 * {@link #INSTALL_ALLOW_TEST}. 3333 * @param installerPackageName Optional package name of the application that 3334 * is performing the installation. This identifies which market 3335 * the package came from. 3336 * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int, 3337 * String)} instead. This method will continue to be supported 3338 * but the older observer interface will not get additional 3339 * failure details. 3340 */ 3341 // @SystemApi 3342 public abstract void installPackage( 3343 Uri packageURI, IPackageInstallObserver observer, int flags, 3344 String installerPackageName); 3345 3346 /** 3347 * Similar to 3348 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3349 * with an extra verification file provided. 3350 * 3351 * @param packageURI The location of the package file to install. This can 3352 * be a 'file:' or a 'content:' URI. 3353 * @param observer An observer callback to get notified when the package 3354 * installation is complete. 3355 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3356 * will be called when that happens. This parameter must not be 3357 * null. 3358 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3359 * {@link #INSTALL_REPLACE_EXISTING}, 3360 * {@link #INSTALL_ALLOW_TEST}. 3361 * @param installerPackageName Optional package name of the application that 3362 * is performing the installation. This identifies which market 3363 * the package came from. 3364 * @param verificationURI The location of the supplementary verification 3365 * file. This can be a 'file:' or a 'content:' URI. May be 3366 * {@code null}. 3367 * @param manifestDigest an object that holds the digest of the package 3368 * which can be used to verify ownership. May be {@code null}. 3369 * @param encryptionParams if the package to be installed is encrypted, 3370 * these parameters describing the encryption and authentication 3371 * used. May be {@code null}. 3372 * @hide 3373 * @deprecated Use {@link #installPackageWithVerification(Uri, 3374 * PackageInstallObserver, int, String, Uri, ManifestDigest, 3375 * ContainerEncryptionParams)} instead. This method will 3376 * continue to be supported but the older observer interface 3377 * will not get additional failure details. 3378 */ 3379 // @SystemApi 3380 public abstract void installPackageWithVerification(Uri packageURI, 3381 IPackageInstallObserver observer, int flags, String installerPackageName, 3382 Uri verificationURI, ManifestDigest manifestDigest, 3383 ContainerEncryptionParams encryptionParams); 3384 3385 /** 3386 * Similar to 3387 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3388 * with an extra verification information provided. 3389 * 3390 * @param packageURI The location of the package file to install. This can 3391 * be a 'file:' or a 'content:' URI. 3392 * @param observer An observer callback to get notified when the package 3393 * installation is complete. 3394 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3395 * will be called when that happens. This parameter must not be 3396 * null. 3397 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3398 * {@link #INSTALL_REPLACE_EXISTING}, 3399 * {@link #INSTALL_ALLOW_TEST}. 3400 * @param installerPackageName Optional package name of the application that 3401 * is performing the installation. This identifies which market 3402 * the package came from. 3403 * @param verificationParams an object that holds signal information to 3404 * assist verification. May be {@code null}. 3405 * @param encryptionParams if the package to be installed is encrypted, 3406 * these parameters describing the encryption and authentication 3407 * used. May be {@code null}. 3408 * @hide 3409 * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri, 3410 * PackageInstallObserver, int, String, VerificationParams, 3411 * ContainerEncryptionParams)} instead. This method will 3412 * continue to be supported but the older observer interface 3413 * will not get additional failure details. 3414 */ 3415 @Deprecated 3416 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 3417 IPackageInstallObserver observer, int flags, String installerPackageName, 3418 VerificationParams verificationParams, 3419 ContainerEncryptionParams encryptionParams); 3420 3421 // Package-install variants that take the new, expanded form of observer interface. 3422 // Note that these *also* take the original observer type and will redundantly 3423 // report the same information to that observer if supplied; but it is not required. 3424 3425 /** 3426 * @hide 3427 * 3428 * Install a package. Since this may take a little while, the result will 3429 * be posted back to the given observer. An installation will fail if the calling context 3430 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the 3431 * package named in the package file's manifest is already installed, or if there's no space 3432 * available on the device. 3433 * 3434 * @param packageURI The location of the package file to install. This can be a 'file:' or a 3435 * 'content:' URI. 3436 * @param observer An observer callback to get notified when the package installation is 3437 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3438 * called when that happens. This parameter must not be null. 3439 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3440 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3441 * @param installerPackageName Optional package name of the application that is performing the 3442 * installation. This identifies which market the package came from. 3443 */ 3444 public abstract void installPackage( 3445 Uri packageURI, PackageInstallObserver observer, 3446 int flags, String installerPackageName); 3447 3448 /** 3449 * Similar to 3450 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3451 * with an extra verification file provided. 3452 * 3453 * @param packageURI The location of the package file to install. This can 3454 * be a 'file:' or a 'content:' URI. 3455 * @param observer An observer callback to get notified when the package installation is 3456 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3457 * called when that happens. This parameter must not be null. 3458 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3459 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3460 * @param installerPackageName Optional package name of the application that 3461 * is performing the installation. This identifies which market 3462 * the package came from. 3463 * @param verificationURI The location of the supplementary verification 3464 * file. This can be a 'file:' or a 'content:' URI. May be 3465 * {@code null}. 3466 * @param manifestDigest an object that holds the digest of the package 3467 * which can be used to verify ownership. May be {@code null}. 3468 * @param encryptionParams if the package to be installed is encrypted, 3469 * these parameters describing the encryption and authentication 3470 * used. May be {@code null}. 3471 * @hide 3472 */ 3473 public abstract void installPackageWithVerification(Uri packageURI, 3474 PackageInstallObserver observer, int flags, String installerPackageName, 3475 Uri verificationURI, ManifestDigest manifestDigest, 3476 ContainerEncryptionParams encryptionParams); 3477 3478 /** 3479 * Similar to 3480 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3481 * with an extra verification information provided. 3482 * 3483 * @param packageURI The location of the package file to install. This can 3484 * be a 'file:' or a 'content:' URI. 3485 * @param observer An observer callback to get notified when the package installation is 3486 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3487 * called when that happens. This parameter must not be null. 3488 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3489 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3490 * @param installerPackageName Optional package name of the application that 3491 * is performing the installation. This identifies which market 3492 * the package came from. 3493 * @param verificationParams an object that holds signal information to 3494 * assist verification. May be {@code null}. 3495 * @param encryptionParams if the package to be installed is encrypted, 3496 * these parameters describing the encryption and authentication 3497 * used. May be {@code null}. 3498 * 3499 * @hide 3500 */ 3501 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 3502 PackageInstallObserver observer, int flags, String installerPackageName, 3503 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams); 3504 3505 /** 3506 * If there is already an application with the given package name installed 3507 * on the system for other users, also install it for the calling user. 3508 * @hide 3509 */ 3510 // @SystemApi 3511 public abstract int installExistingPackage(String packageName) 3512 throws NameNotFoundException; 3513 3514 /** 3515 * Allows a package listening to the 3516 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 3517 * broadcast} to respond to the package manager. The response must include 3518 * the {@code verificationCode} which is one of 3519 * {@link PackageManager#VERIFICATION_ALLOW} or 3520 * {@link PackageManager#VERIFICATION_REJECT}. 3521 * 3522 * @param id pending package identifier as passed via the 3523 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 3524 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 3525 * or {@link PackageManager#VERIFICATION_REJECT}. 3526 * @throws SecurityException if the caller does not have the 3527 * PACKAGE_VERIFICATION_AGENT permission. 3528 */ 3529 public abstract void verifyPendingInstall(int id, int verificationCode); 3530 3531 /** 3532 * Allows a package listening to the 3533 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 3534 * broadcast} to extend the default timeout for a response and declare what 3535 * action to perform after the timeout occurs. The response must include 3536 * the {@code verificationCodeAtTimeout} which is one of 3537 * {@link PackageManager#VERIFICATION_ALLOW} or 3538 * {@link PackageManager#VERIFICATION_REJECT}. 3539 * 3540 * This method may only be called once per package id. Additional calls 3541 * will have no effect. 3542 * 3543 * @param id pending package identifier as passed via the 3544 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 3545 * @param verificationCodeAtTimeout either 3546 * {@link PackageManager#VERIFICATION_ALLOW} or 3547 * {@link PackageManager#VERIFICATION_REJECT}. If 3548 * {@code verificationCodeAtTimeout} is neither 3549 * {@link PackageManager#VERIFICATION_ALLOW} or 3550 * {@link PackageManager#VERIFICATION_REJECT}, then 3551 * {@code verificationCodeAtTimeout} will default to 3552 * {@link PackageManager#VERIFICATION_REJECT}. 3553 * @param millisecondsToDelay the amount of time requested for the timeout. 3554 * Must be positive and less than 3555 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 3556 * {@code millisecondsToDelay} is out of bounds, 3557 * {@code millisecondsToDelay} will be set to the closest in 3558 * bounds value; namely, 0 or 3559 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 3560 * @throws SecurityException if the caller does not have the 3561 * PACKAGE_VERIFICATION_AGENT permission. 3562 */ 3563 public abstract void extendVerificationTimeout(int id, 3564 int verificationCodeAtTimeout, long millisecondsToDelay); 3565 3566 /** 3567 * Allows a package listening to the 3568 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification 3569 * broadcast} to respond to the package manager. The response must include 3570 * the {@code verificationCode} which is one of 3571 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 3572 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 3573 * 3574 * @param verificationId pending package identifier as passed via the 3575 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 3576 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 3577 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 3578 * @param outFailedDomains a list of failed domains if the verificationCode is 3579 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 3580 * @throws SecurityException if the caller does not have the 3581 * INTENT_FILTER_VERIFICATION_AGENT permission. 3582 * 3583 * @hide 3584 */ 3585 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 3586 List<String> outFailedDomains); 3587 3588 /** 3589 * Get the status of a Domain Verification Result for an IntentFilter. This is 3590 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 3591 * {@link android.content.IntentFilter#getAutoVerify()} 3592 * 3593 * This is used by the ResolverActivity to change the status depending on what the User select 3594 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 3595 * for a domain. 3596 * 3597 * @param packageName The package name of the Activity associated with the IntentFilter. 3598 * @param userId The user id. 3599 * 3600 * @return The status to set to. This can be 3601 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 3602 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 3603 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 3604 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 3605 * 3606 * @hide 3607 */ 3608 public abstract int getIntentVerificationStatus(String packageName, int userId); 3609 3610 /** 3611 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 3612 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 3613 * {@link android.content.IntentFilter#getAutoVerify()} 3614 * 3615 * This is used by the ResolverActivity to change the status depending on what the User select 3616 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 3617 * for a domain. 3618 * 3619 * @param packageName The package name of the Activity associated with the IntentFilter. 3620 * @param status The status to set to. This can be 3621 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 3622 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 3623 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 3624 * @param userId The user id. 3625 * 3626 * @return true if the status has been set. False otherwise. 3627 * 3628 * @hide 3629 */ 3630 public abstract boolean updateIntentVerificationStatus(String packageName, int status, 3631 int userId); 3632 3633 /** 3634 * Get the list of IntentFilterVerificationInfo for a specific package and User. 3635 * 3636 * @param packageName the package name. When this parameter is set to a non null value, 3637 * the results will be filtered by the package name provided. 3638 * Otherwise, there will be no filtering and it will return a list 3639 * corresponding for all packages 3640 * 3641 * @return a list of IntentFilterVerificationInfo for a specific package. 3642 * 3643 * @hide 3644 */ 3645 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 3646 String packageName); 3647 3648 /** 3649 * Get the list of IntentFilter for a specific package. 3650 * 3651 * @param packageName the package name. This parameter is set to a non null value, 3652 * the list will contain all the IntentFilter for that package. 3653 * Otherwise, the list will be empty. 3654 * 3655 * @return a list of IntentFilter for a specific package. 3656 * 3657 * @hide 3658 */ 3659 public abstract List<IntentFilter> getAllIntentFilters(String packageName); 3660 3661 /** 3662 * Change the installer associated with a given package. There are limitations 3663 * on how the installer package can be changed; in particular: 3664 * <ul> 3665 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 3666 * is not signed with the same certificate as the calling application. 3667 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 3668 * has an installer package, and that installer package is not signed with 3669 * the same certificate as the calling application. 3670 * </ul> 3671 * 3672 * @param targetPackage The installed package whose installer will be changed. 3673 * @param installerPackageName The package name of the new installer. May be 3674 * null to clear the association. 3675 */ 3676 public abstract void setInstallerPackageName(String targetPackage, 3677 String installerPackageName); 3678 3679 /** 3680 * Attempts to delete a package. Since this may take a little while, the result will 3681 * be posted back to the given observer. A deletion will fail if the calling context 3682 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 3683 * named package cannot be found, or if the named package is a "system package". 3684 * (TODO: include pointer to documentation on "system packages") 3685 * 3686 * @param packageName The name of the package to delete 3687 * @param observer An observer callback to get notified when the package deletion is 3688 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 3689 * called when that happens. observer may be null to indicate that no callback is desired. 3690 * @param flags - possible values: {@link #DELETE_KEEP_DATA}, 3691 * {@link #DELETE_ALL_USERS}. 3692 * 3693 * @hide 3694 */ 3695 // @SystemApi 3696 public abstract void deletePackage( 3697 String packageName, IPackageDeleteObserver observer, int flags); 3698 3699 /** 3700 * Retrieve the package name of the application that installed a package. This identifies 3701 * which market the package came from. 3702 * 3703 * @param packageName The name of the package to query 3704 */ 3705 public abstract String getInstallerPackageName(String packageName); 3706 3707 /** 3708 * Attempts to clear the user data directory of an application. 3709 * Since this may take a little while, the result will 3710 * be posted back to the given observer. A deletion will fail if the 3711 * named package cannot be found, or if the named package is a "system package". 3712 * 3713 * @param packageName The name of the package 3714 * @param observer An observer callback to get notified when the operation is finished 3715 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 3716 * will be called when that happens. observer may be null to indicate that 3717 * no callback is desired. 3718 * 3719 * @hide 3720 */ 3721 public abstract void clearApplicationUserData(String packageName, 3722 IPackageDataObserver observer); 3723 /** 3724 * Attempts to delete the cache files associated with an application. 3725 * Since this may take a little while, the result will 3726 * be posted back to the given observer. A deletion will fail if the calling context 3727 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 3728 * named package cannot be found, or if the named package is a "system package". 3729 * 3730 * @param packageName The name of the package to delete 3731 * @param observer An observer callback to get notified when the cache file deletion 3732 * is complete. 3733 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 3734 * will be called when that happens. observer may be null to indicate that 3735 * no callback is desired. 3736 * 3737 * @hide 3738 */ 3739 public abstract void deleteApplicationCacheFiles(String packageName, 3740 IPackageDataObserver observer); 3741 3742 /** 3743 * Free storage by deleting LRU sorted list of cache files across 3744 * all applications. If the currently available free storage 3745 * on the device is greater than or equal to the requested 3746 * free storage, no cache files are cleared. If the currently 3747 * available storage on the device is less than the requested 3748 * free storage, some or all of the cache files across 3749 * all applications are deleted (based on last accessed time) 3750 * to increase the free storage space on the device to 3751 * the requested value. There is no guarantee that clearing all 3752 * the cache files from all applications will clear up 3753 * enough storage to achieve the desired value. 3754 * @param freeStorageSize The number of bytes of storage to be 3755 * freed by the system. Say if freeStorageSize is XX, 3756 * and the current free storage is YY, 3757 * if XX is less than YY, just return. if not free XX-YY number 3758 * of bytes if possible. 3759 * @param observer call back used to notify when 3760 * the operation is completed 3761 * 3762 * @hide 3763 */ 3764 // @SystemApi 3765 public abstract void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer); 3766 3767 /** 3768 * Free storage by deleting LRU sorted list of cache files across 3769 * all applications. If the currently available free storage 3770 * on the device is greater than or equal to the requested 3771 * free storage, no cache files are cleared. If the currently 3772 * available storage on the device is less than the requested 3773 * free storage, some or all of the cache files across 3774 * all applications are deleted (based on last accessed time) 3775 * to increase the free storage space on the device to 3776 * the requested value. There is no guarantee that clearing all 3777 * the cache files from all applications will clear up 3778 * enough storage to achieve the desired value. 3779 * @param freeStorageSize The number of bytes of storage to be 3780 * freed by the system. Say if freeStorageSize is XX, 3781 * and the current free storage is YY, 3782 * if XX is less than YY, just return. if not free XX-YY number 3783 * of bytes if possible. 3784 * @param pi IntentSender call back used to 3785 * notify when the operation is completed.May be null 3786 * to indicate that no call back is desired. 3787 * 3788 * @hide 3789 */ 3790 public abstract void freeStorage(long freeStorageSize, IntentSender pi); 3791 3792 /** 3793 * Retrieve the size information for a package. 3794 * Since this may take a little while, the result will 3795 * be posted back to the given observer. The calling context 3796 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 3797 * 3798 * @param packageName The name of the package whose size information is to be retrieved 3799 * @param userHandle The user whose size information should be retrieved. 3800 * @param observer An observer callback to get notified when the operation 3801 * is complete. 3802 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 3803 * The observer's callback is invoked with a PackageStats object(containing the 3804 * code, data and cache sizes of the package) and a boolean value representing 3805 * the status of the operation. observer may be null to indicate that 3806 * no callback is desired. 3807 * 3808 * @hide 3809 */ 3810 public abstract void getPackageSizeInfo(String packageName, int userHandle, 3811 IPackageStatsObserver observer); 3812 3813 /** 3814 * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but 3815 * returns the size for the calling user. 3816 * 3817 * @hide 3818 */ 3819 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 3820 getPackageSizeInfo(packageName, UserHandle.myUserId(), observer); 3821 } 3822 3823 /** 3824 * @deprecated This function no longer does anything; it was an old 3825 * approach to managing preferred activities, which has been superseded 3826 * by (and conflicts with) the modern activity-based preferences. 3827 */ 3828 @Deprecated 3829 public abstract void addPackageToPreferred(String packageName); 3830 3831 /** 3832 * @deprecated This function no longer does anything; it was an old 3833 * approach to managing preferred activities, which has been superseded 3834 * by (and conflicts with) the modern activity-based preferences. 3835 */ 3836 @Deprecated 3837 public abstract void removePackageFromPreferred(String packageName); 3838 3839 /** 3840 * Retrieve the list of all currently configured preferred packages. The 3841 * first package on the list is the most preferred, the last is the 3842 * least preferred. 3843 * 3844 * @param flags Additional option flags. Use any combination of 3845 * {@link #GET_ACTIVITIES}, 3846 * {@link #GET_GIDS}, 3847 * {@link #GET_CONFIGURATIONS}, 3848 * {@link #GET_INSTRUMENTATION}, 3849 * {@link #GET_PERMISSIONS}, 3850 * {@link #GET_PROVIDERS}, 3851 * {@link #GET_RECEIVERS}, 3852 * {@link #GET_SERVICES}, 3853 * {@link #GET_SIGNATURES}, to modify the data returned. 3854 * 3855 * @return Returns a list of PackageInfo objects describing each 3856 * preferred application, in order of preference. 3857 * 3858 * @see #GET_ACTIVITIES 3859 * @see #GET_GIDS 3860 * @see #GET_CONFIGURATIONS 3861 * @see #GET_INSTRUMENTATION 3862 * @see #GET_PERMISSIONS 3863 * @see #GET_PROVIDERS 3864 * @see #GET_RECEIVERS 3865 * @see #GET_SERVICES 3866 * @see #GET_SIGNATURES 3867 */ 3868 public abstract List<PackageInfo> getPreferredPackages(int flags); 3869 3870 /** 3871 * @deprecated This is a protected API that should not have been available 3872 * to third party applications. It is the platform's responsibility for 3873 * assigning preferred activities and this cannot be directly modified. 3874 * 3875 * Add a new preferred activity mapping to the system. This will be used 3876 * to automatically select the given activity component when 3877 * {@link Context#startActivity(Intent) Context.startActivity()} finds 3878 * multiple matching activities and also matches the given filter. 3879 * 3880 * @param filter The set of intents under which this activity will be 3881 * made preferred. 3882 * @param match The IntentFilter match category that this preference 3883 * applies to. 3884 * @param set The set of activities that the user was picking from when 3885 * this preference was made. 3886 * @param activity The component name of the activity that is to be 3887 * preferred. 3888 */ 3889 @Deprecated 3890 public abstract void addPreferredActivity(IntentFilter filter, int match, 3891 ComponentName[] set, ComponentName activity); 3892 3893 /** 3894 * Same as {@link #addPreferredActivity(IntentFilter, int, 3895 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 3896 to. 3897 * @hide 3898 */ 3899 public void addPreferredActivity(IntentFilter filter, int match, 3900 ComponentName[] set, ComponentName activity, int userId) { 3901 throw new RuntimeException("Not implemented. Must override in a subclass."); 3902 } 3903 3904 /** 3905 * @deprecated This is a protected API that should not have been available 3906 * to third party applications. It is the platform's responsibility for 3907 * assigning preferred activities and this cannot be directly modified. 3908 * 3909 * Replaces an existing preferred activity mapping to the system, and if that were not present 3910 * adds a new preferred activity. This will be used 3911 * to automatically select the given activity component when 3912 * {@link Context#startActivity(Intent) Context.startActivity()} finds 3913 * multiple matching activities and also matches the given filter. 3914 * 3915 * @param filter The set of intents under which this activity will be 3916 * made preferred. 3917 * @param match The IntentFilter match category that this preference 3918 * applies to. 3919 * @param set The set of activities that the user was picking from when 3920 * this preference was made. 3921 * @param activity The component name of the activity that is to be 3922 * preferred. 3923 * @hide 3924 */ 3925 @Deprecated 3926 public abstract void replacePreferredActivity(IntentFilter filter, int match, 3927 ComponentName[] set, ComponentName activity); 3928 3929 /** 3930 * @hide 3931 */ 3932 @Deprecated 3933 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 3934 ComponentName[] set, ComponentName activity, int userId) { 3935 throw new RuntimeException("Not implemented. Must override in a subclass."); 3936 } 3937 3938 /** 3939 * Remove all preferred activity mappings, previously added with 3940 * {@link #addPreferredActivity}, from the 3941 * system whose activities are implemented in the given package name. 3942 * An application can only clear its own package(s). 3943 * 3944 * @param packageName The name of the package whose preferred activity 3945 * mappings are to be removed. 3946 */ 3947 public abstract void clearPackagePreferredActivities(String packageName); 3948 3949 /** 3950 * Retrieve all preferred activities, previously added with 3951 * {@link #addPreferredActivity}, that are 3952 * currently registered with the system. 3953 * 3954 * @param outFilters A required list in which to place the filters of all of the 3955 * preferred activities. 3956 * @param outActivities A required list in which to place the component names of 3957 * all of the preferred activities. 3958 * @param packageName An optional package in which you would like to limit 3959 * the list. If null, all activities will be returned; if non-null, only 3960 * those activities in the given package are returned. 3961 * 3962 * @return Returns the total number of registered preferred activities 3963 * (the number of distinct IntentFilter records, not the number of unique 3964 * activity components) that were found. 3965 */ 3966 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 3967 @NonNull List<ComponentName> outActivities, String packageName); 3968 3969 /** 3970 * Ask for the set of available 'home' activities and the current explicit 3971 * default, if any. 3972 * @hide 3973 */ 3974 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 3975 3976 /** 3977 * Set the enabled setting for a package component (activity, receiver, service, provider). 3978 * This setting will override any enabled state which may have been set by the component in its 3979 * manifest. 3980 * 3981 * @param componentName The component to enable 3982 * @param newState The new enabled state for the component. The legal values for this state 3983 * are: 3984 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 3985 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 3986 * and 3987 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 3988 * The last one removes the setting, thereby restoring the component's state to 3989 * whatever was set in it's manifest (or enabled, by default). 3990 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 3991 */ 3992 public abstract void setComponentEnabledSetting(ComponentName componentName, 3993 int newState, int flags); 3994 3995 3996 /** 3997 * Return the enabled setting for a package component (activity, 3998 * receiver, service, provider). This returns the last value set by 3999 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 4000 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 4001 * the value originally specified in the manifest has not been modified. 4002 * 4003 * @param componentName The component to retrieve. 4004 * @return Returns the current enabled state for the component. May 4005 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4006 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 4007 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 4008 * component's enabled state is based on the original information in 4009 * the manifest as found in {@link ComponentInfo}. 4010 */ 4011 public abstract int getComponentEnabledSetting(ComponentName componentName); 4012 4013 /** 4014 * Set the enabled setting for an application 4015 * This setting will override any enabled state which may have been set by the application in 4016 * its manifest. It also overrides the enabled state set in the manifest for any of the 4017 * application's components. It does not override any enabled state set by 4018 * {@link #setComponentEnabledSetting} for any of the application's components. 4019 * 4020 * @param packageName The package name of the application to enable 4021 * @param newState The new enabled state for the component. The legal values for this state 4022 * are: 4023 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4024 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 4025 * and 4026 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 4027 * The last one removes the setting, thereby restoring the applications's state to 4028 * whatever was set in its manifest (or enabled, by default). 4029 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 4030 */ 4031 public abstract void setApplicationEnabledSetting(String packageName, 4032 int newState, int flags); 4033 4034 /** 4035 * Return the enabled setting for an application. This returns 4036 * the last value set by 4037 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 4038 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 4039 * the value originally specified in the manifest has not been modified. 4040 * 4041 * @param packageName The package name of the application to retrieve. 4042 * @return Returns the current enabled state for the application. May 4043 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4044 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 4045 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 4046 * application's enabled state is based on the original information in 4047 * the manifest as found in {@link ComponentInfo}. 4048 * @throws IllegalArgumentException if the named package does not exist. 4049 */ 4050 public abstract int getApplicationEnabledSetting(String packageName); 4051 4052 /** 4053 * Puts the package in a hidden state, which is almost like an uninstalled state, 4054 * making the package unavailable, but it doesn't remove the data or the actual 4055 * package file. Application can be unhidden by either resetting the hidden state 4056 * or by installing it, such as with {@link #installExistingPackage(String)} 4057 * @hide 4058 */ 4059 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 4060 UserHandle userHandle); 4061 4062 /** 4063 * Returns the hidden state of a package. 4064 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 4065 * @hide 4066 */ 4067 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 4068 UserHandle userHandle); 4069 4070 /** 4071 * Return whether the device has been booted into safe mode. 4072 */ 4073 public abstract boolean isSafeMode(); 4074 4075 /** 4076 * Return the {@link KeySet} associated with the String alias for this 4077 * application. 4078 * 4079 * @param alias The alias for a given {@link KeySet} as defined in the 4080 * application's AndroidManifest.xml. 4081 * @hide 4082 */ 4083 public abstract KeySet getKeySetByAlias(String packageName, String alias); 4084 4085 /** Return the signing {@link KeySet} for this application. 4086 * @hide 4087 */ 4088 public abstract KeySet getSigningKeySet(String packageName); 4089 4090 /** 4091 * Return whether the package denoted by packageName has been signed by all 4092 * of the keys specified by the {@link KeySet} ks. This will return true if 4093 * the package has been signed by additional keys (a superset) as well. 4094 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 4095 * @hide 4096 */ 4097 public abstract boolean isSignedBy(String packageName, KeySet ks); 4098 4099 /** 4100 * Return whether the package denoted by packageName has been signed by all 4101 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 4102 * {@link #isSignedBy(String packageName, KeySet ks)}. 4103 * @hide 4104 */ 4105 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 4106 4107 /** 4108 * Attempts to move package resources from internal to external media or vice versa. 4109 * Since this may take a little while, the result will 4110 * be posted back to the given observer. This call may fail if the calling context 4111 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the 4112 * named package cannot be found, or if the named package is a "system package". 4113 * 4114 * @param packageName The name of the package to delete 4115 * @param observer An observer callback to get notified when the package move is 4116 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be 4117 * called when that happens. observer may be null to indicate that no callback is desired. 4118 * @param flags To indicate install location {@link #MOVE_INTERNAL} or 4119 * {@link #MOVE_EXTERNAL_MEDIA} 4120 * 4121 * @hide 4122 */ 4123 @Deprecated 4124 public abstract void movePackage(String packageName, IPackageMoveObserver observer, int flags); 4125 4126 /** {@hide} */ 4127 public abstract void movePackageAndData(String packageName, String volumeUuid, 4128 IPackageMoveObserver observer); 4129 4130 /** 4131 * Returns the device identity that verifiers can use to associate their scheme to a particular 4132 * device. This should not be used by anything other than a package verifier. 4133 * 4134 * @return identity that uniquely identifies current device 4135 * @hide 4136 */ 4137 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 4138 4139 /** 4140 * Returns true if the device is upgrading, such as first boot after OTA. 4141 * 4142 * @hide 4143 */ 4144 public abstract boolean isUpgrade(); 4145 4146 /** 4147 * Return interface that offers the ability to install, upgrade, and remove 4148 * applications on the device. 4149 */ 4150 public abstract @NonNull PackageInstaller getPackageInstaller(); 4151 4152 /** 4153 * Returns the data directory for a particular package and user. 4154 * 4155 * @hide 4156 */ 4157 public static File getDataDirForUser(String volumeUuid, String packageName, int userId) { 4158 // TODO: This should be shared with Installer's knowledge of user directory 4159 final File base; 4160 if (TextUtils.isEmpty(volumeUuid)) { 4161 base = Environment.getDataDirectory(); 4162 } else { 4163 base = new File("/mnt/expand/" + volumeUuid); 4164 } 4165 return new File(base, "user/" + userId + "/" + packageName); 4166 } 4167 4168 /** 4169 * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the 4170 * user with id sourceUserId can also be be resolved by activities in the user with id 4171 * targetUserId if they match the specified intent filter. 4172 * @param filter The {@link IntentFilter} the intent has to match 4173 * @param sourceUserId The source user id. 4174 * @param targetUserId The target user id. 4175 * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE} 4176 * @hide 4177 */ 4178 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 4179 int targetUserId, int flags); 4180 4181 /** 4182 * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their 4183 * source, and have been set by the app calling this method. 4184 * @param sourceUserId The source user id. 4185 * @hide 4186 */ 4187 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 4188 4189 /** 4190 * @hide 4191 */ 4192 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 4193 4194 /** 4195 * @hide 4196 */ 4197 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 4198 4199 /** {@hide} */ 4200 public abstract boolean isPackageAvailable(String packageName); 4201 4202 /** {@hide} */ 4203 public static String installStatusToString(int status, String msg) { 4204 final String str = installStatusToString(status); 4205 if (msg != null) { 4206 return str + ": " + msg; 4207 } else { 4208 return str; 4209 } 4210 } 4211 4212 /** {@hide} */ 4213 public static String installStatusToString(int status) { 4214 switch (status) { 4215 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 4216 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 4217 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 4218 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 4219 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 4220 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 4221 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 4222 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 4223 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 4224 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 4225 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 4226 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 4227 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 4228 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 4229 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 4230 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 4231 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 4232 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 4233 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 4234 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 4235 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 4236 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 4237 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 4238 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 4239 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 4240 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 4241 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 4242 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 4243 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 4244 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 4245 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 4246 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 4247 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 4248 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 4249 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 4250 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 4251 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 4252 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 4253 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 4254 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 4255 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 4256 default: return Integer.toString(status); 4257 } 4258 } 4259 4260 /** {@hide} */ 4261 public static int installStatusToPublicStatus(int status) { 4262 switch (status) { 4263 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 4264 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4265 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 4266 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 4267 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 4268 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4269 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4270 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4271 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4272 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4273 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4274 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 4275 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4276 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4277 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4278 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 4279 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4280 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4281 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 4282 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 4283 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 4284 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 4285 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 4286 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 4287 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 4288 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 4289 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 4290 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 4291 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 4292 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 4293 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 4294 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 4295 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 4296 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 4297 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 4298 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 4299 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 4300 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4301 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4302 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4303 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 4304 default: return PackageInstaller.STATUS_FAILURE; 4305 } 4306 } 4307 4308 /** {@hide} */ 4309 public static String deleteStatusToString(int status, String msg) { 4310 final String str = deleteStatusToString(status); 4311 if (msg != null) { 4312 return str + ": " + msg; 4313 } else { 4314 return str; 4315 } 4316 } 4317 4318 /** {@hide} */ 4319 public static String deleteStatusToString(int status) { 4320 switch (status) { 4321 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 4322 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 4323 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 4324 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 4325 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 4326 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 4327 default: return Integer.toString(status); 4328 } 4329 } 4330 4331 /** {@hide} */ 4332 public static int deleteStatusToPublicStatus(int status) { 4333 switch (status) { 4334 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 4335 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 4336 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 4337 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 4338 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 4339 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 4340 default: return PackageInstaller.STATUS_FAILURE; 4341 } 4342 } 4343 4344 /** {@hide} */ 4345 public static class LegacyPackageInstallObserver extends PackageInstallObserver { 4346 private final IPackageInstallObserver mLegacy; 4347 4348 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { 4349 mLegacy = legacy; 4350 } 4351 4352 @Override 4353 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 4354 Bundle extras) { 4355 if (mLegacy == null) return; 4356 try { 4357 mLegacy.packageInstalled(basePackageName, returnCode); 4358 } catch (RemoteException ignored) { 4359 } 4360 } 4361 } 4362 4363 /** {@hide} */ 4364 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 4365 private final IPackageDeleteObserver mLegacy; 4366 4367 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 4368 mLegacy = legacy; 4369 } 4370 4371 @Override 4372 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 4373 if (mLegacy == null) return; 4374 try { 4375 mLegacy.packageDeleted(basePackageName, returnCode); 4376 } catch (RemoteException ignored) { 4377 } 4378 } 4379 } 4380} 4381