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