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