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