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