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