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