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