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