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