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