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