PackageManager.java revision 56f715160e12c7262502e6cf3e217c991adf7494
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 any 1767 * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION}, 1768 * or {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF} features. 1769 * 1770 * @hide 1771 */ 1772 @SdkConstant(SdkConstantType.FEATURE) 1773 public static final String FEATURE_NFC_ANY = "android.hardware.nfc.any"; 1774 1775 /** 1776 * Feature for {@link #getSystemAvailableFeatures} and 1777 * {@link #hasSystemFeature}: The device supports the OpenGL ES 1778 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 1779 * Android Extension Pack</a>. 1780 */ 1781 @SdkConstant(SdkConstantType.FEATURE) 1782 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 1783 1784 /** 1785 * Feature for {@link #getSystemAvailableFeatures} and 1786 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API 1787 * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate 1788 * what level of optional hardware features limits it supports. 1789 * <p> 1790 * Level 0 includes the base Vulkan requirements as well as: 1791 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul> 1792 * <p> 1793 * Level 1 additionally includes: 1794 * <ul> 1795 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li> 1796 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li> 1797 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li> 1798 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li> 1799 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li> 1800 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li> 1801 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li> 1802 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li> 1803 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li> 1804 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li> 1805 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li> 1806 * </ul> 1807 */ 1808 @SdkConstant(SdkConstantType.FEATURE) 1809 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level"; 1810 1811 /** 1812 * Feature for {@link #getSystemAvailableFeatures} and 1813 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API 1814 * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate 1815 * what level of optional compute features are supported beyond the Vulkan 1.0 requirements. 1816 * <p> 1817 * Compute level 0 indicates support for: 1818 * <ul> 1819 * <li>Ability to use pointers to buffer data from shaders</li> 1820 * <li>Ability to load/store 16-bit values from buffers</li> 1821 * <li>Ability to control shader floating point rounding mode</li> 1822 * </ul> 1823 */ 1824 @SdkConstant(SdkConstantType.FEATURE) 1825 public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute"; 1826 1827 /** 1828 * Feature for {@link #getSystemAvailableFeatures} and 1829 * {@link #hasSystemFeature(String, int)}: The version of this feature indicates the highest 1830 * {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices that support 1831 * the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The feature version 1832 * uses the same encoding as Vulkan version numbers: 1833 * <ul> 1834 * <li>Major version number in bits 31-22</li> 1835 * <li>Minor version number in bits 21-12</li> 1836 * <li>Patch version number in bits 11-0</li> 1837 * </ul> 1838 */ 1839 @SdkConstant(SdkConstantType.FEATURE) 1840 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version"; 1841 1842 /** 1843 * The device includes broadcast radio tuner. 1844 * 1845 * @hide FutureFeature 1846 */ 1847 @SdkConstant(SdkConstantType.FEATURE) 1848 public static final String FEATURE_RADIO = "android.hardware.radio"; 1849 1850 /** 1851 * Feature for {@link #getSystemAvailableFeatures} and 1852 * {@link #hasSystemFeature}: The device includes an accelerometer. 1853 */ 1854 @SdkConstant(SdkConstantType.FEATURE) 1855 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 1856 1857 /** 1858 * Feature for {@link #getSystemAvailableFeatures} and 1859 * {@link #hasSystemFeature}: The device includes a barometer (air 1860 * pressure sensor.) 1861 */ 1862 @SdkConstant(SdkConstantType.FEATURE) 1863 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 1864 1865 /** 1866 * Feature for {@link #getSystemAvailableFeatures} and 1867 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 1868 */ 1869 @SdkConstant(SdkConstantType.FEATURE) 1870 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 1871 1872 /** 1873 * Feature for {@link #getSystemAvailableFeatures} and 1874 * {@link #hasSystemFeature}: The device includes a gyroscope. 1875 */ 1876 @SdkConstant(SdkConstantType.FEATURE) 1877 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 1878 1879 /** 1880 * Feature for {@link #getSystemAvailableFeatures} and 1881 * {@link #hasSystemFeature}: The device includes a light sensor. 1882 */ 1883 @SdkConstant(SdkConstantType.FEATURE) 1884 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 1885 1886 /** 1887 * Feature for {@link #getSystemAvailableFeatures} and 1888 * {@link #hasSystemFeature}: The device includes a proximity sensor. 1889 */ 1890 @SdkConstant(SdkConstantType.FEATURE) 1891 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 1892 1893 /** 1894 * Feature for {@link #getSystemAvailableFeatures} and 1895 * {@link #hasSystemFeature}: The device includes a hardware step counter. 1896 */ 1897 @SdkConstant(SdkConstantType.FEATURE) 1898 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 1899 1900 /** 1901 * Feature for {@link #getSystemAvailableFeatures} and 1902 * {@link #hasSystemFeature}: The device includes a hardware step detector. 1903 */ 1904 @SdkConstant(SdkConstantType.FEATURE) 1905 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 1906 1907 /** 1908 * Feature for {@link #getSystemAvailableFeatures} and 1909 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 1910 */ 1911 @SdkConstant(SdkConstantType.FEATURE) 1912 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 1913 1914 /** 1915 * Feature for {@link #getSystemAvailableFeatures} and 1916 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram. 1917 */ 1918 @SdkConstant(SdkConstantType.FEATURE) 1919 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 1920 "android.hardware.sensor.heartrate.ecg"; 1921 1922 /** 1923 * Feature for {@link #getSystemAvailableFeatures} and 1924 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 1925 */ 1926 @SdkConstant(SdkConstantType.FEATURE) 1927 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 1928 "android.hardware.sensor.relative_humidity"; 1929 1930 /** 1931 * Feature for {@link #getSystemAvailableFeatures} and 1932 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 1933 */ 1934 @SdkConstant(SdkConstantType.FEATURE) 1935 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 1936 "android.hardware.sensor.ambient_temperature"; 1937 1938 /** 1939 * Feature for {@link #getSystemAvailableFeatures} and 1940 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing 1941 * capabilities. 1942 */ 1943 @SdkConstant(SdkConstantType.FEATURE) 1944 public static final String FEATURE_HIFI_SENSORS = 1945 "android.hardware.sensor.hifi_sensors"; 1946 1947 /** 1948 * Feature for {@link #getSystemAvailableFeatures} and 1949 * {@link #hasSystemFeature}: The device has a telephony radio with data 1950 * communication support. 1951 */ 1952 @SdkConstant(SdkConstantType.FEATURE) 1953 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 1954 1955 /** 1956 * Feature for {@link #getSystemAvailableFeatures} and 1957 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 1958 */ 1959 @SdkConstant(SdkConstantType.FEATURE) 1960 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 1961 1962 /** 1963 * Feature for {@link #getSystemAvailableFeatures} and 1964 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 1965 */ 1966 @SdkConstant(SdkConstantType.FEATURE) 1967 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 1968 1969 /** 1970 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1971 * The device supports telephony carrier restriction mechanism. 1972 * 1973 * <p>Devices declaring this feature must have an implementation of the 1974 * {@link android.telephony.TelephonyManager#getAllowedCarriers} and 1975 * {@link android.telephony.TelephonyManager#setAllowedCarriers}. 1976 * @hide 1977 */ 1978 @SystemApi 1979 @SdkConstant(SdkConstantType.FEATURE) 1980 public static final String FEATURE_TELEPHONY_CARRIERLOCK = 1981 "android.hardware.telephony.carrierlock"; 1982 1983 /** 1984 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 1985 * supports embedded subscriptions on eUICCs. 1986 * TODO(b/35851809): Make this public. 1987 * @hide 1988 */ 1989 @SdkConstant(SdkConstantType.FEATURE) 1990 public static final String FEATURE_TELEPHONY_EUICC = "android.hardware.telephony.euicc"; 1991 1992 /** 1993 * Feature for {@link #getSystemAvailableFeatures} and 1994 * {@link #hasSystemFeature}: The device supports connecting to USB devices 1995 * as the USB host. 1996 */ 1997 @SdkConstant(SdkConstantType.FEATURE) 1998 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 1999 2000 /** 2001 * Feature for {@link #getSystemAvailableFeatures} and 2002 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 2003 */ 2004 @SdkConstant(SdkConstantType.FEATURE) 2005 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 2006 2007 /** 2008 * Feature for {@link #getSystemAvailableFeatures} and 2009 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 2010 */ 2011 @SdkConstant(SdkConstantType.FEATURE) 2012 public static final String FEATURE_SIP = "android.software.sip"; 2013 2014 /** 2015 * Feature for {@link #getSystemAvailableFeatures} and 2016 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 2017 */ 2018 @SdkConstant(SdkConstantType.FEATURE) 2019 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 2020 2021 /** 2022 * Feature for {@link #getSystemAvailableFeatures} and 2023 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device. 2024 */ 2025 @SdkConstant(SdkConstantType.FEATURE) 2026 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice"; 2027 2028 /** 2029 * Feature for {@link #getSystemAvailableFeatures} and 2030 * {@link #hasSystemFeature}: The device's display has a touch screen. 2031 */ 2032 @SdkConstant(SdkConstantType.FEATURE) 2033 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 2034 2035 /** 2036 * Feature for {@link #getSystemAvailableFeatures} and 2037 * {@link #hasSystemFeature}: The device's touch screen supports 2038 * multitouch sufficient for basic two-finger gesture detection. 2039 */ 2040 @SdkConstant(SdkConstantType.FEATURE) 2041 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 2042 2043 /** 2044 * Feature for {@link #getSystemAvailableFeatures} and 2045 * {@link #hasSystemFeature}: The device's touch screen is capable of 2046 * tracking two or more fingers fully independently. 2047 */ 2048 @SdkConstant(SdkConstantType.FEATURE) 2049 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 2050 2051 /** 2052 * Feature for {@link #getSystemAvailableFeatures} and 2053 * {@link #hasSystemFeature}: The device's touch screen is capable of 2054 * tracking a full hand of fingers fully independently -- that is, 5 or 2055 * more simultaneous independent pointers. 2056 */ 2057 @SdkConstant(SdkConstantType.FEATURE) 2058 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 2059 2060 /** 2061 * Feature for {@link #getSystemAvailableFeatures} and 2062 * {@link #hasSystemFeature}: The device does not have a touch screen, but 2063 * does support touch emulation for basic events. For instance, the 2064 * device might use a mouse or remote control to drive a cursor, and 2065 * emulate basic touch pointer events like down, up, drag, etc. All 2066 * devices that support android.hardware.touchscreen or a sub-feature are 2067 * presumed to also support faketouch. 2068 */ 2069 @SdkConstant(SdkConstantType.FEATURE) 2070 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 2071 2072 /** 2073 * Feature for {@link #getSystemAvailableFeatures} and 2074 * {@link #hasSystemFeature}: The device does not have a touch screen, but 2075 * does support touch emulation for basic events that supports distinct 2076 * tracking of two or more fingers. This is an extension of 2077 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 2078 * that unlike a distinct multitouch screen as defined by 2079 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 2080 * devices will not actually provide full two-finger gestures since the 2081 * input is being transformed to cursor movement on the screen. That is, 2082 * single finger gestures will move a cursor; two-finger swipes will 2083 * result in single-finger touch events; other two-finger gestures will 2084 * result in the corresponding two-finger touch event. 2085 */ 2086 @SdkConstant(SdkConstantType.FEATURE) 2087 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 2088 2089 /** 2090 * Feature for {@link #getSystemAvailableFeatures} and 2091 * {@link #hasSystemFeature}: The device does not have a touch screen, but 2092 * does support touch emulation for basic events that supports tracking 2093 * a hand of fingers (5 or more fingers) fully independently. 2094 * This is an extension of 2095 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 2096 * that unlike a multitouch screen as defined by 2097 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 2098 * gestures can be detected due to the limitations described for 2099 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 2100 */ 2101 @SdkConstant(SdkConstantType.FEATURE) 2102 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 2103 2104 /** 2105 * Feature for {@link #getSystemAvailableFeatures} and 2106 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint. 2107 */ 2108 @SdkConstant(SdkConstantType.FEATURE) 2109 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; 2110 2111 /** 2112 * Feature for {@link #getSystemAvailableFeatures} and 2113 * {@link #hasSystemFeature}: The device supports portrait orientation 2114 * screens. For backwards compatibility, you can assume that if neither 2115 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 2116 * both portrait and landscape. 2117 */ 2118 @SdkConstant(SdkConstantType.FEATURE) 2119 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 2120 2121 /** 2122 * Feature for {@link #getSystemAvailableFeatures} and 2123 * {@link #hasSystemFeature}: The device supports landscape orientation 2124 * screens. For backwards compatibility, you can assume that if neither 2125 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 2126 * both portrait and landscape. 2127 */ 2128 @SdkConstant(SdkConstantType.FEATURE) 2129 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 2130 2131 /** 2132 * Feature for {@link #getSystemAvailableFeatures} and 2133 * {@link #hasSystemFeature}: The device supports live wallpapers. 2134 */ 2135 @SdkConstant(SdkConstantType.FEATURE) 2136 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 2137 /** 2138 * Feature for {@link #getSystemAvailableFeatures} and 2139 * {@link #hasSystemFeature}: The device supports app widgets. 2140 */ 2141 @SdkConstant(SdkConstantType.FEATURE) 2142 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 2143 2144 /** 2145 * @hide 2146 * Feature for {@link #getSystemAvailableFeatures} and 2147 * {@link #hasSystemFeature}: The device supports 2148 * {@link android.service.voice.VoiceInteractionService} and 2149 * {@link android.app.VoiceInteractor}. 2150 */ 2151 @SdkConstant(SdkConstantType.FEATURE) 2152 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 2153 2154 2155 /** 2156 * Feature for {@link #getSystemAvailableFeatures} and 2157 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 2158 * by third party applications. 2159 */ 2160 @SdkConstant(SdkConstantType.FEATURE) 2161 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 2162 2163 /** 2164 * Feature for {@link #getSystemAvailableFeatures} and 2165 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 2166 * with the {@link android.inputmethodservice.InputMethodService} API. 2167 */ 2168 @SdkConstant(SdkConstantType.FEATURE) 2169 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 2170 2171 /** 2172 * Feature for {@link #getSystemAvailableFeatures} and 2173 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 2174 */ 2175 @SdkConstant(SdkConstantType.FEATURE) 2176 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 2177 2178 /** 2179 * Feature for {@link #getSystemAvailableFeatures} and 2180 * {@link #hasSystemFeature}: The device supports leanback UI. This is 2181 * typically used in a living room television experience, but is a software 2182 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 2183 * feature will use resources associated with the "television" UI mode. 2184 */ 2185 @SdkConstant(SdkConstantType.FEATURE) 2186 public static final String FEATURE_LEANBACK = "android.software.leanback"; 2187 2188 /** 2189 * Feature for {@link #getSystemAvailableFeatures} and 2190 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 2191 * applications designed for this experience should be run, though this is 2192 * not enforced by the system. 2193 */ 2194 @SdkConstant(SdkConstantType.FEATURE) 2195 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 2196 2197 /** 2198 * Feature for {@link #getSystemAvailableFeatures} and 2199 * {@link #hasSystemFeature}: The device supports live TV and can display 2200 * contents from TV inputs implemented with the 2201 * {@link android.media.tv.TvInputService} API. 2202 */ 2203 @SdkConstant(SdkConstantType.FEATURE) 2204 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 2205 2206 /** 2207 * Feature for {@link #getSystemAvailableFeatures} and 2208 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 2209 */ 2210 @SdkConstant(SdkConstantType.FEATURE) 2211 public static final String FEATURE_WIFI = "android.hardware.wifi"; 2212 2213 /** 2214 * Feature for {@link #getSystemAvailableFeatures} and 2215 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 2216 */ 2217 @SdkConstant(SdkConstantType.FEATURE) 2218 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 2219 2220 /** 2221 * Feature for {@link #getSystemAvailableFeatures} and 2222 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware. 2223 */ 2224 @SdkConstant(SdkConstantType.FEATURE) 2225 public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware"; 2226 2227 /** 2228 * Feature for {@link #getSystemAvailableFeatures} and 2229 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 2230 * on a vehicle headunit. A headunit here is defined to be inside a 2231 * vehicle that may or may not be moving. A headunit uses either a 2232 * primary display in the center console and/or additional displays in 2233 * the instrument cluster or elsewhere in the vehicle. Headunit display(s) 2234 * have limited size and resolution. The user will likely be focused on 2235 * driving so limiting driver distraction is a primary concern. User input 2236 * can be a variety of hard buttons, touch, rotary controllers and even mouse- 2237 * like interfaces. 2238 */ 2239 @SdkConstant(SdkConstantType.FEATURE) 2240 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive"; 2241 2242 /** 2243 * Feature for {@link #getSystemAvailableFeatures} and 2244 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 2245 * on a television. Television here is defined to be a typical living 2246 * room television experience: displayed on a big screen, where the user 2247 * is sitting far away from it, and the dominant form of input will be 2248 * something like a DPAD, not through touch or mouse. 2249 * @deprecated use {@link #FEATURE_LEANBACK} instead. 2250 */ 2251 @Deprecated 2252 @SdkConstant(SdkConstantType.FEATURE) 2253 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 2254 2255 /** 2256 * Feature for {@link #getSystemAvailableFeatures} and 2257 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 2258 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 2259 * the wrist. The user is very close when interacting with the device. 2260 */ 2261 @SdkConstant(SdkConstantType.FEATURE) 2262 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 2263 2264 /** 2265 * Feature for {@link #getSystemAvailableFeatures} and 2266 * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded 2267 * device is defined as a full stack Android device with or without a display and no 2268 * user-installable apps. 2269 */ 2270 @SdkConstant(SdkConstantType.FEATURE) 2271 public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded"; 2272 2273 /** 2274 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2275 * The device supports printing. 2276 */ 2277 @SdkConstant(SdkConstantType.FEATURE) 2278 public static final String FEATURE_PRINTING = "android.software.print"; 2279 2280 /** 2281 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2282 * The device supports {@link android.companion.CompanionDeviceManager#associate associating} 2283 * with devices via {@link android.companion.CompanionDeviceManager}. 2284 */ 2285 @SdkConstant(SdkConstantType.FEATURE) 2286 public static final String FEATURE_COMPANION_DEVICE_SETUP 2287 = "android.software.companion_device_setup"; 2288 2289 /** 2290 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2291 * The device can perform backup and restore operations on installed applications. 2292 */ 2293 @SdkConstant(SdkConstantType.FEATURE) 2294 public static final String FEATURE_BACKUP = "android.software.backup"; 2295 2296 /** 2297 * Feature for {@link #getSystemAvailableFeatures} and 2298 * {@link #hasSystemFeature}: The device supports freeform window management. 2299 * Windows have title bars and can be moved and resized. 2300 */ 2301 // If this feature is present, you also need to set 2302 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay. 2303 @SdkConstant(SdkConstantType.FEATURE) 2304 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT 2305 = "android.software.freeform_window_management"; 2306 2307 /** 2308 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2309 * The device supports picture-in-picture multi-window mode. 2310 */ 2311 @SdkConstant(SdkConstantType.FEATURE) 2312 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; 2313 2314 /** 2315 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2316 * The device supports running activities on secondary displays. 2317 */ 2318 @SdkConstant(SdkConstantType.FEATURE) 2319 public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS 2320 = "android.software.activities_on_secondary_displays"; 2321 2322 /** 2323 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2324 * The device supports creating secondary users and managed profiles via 2325 * {@link DevicePolicyManager}. 2326 */ 2327 @SdkConstant(SdkConstantType.FEATURE) 2328 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 2329 2330 /** 2331 * @hide 2332 * TODO: Remove after dependencies updated b/17392243 2333 */ 2334 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 2335 2336 /** 2337 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2338 * The device supports verified boot. 2339 */ 2340 @SdkConstant(SdkConstantType.FEATURE) 2341 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 2342 2343 /** 2344 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2345 * The device supports secure removal of users. When a user is deleted the data associated 2346 * with that user is securely deleted and no longer available. 2347 */ 2348 @SdkConstant(SdkConstantType.FEATURE) 2349 public static final String FEATURE_SECURELY_REMOVES_USERS 2350 = "android.software.securely_removes_users"; 2351 2352 /** {@hide} */ 2353 @SdkConstant(SdkConstantType.FEATURE) 2354 public static final String FEATURE_FILE_BASED_ENCRYPTION 2355 = "android.software.file_based_encryption"; 2356 2357 /** 2358 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2359 * The device has a full implementation of the android.webkit.* APIs. Devices 2360 * lacking this feature will not have a functioning WebView implementation. 2361 */ 2362 @SdkConstant(SdkConstantType.FEATURE) 2363 public static final String FEATURE_WEBVIEW = "android.software.webview"; 2364 2365 /** 2366 * Feature for {@link #getSystemAvailableFeatures} and 2367 * {@link #hasSystemFeature}: This device supports ethernet. 2368 */ 2369 @SdkConstant(SdkConstantType.FEATURE) 2370 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 2371 2372 /** 2373 * Feature for {@link #getSystemAvailableFeatures} and 2374 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 2375 * @hide 2376 */ 2377 @SdkConstant(SdkConstantType.FEATURE) 2378 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 2379 2380 /** 2381 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2382 * The device has all of the inputs necessary to be considered a compatible game controller, or 2383 * includes a compatible game controller in the box. 2384 */ 2385 @SdkConstant(SdkConstantType.FEATURE) 2386 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 2387 2388 /** 2389 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2390 * The device has a full implementation of the android.media.midi.* APIs. 2391 */ 2392 @SdkConstant(SdkConstantType.FEATURE) 2393 public static final String FEATURE_MIDI = "android.software.midi"; 2394 2395 /** 2396 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2397 * The device implements an optimized mode for virtual reality (VR) applications that handles 2398 * stereoscopic rendering of notifications, and disables most monocular system UI components 2399 * while a VR application has user focus. 2400 * Devices declaring this feature must include an application implementing a 2401 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 2402 * {@link android.app.Activity#setVrModeEnabled}. 2403 */ 2404 @SdkConstant(SdkConstantType.FEATURE) 2405 public static final String FEATURE_VR_MODE = "android.software.vr.mode"; 2406 2407 /** 2408 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2409 * The device implements {@link #FEATURE_VR_MODE} but additionally meets extra CDD requirements 2410 * to provide a high-quality VR experience. In general, devices declaring this feature will 2411 * additionally: 2412 * <ul> 2413 * <li>Deliver consistent performance at a high framerate over an extended period of time 2414 * for typical VR application CPU/GPU workloads with a minimal number of frame drops for VR 2415 * applications that have called 2416 * {@link android.view.Window#setSustainedPerformanceMode}.</li> 2417 * <li>Implement {@link #FEATURE_HIFI_SENSORS} and have a low sensor latency.</li> 2418 * <li>Include optimizations to lower display persistence while running VR applications.</li> 2419 * <li>Implement an optimized render path to minimize latency to draw to the device's main 2420 * display.</li> 2421 * <li>Include the following EGL extensions: EGL_ANDROID_create_native_client_buffer, 2422 * EGL_ANDROID_front_buffer_auto_refresh, EGL_EXT_protected_content, 2423 * EGL_KHR_mutable_render_buffer, EGL_KHR_reusable_sync, and EGL_KHR_wait_sync.</li> 2424 * <li>Provide at least one CPU core that is reserved for use solely by the top, foreground 2425 * VR application process for critical render threads while such an application is 2426 * running.</li> 2427 * </ul> 2428 */ 2429 @SdkConstant(SdkConstantType.FEATURE) 2430 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE 2431 = "android.hardware.vr.high_performance"; 2432 2433 /** 2434 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2435 * The device supports autofill of user credentials, addresses, credit cards, etc 2436 * via integration with {@link android.service.autofill.AutofillService autofill 2437 * providers}. 2438 */ 2439 @SdkConstant(SdkConstantType.FEATURE) 2440 public static final String FEATURE_AUTOFILL = "android.software.autofill"; 2441 2442 /** 2443 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2444 * The device implements headtracking suitable for a VR device. 2445 */ 2446 @SdkConstant(SdkConstantType.FEATURE) 2447 public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking"; 2448 2449 /** 2450 * Action to external storage service to clean out removed apps. 2451 * @hide 2452 */ 2453 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 2454 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 2455 2456 /** 2457 * Extra field name for the URI to a verification file. Passed to a package 2458 * verifier. 2459 * 2460 * @hide 2461 */ 2462 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 2463 2464 /** 2465 * Extra field name for the ID of a package pending verification. Passed to 2466 * a package verifier and is used to call back to 2467 * {@link PackageManager#verifyPendingInstall(int, int)} 2468 */ 2469 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 2470 2471 /** 2472 * Extra field name for the package identifier which is trying to install 2473 * the package. 2474 * 2475 * @hide 2476 */ 2477 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 2478 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 2479 2480 /** 2481 * Extra field name for the requested install flags for a package pending 2482 * verification. Passed to a package verifier. 2483 * 2484 * @hide 2485 */ 2486 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 2487 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 2488 2489 /** 2490 * Extra field name for the uid of who is requesting to install 2491 * the package. 2492 * 2493 * @hide 2494 */ 2495 public static final String EXTRA_VERIFICATION_INSTALLER_UID 2496 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 2497 2498 /** 2499 * Extra field name for the package name of a package pending verification. 2500 * 2501 * @hide 2502 */ 2503 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 2504 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 2505 /** 2506 * Extra field name for the result of a verification, either 2507 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 2508 * Passed to package verifiers after a package is verified. 2509 */ 2510 public static final String EXTRA_VERIFICATION_RESULT 2511 = "android.content.pm.extra.VERIFICATION_RESULT"; 2512 2513 /** 2514 * Extra field name for the version code of a package pending verification. 2515 * 2516 * @hide 2517 */ 2518 public static final String EXTRA_VERIFICATION_VERSION_CODE 2519 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 2520 2521 /** 2522 * Extra field name for the ID of a intent filter pending verification. 2523 * Passed to an intent filter verifier and is used to call back to 2524 * {@link #verifyIntentFilter} 2525 * 2526 * @hide 2527 */ 2528 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 2529 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 2530 2531 /** 2532 * Extra field name for the scheme used for an intent filter pending verification. Passed to 2533 * an intent filter verifier and is used to construct the URI to verify against. 2534 * 2535 * Usually this is "https" 2536 * 2537 * @hide 2538 */ 2539 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 2540 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 2541 2542 /** 2543 * Extra field name for the host names to be used for an intent filter pending verification. 2544 * Passed to an intent filter verifier and is used to construct the URI to verify the 2545 * intent filter. 2546 * 2547 * This is a space delimited list of hosts. 2548 * 2549 * @hide 2550 */ 2551 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 2552 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 2553 2554 /** 2555 * Extra field name for the package name to be used for an intent filter pending verification. 2556 * Passed to an intent filter verifier and is used to check the verification responses coming 2557 * from the hosts. Each host response will need to include the package name of APK containing 2558 * the intent filter. 2559 * 2560 * @hide 2561 */ 2562 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 2563 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 2564 2565 /** 2566 * The action used to request that the user approve a permission request 2567 * from the application. 2568 * 2569 * @hide 2570 */ 2571 @SystemApi 2572 public static final String ACTION_REQUEST_PERMISSIONS = 2573 "android.content.pm.action.REQUEST_PERMISSIONS"; 2574 2575 /** 2576 * The names of the requested permissions. 2577 * <p> 2578 * <strong>Type:</strong> String[] 2579 * </p> 2580 * 2581 * @hide 2582 */ 2583 @SystemApi 2584 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 2585 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 2586 2587 /** 2588 * The results from the permissions request. 2589 * <p> 2590 * <strong>Type:</strong> int[] of #PermissionResult 2591 * </p> 2592 * 2593 * @hide 2594 */ 2595 @SystemApi 2596 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 2597 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 2598 2599 /** 2600 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2601 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 2602 * the existing definition for the permission. 2603 * @hide 2604 */ 2605 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 2606 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 2607 2608 /** 2609 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2610 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 2611 * being redundantly defined by the package being installed. 2612 * @hide 2613 */ 2614 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 2615 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 2616 2617 /** 2618 * Permission flag: The permission is set in its current state 2619 * by the user and apps can still request it at runtime. 2620 * 2621 * @hide 2622 */ 2623 @SystemApi 2624 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 2625 2626 /** 2627 * Permission flag: The permission is set in its current state 2628 * by the user and it is fixed, i.e. apps can no longer request 2629 * this permission. 2630 * 2631 * @hide 2632 */ 2633 @SystemApi 2634 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 2635 2636 /** 2637 * Permission flag: The permission is set in its current state 2638 * by device policy and neither apps nor the user can change 2639 * its state. 2640 * 2641 * @hide 2642 */ 2643 @SystemApi 2644 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 2645 2646 /** 2647 * Permission flag: The permission is set in a granted state but 2648 * access to resources it guards is restricted by other means to 2649 * enable revoking a permission on legacy apps that do not support 2650 * runtime permissions. If this permission is upgraded to runtime 2651 * because the app was updated to support runtime permissions, the 2652 * the permission will be revoked in the upgrade process. 2653 * 2654 * @hide 2655 */ 2656 @SystemApi 2657 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 2658 2659 /** 2660 * Permission flag: The permission is set in its current state 2661 * because the app is a component that is a part of the system. 2662 * 2663 * @hide 2664 */ 2665 @SystemApi 2666 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 2667 2668 /** 2669 * Permission flag: The permission is granted by default because it 2670 * enables app functionality that is expected to work out-of-the-box 2671 * for providing a smooth user experience. For example, the phone app 2672 * is expected to have the phone permission. 2673 * 2674 * @hide 2675 */ 2676 @SystemApi 2677 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 2678 2679 /** 2680 * Permission flag: The permission has to be reviewed before any of 2681 * the app components can run. 2682 * 2683 * @hide 2684 */ 2685 @SystemApi 2686 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 2687 2688 /** 2689 * Mask for all permission flags. 2690 * 2691 * @hide 2692 */ 2693 @SystemApi 2694 public static final int MASK_PERMISSION_FLAGS = 0xFF; 2695 2696 /** 2697 * This is a library that contains components apps can invoke. For 2698 * example, a services for apps to bind to, or standard chooser UI, 2699 * etc. This library is versioned and backwards compatible. Clients 2700 * should check its version via {@link android.ext.services.Version 2701 * #getVersionCode()} and avoid calling APIs added in later versions. 2702 * 2703 * @hide 2704 */ 2705 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services"; 2706 2707 /** 2708 * This is a library that contains components apps can dynamically 2709 * load. For example, new widgets, helper classes, etc. This library 2710 * is versioned and backwards compatible. Clients should check its 2711 * version via {@link android.ext.shared.Version#getVersionCode()} 2712 * and avoid calling APIs added in later versions. 2713 * 2714 * @hide 2715 */ 2716 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared"; 2717 2718 /** 2719 * Used when starting a process for an Activity. 2720 * 2721 * @hide 2722 */ 2723 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0; 2724 2725 /** 2726 * Used when starting a process for a Service. 2727 * 2728 * @hide 2729 */ 2730 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1; 2731 2732 /** 2733 * Used when moving a Service to the foreground. 2734 * 2735 * @hide 2736 */ 2737 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2; 2738 2739 /** 2740 * Used when starting a process for a BroadcastReceiver. 2741 * 2742 * @hide 2743 */ 2744 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3; 2745 2746 /** 2747 * Used when starting a process for a ContentProvider. 2748 * 2749 * @hide 2750 */ 2751 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4; 2752 2753 /** 2754 * Used when starting a process for a BroadcastReceiver. 2755 * 2756 * @hide 2757 */ 2758 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5; 2759 2760 /** 2761 * Used with Context.getClassLoader() across Android packages. 2762 * 2763 * @hide 2764 */ 2765 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6; 2766 2767 /** 2768 * Used when starting a package within a process for Instrumentation. 2769 * 2770 * @hide 2771 */ 2772 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7; 2773 2774 /** 2775 * Total number of usage reasons. 2776 * 2777 * @hide 2778 */ 2779 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8; 2780 2781 /** 2782 * Constant for specifying the highest installed package version code. 2783 */ 2784 public static final int VERSION_CODE_HIGHEST = -1; 2785 2786 /** 2787 * Retrieve overall information about an application package that is 2788 * installed on the system. 2789 * 2790 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2791 * desired package. 2792 * @param flags Additional option flags. Use any combination of 2793 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2794 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2795 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2796 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2797 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2798 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2799 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2800 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2801 * {@link #MATCH_UNINSTALLED_PACKAGES} 2802 * to modify the data returned. 2803 * 2804 * @return A PackageInfo object containing information about the 2805 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2806 * package is not found in the list of installed applications, the 2807 * package information is retrieved from the list of uninstalled 2808 * applications (which includes installed applications as well as 2809 * applications with data directory i.e. applications which had been 2810 * deleted with {@code DONT_DELETE_DATA} flag set). 2811 * @throws NameNotFoundException if a package with the given name cannot be 2812 * found on the system. 2813 * @see #GET_ACTIVITIES 2814 * @see #GET_CONFIGURATIONS 2815 * @see #GET_GIDS 2816 * @see #GET_INSTRUMENTATION 2817 * @see #GET_INTENT_FILTERS 2818 * @see #GET_META_DATA 2819 * @see #GET_PERMISSIONS 2820 * @see #GET_PROVIDERS 2821 * @see #GET_RECEIVERS 2822 * @see #GET_SERVICES 2823 * @see #GET_SHARED_LIBRARY_FILES 2824 * @see #GET_SIGNATURES 2825 * @see #GET_URI_PERMISSION_PATTERNS 2826 * @see #MATCH_DISABLED_COMPONENTS 2827 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2828 * @see #MATCH_UNINSTALLED_PACKAGES 2829 */ 2830 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) 2831 throws NameNotFoundException; 2832 2833 /** 2834 * Retrieve overall information about an application package that is 2835 * installed on the system. This method can be used for retrieving 2836 * information about packages for which multiple versions can be 2837 * installed at the time. Currently only packages hosting static shared 2838 * libraries can have multiple installed versions. The method can also 2839 * be used to get info for a package that has a single version installed 2840 * by passing {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage} 2841 * constructor. 2842 * 2843 * @param versionedPackage The versioned packages for which to query. 2844 * @param flags Additional option flags. Use any combination of 2845 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2846 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2847 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2848 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2849 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2850 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2851 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2852 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2853 * {@link #MATCH_UNINSTALLED_PACKAGES} 2854 * to modify the data returned. 2855 * 2856 * @return A PackageInfo object containing information about the 2857 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2858 * package is not found in the list of installed applications, the 2859 * package information is retrieved from the list of uninstalled 2860 * applications (which includes installed applications as well as 2861 * applications with data directory i.e. applications which had been 2862 * deleted with {@code DONT_DELETE_DATA} flag set). 2863 * @throws NameNotFoundException if a package with the given name cannot be 2864 * found on the system. 2865 * @see #GET_ACTIVITIES 2866 * @see #GET_CONFIGURATIONS 2867 * @see #GET_GIDS 2868 * @see #GET_INSTRUMENTATION 2869 * @see #GET_INTENT_FILTERS 2870 * @see #GET_META_DATA 2871 * @see #GET_PERMISSIONS 2872 * @see #GET_PROVIDERS 2873 * @see #GET_RECEIVERS 2874 * @see #GET_SERVICES 2875 * @see #GET_SHARED_LIBRARY_FILES 2876 * @see #GET_SIGNATURES 2877 * @see #GET_URI_PERMISSION_PATTERNS 2878 * @see #MATCH_DISABLED_COMPONENTS 2879 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2880 * @see #MATCH_UNINSTALLED_PACKAGES 2881 */ 2882 public abstract PackageInfo getPackageInfo(VersionedPackage versionedPackage, 2883 @PackageInfoFlags int flags) throws NameNotFoundException; 2884 2885 /** 2886 * Retrieve overall information about an application package that is 2887 * installed on the system. 2888 * 2889 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2890 * desired package. 2891 * @param flags Additional option flags. Use any combination of 2892 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2893 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2894 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2895 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2896 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2897 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2898 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2899 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2900 * {@link #MATCH_UNINSTALLED_PACKAGES} 2901 * to modify the data returned. 2902 * @param userId The user id. 2903 * 2904 * @return A PackageInfo object containing information about the 2905 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2906 * package is not found in the list of installed applications, the 2907 * package information is retrieved from the list of uninstalled 2908 * applications (which includes installed applications as well as 2909 * applications with data directory i.e. applications which had been 2910 * deleted with {@code DONT_DELETE_DATA} flag set). 2911 * @throws NameNotFoundException if a package with the given name cannot be 2912 * found on the system. 2913 * @see #GET_ACTIVITIES 2914 * @see #GET_CONFIGURATIONS 2915 * @see #GET_GIDS 2916 * @see #GET_INSTRUMENTATION 2917 * @see #GET_INTENT_FILTERS 2918 * @see #GET_META_DATA 2919 * @see #GET_PERMISSIONS 2920 * @see #GET_PROVIDERS 2921 * @see #GET_RECEIVERS 2922 * @see #GET_SERVICES 2923 * @see #GET_SHARED_LIBRARY_FILES 2924 * @see #GET_SIGNATURES 2925 * @see #GET_URI_PERMISSION_PATTERNS 2926 * @see #MATCH_DISABLED_COMPONENTS 2927 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2928 * @see #MATCH_UNINSTALLED_PACKAGES 2929 * 2930 * @hide 2931 */ 2932 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 2933 public abstract PackageInfo getPackageInfoAsUser(String packageName, 2934 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 2935 2936 /** 2937 * Map from the current package names in use on the device to whatever 2938 * the current canonical name of that package is. 2939 * @param names Array of current names to be mapped. 2940 * @return Returns an array of the same size as the original, containing 2941 * the canonical name for each package. 2942 */ 2943 public abstract String[] currentToCanonicalPackageNames(String[] names); 2944 2945 /** 2946 * Map from a packages canonical name to the current name in use on the device. 2947 * @param names Array of new names to be mapped. 2948 * @return Returns an array of the same size as the original, containing 2949 * the current name for each package. 2950 */ 2951 public abstract String[] canonicalToCurrentPackageNames(String[] names); 2952 2953 /** 2954 * Returns a "good" intent to launch a front-door activity in a package. 2955 * This is used, for example, to implement an "open" button when browsing 2956 * through packages. The current implementation looks first for a main 2957 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 2958 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 2959 * <code>null</code> if neither are found. 2960 * 2961 * @param packageName The name of the package to inspect. 2962 * 2963 * @return A fully-qualified {@link Intent} that can be used to launch the 2964 * main activity in the package. Returns <code>null</code> if the package 2965 * does not contain such an activity, or if <em>packageName</em> is not 2966 * recognized. 2967 */ 2968 public abstract Intent getLaunchIntentForPackage(String packageName); 2969 2970 /** 2971 * Return a "good" intent to launch a front-door Leanback activity in a 2972 * package, for use for example to implement an "open" button when browsing 2973 * through packages. The current implementation will look for a main 2974 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 2975 * return null if no main leanback activities are found. 2976 * 2977 * @param packageName The name of the package to inspect. 2978 * @return Returns either a fully-qualified Intent that can be used to launch 2979 * the main Leanback activity in the package, or null if the package 2980 * does not contain such an activity. 2981 */ 2982 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName); 2983 2984 /** 2985 * Return an array of all of the POSIX secondary group IDs that have been 2986 * assigned to the given package. 2987 * <p> 2988 * Note that the same package may have different GIDs under different 2989 * {@link UserHandle} on the same device. 2990 * 2991 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2992 * desired package. 2993 * @return Returns an int array of the assigned GIDs, or null if there are 2994 * none. 2995 * @throws NameNotFoundException if a package with the given name cannot be 2996 * found on the system. 2997 */ 2998 public abstract int[] getPackageGids(String packageName) 2999 throws NameNotFoundException; 3000 3001 /** 3002 * Return an array of all of the POSIX secondary group IDs that have been 3003 * assigned to the given package. 3004 * <p> 3005 * Note that the same package may have different GIDs under different 3006 * {@link UserHandle} on the same device. 3007 * 3008 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3009 * desired package. 3010 * @return Returns an int array of the assigned gids, or null if there are 3011 * none. 3012 * @throws NameNotFoundException if a package with the given name cannot be 3013 * found on the system. 3014 */ 3015 public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags) 3016 throws NameNotFoundException; 3017 3018 /** 3019 * Return the UID associated with the given package name. 3020 * <p> 3021 * Note that the same package will have different UIDs under different 3022 * {@link UserHandle} on the same device. 3023 * 3024 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3025 * desired package. 3026 * @return Returns an integer UID who owns the given package name. 3027 * @throws NameNotFoundException if a package with the given name can not be 3028 * found on the system. 3029 */ 3030 public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags) 3031 throws NameNotFoundException; 3032 3033 /** 3034 * Return the UID associated with the given package name. 3035 * <p> 3036 * Note that the same package will have different UIDs under different 3037 * {@link UserHandle} on the same device. 3038 * 3039 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3040 * desired package. 3041 * @param userId The user handle identifier to look up the package under. 3042 * @return Returns an integer UID who owns the given package name. 3043 * @throws NameNotFoundException if a package with the given name can not be 3044 * found on the system. 3045 * @hide 3046 */ 3047 public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId) 3048 throws NameNotFoundException; 3049 3050 /** 3051 * Return the UID associated with the given package name. 3052 * <p> 3053 * Note that the same package will have different UIDs under different 3054 * {@link UserHandle} on the same device. 3055 * 3056 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3057 * desired package. 3058 * @param userId The user handle identifier to look up the package under. 3059 * @return Returns an integer UID who owns the given package name. 3060 * @throws NameNotFoundException if a package with the given name can not be 3061 * found on the system. 3062 * @hide 3063 */ 3064 public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags, 3065 @UserIdInt int userId) throws NameNotFoundException; 3066 3067 /** 3068 * Retrieve all of the information we know about a particular permission. 3069 * 3070 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 3071 * of the permission you are interested in. 3072 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 3073 * retrieve any meta-data associated with the permission. 3074 * 3075 * @return Returns a {@link PermissionInfo} containing information about the 3076 * permission. 3077 * @throws NameNotFoundException if a package with the given name cannot be 3078 * found on the system. 3079 * 3080 * @see #GET_META_DATA 3081 */ 3082 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags) 3083 throws NameNotFoundException; 3084 3085 /** 3086 * Query for all of the permissions associated with a particular group. 3087 * 3088 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 3089 * of the permission group you are interested in. Use null to 3090 * find all of the permissions not associated with a group. 3091 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 3092 * retrieve any meta-data associated with the permissions. 3093 * 3094 * @return Returns a list of {@link PermissionInfo} containing information 3095 * about all of the permissions in the given group. 3096 * @throws NameNotFoundException if a package with the given name cannot be 3097 * found on the system. 3098 * 3099 * @see #GET_META_DATA 3100 */ 3101 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 3102 @PermissionInfoFlags int flags) throws NameNotFoundException; 3103 3104 /** 3105 * Returns true if Permission Review Mode is enabled, false otherwise. 3106 * 3107 * @hide 3108 */ 3109 @TestApi 3110 public abstract boolean isPermissionReviewModeEnabled(); 3111 3112 /** 3113 * Retrieve all of the information we know about a particular group of 3114 * permissions. 3115 * 3116 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 3117 * of the permission you are interested in. 3118 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 3119 * retrieve any meta-data associated with the permission group. 3120 * 3121 * @return Returns a {@link PermissionGroupInfo} containing information 3122 * about the permission. 3123 * @throws NameNotFoundException if a package with the given name cannot be 3124 * found on the system. 3125 * 3126 * @see #GET_META_DATA 3127 */ 3128 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 3129 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 3130 3131 /** 3132 * Retrieve all of the known permission groups in the system. 3133 * 3134 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 3135 * retrieve any meta-data associated with the permission group. 3136 * 3137 * @return Returns a list of {@link PermissionGroupInfo} containing 3138 * information about all of the known permission groups. 3139 * 3140 * @see #GET_META_DATA 3141 */ 3142 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 3143 @PermissionGroupInfoFlags int flags); 3144 3145 /** 3146 * Retrieve all of the information we know about a particular 3147 * package/application. 3148 * 3149 * @param packageName The full name (i.e. com.google.apps.contacts) of an 3150 * application. 3151 * @param flags Additional option flags. Use any combination of 3152 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3153 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3154 * to modify the data returned. 3155 * 3156 * @return An {@link ApplicationInfo} containing information about the 3157 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 3158 * package is not found in the list of installed applications, the 3159 * application information is retrieved from the list of uninstalled 3160 * applications (which includes installed applications as well as 3161 * applications with data directory i.e. applications which had been 3162 * deleted with {@code DONT_DELETE_DATA} flag set). 3163 * @throws NameNotFoundException if a package with the given name cannot be 3164 * found on the system. 3165 * 3166 * @see #GET_META_DATA 3167 * @see #GET_SHARED_LIBRARY_FILES 3168 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3169 * @see #MATCH_SYSTEM_ONLY 3170 * @see #MATCH_UNINSTALLED_PACKAGES 3171 */ 3172 public abstract ApplicationInfo getApplicationInfo(String packageName, 3173 @ApplicationInfoFlags int flags) throws NameNotFoundException; 3174 3175 /** {@hide} */ 3176 public abstract ApplicationInfo getApplicationInfoAsUser(String packageName, 3177 @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 3178 3179 /** 3180 * Retrieve all of the information we know about a particular activity 3181 * class. 3182 * 3183 * @param component The full component name (i.e. 3184 * com.google.apps.contacts/com.google.apps.contacts. 3185 * ContactsList) of an Activity class. 3186 * @param flags Additional option flags. Use any combination of 3187 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3188 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3189 * {@link #MATCH_DISABLED_COMPONENTS}, 3190 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3191 * {@link #MATCH_DIRECT_BOOT_AWARE}, 3192 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3193 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3194 * returned. 3195 * @return An {@link ActivityInfo} containing information about the 3196 * activity. 3197 * @throws NameNotFoundException if a package with the given name cannot be 3198 * found on the system. 3199 * @see #GET_META_DATA 3200 * @see #GET_SHARED_LIBRARY_FILES 3201 * @see #MATCH_ALL 3202 * @see #MATCH_DEBUG_TRIAGED_MISSING 3203 * @see #MATCH_DEFAULT_ONLY 3204 * @see #MATCH_DISABLED_COMPONENTS 3205 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3206 * @see #MATCH_DIRECT_BOOT_AWARE 3207 * @see #MATCH_DIRECT_BOOT_UNAWARE 3208 * @see #MATCH_SYSTEM_ONLY 3209 * @see #MATCH_UNINSTALLED_PACKAGES 3210 */ 3211 public abstract ActivityInfo getActivityInfo(ComponentName component, 3212 @ComponentInfoFlags int flags) throws NameNotFoundException; 3213 3214 /** 3215 * Retrieve all of the information we know about a particular receiver 3216 * class. 3217 * 3218 * @param component The full component name (i.e. 3219 * com.google.apps.calendar/com.google.apps.calendar. 3220 * CalendarAlarm) of a Receiver class. 3221 * @param flags Additional option flags. Use any combination of 3222 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3223 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3224 * {@link #MATCH_DISABLED_COMPONENTS}, 3225 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3226 * {@link #MATCH_DIRECT_BOOT_AWARE}, 3227 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3228 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3229 * returned. 3230 * @return An {@link ActivityInfo} containing information about the 3231 * receiver. 3232 * @throws NameNotFoundException if a package with the given name cannot be 3233 * found on the system. 3234 * @see #GET_META_DATA 3235 * @see #GET_SHARED_LIBRARY_FILES 3236 * @see #MATCH_ALL 3237 * @see #MATCH_DEBUG_TRIAGED_MISSING 3238 * @see #MATCH_DEFAULT_ONLY 3239 * @see #MATCH_DISABLED_COMPONENTS 3240 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3241 * @see #MATCH_DIRECT_BOOT_AWARE 3242 * @see #MATCH_DIRECT_BOOT_UNAWARE 3243 * @see #MATCH_SYSTEM_ONLY 3244 * @see #MATCH_UNINSTALLED_PACKAGES 3245 */ 3246 public abstract ActivityInfo getReceiverInfo(ComponentName component, 3247 @ComponentInfoFlags int flags) throws NameNotFoundException; 3248 3249 /** 3250 * Retrieve all of the information we know about a particular service class. 3251 * 3252 * @param component The full component name (i.e. 3253 * com.google.apps.media/com.google.apps.media. 3254 * BackgroundPlayback) of a Service class. 3255 * @param flags Additional option flags. Use any combination of 3256 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3257 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3258 * {@link #MATCH_DISABLED_COMPONENTS}, 3259 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3260 * {@link #MATCH_DIRECT_BOOT_AWARE}, 3261 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3262 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3263 * returned. 3264 * @return A {@link ServiceInfo} object containing information about the 3265 * service. 3266 * @throws NameNotFoundException if a package with the given name cannot be 3267 * found on the system. 3268 * @see #GET_META_DATA 3269 * @see #GET_SHARED_LIBRARY_FILES 3270 * @see #MATCH_ALL 3271 * @see #MATCH_DEBUG_TRIAGED_MISSING 3272 * @see #MATCH_DEFAULT_ONLY 3273 * @see #MATCH_DISABLED_COMPONENTS 3274 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3275 * @see #MATCH_DIRECT_BOOT_AWARE 3276 * @see #MATCH_DIRECT_BOOT_UNAWARE 3277 * @see #MATCH_SYSTEM_ONLY 3278 * @see #MATCH_UNINSTALLED_PACKAGES 3279 */ 3280 public abstract ServiceInfo getServiceInfo(ComponentName component, 3281 @ComponentInfoFlags int flags) throws NameNotFoundException; 3282 3283 /** 3284 * Retrieve all of the information we know about a particular content 3285 * provider class. 3286 * 3287 * @param component The full component name (i.e. 3288 * com.google.providers.media/com.google.providers.media. 3289 * MediaProvider) of a ContentProvider class. 3290 * @param flags Additional option flags. Use any combination of 3291 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3292 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3293 * {@link #MATCH_DISABLED_COMPONENTS}, 3294 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3295 * {@link #MATCH_DIRECT_BOOT_AWARE}, 3296 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3297 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3298 * returned. 3299 * @return A {@link ProviderInfo} object containing information about the 3300 * provider. 3301 * @throws NameNotFoundException if a package with the given name cannot be 3302 * found on the system. 3303 * @see #GET_META_DATA 3304 * @see #GET_SHARED_LIBRARY_FILES 3305 * @see #MATCH_ALL 3306 * @see #MATCH_DEBUG_TRIAGED_MISSING 3307 * @see #MATCH_DEFAULT_ONLY 3308 * @see #MATCH_DISABLED_COMPONENTS 3309 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3310 * @see #MATCH_DIRECT_BOOT_AWARE 3311 * @see #MATCH_DIRECT_BOOT_UNAWARE 3312 * @see #MATCH_SYSTEM_ONLY 3313 * @see #MATCH_UNINSTALLED_PACKAGES 3314 */ 3315 public abstract ProviderInfo getProviderInfo(ComponentName component, 3316 @ComponentInfoFlags int flags) throws NameNotFoundException; 3317 3318 /** 3319 * Return a List of all packages that are installed 3320 * on the device. 3321 * 3322 * @param flags Additional option flags. Use any combination of 3323 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 3324 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 3325 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 3326 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 3327 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 3328 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 3329 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 3330 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3331 * {@link #MATCH_UNINSTALLED_PACKAGES} 3332 * to modify the data returned. 3333 * 3334 * @return A List of PackageInfo objects, one for each installed package, 3335 * containing information about the package. In the unlikely case 3336 * there are no installed packages, an empty list is returned. If 3337 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3338 * information is retrieved from the list of uninstalled 3339 * applications (which includes installed applications as well as 3340 * applications with data directory i.e. applications which had been 3341 * deleted with {@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> getInstalledPackages(@PackageInfoFlags int flags); 3361 3362 /** 3363 * Return a List of all installed packages that are currently 3364 * holding any of the given permissions. 3365 * 3366 * @param flags Additional option flags. Use any combination of 3367 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 3368 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 3369 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 3370 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 3371 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 3372 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 3373 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 3374 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3375 * {@link #MATCH_UNINSTALLED_PACKAGES} 3376 * to modify the data returned. 3377 * 3378 * @return A List of PackageInfo objects, one for each installed package 3379 * that holds any of the permissions that were provided, containing 3380 * information about the package. If no installed packages hold any 3381 * of the permissions, an empty list is returned. If flag 3382 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package information 3383 * is retrieved from the list of uninstalled applications (which 3384 * includes installed applications as well as applications with data 3385 * directory i.e. applications which had been deleted with 3386 * {@code DONT_DELETE_DATA} flag set). 3387 * 3388 * @see #GET_ACTIVITIES 3389 * @see #GET_CONFIGURATIONS 3390 * @see #GET_GIDS 3391 * @see #GET_INSTRUMENTATION 3392 * @see #GET_INTENT_FILTERS 3393 * @see #GET_META_DATA 3394 * @see #GET_PERMISSIONS 3395 * @see #GET_PROVIDERS 3396 * @see #GET_RECEIVERS 3397 * @see #GET_SERVICES 3398 * @see #GET_SHARED_LIBRARY_FILES 3399 * @see #GET_SIGNATURES 3400 * @see #GET_URI_PERMISSION_PATTERNS 3401 * @see #MATCH_DISABLED_COMPONENTS 3402 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3403 * @see #MATCH_UNINSTALLED_PACKAGES 3404 */ 3405 public abstract List<PackageInfo> getPackagesHoldingPermissions( 3406 String[] permissions, @PackageInfoFlags int flags); 3407 3408 /** 3409 * Return a List of all packages that are installed on the device, for a specific user. 3410 * Requesting a list of installed packages for another user 3411 * will require the permission INTERACT_ACROSS_USERS_FULL. 3412 * 3413 * @param flags Additional option flags. Use any combination of 3414 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 3415 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 3416 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 3417 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 3418 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 3419 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 3420 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 3421 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3422 * {@link #MATCH_UNINSTALLED_PACKAGES} 3423 * to modify the data returned. 3424 * @param userId The user for whom the installed packages are to be listed 3425 * 3426 * @return A List of PackageInfo objects, one for each installed package, 3427 * containing information about the package. In the unlikely case 3428 * there are no installed packages, an empty list is returned. If 3429 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3430 * information is retrieved from the list of uninstalled 3431 * applications (which includes installed applications as well as 3432 * applications with data directory i.e. applications which had been 3433 * deleted with {@code DONT_DELETE_DATA} flag set). 3434 * 3435 * @see #GET_ACTIVITIES 3436 * @see #GET_CONFIGURATIONS 3437 * @see #GET_GIDS 3438 * @see #GET_INSTRUMENTATION 3439 * @see #GET_INTENT_FILTERS 3440 * @see #GET_META_DATA 3441 * @see #GET_PERMISSIONS 3442 * @see #GET_PROVIDERS 3443 * @see #GET_RECEIVERS 3444 * @see #GET_SERVICES 3445 * @see #GET_SHARED_LIBRARY_FILES 3446 * @see #GET_SIGNATURES 3447 * @see #GET_URI_PERMISSION_PATTERNS 3448 * @see #MATCH_DISABLED_COMPONENTS 3449 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3450 * @see #MATCH_UNINSTALLED_PACKAGES 3451 * 3452 * @hide 3453 */ 3454 @SystemApi 3455 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags, 3456 @UserIdInt int userId); 3457 3458 /** 3459 * Check whether a particular package has been granted a particular 3460 * permission. 3461 * 3462 * @param permName The name of the permission you are checking for. 3463 * @param pkgName The name of the package you are checking against. 3464 * 3465 * @return If the package has the permission, PERMISSION_GRANTED is 3466 * returned. If it does not have the permission, PERMISSION_DENIED 3467 * is returned. 3468 * 3469 * @see #PERMISSION_GRANTED 3470 * @see #PERMISSION_DENIED 3471 */ 3472 @CheckResult 3473 public abstract int checkPermission(String permName, String pkgName); 3474 3475 /** 3476 * Checks whether a particular permissions has been revoked for a 3477 * package by policy. Typically the device owner or the profile owner 3478 * may apply such a policy. The user cannot grant policy revoked 3479 * permissions, hence the only way for an app to get such a permission 3480 * is by a policy change. 3481 * 3482 * @param permName The name of the permission you are checking for. 3483 * @param pkgName The name of the package you are checking against. 3484 * 3485 * @return Whether the permission is restricted by policy. 3486 */ 3487 @CheckResult 3488 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 3489 @NonNull String pkgName); 3490 3491 /** 3492 * Gets the package name of the component controlling runtime permissions. 3493 * 3494 * @return The package name. 3495 * 3496 * @hide 3497 */ 3498 public abstract String getPermissionControllerPackageName(); 3499 3500 /** 3501 * Add a new dynamic permission to the system. For this to work, your 3502 * package must have defined a permission tree through the 3503 * {@link android.R.styleable#AndroidManifestPermissionTree 3504 * <permission-tree>} tag in its manifest. A package can only add 3505 * permissions to trees that were defined by either its own package or 3506 * another with the same user id; a permission is in a tree if it 3507 * matches the name of the permission tree + ".": for example, 3508 * "com.foo.bar" is a member of the permission tree "com.foo". 3509 * 3510 * <p>It is good to make your permission tree name descriptive, because you 3511 * are taking possession of that entire set of permission names. Thus, it 3512 * must be under a domain you control, with a suffix that will not match 3513 * any normal permissions that may be declared in any applications that 3514 * are part of that domain. 3515 * 3516 * <p>New permissions must be added before 3517 * any .apks are installed that use those permissions. Permissions you 3518 * add through this method are remembered across reboots of the device. 3519 * If the given permission already exists, the info you supply here 3520 * will be used to update it. 3521 * 3522 * @param info Description of the permission to be added. 3523 * 3524 * @return Returns true if a new permission was created, false if an 3525 * existing one was updated. 3526 * 3527 * @throws SecurityException if you are not allowed to add the 3528 * given permission name. 3529 * 3530 * @see #removePermission(String) 3531 */ 3532 public abstract boolean addPermission(PermissionInfo info); 3533 3534 /** 3535 * Like {@link #addPermission(PermissionInfo)} but asynchronously 3536 * persists the package manager state after returning from the call, 3537 * allowing it to return quicker and batch a series of adds at the 3538 * expense of no guarantee the added permission will be retained if 3539 * the device is rebooted before it is written. 3540 */ 3541 public abstract boolean addPermissionAsync(PermissionInfo info); 3542 3543 /** 3544 * Removes a permission that was previously added with 3545 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 3546 * -- you are only allowed to remove permissions that you are allowed 3547 * to add. 3548 * 3549 * @param name The name of the permission to remove. 3550 * 3551 * @throws SecurityException if you are not allowed to remove the 3552 * given permission name. 3553 * 3554 * @see #addPermission(PermissionInfo) 3555 */ 3556 public abstract void removePermission(String name); 3557 3558 /** 3559 * Permission flags set when granting or revoking a permission. 3560 * 3561 * @hide 3562 */ 3563 @SystemApi 3564 @IntDef({FLAG_PERMISSION_USER_SET, 3565 FLAG_PERMISSION_USER_FIXED, 3566 FLAG_PERMISSION_POLICY_FIXED, 3567 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 3568 FLAG_PERMISSION_SYSTEM_FIXED, 3569 FLAG_PERMISSION_GRANTED_BY_DEFAULT}) 3570 @Retention(RetentionPolicy.SOURCE) 3571 public @interface PermissionFlags {} 3572 3573 /** 3574 * Grant a runtime permission to an application which the application does not 3575 * already have. The permission must have been requested by the application. 3576 * If the application is not allowed to hold the permission, a {@link 3577 * java.lang.SecurityException} is thrown. If the package or permission is 3578 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 3579 * <p> 3580 * <strong>Note: </strong>Using this API requires holding 3581 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is 3582 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3583 * </p> 3584 * 3585 * @param packageName The package to which to grant the permission. 3586 * @param permissionName The permission name to grant. 3587 * @param user The user for which to grant the permission. 3588 * 3589 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 3590 * 3591 * @hide 3592 */ 3593 @SystemApi 3594 public abstract void grantRuntimePermission(@NonNull String packageName, 3595 @NonNull String permissionName, @NonNull UserHandle user); 3596 3597 /** 3598 * Revoke a runtime permission that was previously granted by {@link 3599 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 3600 * permission must have been requested by and granted to the application. 3601 * If the application is not allowed to hold the permission, a {@link 3602 * java.lang.SecurityException} is thrown. If the package or permission is 3603 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 3604 * <p> 3605 * <strong>Note: </strong>Using this API requires holding 3606 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 3607 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3608 * </p> 3609 * 3610 * @param packageName The package from which to revoke the permission. 3611 * @param permissionName The permission name to revoke. 3612 * @param user The user for which to revoke the permission. 3613 * 3614 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 3615 * 3616 * @hide 3617 */ 3618 @SystemApi 3619 public abstract void revokeRuntimePermission(@NonNull String packageName, 3620 @NonNull String permissionName, @NonNull UserHandle user); 3621 3622 /** 3623 * Gets the state flags associated with a permission. 3624 * 3625 * @param permissionName The permission for which to get the flags. 3626 * @param packageName The package name for which to get the flags. 3627 * @param user The user for which to get permission flags. 3628 * @return The permission flags. 3629 * 3630 * @hide 3631 */ 3632 @SystemApi 3633 public abstract @PermissionFlags int getPermissionFlags(String permissionName, 3634 String packageName, @NonNull UserHandle user); 3635 3636 /** 3637 * Updates the flags associated with a permission by replacing the flags in 3638 * the specified mask with the provided flag values. 3639 * 3640 * @param permissionName The permission for which to update the flags. 3641 * @param packageName The package name for which to update the flags. 3642 * @param flagMask The flags which to replace. 3643 * @param flagValues The flags with which to replace. 3644 * @param user The user for which to update the permission flags. 3645 * 3646 * @hide 3647 */ 3648 @SystemApi 3649 public abstract void updatePermissionFlags(String permissionName, 3650 String packageName, @PermissionFlags int flagMask, int flagValues, 3651 @NonNull UserHandle user); 3652 3653 /** 3654 * Gets whether you should show UI with rationale for requesting a permission. 3655 * You should do this only if you do not have the permission and the context in 3656 * which the permission is requested does not clearly communicate to the user 3657 * what would be the benefit from grating this permission. 3658 * 3659 * @param permission A permission your app wants to request. 3660 * @return Whether you can show permission rationale UI. 3661 * 3662 * @hide 3663 */ 3664 public abstract boolean shouldShowRequestPermissionRationale(String permission); 3665 3666 /** 3667 * Returns an {@link android.content.Intent} suitable for passing to 3668 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 3669 * which prompts the user to grant permissions to this application. 3670 * 3671 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 3672 * 3673 * @hide 3674 */ 3675 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 3676 if (ArrayUtils.isEmpty(permissions)) { 3677 throw new IllegalArgumentException("permission cannot be null or empty"); 3678 } 3679 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 3680 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 3681 intent.setPackage(getPermissionControllerPackageName()); 3682 return intent; 3683 } 3684 3685 /** 3686 * Compare the signatures of two packages to determine if the same 3687 * signature appears in both of them. If they do contain the same 3688 * signature, then they are allowed special privileges when working 3689 * with each other: they can share the same user-id, run instrumentation 3690 * against each other, etc. 3691 * 3692 * @param pkg1 First package name whose signature will be compared. 3693 * @param pkg2 Second package name whose signature will be compared. 3694 * 3695 * @return Returns an integer indicating whether all signatures on the 3696 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3697 * all signatures match or < 0 if there is not a match ({@link 3698 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3699 * 3700 * @see #checkSignatures(int, int) 3701 * @see #SIGNATURE_MATCH 3702 * @see #SIGNATURE_NO_MATCH 3703 * @see #SIGNATURE_UNKNOWN_PACKAGE 3704 */ 3705 @CheckResult 3706 public abstract int checkSignatures(String pkg1, String pkg2); 3707 3708 /** 3709 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 3710 * the two packages to be checked. This can be useful, for example, 3711 * when doing the check in an IPC, where the UID is the only identity 3712 * available. It is functionally identical to determining the package 3713 * associated with the UIDs and checking their signatures. 3714 * 3715 * @param uid1 First UID whose signature will be compared. 3716 * @param uid2 Second UID whose signature will be compared. 3717 * 3718 * @return Returns an integer indicating whether all signatures on the 3719 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3720 * all signatures match or < 0 if there is not a match ({@link 3721 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3722 * 3723 * @see #checkSignatures(String, String) 3724 * @see #SIGNATURE_MATCH 3725 * @see #SIGNATURE_NO_MATCH 3726 * @see #SIGNATURE_UNKNOWN_PACKAGE 3727 */ 3728 @CheckResult 3729 public abstract int checkSignatures(int uid1, int uid2); 3730 3731 /** 3732 * Retrieve the names of all packages that are associated with a particular 3733 * user id. In most cases, this will be a single package name, the package 3734 * that has been assigned that user id. Where there are multiple packages 3735 * sharing the same user id through the "sharedUserId" mechanism, all 3736 * packages with that id will be returned. 3737 * 3738 * @param uid The user id for which you would like to retrieve the 3739 * associated packages. 3740 * 3741 * @return Returns an array of one or more packages assigned to the user 3742 * id, or null if there are no known packages with the given id. 3743 */ 3744 public abstract @Nullable String[] getPackagesForUid(int uid); 3745 3746 /** 3747 * Retrieve the official name associated with a uid. This name is 3748 * guaranteed to never change, though it is possible for the underlying 3749 * uid to be changed. That is, if you are storing information about 3750 * uids in persistent storage, you should use the string returned 3751 * by this function instead of the raw uid. 3752 * 3753 * @param uid The uid for which you would like to retrieve a name. 3754 * @return Returns a unique name for the given uid, or null if the 3755 * uid is not currently assigned. 3756 */ 3757 public abstract @Nullable String getNameForUid(int uid); 3758 3759 /** 3760 * Return the user id associated with a shared user name. Multiple 3761 * applications can specify a shared user name in their manifest and thus 3762 * end up using a common uid. This might be used for new applications 3763 * that use an existing shared user name and need to know the uid of the 3764 * shared user. 3765 * 3766 * @param sharedUserName The shared user name whose uid is to be retrieved. 3767 * @return Returns the UID associated with the shared user. 3768 * @throws NameNotFoundException if a package with the given name cannot be 3769 * found on the system. 3770 * @hide 3771 */ 3772 public abstract int getUidForSharedUser(String sharedUserName) 3773 throws NameNotFoundException; 3774 3775 /** 3776 * Return a List of all application packages that are installed on the 3777 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 3778 * applications including those deleted with {@code DONT_DELETE_DATA} (partially 3779 * installed apps with data directory) will be returned. 3780 * 3781 * @param flags Additional option flags. Use any combination of 3782 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3783 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS} 3784 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3785 * to modify the data returned. 3786 * 3787 * @return A List of ApplicationInfo objects, one for each installed application. 3788 * In the unlikely case there are no installed packages, an empty list 3789 * is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the 3790 * application information is retrieved from the list of uninstalled 3791 * applications (which includes installed applications as well as 3792 * applications with data directory i.e. applications which had been 3793 * deleted with {@code DONT_DELETE_DATA} flag set). 3794 * 3795 * @see #GET_META_DATA 3796 * @see #GET_SHARED_LIBRARY_FILES 3797 * @see #MATCH_DISABLED_COMPONENTS 3798 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3799 * @see #MATCH_SYSTEM_ONLY 3800 * @see #MATCH_UNINSTALLED_PACKAGES 3801 */ 3802 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags); 3803 3804 /** 3805 * Return a List of all application packages that are installed on the device, for a specific 3806 * user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all applications including 3807 * those deleted with {@code DONT_DELETE_DATA} (partially installed apps with data directory) 3808 * will be returned. 3809 * 3810 * @param flags Additional option flags. Use any combination of 3811 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3812 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS} 3813 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3814 * to modify the data returned. 3815 * @param userId The user for whom the installed applications are to be listed 3816 * 3817 * @return A List of ApplicationInfo objects, one for each installed application. 3818 * In the unlikely case there are no installed packages, an empty list 3819 * is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the 3820 * application information is retrieved from the list of uninstalled 3821 * applications (which includes installed applications as well as 3822 * applications with data directory i.e. applications which had been 3823 * deleted with {@code DONT_DELETE_DATA} flag set). 3824 * @hide 3825 * 3826 * @see #GET_META_DATA 3827 * @see #GET_SHARED_LIBRARY_FILES 3828 * @see #MATCH_DISABLED_COMPONENTS 3829 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3830 * @see #MATCH_SYSTEM_ONLY 3831 * @see #MATCH_UNINSTALLED_PACKAGES 3832 */ 3833 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser( 3834 @ApplicationInfoFlags int flags, @UserIdInt int userId); 3835 3836 /** 3837 * Gets the instant applications the user recently used. Requires 3838 * holding "android.permission.ACCESS_INSTANT_APPS". 3839 * 3840 * @return The instant app list. 3841 * 3842 * @hide 3843 */ 3844 @SystemApi 3845 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) 3846 public abstract @NonNull List<InstantAppInfo> getInstantApps(); 3847 3848 /** 3849 * Gets the icon for an instant application. 3850 * 3851 * @param packageName The app package name. 3852 * 3853 * @hide 3854 */ 3855 @SystemApi 3856 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) 3857 public abstract @Nullable Drawable getInstantAppIcon(String packageName); 3858 3859 /** 3860 * Gets whether this application is an instant app. 3861 * 3862 * @return Whether caller is an instant app. 3863 * 3864 * @see #isInstantApp(String) 3865 * @see #setInstantAppCookie(byte[]) 3866 * @see #getInstantAppCookie() 3867 * @see #getInstantAppCookieMaxSize() 3868 */ 3869 public abstract boolean isInstantApp(); 3870 3871 /** 3872 * Gets whether the given package is an instant app. 3873 * 3874 * @param packageName The package to check 3875 * @return Whether the given package is an instant app. 3876 * 3877 * @see #isInstantApp() 3878 * @see #setInstantAppCookie(byte[]) 3879 * @see #getInstantAppCookie() 3880 * @see #getInstantAppCookieMaxSize() 3881 */ 3882 public abstract boolean isInstantApp(String packageName); 3883 3884 /** 3885 * Gets the maximum size in bytes of the cookie data an instant app 3886 * can store on the device. 3887 * 3888 * @return The max cookie size in bytes. 3889 * 3890 * @see #isInstantApp() 3891 * @see #isInstantApp(String) 3892 * @see #setInstantAppCookie(byte[]) 3893 * @see #getInstantAppCookie() 3894 */ 3895 public abstract int getInstantAppCookieMaxSize(); 3896 3897 /** 3898 * Gets the instant application cookie for this app. Non 3899 * instant apps and apps that were instant but were upgraded 3900 * to normal apps can still access this API. For instant apps 3901 * this cooke is cached for some time after uninstall while for 3902 * normal apps the cookie is deleted after the app is uninstalled. 3903 * The cookie is always present while the app is installed. 3904 * 3905 * @return The cookie. 3906 * 3907 * @see #isInstantApp() 3908 * @see #isInstantApp(String) 3909 * @see #setInstantAppCookie(byte[]) 3910 * @see #getInstantAppCookieMaxSize() 3911 */ 3912 public abstract @NonNull byte[] getInstantAppCookie(); 3913 3914 /** 3915 * Sets the instant application cookie for the calling app. Non 3916 * instant apps and apps that were instant but were upgraded 3917 * to normal apps can still access this API. For instant apps 3918 * this cooke is cached for some time after uninstall while for 3919 * normal apps the cookie is deleted after the app is uninstalled. 3920 * The cookie is always present while the app is installed. The 3921 * cookie size is limited by {@link #getInstantAppCookieMaxSize()}. 3922 * If the provided cookie size is over the limit this method 3923 * returns <code>false</code>. Passing <code>null</code> or an empty 3924 * array clears the cookie. 3925 * </p> 3926 * 3927 * @param cookie The cookie data. 3928 * @return Whether the cookie was set. 3929 * 3930 * @see #isInstantApp() 3931 * @see #isInstantApp(String) 3932 * @see #getInstantAppCookieMaxSize() 3933 * @see #getInstantAppCookie() 3934 */ 3935 public abstract boolean setInstantAppCookie(@Nullable byte[] cookie); 3936 3937 /** 3938 * Get a list of shared libraries that are available on the 3939 * system. 3940 * 3941 * @return An array of shared library names that are 3942 * available on the system, or null if none are installed. 3943 * 3944 */ 3945 public abstract String[] getSystemSharedLibraryNames(); 3946 3947 /** 3948 * Get a list of shared libraries on the device. 3949 * 3950 * @param flags To filter the libraries to return. 3951 * @return The shared library list. 3952 * 3953 * @see #MATCH_FACTORY_ONLY 3954 * @see #MATCH_KNOWN_PACKAGES 3955 * @see #MATCH_ANY_USER 3956 * @see #MATCH_UNINSTALLED_PACKAGES 3957 */ 3958 public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries( 3959 @InstallFlags int flags); 3960 3961 /** 3962 * Get a list of shared libraries on the device. 3963 * 3964 * @param flags To filter the libraries to return. 3965 * @param userId The user to query for. 3966 * @return The shared library list. 3967 * 3968 * @see #MATCH_FACTORY_ONLY 3969 * @see #MATCH_KNOWN_PACKAGES 3970 * @see #MATCH_ANY_USER 3971 * @see #MATCH_UNINSTALLED_PACKAGES 3972 * 3973 * @hide 3974 */ 3975 public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser( 3976 @InstallFlags int flags, @UserIdInt int userId); 3977 3978 /** 3979 * Get the name of the package hosting the services shared library. 3980 * 3981 * @return The library host package. 3982 * 3983 * @hide 3984 */ 3985 public abstract @NonNull String getServicesSystemSharedLibraryPackageName(); 3986 3987 /** 3988 * Get the name of the package hosting the shared components shared library. 3989 * 3990 * @return The library host package. 3991 * 3992 * @hide 3993 */ 3994 public abstract @NonNull String getSharedSystemSharedLibraryPackageName(); 3995 3996 /** 3997 * Returns the names of the packages that have been changed 3998 * [eg. added, removed or updated] since the given sequence 3999 * number. 4000 * <p>If no packages have been changed, returns <code>null</code>. 4001 * <p>The sequence number starts at <code>0</code> and is 4002 * reset every boot. 4003 */ 4004 public abstract @Nullable ChangedPackages getChangedPackages( 4005 @IntRange(from=0) int sequenceNumber); 4006 4007 /** 4008 * Get a list of features that are available on the 4009 * system. 4010 * 4011 * @return An array of FeatureInfo classes describing the features 4012 * that are available on the system, or null if there are none(!!). 4013 */ 4014 public abstract FeatureInfo[] getSystemAvailableFeatures(); 4015 4016 /** 4017 * Check whether the given feature name is one of the available features as 4018 * returned by {@link #getSystemAvailableFeatures()}. This tests for the 4019 * presence of <em>any</em> version of the given feature name; use 4020 * {@link #hasSystemFeature(String, int)} to check for a minimum version. 4021 * 4022 * @return Returns true if the devices supports the feature, else false. 4023 */ 4024 public abstract boolean hasSystemFeature(String name); 4025 4026 /** 4027 * Check whether the given feature name and version is one of the available 4028 * features as returned by {@link #getSystemAvailableFeatures()}. Since 4029 * features are defined to always be backwards compatible, this returns true 4030 * if the available feature version is greater than or equal to the 4031 * requested version. 4032 * 4033 * @return Returns true if the devices supports the feature, else false. 4034 */ 4035 public abstract boolean hasSystemFeature(String name, int version); 4036 4037 /** 4038 * Determine the best action to perform for a given Intent. This is how 4039 * {@link Intent#resolveActivity} finds an activity if a class has not been 4040 * explicitly specified. 4041 * <p> 4042 * <em>Note:</em> if using an implicit Intent (without an explicit 4043 * ComponentName specified), be sure to consider whether to set the 4044 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 4045 * activity in the same way that 4046 * {@link android.content.Context#startActivity(Intent)} and 4047 * {@link android.content.Intent#resolveActivity(PackageManager) 4048 * Intent.resolveActivity(PackageManager)} do. 4049 * </p> 4050 * 4051 * @param intent An intent containing all of the desired specification 4052 * (action, data, type, category, and/or component). 4053 * @param flags Additional option flags. Use any combination of 4054 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4055 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4056 * {@link #MATCH_DISABLED_COMPONENTS}, 4057 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4058 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4059 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4060 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4061 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 4062 * to limit the resolution to only those activities that support 4063 * the {@link android.content.Intent#CATEGORY_DEFAULT}. 4064 * @return Returns a ResolveInfo object containing the final activity intent 4065 * that was determined to be the best action. Returns null if no 4066 * matching activity was found. If multiple matching activities are 4067 * found and there is no default set, returns a ResolveInfo object 4068 * containing something else, such as the activity resolver. 4069 * @see #GET_META_DATA 4070 * @see #GET_RESOLVED_FILTER 4071 * @see #GET_SHARED_LIBRARY_FILES 4072 * @see #MATCH_ALL 4073 * @see #MATCH_DISABLED_COMPONENTS 4074 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4075 * @see #MATCH_DEFAULT_ONLY 4076 * @see #MATCH_DIRECT_BOOT_AWARE 4077 * @see #MATCH_DIRECT_BOOT_UNAWARE 4078 * @see #MATCH_SYSTEM_ONLY 4079 * @see #MATCH_UNINSTALLED_PACKAGES 4080 */ 4081 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags); 4082 4083 /** 4084 * Determine the best action to perform for a given Intent for a given user. 4085 * This is how {@link Intent#resolveActivity} finds an activity if a class 4086 * has not been explicitly specified. 4087 * <p> 4088 * <em>Note:</em> if using an implicit Intent (without an explicit 4089 * ComponentName specified), be sure to consider whether to set the 4090 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 4091 * activity in the same way that 4092 * {@link android.content.Context#startActivity(Intent)} and 4093 * {@link android.content.Intent#resolveActivity(PackageManager) 4094 * Intent.resolveActivity(PackageManager)} do. 4095 * </p> 4096 * 4097 * @param intent An intent containing all of the desired specification 4098 * (action, data, type, category, and/or component). 4099 * @param flags Additional option flags. Use any combination of 4100 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4101 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4102 * {@link #MATCH_DISABLED_COMPONENTS}, 4103 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4104 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4105 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4106 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4107 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 4108 * to limit the resolution to only those activities that support 4109 * the {@link android.content.Intent#CATEGORY_DEFAULT}. 4110 * @param userId The user id. 4111 * @return Returns a ResolveInfo object containing the final activity intent 4112 * that was determined to be the best action. Returns null if no 4113 * matching activity was found. If multiple matching activities are 4114 * found and there is no default set, returns a ResolveInfo object 4115 * containing something else, such as the activity resolver. 4116 * @see #GET_META_DATA 4117 * @see #GET_RESOLVED_FILTER 4118 * @see #GET_SHARED_LIBRARY_FILES 4119 * @see #MATCH_ALL 4120 * @see #MATCH_DISABLED_COMPONENTS 4121 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4122 * @see #MATCH_DEFAULT_ONLY 4123 * @see #MATCH_DIRECT_BOOT_AWARE 4124 * @see #MATCH_DIRECT_BOOT_UNAWARE 4125 * @see #MATCH_SYSTEM_ONLY 4126 * @see #MATCH_UNINSTALLED_PACKAGES 4127 * @hide 4128 */ 4129 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags, 4130 @UserIdInt int userId); 4131 4132 /** 4133 * Retrieve all activities that can be performed for the given intent. 4134 * 4135 * @param intent The desired intent as per resolveActivity(). 4136 * @param flags Additional option flags. Use any combination of 4137 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4138 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4139 * {@link #MATCH_DISABLED_COMPONENTS}, 4140 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4141 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4142 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4143 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4144 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 4145 * to limit the resolution to only those activities that support 4146 * the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 4147 * {@link #MATCH_ALL} to prevent any filtering of the results. 4148 * @return Returns a List of ResolveInfo objects containing one entry for 4149 * each matching activity, ordered from best to worst. In other 4150 * words, the first item is what would be returned by 4151 * {@link #resolveActivity}. If there are no matching activities, an 4152 * empty list is returned. 4153 * @see #GET_META_DATA 4154 * @see #GET_RESOLVED_FILTER 4155 * @see #GET_SHARED_LIBRARY_FILES 4156 * @see #MATCH_ALL 4157 * @see #MATCH_DISABLED_COMPONENTS 4158 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4159 * @see #MATCH_DEFAULT_ONLY 4160 * @see #MATCH_DIRECT_BOOT_AWARE 4161 * @see #MATCH_DIRECT_BOOT_UNAWARE 4162 * @see #MATCH_SYSTEM_ONLY 4163 * @see #MATCH_UNINSTALLED_PACKAGES 4164 */ 4165 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 4166 @ResolveInfoFlags int flags); 4167 4168 /** 4169 * Retrieve all activities that can be performed for the given intent, for a 4170 * specific user. 4171 * 4172 * @param intent The desired intent as per resolveActivity(). 4173 * @param flags Additional option flags. Use any combination of 4174 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4175 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4176 * {@link #MATCH_DISABLED_COMPONENTS}, 4177 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4178 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4179 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4180 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4181 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 4182 * to limit the resolution to only those activities that support 4183 * the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 4184 * {@link #MATCH_ALL} to prevent any filtering of the results. 4185 * @return Returns a List of ResolveInfo objects containing one entry for 4186 * each matching activity, ordered from best to worst. In other 4187 * words, the first item is what would be returned by 4188 * {@link #resolveActivity}. If there are no matching activities, an 4189 * empty list is returned. 4190 * @see #GET_META_DATA 4191 * @see #GET_RESOLVED_FILTER 4192 * @see #GET_SHARED_LIBRARY_FILES 4193 * @see #MATCH_ALL 4194 * @see #MATCH_DISABLED_COMPONENTS 4195 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4196 * @see #MATCH_DEFAULT_ONLY 4197 * @see #MATCH_DIRECT_BOOT_AWARE 4198 * @see #MATCH_DIRECT_BOOT_UNAWARE 4199 * @see #MATCH_SYSTEM_ONLY 4200 * @see #MATCH_UNINSTALLED_PACKAGES 4201 * @hide 4202 */ 4203 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 4204 @ResolveInfoFlags int flags, @UserIdInt int userId); 4205 4206 /** 4207 * Retrieve a set of activities that should be presented to the user as 4208 * similar options. This is like {@link #queryIntentActivities}, except it 4209 * also allows you to supply a list of more explicit Intents that you would 4210 * like to resolve to particular options, and takes care of returning the 4211 * final ResolveInfo list in a reasonable order, with no duplicates, based 4212 * on those inputs. 4213 * 4214 * @param caller The class name of the activity that is making the request. 4215 * This activity will never appear in the output list. Can be 4216 * null. 4217 * @param specifics An array of Intents that should be resolved to the first 4218 * specific results. Can be null. 4219 * @param intent The desired intent as per resolveActivity(). 4220 * @param flags Additional option flags. Use any combination of 4221 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4222 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4223 * {@link #MATCH_DISABLED_COMPONENTS}, 4224 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4225 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4226 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4227 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4228 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 4229 * to limit the resolution to only those activities that support 4230 * the {@link android.content.Intent#CATEGORY_DEFAULT}. 4231 * @return Returns a List of ResolveInfo objects containing one entry for 4232 * each matching activity. The list is ordered first by all of the 4233 * intents resolved in <var>specifics</var> and then any additional 4234 * activities that can handle <var>intent</var> but did not get 4235 * included by one of the <var>specifics</var> intents. If there are 4236 * no matching activities, an empty list is returned. 4237 * @see #GET_META_DATA 4238 * @see #GET_RESOLVED_FILTER 4239 * @see #GET_SHARED_LIBRARY_FILES 4240 * @see #MATCH_ALL 4241 * @see #MATCH_DISABLED_COMPONENTS 4242 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4243 * @see #MATCH_DEFAULT_ONLY 4244 * @see #MATCH_DIRECT_BOOT_AWARE 4245 * @see #MATCH_DIRECT_BOOT_UNAWARE 4246 * @see #MATCH_SYSTEM_ONLY 4247 * @see #MATCH_UNINSTALLED_PACKAGES 4248 */ 4249 public abstract List<ResolveInfo> queryIntentActivityOptions( 4250 ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags); 4251 4252 /** 4253 * Retrieve all receivers that can handle a broadcast of the given intent. 4254 * 4255 * @param intent The desired intent as per resolveActivity(). 4256 * @param flags Additional option flags. Use any combination of 4257 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4258 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4259 * {@link #MATCH_DISABLED_COMPONENTS}, 4260 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4261 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4262 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4263 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4264 * returned. 4265 * @return Returns a List of ResolveInfo objects containing one entry for 4266 * each matching receiver, ordered from best to worst. If there are 4267 * no matching receivers, an empty list or null is returned. 4268 * @see #GET_META_DATA 4269 * @see #GET_RESOLVED_FILTER 4270 * @see #GET_SHARED_LIBRARY_FILES 4271 * @see #MATCH_ALL 4272 * @see #MATCH_DISABLED_COMPONENTS 4273 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4274 * @see #MATCH_DEFAULT_ONLY 4275 * @see #MATCH_DIRECT_BOOT_AWARE 4276 * @see #MATCH_DIRECT_BOOT_UNAWARE 4277 * @see #MATCH_SYSTEM_ONLY 4278 * @see #MATCH_UNINSTALLED_PACKAGES 4279 */ 4280 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 4281 @ResolveInfoFlags int flags); 4282 4283 /** 4284 * Retrieve all receivers that can handle a broadcast of the given intent, 4285 * for a specific user. 4286 * 4287 * @param intent The desired intent as per resolveActivity(). 4288 * @param flags Additional option flags. Use any combination of 4289 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4290 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4291 * {@link #MATCH_DISABLED_COMPONENTS}, 4292 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4293 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4294 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4295 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4296 * returned. 4297 * @param userHandle UserHandle of the user being queried. 4298 * @return Returns a List of ResolveInfo objects containing one entry for 4299 * each matching receiver, ordered from best to worst. If there are 4300 * no matching receivers, an empty list or null is returned. 4301 * @see #GET_META_DATA 4302 * @see #GET_RESOLVED_FILTER 4303 * @see #GET_SHARED_LIBRARY_FILES 4304 * @see #MATCH_ALL 4305 * @see #MATCH_DISABLED_COMPONENTS 4306 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4307 * @see #MATCH_DEFAULT_ONLY 4308 * @see #MATCH_DIRECT_BOOT_AWARE 4309 * @see #MATCH_DIRECT_BOOT_UNAWARE 4310 * @see #MATCH_SYSTEM_ONLY 4311 * @see #MATCH_UNINSTALLED_PACKAGES 4312 * @hide 4313 */ 4314 @SystemApi 4315 public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 4316 @ResolveInfoFlags int flags, UserHandle userHandle) { 4317 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 4318 } 4319 4320 /** 4321 * @hide 4322 */ 4323 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 4324 @ResolveInfoFlags int flags, @UserIdInt int userId); 4325 4326 4327 /** {@hide} */ 4328 @Deprecated 4329 public List<ResolveInfo> queryBroadcastReceivers(Intent intent, 4330 @ResolveInfoFlags int flags, @UserIdInt int userId) { 4331 final String msg = "Shame on you for calling the hidden API " 4332 + "queryBroadcastReceivers(). Shame!"; 4333 if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) { 4334 throw new UnsupportedOperationException(msg); 4335 } else { 4336 Log.d(TAG, msg); 4337 return queryBroadcastReceiversAsUser(intent, flags, userId); 4338 } 4339 } 4340 4341 /** 4342 * Determine the best service to handle for a given Intent. 4343 * 4344 * @param intent An intent containing all of the desired specification 4345 * (action, data, type, category, and/or component). 4346 * @param flags Additional option flags. Use any combination of 4347 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4348 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4349 * {@link #MATCH_DISABLED_COMPONENTS}, 4350 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4351 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4352 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4353 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4354 * returned. 4355 * @return Returns a ResolveInfo object containing the final service intent 4356 * that was determined to be the best action. Returns null if no 4357 * matching service was found. 4358 * @see #GET_META_DATA 4359 * @see #GET_RESOLVED_FILTER 4360 * @see #GET_SHARED_LIBRARY_FILES 4361 * @see #MATCH_ALL 4362 * @see #MATCH_DISABLED_COMPONENTS 4363 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4364 * @see #MATCH_DEFAULT_ONLY 4365 * @see #MATCH_DIRECT_BOOT_AWARE 4366 * @see #MATCH_DIRECT_BOOT_UNAWARE 4367 * @see #MATCH_SYSTEM_ONLY 4368 * @see #MATCH_UNINSTALLED_PACKAGES 4369 */ 4370 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags); 4371 4372 /** 4373 * Retrieve all services that can match the given intent. 4374 * 4375 * @param intent The desired intent as per resolveService(). 4376 * @param flags Additional option flags. Use any combination of 4377 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4378 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4379 * {@link #MATCH_DISABLED_COMPONENTS}, 4380 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4381 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4382 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4383 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4384 * returned. 4385 * @return Returns a List of ResolveInfo objects containing one entry for 4386 * each matching service, ordered from best to worst. In other 4387 * words, the first item is what would be returned by 4388 * {@link #resolveService}. If there are no matching services, an 4389 * empty list or null is returned. 4390 * @see #GET_META_DATA 4391 * @see #GET_RESOLVED_FILTER 4392 * @see #GET_SHARED_LIBRARY_FILES 4393 * @see #MATCH_ALL 4394 * @see #MATCH_DISABLED_COMPONENTS 4395 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4396 * @see #MATCH_DEFAULT_ONLY 4397 * @see #MATCH_DIRECT_BOOT_AWARE 4398 * @see #MATCH_DIRECT_BOOT_UNAWARE 4399 * @see #MATCH_SYSTEM_ONLY 4400 * @see #MATCH_UNINSTALLED_PACKAGES 4401 */ 4402 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 4403 @ResolveInfoFlags int flags); 4404 4405 /** 4406 * Retrieve all services that can match the given intent for a given user. 4407 * 4408 * @param intent The desired intent as per resolveService(). 4409 * @param flags Additional option flags. Use any combination of 4410 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4411 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4412 * {@link #MATCH_DISABLED_COMPONENTS}, 4413 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4414 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4415 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4416 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4417 * returned. 4418 * @param userId The user id. 4419 * @return Returns a List of ResolveInfo objects containing one entry for 4420 * each matching service, ordered from best to worst. In other 4421 * words, the first item is what would be returned by 4422 * {@link #resolveService}. If there are no matching services, an 4423 * empty list or null is returned. 4424 * @see #GET_META_DATA 4425 * @see #GET_RESOLVED_FILTER 4426 * @see #GET_SHARED_LIBRARY_FILES 4427 * @see #MATCH_ALL 4428 * @see #MATCH_DISABLED_COMPONENTS 4429 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4430 * @see #MATCH_DEFAULT_ONLY 4431 * @see #MATCH_DIRECT_BOOT_AWARE 4432 * @see #MATCH_DIRECT_BOOT_UNAWARE 4433 * @see #MATCH_SYSTEM_ONLY 4434 * @see #MATCH_UNINSTALLED_PACKAGES 4435 * @hide 4436 */ 4437 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 4438 @ResolveInfoFlags int flags, @UserIdInt int userId); 4439 4440 /** 4441 * Retrieve all providers that can match the given intent. 4442 * 4443 * @param intent An intent containing all of the desired specification 4444 * (action, data, type, category, and/or component). 4445 * @param flags Additional option flags. Use any combination of 4446 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4447 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4448 * {@link #MATCH_DISABLED_COMPONENTS}, 4449 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4450 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4451 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4452 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4453 * returned. 4454 * @param userId The user id. 4455 * @return Returns a List of ResolveInfo objects containing one entry for 4456 * each matching provider, ordered from best to worst. If there are 4457 * no matching services, an empty list or null is returned. 4458 * @see #GET_META_DATA 4459 * @see #GET_RESOLVED_FILTER 4460 * @see #GET_SHARED_LIBRARY_FILES 4461 * @see #MATCH_ALL 4462 * @see #MATCH_DISABLED_COMPONENTS 4463 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4464 * @see #MATCH_DEFAULT_ONLY 4465 * @see #MATCH_DIRECT_BOOT_AWARE 4466 * @see #MATCH_DIRECT_BOOT_UNAWARE 4467 * @see #MATCH_SYSTEM_ONLY 4468 * @see #MATCH_UNINSTALLED_PACKAGES 4469 * @hide 4470 */ 4471 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 4472 Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId); 4473 4474 /** 4475 * Retrieve all providers that can match the given intent. 4476 * 4477 * @param intent An intent containing all of the desired specification 4478 * (action, data, type, category, and/or component). 4479 * @param flags Additional option flags. Use any combination of 4480 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4481 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4482 * {@link #MATCH_DISABLED_COMPONENTS}, 4483 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4484 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4485 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4486 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4487 * returned. 4488 * @return Returns a List of ResolveInfo objects containing one entry for 4489 * each matching provider, ordered from best to worst. If there are 4490 * no matching services, an empty list or null is returned. 4491 * @see #GET_META_DATA 4492 * @see #GET_RESOLVED_FILTER 4493 * @see #GET_SHARED_LIBRARY_FILES 4494 * @see #MATCH_ALL 4495 * @see #MATCH_DISABLED_COMPONENTS 4496 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4497 * @see #MATCH_DEFAULT_ONLY 4498 * @see #MATCH_DIRECT_BOOT_AWARE 4499 * @see #MATCH_DIRECT_BOOT_UNAWARE 4500 * @see #MATCH_SYSTEM_ONLY 4501 * @see #MATCH_UNINSTALLED_PACKAGES 4502 */ 4503 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, 4504 @ResolveInfoFlags int flags); 4505 4506 /** 4507 * Find a single content provider by its base path name. 4508 * 4509 * @param name The name of the provider to find. 4510 * @param flags Additional option flags. Use any combination of 4511 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 4512 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 4513 * {@link #MATCH_DISABLED_COMPONENTS}, 4514 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4515 * {@link #MATCH_DIRECT_BOOT_AWARE}, 4516 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4517 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4518 * returned. 4519 * @return A {@link ProviderInfo} object containing information about the 4520 * provider. If a provider was not found, returns null. 4521 * @see #GET_META_DATA 4522 * @see #GET_SHARED_LIBRARY_FILES 4523 * @see #MATCH_ALL 4524 * @see #MATCH_DEBUG_TRIAGED_MISSING 4525 * @see #MATCH_DEFAULT_ONLY 4526 * @see #MATCH_DISABLED_COMPONENTS 4527 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4528 * @see #MATCH_DIRECT_BOOT_AWARE 4529 * @see #MATCH_DIRECT_BOOT_UNAWARE 4530 * @see #MATCH_SYSTEM_ONLY 4531 * @see #MATCH_UNINSTALLED_PACKAGES 4532 */ 4533 public abstract ProviderInfo resolveContentProvider(String name, 4534 @ComponentInfoFlags int flags); 4535 4536 /** 4537 * Find a single content provider by its base path name. 4538 * 4539 * @param name The name of the provider to find. 4540 * @param flags Additional option flags. Use any combination of 4541 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 4542 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 4543 * {@link #MATCH_DISABLED_COMPONENTS}, 4544 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4545 * {@link #MATCH_DIRECT_BOOT_AWARE}, 4546 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4547 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4548 * returned. 4549 * @param userId The user id. 4550 * @return A {@link ProviderInfo} object containing information about the 4551 * provider. If a provider was not found, returns null. 4552 * @see #GET_META_DATA 4553 * @see #GET_SHARED_LIBRARY_FILES 4554 * @see #MATCH_ALL 4555 * @see #MATCH_DEBUG_TRIAGED_MISSING 4556 * @see #MATCH_DEFAULT_ONLY 4557 * @see #MATCH_DISABLED_COMPONENTS 4558 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4559 * @see #MATCH_DIRECT_BOOT_AWARE 4560 * @see #MATCH_DIRECT_BOOT_UNAWARE 4561 * @see #MATCH_SYSTEM_ONLY 4562 * @see #MATCH_UNINSTALLED_PACKAGES 4563 * @hide 4564 */ 4565 public abstract ProviderInfo resolveContentProviderAsUser(String name, 4566 @ComponentInfoFlags int flags, @UserIdInt int userId); 4567 4568 /** 4569 * Retrieve content provider information. 4570 * <p> 4571 * <em>Note: unlike most other methods, an empty result set is indicated 4572 * by a null return instead of an empty list.</em> 4573 * 4574 * @param processName If non-null, limits the returned providers to only 4575 * those that are hosted by the given process. If null, all 4576 * content providers are returned. 4577 * @param uid If <var>processName</var> is non-null, this is the required 4578 * uid owning the requested content providers. 4579 * @param flags Additional option flags. Use any combination of 4580 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 4581 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 4582 * {@link #MATCH_DISABLED_COMPONENTS}, 4583 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4584 * {@link #MATCH_DIRECT_BOOT_AWARE}, 4585 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4586 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4587 * returned. 4588 * @return A list of {@link ProviderInfo} objects containing one entry for 4589 * each provider either matching <var>processName</var> or, if 4590 * <var>processName</var> is null, all known content providers. 4591 * <em>If there are no matching providers, null is returned.</em> 4592 * @see #GET_META_DATA 4593 * @see #GET_SHARED_LIBRARY_FILES 4594 * @see #MATCH_ALL 4595 * @see #MATCH_DEBUG_TRIAGED_MISSING 4596 * @see #MATCH_DEFAULT_ONLY 4597 * @see #MATCH_DISABLED_COMPONENTS 4598 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4599 * @see #MATCH_DIRECT_BOOT_AWARE 4600 * @see #MATCH_DIRECT_BOOT_UNAWARE 4601 * @see #MATCH_SYSTEM_ONLY 4602 * @see #MATCH_UNINSTALLED_PACKAGES 4603 */ 4604 public abstract List<ProviderInfo> queryContentProviders( 4605 String processName, int uid, @ComponentInfoFlags int flags); 4606 4607 /** 4608 * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null, 4609 * it only returns providers which have metadata with the {@code metaDataKey} key. 4610 * 4611 * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider. 4612 * You really shouldn't need it. Other apps should use {@link #queryIntentContentProviders} 4613 * instead. 4614 * 4615 * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly 4616 * scan the GAL providers on the device. Unfortunately the discovery protocol used metadata 4617 * to mark GAL providers, rather than intent filters, so we can't use 4618 * {@link #queryIntentContentProviders} for that. 4619 * 4620 * @hide 4621 */ 4622 public List<ProviderInfo> queryContentProviders( 4623 String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey) { 4624 // Provide the default implementation for mocks. 4625 return queryContentProviders(processName, uid, flags); 4626 } 4627 4628 /** 4629 * Retrieve all of the information we know about a particular 4630 * instrumentation class. 4631 * 4632 * @param className The full name (i.e. 4633 * com.google.apps.contacts.InstrumentList) of an 4634 * Instrumentation class. 4635 * @param flags Additional option flags. Use any combination of 4636 * {@link #GET_META_DATA} 4637 * to modify the data returned. 4638 * 4639 * @return An {@link InstrumentationInfo} object containing information about the 4640 * instrumentation. 4641 * @throws NameNotFoundException if a package with the given name cannot be 4642 * found on the system. 4643 * 4644 * @see #GET_META_DATA 4645 */ 4646 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className, 4647 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 4648 4649 /** 4650 * Retrieve information about available instrumentation code. May be used 4651 * to retrieve either all instrumentation code, or only the code targeting 4652 * a particular package. 4653 * 4654 * @param targetPackage If null, all instrumentation is returned; only the 4655 * instrumentation targeting this package name is 4656 * returned. 4657 * @param flags Additional option flags. Use any combination of 4658 * {@link #GET_META_DATA} 4659 * to modify the data returned. 4660 * 4661 * @return A list of {@link InstrumentationInfo} objects containing one 4662 * entry for each matching instrumentation. If there are no 4663 * instrumentation available, returns an empty list. 4664 * 4665 * @see #GET_META_DATA 4666 */ 4667 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage, 4668 @InstrumentationInfoFlags int flags); 4669 4670 /** 4671 * Retrieve an image from a package. This is a low-level API used by 4672 * the various package manager info structures (such as 4673 * {@link ComponentInfo} to implement retrieval of their associated 4674 * icon. 4675 * 4676 * @param packageName The name of the package that this icon is coming from. 4677 * Cannot be null. 4678 * @param resid The resource identifier of the desired image. Cannot be 0. 4679 * @param appInfo Overall information about <var>packageName</var>. This 4680 * may be null, in which case the application information will be retrieved 4681 * for you if needed; if you already have this information around, it can 4682 * be much more efficient to supply it here. 4683 * 4684 * @return Returns a Drawable holding the requested image. Returns null if 4685 * an image could not be found for any reason. 4686 */ 4687 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid, 4688 ApplicationInfo appInfo); 4689 4690 /** 4691 * Retrieve the icon associated with an activity. Given the full name of 4692 * an activity, retrieves the information about it and calls 4693 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 4694 * If the activity cannot be found, NameNotFoundException is thrown. 4695 * 4696 * @param activityName Name of the activity whose icon is to be retrieved. 4697 * 4698 * @return Returns the image of the icon, or the default activity icon if 4699 * it could not be found. Does not return null. 4700 * @throws NameNotFoundException Thrown if the resources for the given 4701 * activity could not be loaded. 4702 * 4703 * @see #getActivityIcon(Intent) 4704 */ 4705 public abstract Drawable getActivityIcon(ComponentName activityName) 4706 throws NameNotFoundException; 4707 4708 /** 4709 * Retrieve the icon associated with an Intent. If intent.getClassName() is 4710 * set, this simply returns the result of 4711 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 4712 * component and returns the icon associated with the resolved component. 4713 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4714 * to a component, NameNotFoundException is thrown. 4715 * 4716 * @param intent The intent for which you would like to retrieve an icon. 4717 * 4718 * @return Returns the image of the icon, or the default activity icon if 4719 * it could not be found. Does not return null. 4720 * @throws NameNotFoundException Thrown if the resources for application 4721 * matching the given intent could not be loaded. 4722 * 4723 * @see #getActivityIcon(ComponentName) 4724 */ 4725 public abstract Drawable getActivityIcon(Intent intent) 4726 throws NameNotFoundException; 4727 4728 /** 4729 * Retrieve the banner associated with an activity. Given the full name of 4730 * an activity, retrieves the information about it and calls 4731 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 4732 * banner. If the activity cannot be found, NameNotFoundException is thrown. 4733 * 4734 * @param activityName Name of the activity whose banner is to be retrieved. 4735 * @return Returns the image of the banner, or null if the activity has no 4736 * banner specified. 4737 * @throws NameNotFoundException Thrown if the resources for the given 4738 * activity could not be loaded. 4739 * @see #getActivityBanner(Intent) 4740 */ 4741 public abstract Drawable getActivityBanner(ComponentName activityName) 4742 throws NameNotFoundException; 4743 4744 /** 4745 * Retrieve the banner associated with an Intent. If intent.getClassName() 4746 * is set, this simply returns the result of 4747 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 4748 * intent's component and returns the banner associated with the resolved 4749 * component. If intent.getClassName() cannot be found or the Intent cannot 4750 * be resolved to a component, NameNotFoundException is thrown. 4751 * 4752 * @param intent The intent for which you would like to retrieve a banner. 4753 * @return Returns the image of the banner, or null if the activity has no 4754 * banner specified. 4755 * @throws NameNotFoundException Thrown if the resources for application 4756 * matching the given intent could not be loaded. 4757 * @see #getActivityBanner(ComponentName) 4758 */ 4759 public abstract Drawable getActivityBanner(Intent intent) 4760 throws NameNotFoundException; 4761 4762 /** 4763 * Return the generic icon for an activity that is used when no specific 4764 * icon is defined. 4765 * 4766 * @return Drawable Image of the icon. 4767 */ 4768 public abstract Drawable getDefaultActivityIcon(); 4769 4770 /** 4771 * Retrieve the icon associated with an application. If it has not defined 4772 * an icon, the default app icon is returned. Does not return null. 4773 * 4774 * @param info Information about application being queried. 4775 * 4776 * @return Returns the image of the icon, or the default application icon 4777 * if it could not be found. 4778 * 4779 * @see #getApplicationIcon(String) 4780 */ 4781 public abstract Drawable getApplicationIcon(ApplicationInfo info); 4782 4783 /** 4784 * Retrieve the icon associated with an application. Given the name of the 4785 * application's package, retrieves the information about it and calls 4786 * getApplicationIcon() to return its icon. If the application cannot be 4787 * found, NameNotFoundException is thrown. 4788 * 4789 * @param packageName Name of the package whose application icon is to be 4790 * retrieved. 4791 * 4792 * @return Returns the image of the icon, or the default application icon 4793 * if it could not be found. Does not return null. 4794 * @throws NameNotFoundException Thrown if the resources for the given 4795 * application could not be loaded. 4796 * 4797 * @see #getApplicationIcon(ApplicationInfo) 4798 */ 4799 public abstract Drawable getApplicationIcon(String packageName) 4800 throws NameNotFoundException; 4801 4802 /** 4803 * Retrieve the banner associated with an application. 4804 * 4805 * @param info Information about application being queried. 4806 * @return Returns the image of the banner or null if the application has no 4807 * banner specified. 4808 * @see #getApplicationBanner(String) 4809 */ 4810 public abstract Drawable getApplicationBanner(ApplicationInfo info); 4811 4812 /** 4813 * Retrieve the banner associated with an application. Given the name of the 4814 * application's package, retrieves the information about it and calls 4815 * getApplicationIcon() to return its banner. If the application cannot be 4816 * found, NameNotFoundException is thrown. 4817 * 4818 * @param packageName Name of the package whose application banner is to be 4819 * retrieved. 4820 * @return Returns the image of the banner or null if the application has no 4821 * banner specified. 4822 * @throws NameNotFoundException Thrown if the resources for the given 4823 * application could not be loaded. 4824 * @see #getApplicationBanner(ApplicationInfo) 4825 */ 4826 public abstract Drawable getApplicationBanner(String packageName) 4827 throws NameNotFoundException; 4828 4829 /** 4830 * Retrieve the logo associated with an activity. Given the full name of an 4831 * activity, retrieves the information about it and calls 4832 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 4833 * logo. If the activity cannot be found, NameNotFoundException is thrown. 4834 * 4835 * @param activityName Name of the activity whose logo is to be retrieved. 4836 * @return Returns the image of the logo or null if the activity has no logo 4837 * specified. 4838 * @throws NameNotFoundException Thrown if the resources for the given 4839 * activity could not be loaded. 4840 * @see #getActivityLogo(Intent) 4841 */ 4842 public abstract Drawable getActivityLogo(ComponentName activityName) 4843 throws NameNotFoundException; 4844 4845 /** 4846 * Retrieve the logo associated with an Intent. If intent.getClassName() is 4847 * set, this simply returns the result of 4848 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 4849 * component and returns the logo associated with the resolved component. 4850 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4851 * to a component, NameNotFoundException is thrown. 4852 * 4853 * @param intent The intent for which you would like to retrieve a logo. 4854 * 4855 * @return Returns the image of the logo, or null if the activity has no 4856 * logo specified. 4857 * 4858 * @throws NameNotFoundException Thrown if the resources for application 4859 * matching the given intent could not be loaded. 4860 * 4861 * @see #getActivityLogo(ComponentName) 4862 */ 4863 public abstract Drawable getActivityLogo(Intent intent) 4864 throws NameNotFoundException; 4865 4866 /** 4867 * Retrieve the logo associated with an application. If it has not specified 4868 * a logo, this method returns null. 4869 * 4870 * @param info Information about application being queried. 4871 * 4872 * @return Returns the image of the logo, or null if no logo is specified 4873 * by the application. 4874 * 4875 * @see #getApplicationLogo(String) 4876 */ 4877 public abstract Drawable getApplicationLogo(ApplicationInfo info); 4878 4879 /** 4880 * Retrieve the logo associated with an application. Given the name of the 4881 * application's package, retrieves the information about it and calls 4882 * getApplicationLogo() to return its logo. If the application cannot be 4883 * found, NameNotFoundException is thrown. 4884 * 4885 * @param packageName Name of the package whose application logo is to be 4886 * retrieved. 4887 * 4888 * @return Returns the image of the logo, or null if no application logo 4889 * has been specified. 4890 * 4891 * @throws NameNotFoundException Thrown if the resources for the given 4892 * application could not be loaded. 4893 * 4894 * @see #getApplicationLogo(ApplicationInfo) 4895 */ 4896 public abstract Drawable getApplicationLogo(String packageName) 4897 throws NameNotFoundException; 4898 4899 /** 4900 * If the target user is a managed profile, then this returns a badged copy of the given icon 4901 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use 4902 * {@link #getUserBadgedDrawableForDensity( 4903 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 4904 * <p> 4905 * If the original drawable is a BitmapDrawable and the backing bitmap is 4906 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 4907 * is performed in place and the original drawable is returned. 4908 * </p> 4909 * 4910 * @param icon The icon to badge. 4911 * @param user The target user. 4912 * @return A drawable that combines the original icon and a badge as 4913 * determined by the system. 4914 */ 4915 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 4916 4917 /** 4918 * If the target user is a managed profile of the calling user or the caller 4919 * is itself a managed profile, then this returns a badged copy of the given 4920 * drawable allowing the user to distinguish it from the original drawable. 4921 * The caller can specify the location in the bounds of the drawable to be 4922 * badged where the badge should be applied as well as the density of the 4923 * badge to be used. 4924 * <p> 4925 * If the original drawable is a BitmapDrawable and the backing bitmap is 4926 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 4927 * is performed in place and the original drawable is returned. 4928 * </p> 4929 * 4930 * @param drawable The drawable to badge. 4931 * @param user The target user. 4932 * @param badgeLocation Where in the bounds of the badged drawable to place 4933 * the badge. If it's {@code null}, the badge is applied on top of the entire 4934 * drawable being badged. 4935 * @param badgeDensity The optional desired density for the badge as per 4936 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive, 4937 * the density of the display is used. 4938 * @return A drawable that combines the original drawable and a badge as 4939 * determined by the system. 4940 */ 4941 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 4942 UserHandle user, Rect badgeLocation, int badgeDensity); 4943 4944 /** 4945 * If the target user is a managed profile of the calling user or the caller 4946 * is itself a managed profile, then this returns a drawable to use as a small 4947 * icon to include in a view to distinguish it from the original icon. 4948 * 4949 * @param user The target user. 4950 * @param density The optional desired density for the badge as per 4951 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4952 * the density of the current display is used. 4953 * @return the drawable or null if no drawable is required. 4954 * @hide 4955 */ 4956 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 4957 4958 /** 4959 * If the target user is a managed profile of the calling user or the caller 4960 * is itself a managed profile, then this returns a drawable to use as a small 4961 * icon to include in a view to distinguish it from the original icon. This version 4962 * doesn't have background protection and should be used over a light background instead of 4963 * a badge. 4964 * 4965 * @param user The target user. 4966 * @param density The optional desired density for the badge as per 4967 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4968 * the density of the current display is used. 4969 * @return the drawable or null if no drawable is required. 4970 * @hide 4971 */ 4972 public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density); 4973 4974 /** 4975 * If the target user is a managed profile of the calling user or the caller 4976 * is itself a managed profile, then this returns a copy of the label with 4977 * badging for accessibility services like talkback. E.g. passing in "Email" 4978 * and it might return "Work Email" for Email in the work profile. 4979 * 4980 * @param label The label to change. 4981 * @param user The target user. 4982 * @return A label that combines the original label and a badge as 4983 * determined by the system. 4984 */ 4985 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 4986 4987 /** 4988 * Retrieve text from a package. This is a low-level API used by 4989 * the various package manager info structures (such as 4990 * {@link ComponentInfo} to implement retrieval of their associated 4991 * labels and other text. 4992 * 4993 * @param packageName The name of the package that this text is coming from. 4994 * Cannot be null. 4995 * @param resid The resource identifier of the desired text. Cannot be 0. 4996 * @param appInfo Overall information about <var>packageName</var>. This 4997 * may be null, in which case the application information will be retrieved 4998 * for you if needed; if you already have this information around, it can 4999 * be much more efficient to supply it here. 5000 * 5001 * @return Returns a CharSequence holding the requested text. Returns null 5002 * if the text could not be found for any reason. 5003 */ 5004 public abstract CharSequence getText(String packageName, @StringRes int resid, 5005 ApplicationInfo appInfo); 5006 5007 /** 5008 * Retrieve an XML file from a package. This is a low-level API used to 5009 * retrieve XML meta data. 5010 * 5011 * @param packageName The name of the package that this xml is coming from. 5012 * Cannot be null. 5013 * @param resid The resource identifier of the desired xml. Cannot be 0. 5014 * @param appInfo Overall information about <var>packageName</var>. This 5015 * may be null, in which case the application information will be retrieved 5016 * for you if needed; if you already have this information around, it can 5017 * be much more efficient to supply it here. 5018 * 5019 * @return Returns an XmlPullParser allowing you to parse out the XML 5020 * data. Returns null if the xml resource could not be found for any 5021 * reason. 5022 */ 5023 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid, 5024 ApplicationInfo appInfo); 5025 5026 /** 5027 * Return the label to use for this application. 5028 * 5029 * @return Returns the label associated with this application, or null if 5030 * it could not be found for any reason. 5031 * @param info The application to get the label of. 5032 */ 5033 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 5034 5035 /** 5036 * Retrieve the resources associated with an activity. Given the full 5037 * name of an activity, retrieves the information about it and calls 5038 * getResources() to return its application's resources. If the activity 5039 * cannot be found, NameNotFoundException is thrown. 5040 * 5041 * @param activityName Name of the activity whose resources are to be 5042 * retrieved. 5043 * 5044 * @return Returns the application's Resources. 5045 * @throws NameNotFoundException Thrown if the resources for the given 5046 * application could not be loaded. 5047 * 5048 * @see #getResourcesForApplication(ApplicationInfo) 5049 */ 5050 public abstract Resources getResourcesForActivity(ComponentName activityName) 5051 throws NameNotFoundException; 5052 5053 /** 5054 * Retrieve the resources for an application. Throws NameNotFoundException 5055 * if the package is no longer installed. 5056 * 5057 * @param app Information about the desired application. 5058 * 5059 * @return Returns the application's Resources. 5060 * @throws NameNotFoundException Thrown if the resources for the given 5061 * application could not be loaded (most likely because it was uninstalled). 5062 */ 5063 public abstract Resources getResourcesForApplication(ApplicationInfo app) 5064 throws NameNotFoundException; 5065 5066 /** 5067 * Retrieve the resources associated with an application. Given the full 5068 * package name of an application, retrieves the information about it and 5069 * calls getResources() to return its application's resources. If the 5070 * appPackageName cannot be found, NameNotFoundException is thrown. 5071 * 5072 * @param appPackageName Package name of the application whose resources 5073 * are to be retrieved. 5074 * 5075 * @return Returns the application's Resources. 5076 * @throws NameNotFoundException Thrown if the resources for the given 5077 * application could not be loaded. 5078 * 5079 * @see #getResourcesForApplication(ApplicationInfo) 5080 */ 5081 public abstract Resources getResourcesForApplication(String appPackageName) 5082 throws NameNotFoundException; 5083 5084 /** @hide */ 5085 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, 5086 @UserIdInt int userId) throws NameNotFoundException; 5087 5088 /** 5089 * Retrieve overall information about an application package defined 5090 * in a package archive file 5091 * 5092 * @param archiveFilePath The path to the archive file 5093 * @param flags Additional option flags. Use any combination of 5094 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 5095 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 5096 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 5097 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 5098 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 5099 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 5100 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 5101 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 5102 * {@link #MATCH_UNINSTALLED_PACKAGES} 5103 * to modify the data returned. 5104 * 5105 * @return A PackageInfo object containing information about the 5106 * package archive. If the package could not be parsed, 5107 * returns null. 5108 * 5109 * @see #GET_ACTIVITIES 5110 * @see #GET_CONFIGURATIONS 5111 * @see #GET_GIDS 5112 * @see #GET_INSTRUMENTATION 5113 * @see #GET_INTENT_FILTERS 5114 * @see #GET_META_DATA 5115 * @see #GET_PERMISSIONS 5116 * @see #GET_PROVIDERS 5117 * @see #GET_RECEIVERS 5118 * @see #GET_SERVICES 5119 * @see #GET_SHARED_LIBRARY_FILES 5120 * @see #GET_SIGNATURES 5121 * @see #GET_URI_PERMISSION_PATTERNS 5122 * @see #MATCH_DISABLED_COMPONENTS 5123 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 5124 * @see #MATCH_UNINSTALLED_PACKAGES 5125 * 5126 */ 5127 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) { 5128 final PackageParser parser = new PackageParser(); 5129 parser.setCallback(new PackageParser.CallbackImpl(this)); 5130 final File apkFile = new File(archiveFilePath); 5131 try { 5132 if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) { 5133 // Caller expressed an explicit opinion about what encryption 5134 // aware/unaware components they want to see, so fall through and 5135 // give them what they want 5136 } else { 5137 // Caller expressed no opinion, so match everything 5138 flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE; 5139 } 5140 5141 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 5142 if ((flags & GET_SIGNATURES) != 0) { 5143 PackageParser.collectCertificates(pkg, 0); 5144 } 5145 PackageUserState state = new PackageUserState(); 5146 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 5147 } catch (PackageParserException e) { 5148 return null; 5149 } 5150 } 5151 5152 /** 5153 * @deprecated replaced by {@link PackageInstaller} 5154 * @hide 5155 */ 5156 @Deprecated 5157 public abstract void installPackage( 5158 Uri packageURI, 5159 IPackageInstallObserver observer, 5160 @InstallFlags int flags, 5161 String installerPackageName); 5162 /** 5163 * @deprecated replaced by {@link PackageInstaller} 5164 * @hide 5165 */ 5166 @Deprecated 5167 public abstract void installPackage( 5168 Uri packageURI, 5169 PackageInstallObserver observer, 5170 @InstallFlags int flags, 5171 String installerPackageName); 5172 5173 /** 5174 * If there is already an application with the given package name installed 5175 * on the system for other users, also install it for the calling user. 5176 * @hide 5177 */ 5178 public abstract int installExistingPackage(String packageName) throws NameNotFoundException; 5179 5180 /** 5181 * If there is already an application with the given package name installed 5182 * on the system for other users, also install it for the specified user. 5183 * @hide 5184 */ 5185 @RequiresPermission(anyOf = { 5186 Manifest.permission.INSTALL_PACKAGES, 5187 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 5188 public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId) 5189 throws NameNotFoundException; 5190 5191 /** 5192 * Allows a package listening to the 5193 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 5194 * broadcast} to respond to the package manager. The response must include 5195 * the {@code verificationCode} which is one of 5196 * {@link PackageManager#VERIFICATION_ALLOW} or 5197 * {@link PackageManager#VERIFICATION_REJECT}. 5198 * 5199 * @param id pending package identifier as passed via the 5200 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 5201 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 5202 * or {@link PackageManager#VERIFICATION_REJECT}. 5203 * @throws SecurityException if the caller does not have the 5204 * PACKAGE_VERIFICATION_AGENT permission. 5205 */ 5206 public abstract void verifyPendingInstall(int id, int verificationCode); 5207 5208 /** 5209 * Allows a package listening to the 5210 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 5211 * broadcast} to extend the default timeout for a response and declare what 5212 * action to perform after the timeout occurs. The response must include 5213 * the {@code verificationCodeAtTimeout} which is one of 5214 * {@link PackageManager#VERIFICATION_ALLOW} or 5215 * {@link PackageManager#VERIFICATION_REJECT}. 5216 * 5217 * This method may only be called once per package id. Additional calls 5218 * will have no effect. 5219 * 5220 * @param id pending package identifier as passed via the 5221 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 5222 * @param verificationCodeAtTimeout either 5223 * {@link PackageManager#VERIFICATION_ALLOW} or 5224 * {@link PackageManager#VERIFICATION_REJECT}. If 5225 * {@code verificationCodeAtTimeout} is neither 5226 * {@link PackageManager#VERIFICATION_ALLOW} or 5227 * {@link PackageManager#VERIFICATION_REJECT}, then 5228 * {@code verificationCodeAtTimeout} will default to 5229 * {@link PackageManager#VERIFICATION_REJECT}. 5230 * @param millisecondsToDelay the amount of time requested for the timeout. 5231 * Must be positive and less than 5232 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 5233 * {@code millisecondsToDelay} is out of bounds, 5234 * {@code millisecondsToDelay} will be set to the closest in 5235 * bounds value; namely, 0 or 5236 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 5237 * @throws SecurityException if the caller does not have the 5238 * PACKAGE_VERIFICATION_AGENT permission. 5239 */ 5240 public abstract void extendVerificationTimeout(int id, 5241 int verificationCodeAtTimeout, long millisecondsToDelay); 5242 5243 /** 5244 * Allows a package listening to the 5245 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification 5246 * broadcast to respond to the package manager. The response must include 5247 * the {@code verificationCode} which is one of 5248 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 5249 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 5250 * 5251 * @param verificationId pending package identifier as passed via the 5252 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 5253 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 5254 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 5255 * @param failedDomains a list of failed domains if the verificationCode is 5256 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 5257 * @throws SecurityException if the caller does not have the 5258 * INTENT_FILTER_VERIFICATION_AGENT permission. 5259 * 5260 * @hide 5261 */ 5262 @SystemApi 5263 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 5264 List<String> failedDomains); 5265 5266 /** 5267 * Get the status of a Domain Verification Result for an IntentFilter. This is 5268 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 5269 * {@link android.content.IntentFilter#getAutoVerify()} 5270 * 5271 * This is used by the ResolverActivity to change the status depending on what the User select 5272 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 5273 * for a domain. 5274 * 5275 * @param packageName The package name of the Activity associated with the IntentFilter. 5276 * @param userId The user id. 5277 * 5278 * @return The status to set to. This can be 5279 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 5280 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 5281 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 5282 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 5283 * 5284 * @hide 5285 */ 5286 @SystemApi 5287 public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId); 5288 5289 /** 5290 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 5291 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 5292 * {@link android.content.IntentFilter#getAutoVerify()} 5293 * 5294 * This is used by the ResolverActivity to change the status depending on what the User select 5295 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 5296 * for a domain. 5297 * 5298 * @param packageName The package name of the Activity associated with the IntentFilter. 5299 * @param status The status to set to. This can be 5300 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 5301 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 5302 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 5303 * @param userId The user id. 5304 * 5305 * @return true if the status has been set. False otherwise. 5306 * 5307 * @hide 5308 */ 5309 @SystemApi 5310 public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status, 5311 @UserIdInt int userId); 5312 5313 /** 5314 * Get the list of IntentFilterVerificationInfo for a specific package and User. 5315 * 5316 * @param packageName the package name. When this parameter is set to a non null value, 5317 * the results will be filtered by the package name provided. 5318 * Otherwise, there will be no filtering and it will return a list 5319 * corresponding for all packages 5320 * 5321 * @return a list of IntentFilterVerificationInfo for a specific package. 5322 * 5323 * @hide 5324 */ 5325 @SystemApi 5326 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 5327 String packageName); 5328 5329 /** 5330 * Get the list of IntentFilter for a specific package. 5331 * 5332 * @param packageName the package name. This parameter is set to a non null value, 5333 * the list will contain all the IntentFilter for that package. 5334 * Otherwise, the list will be empty. 5335 * 5336 * @return a list of IntentFilter for a specific package. 5337 * 5338 * @hide 5339 */ 5340 @SystemApi 5341 public abstract List<IntentFilter> getAllIntentFilters(String packageName); 5342 5343 /** 5344 * Get the default Browser package name for a specific user. 5345 * 5346 * @param userId The user id. 5347 * 5348 * @return the package name of the default Browser for the specified user. If the user id passed 5349 * is -1 (all users) it will return a null value. 5350 * 5351 * @hide 5352 */ 5353 @TestApi 5354 @SystemApi 5355 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId); 5356 5357 /** 5358 * Set the default Browser package name for a specific user. 5359 * 5360 * @param packageName The package name of the default Browser. 5361 * @param userId The user id. 5362 * 5363 * @return true if the default Browser for the specified user has been set, 5364 * otherwise return false. If the user id passed is -1 (all users) this call will not 5365 * do anything and just return false. 5366 * 5367 * @hide 5368 */ 5369 @SystemApi 5370 public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName, 5371 @UserIdInt int userId); 5372 5373 /** 5374 * Change the installer associated with a given package. There are limitations 5375 * on how the installer package can be changed; in particular: 5376 * <ul> 5377 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 5378 * is not signed with the same certificate as the calling application. 5379 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 5380 * has an installer package, and that installer package is not signed with 5381 * the same certificate as the calling application. 5382 * </ul> 5383 * 5384 * @param targetPackage The installed package whose installer will be changed. 5385 * @param installerPackageName The package name of the new installer. May be 5386 * null to clear the association. 5387 */ 5388 public abstract void setInstallerPackageName(String targetPackage, 5389 String installerPackageName); 5390 5391 /** @hide */ 5392 @SystemApi 5393 @RequiresPermission(Manifest.permission.INSTALL_PACKAGES) 5394 public abstract void setUpdateAvailable(String packageName, boolean updateAvaialble); 5395 5396 /** 5397 * Attempts to delete a package. Since this may take a little while, the 5398 * result will be posted back to the given observer. A deletion will fail if 5399 * the calling context lacks the 5400 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 5401 * named package cannot be found, or if the named package is a system 5402 * package. 5403 * 5404 * @param packageName The name of the package to delete 5405 * @param observer An observer callback to get notified when the package 5406 * deletion is complete. 5407 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 5408 * will be called when that happens. observer may be null to 5409 * indicate that no callback is desired. 5410 * @hide 5411 */ 5412 @RequiresPermission(Manifest.permission.DELETE_PACKAGES) 5413 public abstract void deletePackage(String packageName, IPackageDeleteObserver observer, 5414 @DeleteFlags int flags); 5415 5416 /** 5417 * Attempts to delete a package. Since this may take a little while, the 5418 * result will be posted back to the given observer. A deletion will fail if 5419 * the named package cannot be found, or if the named package is a system 5420 * package. 5421 * 5422 * @param packageName The name of the package to delete 5423 * @param observer An observer callback to get notified when the package 5424 * deletion is complete. 5425 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 5426 * will be called when that happens. observer may be null to 5427 * indicate that no callback is desired. 5428 * @param userId The user Id 5429 * @hide 5430 */ 5431 @RequiresPermission(anyOf = { 5432 Manifest.permission.DELETE_PACKAGES, 5433 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 5434 public abstract void deletePackageAsUser(@NonNull String packageName, 5435 IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId); 5436 5437 /** 5438 * Retrieve the package name of the application that installed a package. This identifies 5439 * which market the package came from. 5440 * 5441 * @param packageName The name of the package to query 5442 */ 5443 public abstract String getInstallerPackageName(String packageName); 5444 5445 /** 5446 * Attempts to clear the user data directory of an application. 5447 * Since this may take a little while, the result will 5448 * be posted back to the given observer. A deletion will fail if the 5449 * named package cannot be found, or if the named package is a "system package". 5450 * 5451 * @param packageName The name of the package 5452 * @param observer An observer callback to get notified when the operation is finished 5453 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5454 * will be called when that happens. observer may be null to indicate that 5455 * no callback is desired. 5456 * 5457 * @hide 5458 */ 5459 public abstract void clearApplicationUserData(String packageName, 5460 IPackageDataObserver observer); 5461 /** 5462 * Attempts to delete the cache files associated with an application. 5463 * Since this may take a little while, the result will 5464 * be posted back to the given observer. A deletion will fail if the calling context 5465 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 5466 * named package cannot be found, or if the named package is a "system package". 5467 * 5468 * @param packageName The name of the package to delete 5469 * @param observer An observer callback to get notified when the cache file deletion 5470 * is complete. 5471 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5472 * will be called when that happens. observer may be null to indicate that 5473 * no callback is desired. 5474 * 5475 * @hide 5476 */ 5477 public abstract void deleteApplicationCacheFiles(String packageName, 5478 IPackageDataObserver observer); 5479 5480 /** 5481 * Attempts to delete the cache files associated with an application for a given user. Since 5482 * this may take a little while, the result will be posted back to the given observer. A 5483 * deletion will fail if the calling context lacks the 5484 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package 5485 * cannot be found, or if the named package is a "system package". If {@code userId} does not 5486 * belong to the calling user, the caller must have 5487 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission. 5488 * 5489 * @param packageName The name of the package to delete 5490 * @param userId the user for which the cache files needs to be deleted 5491 * @param observer An observer callback to get notified when the cache file deletion is 5492 * complete. 5493 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5494 * will be called when that happens. observer may be null to indicate that no 5495 * callback is desired. 5496 * @hide 5497 */ 5498 public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId, 5499 IPackageDataObserver observer); 5500 5501 /** 5502 * Free storage by deleting LRU sorted list of cache files across 5503 * all applications. If the currently available free storage 5504 * on the device is greater than or equal to the requested 5505 * free storage, no cache files are cleared. If the currently 5506 * available storage on the device is less than the requested 5507 * free storage, some or all of the cache files across 5508 * all applications are deleted (based on last accessed time) 5509 * to increase the free storage space on the device to 5510 * the requested value. There is no guarantee that clearing all 5511 * the cache files from all applications will clear up 5512 * enough storage to achieve the desired value. 5513 * @param freeStorageSize The number of bytes of storage to be 5514 * freed by the system. Say if freeStorageSize is XX, 5515 * and the current free storage is YY, 5516 * if XX is less than YY, just return. if not free XX-YY number 5517 * of bytes if possible. 5518 * @param observer call back used to notify when 5519 * the operation is completed 5520 * 5521 * @hide 5522 */ 5523 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) { 5524 freeStorageAndNotify(null, freeStorageSize, observer); 5525 } 5526 5527 /** {@hide} */ 5528 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize, 5529 IPackageDataObserver observer); 5530 5531 /** 5532 * Free storage by deleting LRU sorted list of cache files across 5533 * all applications. If the currently available free storage 5534 * on the device is greater than or equal to the requested 5535 * free storage, no cache files are cleared. If the currently 5536 * available storage on the device is less than the requested 5537 * free storage, some or all of the cache files across 5538 * all applications are deleted (based on last accessed time) 5539 * to increase the free storage space on the device to 5540 * the requested value. There is no guarantee that clearing all 5541 * the cache files from all applications will clear up 5542 * enough storage to achieve the desired value. 5543 * @param freeStorageSize The number of bytes of storage to be 5544 * freed by the system. Say if freeStorageSize is XX, 5545 * and the current free storage is YY, 5546 * if XX is less than YY, just return. if not free XX-YY number 5547 * of bytes if possible. 5548 * @param pi IntentSender call back used to 5549 * notify when the operation is completed.May be null 5550 * to indicate that no call back is desired. 5551 * 5552 * @hide 5553 */ 5554 public void freeStorage(long freeStorageSize, IntentSender pi) { 5555 freeStorage(null, freeStorageSize, pi); 5556 } 5557 5558 /** {@hide} */ 5559 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi); 5560 5561 /** 5562 * Retrieve the size information for a package. 5563 * Since this may take a little while, the result will 5564 * be posted back to the given observer. The calling context 5565 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 5566 * 5567 * @param packageName The name of the package whose size information is to be retrieved 5568 * @param userId The user whose size information should be retrieved. 5569 * @param observer An observer callback to get notified when the operation 5570 * is complete. 5571 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 5572 * The observer's callback is invoked with a PackageStats object(containing the 5573 * code, data and cache sizes of the package) and a boolean value representing 5574 * the status of the operation. observer may be null to indicate that 5575 * no callback is desired. 5576 * 5577 * @deprecated use {@link StorageStatsManager} instead. 5578 * @hide 5579 */ 5580 @Deprecated 5581 public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId, 5582 IPackageStatsObserver observer); 5583 5584 /** 5585 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but 5586 * returns the size for the calling user. 5587 * 5588 * @deprecated use {@link StorageStatsManager} instead. 5589 * @hide 5590 */ 5591 @Deprecated 5592 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 5593 getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer); 5594 } 5595 5596 /** 5597 * @deprecated This function no longer does anything; it was an old 5598 * approach to managing preferred activities, which has been superseded 5599 * by (and conflicts with) the modern activity-based preferences. 5600 */ 5601 @Deprecated 5602 public abstract void addPackageToPreferred(String packageName); 5603 5604 /** 5605 * @deprecated This function no longer does anything; it was an old 5606 * approach to managing preferred activities, which has been superseded 5607 * by (and conflicts with) the modern activity-based preferences. 5608 */ 5609 @Deprecated 5610 public abstract void removePackageFromPreferred(String packageName); 5611 5612 /** 5613 * Retrieve the list of all currently configured preferred packages. The 5614 * first package on the list is the most preferred, the last is the 5615 * least preferred. 5616 * 5617 * @param flags Additional option flags. Use any combination of 5618 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 5619 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 5620 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 5621 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 5622 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 5623 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 5624 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 5625 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 5626 * {@link #MATCH_UNINSTALLED_PACKAGES} 5627 * to modify the data returned. 5628 * 5629 * @return A List of PackageInfo objects, one for each preferred application, 5630 * in order of preference. 5631 * 5632 * @see #GET_ACTIVITIES 5633 * @see #GET_CONFIGURATIONS 5634 * @see #GET_GIDS 5635 * @see #GET_INSTRUMENTATION 5636 * @see #GET_INTENT_FILTERS 5637 * @see #GET_META_DATA 5638 * @see #GET_PERMISSIONS 5639 * @see #GET_PROVIDERS 5640 * @see #GET_RECEIVERS 5641 * @see #GET_SERVICES 5642 * @see #GET_SHARED_LIBRARY_FILES 5643 * @see #GET_SIGNATURES 5644 * @see #GET_URI_PERMISSION_PATTERNS 5645 * @see #MATCH_DISABLED_COMPONENTS 5646 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 5647 * @see #MATCH_UNINSTALLED_PACKAGES 5648 */ 5649 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags); 5650 5651 /** 5652 * @deprecated This is a protected API that should not have been available 5653 * to third party applications. It is the platform's responsibility for 5654 * assigning preferred activities and this cannot be directly modified. 5655 * 5656 * Add a new preferred activity mapping to the system. This will be used 5657 * to automatically select the given activity component when 5658 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5659 * multiple matching activities and also matches the given filter. 5660 * 5661 * @param filter The set of intents under which this activity will be 5662 * made preferred. 5663 * @param match The IntentFilter match category that this preference 5664 * applies to. 5665 * @param set The set of activities that the user was picking from when 5666 * this preference was made. 5667 * @param activity The component name of the activity that is to be 5668 * preferred. 5669 */ 5670 @Deprecated 5671 public abstract void addPreferredActivity(IntentFilter filter, int match, 5672 ComponentName[] set, ComponentName activity); 5673 5674 /** 5675 * Same as {@link #addPreferredActivity(IntentFilter, int, 5676 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 5677 to. 5678 * @hide 5679 */ 5680 public void addPreferredActivityAsUser(IntentFilter filter, int match, 5681 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5682 throw new RuntimeException("Not implemented. Must override in a subclass."); 5683 } 5684 5685 /** 5686 * @deprecated This is a protected API that should not have been available 5687 * to third party applications. It is the platform's responsibility for 5688 * assigning preferred activities and this cannot be directly modified. 5689 * 5690 * Replaces an existing preferred activity mapping to the system, and if that were not present 5691 * adds a new preferred activity. This will be used 5692 * to automatically select the given activity component when 5693 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5694 * multiple matching activities and also matches the given filter. 5695 * 5696 * @param filter The set of intents under which this activity will be 5697 * made preferred. 5698 * @param match The IntentFilter match category that this preference 5699 * applies to. 5700 * @param set The set of activities that the user was picking from when 5701 * this preference was made. 5702 * @param activity The component name of the activity that is to be 5703 * preferred. 5704 * @hide 5705 */ 5706 @Deprecated 5707 public abstract void replacePreferredActivity(IntentFilter filter, int match, 5708 ComponentName[] set, ComponentName activity); 5709 5710 /** 5711 * @hide 5712 */ 5713 @Deprecated 5714 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 5715 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5716 throw new RuntimeException("Not implemented. Must override in a subclass."); 5717 } 5718 5719 /** 5720 * Remove all preferred activity mappings, previously added with 5721 * {@link #addPreferredActivity}, from the 5722 * system whose activities are implemented in the given package name. 5723 * An application can only clear its own package(s). 5724 * 5725 * @param packageName The name of the package whose preferred activity 5726 * mappings are to be removed. 5727 */ 5728 public abstract void clearPackagePreferredActivities(String packageName); 5729 5730 /** 5731 * Retrieve all preferred activities, previously added with 5732 * {@link #addPreferredActivity}, that are 5733 * currently registered with the system. 5734 * 5735 * @param outFilters A required list in which to place the filters of all of the 5736 * preferred activities. 5737 * @param outActivities A required list in which to place the component names of 5738 * all of the preferred activities. 5739 * @param packageName An optional package in which you would like to limit 5740 * the list. If null, all activities will be returned; if non-null, only 5741 * those activities in the given package are returned. 5742 * 5743 * @return Returns the total number of registered preferred activities 5744 * (the number of distinct IntentFilter records, not the number of unique 5745 * activity components) that were found. 5746 */ 5747 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 5748 @NonNull List<ComponentName> outActivities, String packageName); 5749 5750 /** 5751 * Ask for the set of available 'home' activities and the current explicit 5752 * default, if any. 5753 * @hide 5754 */ 5755 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 5756 5757 /** 5758 * Set the enabled setting for a package component (activity, receiver, service, provider). 5759 * This setting will override any enabled state which may have been set by the component in its 5760 * manifest. 5761 * 5762 * @param componentName The component to enable 5763 * @param newState The new enabled state for the component. The legal values for this state 5764 * are: 5765 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5766 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 5767 * and 5768 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 5769 * The last one removes the setting, thereby restoring the component's state to 5770 * whatever was set in it's manifest (or enabled, by default). 5771 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 5772 */ 5773 public abstract void setComponentEnabledSetting(ComponentName componentName, 5774 int newState, int flags); 5775 5776 /** 5777 * Return the enabled setting for a package component (activity, 5778 * receiver, service, provider). This returns the last value set by 5779 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 5780 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5781 * the value originally specified in the manifest has not been modified. 5782 * 5783 * @param componentName The component to retrieve. 5784 * @return Returns the current enabled state for the component. May 5785 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5786 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 5787 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 5788 * component's enabled state is based on the original information in 5789 * the manifest as found in {@link ComponentInfo}. 5790 */ 5791 public abstract int getComponentEnabledSetting(ComponentName componentName); 5792 5793 /** 5794 * Set the enabled setting for an application 5795 * This setting will override any enabled state which may have been set by the application in 5796 * its manifest. It also overrides the enabled state set in the manifest for any of the 5797 * application's components. It does not override any enabled state set by 5798 * {@link #setComponentEnabledSetting} for any of the application's components. 5799 * 5800 * @param packageName The package name of the application to enable 5801 * @param newState The new enabled state for the component. The legal values for this state 5802 * are: 5803 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5804 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 5805 * and 5806 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 5807 * The last one removes the setting, thereby restoring the applications's state to 5808 * whatever was set in its manifest (or enabled, by default). 5809 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 5810 */ 5811 public abstract void setApplicationEnabledSetting(String packageName, 5812 int newState, int flags); 5813 5814 /** 5815 * Return the enabled setting for an application. This returns 5816 * the last value set by 5817 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 5818 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5819 * the value originally specified in the manifest has not been modified. 5820 * 5821 * @param packageName The package name of the application to retrieve. 5822 * @return Returns the current enabled state for the application. May 5823 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5824 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 5825 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 5826 * application's enabled state is based on the original information in 5827 * the manifest as found in {@link ApplicationInfo}. 5828 * @throws IllegalArgumentException if the named package does not exist. 5829 */ 5830 public abstract int getApplicationEnabledSetting(String packageName); 5831 5832 /** 5833 * Flush the package restrictions for a given user to disk. This forces the package restrictions 5834 * like component and package enabled settings to be written to disk and avoids the delay that 5835 * is otherwise present when changing those settings. 5836 * 5837 * @param userId Ther userId of the user whose restrictions are to be flushed. 5838 * @hide 5839 */ 5840 public abstract void flushPackageRestrictionsAsUser(int userId); 5841 5842 /** 5843 * Puts the package in a hidden state, which is almost like an uninstalled state, 5844 * making the package unavailable, but it doesn't remove the data or the actual 5845 * package file. Application can be unhidden by either resetting the hidden state 5846 * or by installing it, such as with {@link #installExistingPackage(String)} 5847 * @hide 5848 */ 5849 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 5850 UserHandle userHandle); 5851 5852 /** 5853 * Returns the hidden state of a package. 5854 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 5855 * @hide 5856 */ 5857 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 5858 UserHandle userHandle); 5859 5860 /** 5861 * Return whether the device has been booted into safe mode. 5862 */ 5863 public abstract boolean isSafeMode(); 5864 5865 /** 5866 * Adds a listener for permission changes for installed packages. 5867 * 5868 * @param listener The listener to add. 5869 * 5870 * @hide 5871 */ 5872 @SystemApi 5873 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 5874 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5875 5876 /** 5877 * Remvoes a listener for permission changes for installed packages. 5878 * 5879 * @param listener The listener to remove. 5880 * 5881 * @hide 5882 */ 5883 @SystemApi 5884 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5885 5886 /** 5887 * Return the {@link KeySet} associated with the String alias for this 5888 * application. 5889 * 5890 * @param alias The alias for a given {@link KeySet} as defined in the 5891 * application's AndroidManifest.xml. 5892 * @hide 5893 */ 5894 public abstract KeySet getKeySetByAlias(String packageName, String alias); 5895 5896 /** Return the signing {@link KeySet} for this application. 5897 * @hide 5898 */ 5899 public abstract KeySet getSigningKeySet(String packageName); 5900 5901 /** 5902 * Return whether the package denoted by packageName has been signed by all 5903 * of the keys specified by the {@link KeySet} ks. This will return true if 5904 * the package has been signed by additional keys (a superset) as well. 5905 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 5906 * @hide 5907 */ 5908 public abstract boolean isSignedBy(String packageName, KeySet ks); 5909 5910 /** 5911 * Return whether the package denoted by packageName has been signed by all 5912 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 5913 * {@link #isSignedBy(String packageName, KeySet ks)}. 5914 * @hide 5915 */ 5916 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 5917 5918 /** 5919 * Puts the package in a suspended state, where attempts at starting activities are denied. 5920 * 5921 * <p>It doesn't remove the data or the actual package file. The application notifications 5922 * will be hidden, the application will not show up in recents, will not be able to show 5923 * toasts or dialogs or ring the device. 5924 * 5925 * <p>The package must already be installed. If the package is uninstalled while suspended 5926 * the package will no longer be suspended. 5927 * 5928 * @param packageNames The names of the packages to set the suspended status. 5929 * @param suspended If set to {@code true} than the packages will be suspended, if set to 5930 * {@code false} the packages will be unsuspended. 5931 * @param userId The user id. 5932 * 5933 * @return an array of package names for which the suspended status is not set as requested in 5934 * this method. 5935 * 5936 * @hide 5937 */ 5938 public abstract String[] setPackagesSuspendedAsUser( 5939 String[] packageNames, boolean suspended, @UserIdInt int userId); 5940 5941 /** 5942 * @see #setPackageSuspendedAsUser(String, boolean, int) 5943 * @param packageName The name of the package to get the suspended status of. 5944 * @param userId The user id. 5945 * @return {@code true} if the package is suspended or {@code false} if the package is not 5946 * suspended or could not be found. 5947 * @hide 5948 */ 5949 public abstract boolean isPackageSuspendedForUser(String packageName, int userId); 5950 5951 /** 5952 * Provide a hint of what the {@link ApplicationInfo#category} value should 5953 * be for the given package. 5954 * <p> 5955 * This hint can only be set by the app which installed this package, as 5956 * determined by {@link #getInstallerPackageName(String)}. 5957 */ 5958 public abstract void setApplicationCategoryHint(String packageName, 5959 @ApplicationInfo.Category int categoryHint); 5960 5961 /** {@hide} */ 5962 public static boolean isMoveStatusFinished(int status) { 5963 return (status < 0 || status > 100); 5964 } 5965 5966 /** {@hide} */ 5967 public static abstract class MoveCallback { 5968 public void onCreated(int moveId, Bundle extras) {} 5969 public abstract void onStatusChanged(int moveId, int status, long estMillis); 5970 } 5971 5972 /** {@hide} */ 5973 public abstract int getMoveStatus(int moveId); 5974 5975 /** {@hide} */ 5976 public abstract void registerMoveCallback(MoveCallback callback, Handler handler); 5977 /** {@hide} */ 5978 public abstract void unregisterMoveCallback(MoveCallback callback); 5979 5980 /** {@hide} */ 5981 public abstract int movePackage(String packageName, VolumeInfo vol); 5982 /** {@hide} */ 5983 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app); 5984 /** {@hide} */ 5985 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app); 5986 5987 /** {@hide} */ 5988 public abstract int movePrimaryStorage(VolumeInfo vol); 5989 /** {@hide} */ 5990 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 5991 /** {@hide} */ 5992 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 5993 5994 /** 5995 * Returns the device identity that verifiers can use to associate their scheme to a particular 5996 * device. This should not be used by anything other than a package verifier. 5997 * 5998 * @return identity that uniquely identifies current device 5999 * @hide 6000 */ 6001 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 6002 6003 /** 6004 * Returns true if the device is upgrading, such as first boot after OTA. 6005 * 6006 * @hide 6007 */ 6008 public abstract boolean isUpgrade(); 6009 6010 /** 6011 * Return interface that offers the ability to install, upgrade, and remove 6012 * applications on the device. 6013 */ 6014 public abstract @NonNull PackageInstaller getPackageInstaller(); 6015 6016 /** 6017 * Adds a {@code CrossProfileIntentFilter}. After calling this method all 6018 * intents sent from the user with id sourceUserId can also be be resolved 6019 * by activities in the user with id targetUserId if they match the 6020 * specified intent filter. 6021 * 6022 * @param filter The {@link IntentFilter} the intent has to match 6023 * @param sourceUserId The source user id. 6024 * @param targetUserId The target user id. 6025 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 6026 * {@link #ONLY_IF_NO_MATCH_FOUND}. 6027 * @hide 6028 */ 6029 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 6030 int targetUserId, int flags); 6031 6032 /** 6033 * Clearing {@code CrossProfileIntentFilter}s which have the specified user 6034 * as their source, and have been set by the app calling this method. 6035 * 6036 * @param sourceUserId The source user id. 6037 * @hide 6038 */ 6039 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 6040 6041 /** 6042 * @hide 6043 */ 6044 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 6045 6046 /** 6047 * @hide 6048 */ 6049 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 6050 6051 /** {@hide} */ 6052 public abstract boolean isPackageAvailable(String packageName); 6053 6054 /** {@hide} */ 6055 public static String installStatusToString(int status, String msg) { 6056 final String str = installStatusToString(status); 6057 if (msg != null) { 6058 return str + ": " + msg; 6059 } else { 6060 return str; 6061 } 6062 } 6063 6064 /** {@hide} */ 6065 public static String installStatusToString(int status) { 6066 switch (status) { 6067 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 6068 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 6069 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 6070 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 6071 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 6072 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 6073 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 6074 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 6075 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 6076 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 6077 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 6078 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 6079 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 6080 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 6081 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 6082 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 6083 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 6084 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 6085 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 6086 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 6087 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 6088 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 6089 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 6090 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 6091 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 6092 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 6093 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 6094 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 6095 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 6096 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 6097 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 6098 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 6099 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 6100 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 6101 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 6102 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 6103 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 6104 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 6105 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 6106 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 6107 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 6108 default: return Integer.toString(status); 6109 } 6110 } 6111 6112 /** {@hide} */ 6113 public static int installStatusToPublicStatus(int status) { 6114 switch (status) { 6115 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 6116 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6117 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 6118 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 6119 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 6120 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6121 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6122 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6123 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6124 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6125 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6126 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 6127 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6128 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6129 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6130 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 6131 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6132 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6133 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 6134 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 6135 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 6136 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 6137 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 6138 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 6139 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 6140 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 6141 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 6142 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 6143 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 6144 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 6145 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 6146 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 6147 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 6148 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 6149 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 6150 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 6151 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 6152 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 6153 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6154 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6155 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6156 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 6157 default: return PackageInstaller.STATUS_FAILURE; 6158 } 6159 } 6160 6161 /** {@hide} */ 6162 public static String deleteStatusToString(int status, String msg) { 6163 final String str = deleteStatusToString(status); 6164 if (msg != null) { 6165 return str + ": " + msg; 6166 } else { 6167 return str; 6168 } 6169 } 6170 6171 /** {@hide} */ 6172 public static String deleteStatusToString(int status) { 6173 switch (status) { 6174 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 6175 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 6176 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 6177 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 6178 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 6179 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 6180 case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY"; 6181 default: return Integer.toString(status); 6182 } 6183 } 6184 6185 /** {@hide} */ 6186 public static int deleteStatusToPublicStatus(int status) { 6187 switch (status) { 6188 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 6189 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 6190 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 6191 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 6192 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 6193 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 6194 case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6195 default: return PackageInstaller.STATUS_FAILURE; 6196 } 6197 } 6198 6199 /** {@hide} */ 6200 public static String permissionFlagToString(int flag) { 6201 switch (flag) { 6202 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 6203 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 6204 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 6205 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 6206 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE"; 6207 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 6208 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 6209 default: return Integer.toString(flag); 6210 } 6211 } 6212 6213 /** {@hide} */ 6214 public static class LegacyPackageInstallObserver extends PackageInstallObserver { 6215 private final IPackageInstallObserver mLegacy; 6216 6217 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { 6218 mLegacy = legacy; 6219 } 6220 6221 @Override 6222 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 6223 Bundle extras) { 6224 if (mLegacy == null) return; 6225 try { 6226 mLegacy.packageInstalled(basePackageName, returnCode); 6227 } catch (RemoteException ignored) { 6228 } 6229 } 6230 } 6231 6232 /** {@hide} */ 6233 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 6234 private final IPackageDeleteObserver mLegacy; 6235 6236 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 6237 mLegacy = legacy; 6238 } 6239 6240 @Override 6241 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 6242 if (mLegacy == null) return; 6243 try { 6244 mLegacy.packageDeleted(basePackageName, returnCode); 6245 } catch (RemoteException ignored) { 6246 } 6247 } 6248 } 6249 6250 /** 6251 * Return the install reason that was recorded when a package was first installed for a specific 6252 * user. Requesting the install reason for another user will require the permission 6253 * INTERACT_ACROSS_USERS_FULL. 6254 * 6255 * @param packageName The package for which to retrieve the install reason 6256 * @param user The user for whom to retrieve the install reason 6257 * 6258 * @return The install reason, currently one of {@code INSTALL_REASON_UNKNOWN} and 6259 * {@code INSTALL_REASON_POLICY}. If the package is not installed for the given user, 6260 * {@code INSTALL_REASON_UNKNOWN} is returned. 6261 * 6262 * @see #INSTALL_REASON_UNKNOWN 6263 * @see #INSTALL_REASON_POLICY 6264 * @see #INSTALL_REASON_DEVICE_RESTORE 6265 * @see #INSTALL_REASON_DEVICE_SETUP 6266 * @see #INSTALL_REASON_USER 6267 * 6268 * @hide 6269 */ 6270 @TestApi 6271 public abstract @InstallReason int getInstallReason(String packageName, 6272 @NonNull UserHandle user); 6273 6274 /** 6275 * Checks whether the calling package is allowed to request package installs through package 6276 * installer. Apps are encouraged to call this api before launching the package installer via 6277 * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the 6278 * user can explicitly choose what external sources they trust to install apps on the device. 6279 * If this api returns false, the install request will be blocked by the package installer and 6280 * a dialog will be shown to the user with an option to launch settings to change their 6281 * preference. An application must target Android O or higher and declare permission 6282 * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this api. 6283 * 6284 * @return true if the calling package is trusted by the user to request install packages on 6285 * the device, false otherwise. 6286 * @see {@link android.content.Intent#ACTION_INSTALL_PACKAGE} 6287 * @see {@link android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES} 6288 */ 6289 public abstract boolean canRequestPackageInstalls(); 6290 6291 /** 6292 * Return the {@link ComponentName} of the activity providing Settings for the Instant App 6293 * resolver. 6294 * 6295 * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS} 6296 * @hide 6297 */ 6298 @SystemApi 6299 public abstract ComponentName getInstantAppResolverSettingsComponent(); 6300 6301 /** 6302 * Return the {@link ComponentName} of the activity responsible for installing instant 6303 * applications. 6304 * 6305 * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE} 6306 * @hide 6307 */ 6308 @SystemApi 6309 public abstract ComponentName getInstantAppInstallerComponent(); 6310} 6311