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