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