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