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