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