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