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