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