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