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