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