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