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