PackageManager.java revision 0a111ad6d08db275aa1d7d2079ab017eeb05578b
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, as defined in the Android Compatibility Definition Document (CDD) 1660 * <a href="https://source.android.com/compatibility/android-cdd#7_8_audio">section 7.8 Audio</a>. 1661 */ 1662 @SdkConstant(SdkConstantType.FEATURE) 1663 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output"; 1664 1665 /** 1666 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1667 * The device has professional audio level of functionality and performance. 1668 */ 1669 @SdkConstant(SdkConstantType.FEATURE) 1670 public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro"; 1671 1672 /** 1673 * Feature for {@link #getSystemAvailableFeatures} and 1674 * {@link #hasSystemFeature}: The device is capable of communicating with 1675 * other devices via Bluetooth. 1676 */ 1677 @SdkConstant(SdkConstantType.FEATURE) 1678 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 1679 1680 /** 1681 * Feature for {@link #getSystemAvailableFeatures} and 1682 * {@link #hasSystemFeature}: The device is capable of communicating with 1683 * other devices via Bluetooth Low Energy radio. 1684 */ 1685 @SdkConstant(SdkConstantType.FEATURE) 1686 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le"; 1687 1688 /** 1689 * Feature for {@link #getSystemAvailableFeatures} and 1690 * {@link #hasSystemFeature}: The device has a camera facing away 1691 * from the screen. 1692 */ 1693 @SdkConstant(SdkConstantType.FEATURE) 1694 public static final String FEATURE_CAMERA = "android.hardware.camera"; 1695 1696 /** 1697 * Feature for {@link #getSystemAvailableFeatures} and 1698 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 1699 */ 1700 @SdkConstant(SdkConstantType.FEATURE) 1701 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 1702 1703 /** 1704 * Feature for {@link #getSystemAvailableFeatures} and 1705 * {@link #hasSystemFeature}: The device has at least one camera pointing in 1706 * some direction, or can support an external camera being connected to it. 1707 */ 1708 @SdkConstant(SdkConstantType.FEATURE) 1709 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any"; 1710 1711 /** 1712 * Feature for {@link #getSystemAvailableFeatures} and 1713 * {@link #hasSystemFeature}: The device can support having an external camera connected to it. 1714 * The external camera may not always be connected or available to applications to use. 1715 */ 1716 @SdkConstant(SdkConstantType.FEATURE) 1717 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external"; 1718 1719 /** 1720 * Feature for {@link #getSystemAvailableFeatures} and 1721 * {@link #hasSystemFeature}: The device's camera supports flash. 1722 */ 1723 @SdkConstant(SdkConstantType.FEATURE) 1724 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 1725 1726 /** 1727 * Feature for {@link #getSystemAvailableFeatures} and 1728 * {@link #hasSystemFeature}: The device has a front facing camera. 1729 */ 1730 @SdkConstant(SdkConstantType.FEATURE) 1731 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 1732 1733 /** 1734 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1735 * of the cameras on the device supports the 1736 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware} 1737 * capability level. 1738 */ 1739 @SdkConstant(SdkConstantType.FEATURE) 1740 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full"; 1741 1742 /** 1743 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1744 * of the cameras on the device supports the 1745 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor} 1746 * capability level. 1747 */ 1748 @SdkConstant(SdkConstantType.FEATURE) 1749 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR = 1750 "android.hardware.camera.capability.manual_sensor"; 1751 1752 /** 1753 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1754 * of the cameras on the device supports the 1755 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing} 1756 * capability level. 1757 */ 1758 @SdkConstant(SdkConstantType.FEATURE) 1759 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING = 1760 "android.hardware.camera.capability.manual_post_processing"; 1761 1762 /** 1763 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1764 * of the cameras on the device supports the 1765 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW} 1766 * capability level. 1767 */ 1768 @SdkConstant(SdkConstantType.FEATURE) 1769 public static final String FEATURE_CAMERA_CAPABILITY_RAW = 1770 "android.hardware.camera.capability.raw"; 1771 1772 /** 1773 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1774 * of the cameras on the device supports the 1775 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MOTION_TRACKING 1776 * MOTION_TRACKING} capability level. 1777 */ 1778 @SdkConstant(SdkConstantType.FEATURE) 1779 public static final String FEATURE_CAMERA_AR = 1780 "android.hardware.camera.ar"; 1781 1782 /** 1783 * Feature for {@link #getSystemAvailableFeatures} and 1784 * {@link #hasSystemFeature}: The device is capable of communicating with 1785 * consumer IR devices. 1786 */ 1787 @SdkConstant(SdkConstantType.FEATURE) 1788 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir"; 1789 1790 /** {@hide} */ 1791 @SdkConstant(SdkConstantType.FEATURE) 1792 public static final String FEATURE_CTS = "android.software.cts"; 1793 1794 /** 1795 * Feature for {@link #getSystemAvailableFeatures} and 1796 * {@link #hasSystemFeature}: The device supports one or more methods of 1797 * reporting current location. 1798 */ 1799 @SdkConstant(SdkConstantType.FEATURE) 1800 public static final String FEATURE_LOCATION = "android.hardware.location"; 1801 1802 /** 1803 * Feature for {@link #getSystemAvailableFeatures} and 1804 * {@link #hasSystemFeature}: The device has a Global Positioning System 1805 * receiver and can report precise location. 1806 */ 1807 @SdkConstant(SdkConstantType.FEATURE) 1808 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 1809 1810 /** 1811 * Feature for {@link #getSystemAvailableFeatures} and 1812 * {@link #hasSystemFeature}: The device can report location with coarse 1813 * accuracy using a network-based geolocation system. 1814 */ 1815 @SdkConstant(SdkConstantType.FEATURE) 1816 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 1817 1818 /** 1819 * Feature for {@link #getSystemAvailableFeatures} and 1820 * {@link #hasSystemFeature}: The device's 1821 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns 1822 * true. 1823 */ 1824 @SdkConstant(SdkConstantType.FEATURE) 1825 public static final String FEATURE_RAM_LOW = "android.hardware.ram.low"; 1826 1827 /** 1828 * Feature for {@link #getSystemAvailableFeatures} and 1829 * {@link #hasSystemFeature}: The device's 1830 * {@link ActivityManager#isLowRamDevice() ActivityManager.isLowRamDevice()} method returns 1831 * false. 1832 */ 1833 @SdkConstant(SdkConstantType.FEATURE) 1834 public static final String FEATURE_RAM_NORMAL = "android.hardware.ram.normal"; 1835 1836 /** 1837 * Feature for {@link #getSystemAvailableFeatures} and 1838 * {@link #hasSystemFeature}: The device can record audio via a 1839 * microphone. 1840 */ 1841 @SdkConstant(SdkConstantType.FEATURE) 1842 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 1843 1844 /** 1845 * Feature for {@link #getSystemAvailableFeatures} and 1846 * {@link #hasSystemFeature}: The device can communicate using Near-Field 1847 * Communications (NFC). 1848 */ 1849 @SdkConstant(SdkConstantType.FEATURE) 1850 public static final String FEATURE_NFC = "android.hardware.nfc"; 1851 1852 /** 1853 * Feature for {@link #getSystemAvailableFeatures} and 1854 * {@link #hasSystemFeature}: The device supports host- 1855 * based NFC card emulation. 1856 * 1857 * TODO remove when depending apps have moved to new constant. 1858 * @hide 1859 * @deprecated 1860 */ 1861 @Deprecated 1862 @SdkConstant(SdkConstantType.FEATURE) 1863 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce"; 1864 1865 /** 1866 * Feature for {@link #getSystemAvailableFeatures} and 1867 * {@link #hasSystemFeature}: The device supports host- 1868 * based NFC card emulation. 1869 */ 1870 @SdkConstant(SdkConstantType.FEATURE) 1871 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; 1872 1873 /** 1874 * Feature for {@link #getSystemAvailableFeatures} and 1875 * {@link #hasSystemFeature}: The device supports host- 1876 * based NFC-F card emulation. 1877 */ 1878 @SdkConstant(SdkConstantType.FEATURE) 1879 public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef"; 1880 1881 /** 1882 * Feature for {@link #getSystemAvailableFeatures} and 1883 * {@link #hasSystemFeature}: The device supports any 1884 * one of the {@link #FEATURE_NFC}, {@link #FEATURE_NFC_HOST_CARD_EMULATION}, 1885 * or {@link #FEATURE_NFC_HOST_CARD_EMULATION_NFCF} features. 1886 * 1887 * @hide 1888 */ 1889 @SdkConstant(SdkConstantType.FEATURE) 1890 public static final String FEATURE_NFC_ANY = "android.hardware.nfc.any"; 1891 1892 /** 1893 * Feature for {@link #getSystemAvailableFeatures} and 1894 * {@link #hasSystemFeature}: The device supports the OpenGL ES 1895 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 1896 * Android Extension Pack</a>. 1897 */ 1898 @SdkConstant(SdkConstantType.FEATURE) 1899 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 1900 1901 /** 1902 * Feature for {@link #getSystemAvailableFeatures} and 1903 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API 1904 * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate 1905 * what level of optional hardware features limits it supports. 1906 * <p> 1907 * Level 0 includes the base Vulkan requirements as well as: 1908 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul> 1909 * <p> 1910 * Level 1 additionally includes: 1911 * <ul> 1912 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li> 1913 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li> 1914 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li> 1915 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li> 1916 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li> 1917 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li> 1918 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li> 1919 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li> 1920 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li> 1921 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li> 1922 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li> 1923 * </ul> 1924 */ 1925 @SdkConstant(SdkConstantType.FEATURE) 1926 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level"; 1927 1928 /** 1929 * Feature for {@link #getSystemAvailableFeatures} and 1930 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API 1931 * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate 1932 * what level of optional compute features that device supports beyond the Vulkan 1.0 1933 * requirements. 1934 * <p> 1935 * Compute level 0 indicates: 1936 * <ul> 1937 * <li>The {@code VK_KHR_variable_pointers} extension and 1938 * {@code VkPhysicalDeviceVariablePointerFeaturesKHR::variablePointers} feature are 1939 supported.</li> 1940 * <li>{@code VkPhysicalDeviceLimits::maxPerStageDescriptorStorageBuffers} is at least 16.</li> 1941 * </ul> 1942 */ 1943 @SdkConstant(SdkConstantType.FEATURE) 1944 public static final String FEATURE_VULKAN_HARDWARE_COMPUTE = "android.hardware.vulkan.compute"; 1945 1946 /** 1947 * Feature for {@link #getSystemAvailableFeatures} and 1948 * {@link #hasSystemFeature(String, int)}: The version of this feature indicates the highest 1949 * {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices that support 1950 * the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The feature version 1951 * uses the same encoding as Vulkan version numbers: 1952 * <ul> 1953 * <li>Major version number in bits 31-22</li> 1954 * <li>Minor version number in bits 21-12</li> 1955 * <li>Patch version number in bits 11-0</li> 1956 * </ul> 1957 * A version of 1.1.0 or higher also indicates: 1958 * <ul> 1959 * <li>The {@code VK_ANDROID_external_memory_android_hardware_buffer} extension is 1960 * supported.</li> 1961 * <li>{@code SYNC_FD} external semaphore and fence handles are supported.</li> 1962 * <li>{@code VkPhysicalDeviceSamplerYcbcrConversionFeatures::samplerYcbcrConversion} is 1963 * supported.</li> 1964 * </ul> 1965 */ 1966 @SdkConstant(SdkConstantType.FEATURE) 1967 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version"; 1968 1969 /** 1970 * Feature for {@link #getSystemAvailableFeatures} and 1971 * {@link #hasSystemFeature}: The device includes broadcast radio tuner. 1972 * @hide 1973 */ 1974 @SystemApi 1975 @SdkConstant(SdkConstantType.FEATURE) 1976 public static final String FEATURE_BROADCAST_RADIO = "android.hardware.broadcastradio"; 1977 1978 /** 1979 * Feature for {@link #getSystemAvailableFeatures} and 1980 * {@link #hasSystemFeature}: The device includes an accelerometer. 1981 */ 1982 @SdkConstant(SdkConstantType.FEATURE) 1983 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 1984 1985 /** 1986 * Feature for {@link #getSystemAvailableFeatures} and 1987 * {@link #hasSystemFeature}: The device includes a barometer (air 1988 * pressure sensor.) 1989 */ 1990 @SdkConstant(SdkConstantType.FEATURE) 1991 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 1992 1993 /** 1994 * Feature for {@link #getSystemAvailableFeatures} and 1995 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 1996 */ 1997 @SdkConstant(SdkConstantType.FEATURE) 1998 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 1999 2000 /** 2001 * Feature for {@link #getSystemAvailableFeatures} and 2002 * {@link #hasSystemFeature}: The device includes a gyroscope. 2003 */ 2004 @SdkConstant(SdkConstantType.FEATURE) 2005 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 2006 2007 /** 2008 * Feature for {@link #getSystemAvailableFeatures} and 2009 * {@link #hasSystemFeature}: The device includes a light sensor. 2010 */ 2011 @SdkConstant(SdkConstantType.FEATURE) 2012 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 2013 2014 /** 2015 * Feature for {@link #getSystemAvailableFeatures} and 2016 * {@link #hasSystemFeature}: The device includes a proximity sensor. 2017 */ 2018 @SdkConstant(SdkConstantType.FEATURE) 2019 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 2020 2021 /** 2022 * Feature for {@link #getSystemAvailableFeatures} and 2023 * {@link #hasSystemFeature}: The device includes a hardware step counter. 2024 */ 2025 @SdkConstant(SdkConstantType.FEATURE) 2026 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 2027 2028 /** 2029 * Feature for {@link #getSystemAvailableFeatures} and 2030 * {@link #hasSystemFeature}: The device includes a hardware step detector. 2031 */ 2032 @SdkConstant(SdkConstantType.FEATURE) 2033 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 2034 2035 /** 2036 * Feature for {@link #getSystemAvailableFeatures} and 2037 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 2038 */ 2039 @SdkConstant(SdkConstantType.FEATURE) 2040 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 2041 2042 /** 2043 * Feature for {@link #getSystemAvailableFeatures} and 2044 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram. 2045 */ 2046 @SdkConstant(SdkConstantType.FEATURE) 2047 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 2048 "android.hardware.sensor.heartrate.ecg"; 2049 2050 /** 2051 * Feature for {@link #getSystemAvailableFeatures} and 2052 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 2053 */ 2054 @SdkConstant(SdkConstantType.FEATURE) 2055 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 2056 "android.hardware.sensor.relative_humidity"; 2057 2058 /** 2059 * Feature for {@link #getSystemAvailableFeatures} and 2060 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 2061 */ 2062 @SdkConstant(SdkConstantType.FEATURE) 2063 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 2064 "android.hardware.sensor.ambient_temperature"; 2065 2066 /** 2067 * Feature for {@link #getSystemAvailableFeatures} and 2068 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing 2069 * capabilities. 2070 */ 2071 @SdkConstant(SdkConstantType.FEATURE) 2072 public static final String FEATURE_HIFI_SENSORS = 2073 "android.hardware.sensor.hifi_sensors"; 2074 2075 /** 2076 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2077 * The device supports a hardware mechanism for invoking an assist gesture. 2078 * @see android.provider.Settings.Secure#ASSIST_GESTURE_ENABLED 2079 * @hide 2080 */ 2081 @SdkConstant(SdkConstantType.FEATURE) 2082 public static final String FEATURE_ASSIST_GESTURE = "android.hardware.sensor.assist"; 2083 2084 /** 2085 * Feature for {@link #getSystemAvailableFeatures} and 2086 * {@link #hasSystemFeature}: The device has a telephony radio with data 2087 * communication support. 2088 */ 2089 @SdkConstant(SdkConstantType.FEATURE) 2090 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 2091 2092 /** 2093 * Feature for {@link #getSystemAvailableFeatures} and 2094 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 2095 */ 2096 @SdkConstant(SdkConstantType.FEATURE) 2097 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 2098 2099 /** 2100 * Feature for {@link #getSystemAvailableFeatures} and 2101 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 2102 */ 2103 @SdkConstant(SdkConstantType.FEATURE) 2104 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 2105 2106 /** 2107 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2108 * The device supports telephony carrier restriction mechanism. 2109 * 2110 * <p>Devices declaring this feature must have an implementation of the 2111 * {@link android.telephony.TelephonyManager#getAllowedCarriers} and 2112 * {@link android.telephony.TelephonyManager#setAllowedCarriers}. 2113 * @hide 2114 */ 2115 @SystemApi 2116 @SdkConstant(SdkConstantType.FEATURE) 2117 public static final String FEATURE_TELEPHONY_CARRIERLOCK = 2118 "android.hardware.telephony.carrierlock"; 2119 2120 /** 2121 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 2122 * supports embedded subscriptions on eUICCs. 2123 */ 2124 @SdkConstant(SdkConstantType.FEATURE) 2125 public static final String FEATURE_TELEPHONY_EUICC = "android.hardware.telephony.euicc"; 2126 2127 /** 2128 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device 2129 * supports cell-broadcast reception using the MBMS APIs. 2130 */ 2131 @SdkConstant(SdkConstantType.FEATURE) 2132 public static final String FEATURE_TELEPHONY_MBMS = "android.hardware.telephony.mbms"; 2133 2134 /** 2135 * Feature for {@link #getSystemAvailableFeatures} and 2136 * {@link #hasSystemFeature}: The device supports connecting to USB devices 2137 * as the USB host. 2138 */ 2139 @SdkConstant(SdkConstantType.FEATURE) 2140 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 2141 2142 /** 2143 * Feature for {@link #getSystemAvailableFeatures} and 2144 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 2145 */ 2146 @SdkConstant(SdkConstantType.FEATURE) 2147 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 2148 2149 /** 2150 * Feature for {@link #getSystemAvailableFeatures} and 2151 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 2152 */ 2153 @SdkConstant(SdkConstantType.FEATURE) 2154 public static final String FEATURE_SIP = "android.software.sip"; 2155 2156 /** 2157 * Feature for {@link #getSystemAvailableFeatures} and 2158 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 2159 */ 2160 @SdkConstant(SdkConstantType.FEATURE) 2161 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 2162 2163 /** 2164 * Feature for {@link #getSystemAvailableFeatures} and 2165 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device. 2166 */ 2167 @SdkConstant(SdkConstantType.FEATURE) 2168 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice"; 2169 2170 /** 2171 * Feature for {@link #getSystemAvailableFeatures} and 2172 * {@link #hasSystemFeature}: The device's display has a touch screen. 2173 */ 2174 @SdkConstant(SdkConstantType.FEATURE) 2175 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 2176 2177 /** 2178 * Feature for {@link #getSystemAvailableFeatures} and 2179 * {@link #hasSystemFeature}: The device's touch screen supports 2180 * multitouch sufficient for basic two-finger gesture detection. 2181 */ 2182 @SdkConstant(SdkConstantType.FEATURE) 2183 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 2184 2185 /** 2186 * Feature for {@link #getSystemAvailableFeatures} and 2187 * {@link #hasSystemFeature}: The device's touch screen is capable of 2188 * tracking two or more fingers fully independently. 2189 */ 2190 @SdkConstant(SdkConstantType.FEATURE) 2191 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 2192 2193 /** 2194 * Feature for {@link #getSystemAvailableFeatures} and 2195 * {@link #hasSystemFeature}: The device's touch screen is capable of 2196 * tracking a full hand of fingers fully independently -- that is, 5 or 2197 * more simultaneous independent pointers. 2198 */ 2199 @SdkConstant(SdkConstantType.FEATURE) 2200 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 2201 2202 /** 2203 * Feature for {@link #getSystemAvailableFeatures} and 2204 * {@link #hasSystemFeature}: The device does not have a touch screen, but 2205 * does support touch emulation for basic events. For instance, the 2206 * device might use a mouse or remote control to drive a cursor, and 2207 * emulate basic touch pointer events like down, up, drag, etc. All 2208 * devices that support android.hardware.touchscreen or a sub-feature are 2209 * presumed to also support faketouch. 2210 */ 2211 @SdkConstant(SdkConstantType.FEATURE) 2212 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 2213 2214 /** 2215 * Feature for {@link #getSystemAvailableFeatures} and 2216 * {@link #hasSystemFeature}: The device does not have a touch screen, but 2217 * does support touch emulation for basic events that supports distinct 2218 * tracking of two or more fingers. This is an extension of 2219 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 2220 * that unlike a distinct multitouch screen as defined by 2221 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 2222 * devices will not actually provide full two-finger gestures since the 2223 * input is being transformed to cursor movement on the screen. That is, 2224 * single finger gestures will move a cursor; two-finger swipes will 2225 * result in single-finger touch events; other two-finger gestures will 2226 * result in the corresponding two-finger touch event. 2227 */ 2228 @SdkConstant(SdkConstantType.FEATURE) 2229 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 2230 2231 /** 2232 * Feature for {@link #getSystemAvailableFeatures} and 2233 * {@link #hasSystemFeature}: The device does not have a touch screen, but 2234 * does support touch emulation for basic events that supports tracking 2235 * a hand of fingers (5 or more fingers) fully independently. 2236 * This is an extension of 2237 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 2238 * that unlike a multitouch screen as defined by 2239 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 2240 * gestures can be detected due to the limitations described for 2241 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 2242 */ 2243 @SdkConstant(SdkConstantType.FEATURE) 2244 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 2245 2246 /** 2247 * Feature for {@link #getSystemAvailableFeatures} and 2248 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint. 2249 */ 2250 @SdkConstant(SdkConstantType.FEATURE) 2251 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; 2252 2253 /** 2254 * Feature for {@link #getSystemAvailableFeatures} and 2255 * {@link #hasSystemFeature}: The device supports portrait orientation 2256 * screens. For backwards compatibility, you can assume that if neither 2257 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 2258 * both portrait and landscape. 2259 */ 2260 @SdkConstant(SdkConstantType.FEATURE) 2261 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 2262 2263 /** 2264 * Feature for {@link #getSystemAvailableFeatures} and 2265 * {@link #hasSystemFeature}: The device supports landscape orientation 2266 * screens. For backwards compatibility, you can assume that if neither 2267 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 2268 * both portrait and landscape. 2269 */ 2270 @SdkConstant(SdkConstantType.FEATURE) 2271 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 2272 2273 /** 2274 * Feature for {@link #getSystemAvailableFeatures} and 2275 * {@link #hasSystemFeature}: The device supports live wallpapers. 2276 */ 2277 @SdkConstant(SdkConstantType.FEATURE) 2278 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 2279 /** 2280 * Feature for {@link #getSystemAvailableFeatures} and 2281 * {@link #hasSystemFeature}: The device supports app widgets. 2282 */ 2283 @SdkConstant(SdkConstantType.FEATURE) 2284 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 2285 /** 2286 * Feature for {@link #getSystemAvailableFeatures} and 2287 * {@link #hasSystemFeature}: The device supports the 2288 * {@link android.R.attr#cantSaveState} API. 2289 */ 2290 @SdkConstant(SdkConstantType.FEATURE) 2291 public static final String FEATURE_CANT_SAVE_STATE = "android.software.cant_save_state"; 2292 2293 /** 2294 * @hide 2295 * Feature for {@link #getSystemAvailableFeatures} and 2296 * {@link #hasSystemFeature}: The device supports 2297 * {@link android.service.voice.VoiceInteractionService} and 2298 * {@link android.app.VoiceInteractor}. 2299 */ 2300 @SdkConstant(SdkConstantType.FEATURE) 2301 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 2302 2303 2304 /** 2305 * Feature for {@link #getSystemAvailableFeatures} and 2306 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 2307 * by third party applications. 2308 */ 2309 @SdkConstant(SdkConstantType.FEATURE) 2310 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 2311 2312 /** 2313 * Feature for {@link #getSystemAvailableFeatures} and 2314 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 2315 * with the {@link android.inputmethodservice.InputMethodService} API. 2316 */ 2317 @SdkConstant(SdkConstantType.FEATURE) 2318 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 2319 2320 /** 2321 * Feature for {@link #getSystemAvailableFeatures} and 2322 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 2323 */ 2324 @SdkConstant(SdkConstantType.FEATURE) 2325 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 2326 2327 /** 2328 * Feature for {@link #getSystemAvailableFeatures} and 2329 * {@link #hasSystemFeature}: The device supports leanback UI. This is 2330 * typically used in a living room television experience, but is a software 2331 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 2332 * feature will use resources associated with the "television" UI mode. 2333 */ 2334 @SdkConstant(SdkConstantType.FEATURE) 2335 public static final String FEATURE_LEANBACK = "android.software.leanback"; 2336 2337 /** 2338 * Feature for {@link #getSystemAvailableFeatures} and 2339 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 2340 * applications designed for this experience should be run, though this is 2341 * not enforced by the system. 2342 */ 2343 @SdkConstant(SdkConstantType.FEATURE) 2344 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 2345 2346 /** 2347 * Feature for {@link #getSystemAvailableFeatures} and 2348 * {@link #hasSystemFeature}: The device supports live TV and can display 2349 * contents from TV inputs implemented with the 2350 * {@link android.media.tv.TvInputService} API. 2351 */ 2352 @SdkConstant(SdkConstantType.FEATURE) 2353 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 2354 2355 /** 2356 * Feature for {@link #getSystemAvailableFeatures} and 2357 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 2358 */ 2359 @SdkConstant(SdkConstantType.FEATURE) 2360 public static final String FEATURE_WIFI = "android.hardware.wifi"; 2361 2362 /** 2363 * Feature for {@link #getSystemAvailableFeatures} and 2364 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 2365 */ 2366 @SdkConstant(SdkConstantType.FEATURE) 2367 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 2368 2369 /** 2370 * Feature for {@link #getSystemAvailableFeatures} and 2371 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware. 2372 */ 2373 @SdkConstant(SdkConstantType.FEATURE) 2374 public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware"; 2375 2376 /** 2377 * Feature for {@link #getSystemAvailableFeatures} and 2378 * {@link #hasSystemFeature}: The device supports Wi-Fi Passpoint and all 2379 * Passpoint related APIs in {@link WifiManager} are supported. Refer to 2380 * {@link WifiManager#addOrUpdatePasspointConfiguration} for more info. 2381 */ 2382 @SdkConstant(SdkConstantType.FEATURE) 2383 public static final String FEATURE_WIFI_PASSPOINT = "android.hardware.wifi.passpoint"; 2384 2385 /** 2386 * Feature for {@link #getSystemAvailableFeatures} and 2387 * {@link #hasSystemFeature}: The device supports Wi-Fi RTT (IEEE 802.11mc). 2388 */ 2389 @SdkConstant(SdkConstantType.FEATURE) 2390 public static final String FEATURE_WIFI_RTT = "android.hardware.wifi.rtt"; 2391 2392 2393 /** 2394 * Feature for {@link #getSystemAvailableFeatures} and 2395 * {@link #hasSystemFeature}: The device supports LoWPAN networking. 2396 * @hide 2397 */ 2398 @SdkConstant(SdkConstantType.FEATURE) 2399 public static final String FEATURE_LOWPAN = "android.hardware.lowpan"; 2400 2401 /** 2402 * Feature for {@link #getSystemAvailableFeatures} and 2403 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 2404 * on a vehicle headunit. A headunit here is defined to be inside a 2405 * vehicle that may or may not be moving. A headunit uses either a 2406 * primary display in the center console and/or additional displays in 2407 * the instrument cluster or elsewhere in the vehicle. Headunit display(s) 2408 * have limited size and resolution. The user will likely be focused on 2409 * driving so limiting driver distraction is a primary concern. User input 2410 * can be a variety of hard buttons, touch, rotary controllers and even mouse- 2411 * like interfaces. 2412 */ 2413 @SdkConstant(SdkConstantType.FEATURE) 2414 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive"; 2415 2416 /** 2417 * Feature for {@link #getSystemAvailableFeatures} and 2418 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 2419 * on a television. Television here is defined to be a typical living 2420 * room television experience: displayed on a big screen, where the user 2421 * is sitting far away from it, and the dominant form of input will be 2422 * something like a DPAD, not through touch or mouse. 2423 * @deprecated use {@link #FEATURE_LEANBACK} instead. 2424 */ 2425 @Deprecated 2426 @SdkConstant(SdkConstantType.FEATURE) 2427 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 2428 2429 /** 2430 * Feature for {@link #getSystemAvailableFeatures} and 2431 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 2432 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 2433 * the wrist. The user is very close when interacting with the device. 2434 */ 2435 @SdkConstant(SdkConstantType.FEATURE) 2436 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 2437 2438 /** 2439 * Feature for {@link #getSystemAvailableFeatures} and 2440 * {@link #hasSystemFeature}: This is a device for IoT and may not have an UI. An embedded 2441 * device is defined as a full stack Android device with or without a display and no 2442 * user-installable apps. 2443 */ 2444 @SdkConstant(SdkConstantType.FEATURE) 2445 public static final String FEATURE_EMBEDDED = "android.hardware.type.embedded"; 2446 2447 /** 2448 * Feature for {@link #getSystemAvailableFeatures} and 2449 * {@link #hasSystemFeature}: This is a device dedicated to be primarily used 2450 * with keyboard, mouse or touchpad. This includes traditional desktop 2451 * computers, laptops and variants such as convertibles or detachables. 2452 * Due to the larger screen, the device will most likely use the 2453 * {@link #FEATURE_FREEFORM_WINDOW_MANAGEMENT} feature as well. 2454 */ 2455 @SdkConstant(SdkConstantType.FEATURE) 2456 public static final String FEATURE_PC = "android.hardware.type.pc"; 2457 2458 /** 2459 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2460 * The device supports printing. 2461 */ 2462 @SdkConstant(SdkConstantType.FEATURE) 2463 public static final String FEATURE_PRINTING = "android.software.print"; 2464 2465 /** 2466 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2467 * The device supports {@link android.companion.CompanionDeviceManager#associate associating} 2468 * with devices via {@link android.companion.CompanionDeviceManager}. 2469 */ 2470 @SdkConstant(SdkConstantType.FEATURE) 2471 public static final String FEATURE_COMPANION_DEVICE_SETUP 2472 = "android.software.companion_device_setup"; 2473 2474 /** 2475 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2476 * The device can perform backup and restore operations on installed applications. 2477 */ 2478 @SdkConstant(SdkConstantType.FEATURE) 2479 public static final String FEATURE_BACKUP = "android.software.backup"; 2480 2481 /** 2482 * Feature for {@link #getSystemAvailableFeatures} and 2483 * {@link #hasSystemFeature}: The device supports freeform window management. 2484 * Windows have title bars and can be moved and resized. 2485 */ 2486 // If this feature is present, you also need to set 2487 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay. 2488 @SdkConstant(SdkConstantType.FEATURE) 2489 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT 2490 = "android.software.freeform_window_management"; 2491 2492 /** 2493 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2494 * The device supports picture-in-picture multi-window mode. 2495 */ 2496 @SdkConstant(SdkConstantType.FEATURE) 2497 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; 2498 2499 /** 2500 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2501 * The device supports running activities on secondary displays. 2502 */ 2503 @SdkConstant(SdkConstantType.FEATURE) 2504 public static final String FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS 2505 = "android.software.activities_on_secondary_displays"; 2506 2507 /** 2508 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2509 * The device supports creating secondary users and managed profiles via 2510 * {@link DevicePolicyManager}. 2511 */ 2512 @SdkConstant(SdkConstantType.FEATURE) 2513 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 2514 2515 /** 2516 * @hide 2517 * TODO: Remove after dependencies updated b/17392243 2518 */ 2519 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 2520 2521 /** 2522 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2523 * The device supports verified boot. 2524 */ 2525 @SdkConstant(SdkConstantType.FEATURE) 2526 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 2527 2528 /** 2529 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2530 * The device supports secure removal of users. When a user is deleted the data associated 2531 * with that user is securely deleted and no longer available. 2532 */ 2533 @SdkConstant(SdkConstantType.FEATURE) 2534 public static final String FEATURE_SECURELY_REMOVES_USERS 2535 = "android.software.securely_removes_users"; 2536 2537 /** {@hide} */ 2538 @TestApi 2539 @SdkConstant(SdkConstantType.FEATURE) 2540 public static final String FEATURE_FILE_BASED_ENCRYPTION 2541 = "android.software.file_based_encryption"; 2542 2543 /** {@hide} */ 2544 @TestApi 2545 @SdkConstant(SdkConstantType.FEATURE) 2546 public static final String FEATURE_ADOPTABLE_STORAGE 2547 = "android.software.adoptable_storage"; 2548 2549 /** 2550 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2551 * The device has a full implementation of the android.webkit.* APIs. Devices 2552 * lacking this feature will not have a functioning WebView implementation. 2553 */ 2554 @SdkConstant(SdkConstantType.FEATURE) 2555 public static final String FEATURE_WEBVIEW = "android.software.webview"; 2556 2557 /** 2558 * Feature for {@link #getSystemAvailableFeatures} and 2559 * {@link #hasSystemFeature}: This device supports ethernet. 2560 */ 2561 @SdkConstant(SdkConstantType.FEATURE) 2562 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 2563 2564 /** 2565 * Feature for {@link #getSystemAvailableFeatures} and 2566 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 2567 * @hide 2568 */ 2569 @SdkConstant(SdkConstantType.FEATURE) 2570 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 2571 2572 /** 2573 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2574 * The device has all of the inputs necessary to be considered a compatible game controller, or 2575 * includes a compatible game controller in the box. 2576 */ 2577 @SdkConstant(SdkConstantType.FEATURE) 2578 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 2579 2580 /** 2581 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2582 * The device has a full implementation of the android.media.midi.* APIs. 2583 */ 2584 @SdkConstant(SdkConstantType.FEATURE) 2585 public static final String FEATURE_MIDI = "android.software.midi"; 2586 2587 /** 2588 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2589 * The device implements an optimized mode for virtual reality (VR) applications that handles 2590 * stereoscopic rendering of notifications, and disables most monocular system UI components 2591 * while a VR application has user focus. 2592 * Devices declaring this feature must include an application implementing a 2593 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 2594 * {@link android.app.Activity#setVrModeEnabled}. 2595 * @deprecated use {@link #FEATURE_VR_MODE_HIGH_PERFORMANCE} instead. 2596 */ 2597 @Deprecated 2598 @SdkConstant(SdkConstantType.FEATURE) 2599 public static final String FEATURE_VR_MODE = "android.software.vr.mode"; 2600 2601 /** 2602 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2603 * The device implements an optimized mode for virtual reality (VR) applications that handles 2604 * stereoscopic rendering of notifications, disables most monocular system UI components 2605 * while a VR application has user focus and meets extra CDD requirements to provide a 2606 * high-quality VR experience. 2607 * Devices declaring this feature must include an application implementing a 2608 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 2609 * {@link android.app.Activity#setVrModeEnabled}. 2610 * and must meet CDD requirements to provide a high-quality VR experience. 2611 */ 2612 @SdkConstant(SdkConstantType.FEATURE) 2613 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE 2614 = "android.hardware.vr.high_performance"; 2615 2616 /** 2617 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2618 * The device supports autofill of user credentials, addresses, credit cards, etc 2619 * via integration with {@link android.service.autofill.AutofillService autofill 2620 * providers}. 2621 */ 2622 @SdkConstant(SdkConstantType.FEATURE) 2623 public static final String FEATURE_AUTOFILL = "android.software.autofill"; 2624 2625 /** 2626 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2627 * The device implements headtracking suitable for a VR device. 2628 */ 2629 @SdkConstant(SdkConstantType.FEATURE) 2630 public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking"; 2631 2632 /** 2633 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2634 * The device has a StrongBox hardware-backed Keystore. 2635 */ 2636 @SdkConstant(SdkConstantType.FEATURE) 2637 public static final String FEATURE_STRONGBOX_KEYSTORE = 2638 "android.hardware.strongbox_keystore"; 2639 2640 /** 2641 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2642 * The device has a Keymaster implementation that supports Device ID attestation. 2643 * 2644 * @see DevicePolicyManager#isDeviceIdAttestationSupported 2645 * @hide 2646 */ 2647 @SdkConstant(SdkConstantType.FEATURE) 2648 public static final String FEATURE_DEVICE_ID_ATTESTATION = 2649 "android.software.device_id_attestation"; 2650 2651 /** 2652 * Action to external storage service to clean out removed apps. 2653 * @hide 2654 */ 2655 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 2656 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 2657 2658 /** 2659 * Extra field name for the URI to a verification file. Passed to a package 2660 * verifier. 2661 * 2662 * @hide 2663 */ 2664 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 2665 2666 /** 2667 * Extra field name for the ID of a package pending verification. Passed to 2668 * a package verifier and is used to call back to 2669 * {@link PackageManager#verifyPendingInstall(int, int)} 2670 */ 2671 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 2672 2673 /** 2674 * Extra field name for the package identifier which is trying to install 2675 * the package. 2676 * 2677 * @hide 2678 */ 2679 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 2680 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 2681 2682 /** 2683 * Extra field name for the requested install flags for a package pending 2684 * verification. Passed to a package verifier. 2685 * 2686 * @hide 2687 */ 2688 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 2689 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 2690 2691 /** 2692 * Extra field name for the uid of who is requesting to install 2693 * the package. 2694 * 2695 * @hide 2696 */ 2697 public static final String EXTRA_VERIFICATION_INSTALLER_UID 2698 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 2699 2700 /** 2701 * Extra field name for the package name of a package pending verification. 2702 * 2703 * @hide 2704 */ 2705 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 2706 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 2707 /** 2708 * Extra field name for the result of a verification, either 2709 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 2710 * Passed to package verifiers after a package is verified. 2711 */ 2712 public static final String EXTRA_VERIFICATION_RESULT 2713 = "android.content.pm.extra.VERIFICATION_RESULT"; 2714 2715 /** 2716 * Extra field name for the version code of a package pending verification. 2717 * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead. 2718 * @hide 2719 */ 2720 @Deprecated 2721 public static final String EXTRA_VERIFICATION_VERSION_CODE 2722 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 2723 2724 /** 2725 * Extra field name for the long version code of a package pending verification. 2726 * 2727 * @hide 2728 */ 2729 public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE = 2730 "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE"; 2731 2732 /** 2733 * Extra field name for the ID of a intent filter pending verification. 2734 * Passed to an intent filter verifier and is used to call back to 2735 * {@link #verifyIntentFilter} 2736 * 2737 * @hide 2738 */ 2739 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 2740 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 2741 2742 /** 2743 * Extra field name for the scheme used for an intent filter pending verification. Passed to 2744 * an intent filter verifier and is used to construct the URI to verify against. 2745 * 2746 * Usually this is "https" 2747 * 2748 * @hide 2749 */ 2750 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 2751 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 2752 2753 /** 2754 * Extra field name for the host names to be used for an intent filter pending verification. 2755 * Passed to an intent filter verifier and is used to construct the URI to verify the 2756 * intent filter. 2757 * 2758 * This is a space delimited list of hosts. 2759 * 2760 * @hide 2761 */ 2762 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 2763 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 2764 2765 /** 2766 * Extra field name for the package name to be used for an intent filter pending verification. 2767 * Passed to an intent filter verifier and is used to check the verification responses coming 2768 * from the hosts. Each host response will need to include the package name of APK containing 2769 * the intent filter. 2770 * 2771 * @hide 2772 */ 2773 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 2774 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 2775 2776 /** 2777 * The action used to request that the user approve a permission request 2778 * from the application. 2779 * 2780 * @hide 2781 */ 2782 @SystemApi 2783 public static final String ACTION_REQUEST_PERMISSIONS = 2784 "android.content.pm.action.REQUEST_PERMISSIONS"; 2785 2786 /** 2787 * The names of the requested permissions. 2788 * <p> 2789 * <strong>Type:</strong> String[] 2790 * </p> 2791 * 2792 * @hide 2793 */ 2794 @SystemApi 2795 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 2796 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 2797 2798 /** 2799 * The results from the permissions request. 2800 * <p> 2801 * <strong>Type:</strong> int[] of #PermissionResult 2802 * </p> 2803 * 2804 * @hide 2805 */ 2806 @SystemApi 2807 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 2808 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 2809 2810 /** 2811 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2812 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 2813 * the existing definition for the permission. 2814 * @hide 2815 */ 2816 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 2817 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 2818 2819 /** 2820 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2821 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 2822 * being redundantly defined by the package being installed. 2823 * @hide 2824 */ 2825 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 2826 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 2827 2828 /** 2829 * Permission flag: The permission is set in its current state 2830 * by the user and apps can still request it at runtime. 2831 * 2832 * @hide 2833 */ 2834 @SystemApi 2835 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 2836 2837 /** 2838 * Permission flag: The permission is set in its current state 2839 * by the user and it is fixed, i.e. apps can no longer request 2840 * this permission. 2841 * 2842 * @hide 2843 */ 2844 @SystemApi 2845 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 2846 2847 /** 2848 * Permission flag: The permission is set in its current state 2849 * by device policy and neither apps nor the user can change 2850 * its state. 2851 * 2852 * @hide 2853 */ 2854 @SystemApi 2855 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 2856 2857 /** 2858 * Permission flag: The permission is set in a granted state but 2859 * access to resources it guards is restricted by other means to 2860 * enable revoking a permission on legacy apps that do not support 2861 * runtime permissions. If this permission is upgraded to runtime 2862 * because the app was updated to support runtime permissions, the 2863 * the permission will be revoked in the upgrade process. 2864 * 2865 * @hide 2866 */ 2867 @SystemApi 2868 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 2869 2870 /** 2871 * Permission flag: The permission is set in its current state 2872 * because the app is a component that is a part of the system. 2873 * 2874 * @hide 2875 */ 2876 @SystemApi 2877 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 2878 2879 /** 2880 * Permission flag: The permission is granted by default because it 2881 * enables app functionality that is expected to work out-of-the-box 2882 * for providing a smooth user experience. For example, the phone app 2883 * is expected to have the phone permission. 2884 * 2885 * @hide 2886 */ 2887 @SystemApi 2888 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 2889 2890 /** 2891 * Permission flag: The permission has to be reviewed before any of 2892 * the app components can run. 2893 * 2894 * @hide 2895 */ 2896 @SystemApi 2897 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 2898 2899 /** 2900 * Mask for all permission flags. 2901 * 2902 * @hide 2903 */ 2904 @SystemApi 2905 public static final int MASK_PERMISSION_FLAGS = 0xFF; 2906 2907 /** 2908 * This is a library that contains components apps can invoke. For 2909 * example, a services for apps to bind to, or standard chooser UI, 2910 * etc. This library is versioned and backwards compatible. Clients 2911 * should check its version via {@link android.ext.services.Version 2912 * #getVersionCode()} and avoid calling APIs added in later versions. 2913 * 2914 * @hide 2915 */ 2916 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services"; 2917 2918 /** 2919 * This is a library that contains components apps can dynamically 2920 * load. For example, new widgets, helper classes, etc. This library 2921 * is versioned and backwards compatible. Clients should check its 2922 * version via {@link android.ext.shared.Version#getVersionCode()} 2923 * and avoid calling APIs added in later versions. 2924 * 2925 * @hide 2926 */ 2927 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared"; 2928 2929 /** 2930 * Used when starting a process for an Activity. 2931 * 2932 * @hide 2933 */ 2934 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0; 2935 2936 /** 2937 * Used when starting a process for a Service. 2938 * 2939 * @hide 2940 */ 2941 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1; 2942 2943 /** 2944 * Used when moving a Service to the foreground. 2945 * 2946 * @hide 2947 */ 2948 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2; 2949 2950 /** 2951 * Used when starting a process for a BroadcastReceiver. 2952 * 2953 * @hide 2954 */ 2955 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3; 2956 2957 /** 2958 * Used when starting a process for a ContentProvider. 2959 * 2960 * @hide 2961 */ 2962 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4; 2963 2964 /** 2965 * Used when starting a process for a BroadcastReceiver. 2966 * 2967 * @hide 2968 */ 2969 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5; 2970 2971 /** 2972 * Used with Context.getClassLoader() across Android packages. 2973 * 2974 * @hide 2975 */ 2976 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6; 2977 2978 /** 2979 * Used when starting a package within a process for Instrumentation. 2980 * 2981 * @hide 2982 */ 2983 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7; 2984 2985 /** 2986 * Total number of usage reasons. 2987 * 2988 * @hide 2989 */ 2990 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8; 2991 2992 /** 2993 * Constant for specifying the highest installed package version code. 2994 */ 2995 public static final int VERSION_CODE_HIGHEST = -1; 2996 2997 /** {@hide} */ 2998 public int getUserId() { 2999 return UserHandle.myUserId(); 3000 } 3001 3002 /** 3003 * Retrieve overall information about an application package that is 3004 * installed on the system. 3005 * 3006 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3007 * desired package. 3008 * @param flags Additional option flags to modify the data returned. 3009 * @return A PackageInfo object containing information about the package. If 3010 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 3011 * is not found in the list of installed applications, the package 3012 * information is retrieved from the list of uninstalled 3013 * applications (which includes installed applications as well as 3014 * applications with data directory i.e. applications which had been 3015 * deleted with {@code DONT_DELETE_DATA} flag set). 3016 * @throws NameNotFoundException if a package with the given name cannot be 3017 * found on the system. 3018 */ 3019 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) 3020 throws NameNotFoundException; 3021 3022 /** 3023 * Retrieve overall information about an application package that is 3024 * installed on the system. This method can be used for retrieving 3025 * information about packages for which multiple versions can be installed 3026 * at the time. Currently only packages hosting static shared libraries can 3027 * have multiple installed versions. The method can also be used to get info 3028 * for a package that has a single version installed by passing 3029 * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage} 3030 * constructor. 3031 * 3032 * @param versionedPackage The versioned package for which to query. 3033 * @param flags Additional option flags to modify the data returned. 3034 * @return A PackageInfo object containing information about the package. If 3035 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 3036 * is not found in the list of installed applications, the package 3037 * information is retrieved from the list of uninstalled 3038 * applications (which includes installed applications as well as 3039 * applications with data directory i.e. applications which had been 3040 * deleted with {@code DONT_DELETE_DATA} flag set). 3041 * @throws NameNotFoundException if a package with the given name cannot be 3042 * found on the system. 3043 */ 3044 public abstract PackageInfo getPackageInfo(VersionedPackage versionedPackage, 3045 @PackageInfoFlags int flags) throws NameNotFoundException; 3046 3047 /** 3048 * Retrieve overall information about an application package that is 3049 * installed on the system. 3050 * 3051 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3052 * desired package. 3053 * @param flags Additional option flags to modify the data returned. 3054 * @param userId The user id. 3055 * @return A PackageInfo object containing information about the package. If 3056 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 3057 * is not found in the list of installed applications, the package 3058 * information is retrieved from the list of uninstalled 3059 * applications (which includes installed applications as well as 3060 * applications with data directory i.e. applications which had been 3061 * deleted with {@code DONT_DELETE_DATA} flag set). 3062 * @throws NameNotFoundException if a package with the given name cannot be 3063 * found on the system. 3064 * @hide 3065 */ 3066 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 3067 public abstract PackageInfo getPackageInfoAsUser(String packageName, 3068 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 3069 3070 /** 3071 * Map from the current package names in use on the device to whatever 3072 * the current canonical name of that package is. 3073 * @param names Array of current names to be mapped. 3074 * @return Returns an array of the same size as the original, containing 3075 * the canonical name for each package. 3076 */ 3077 public abstract String[] currentToCanonicalPackageNames(String[] names); 3078 3079 /** 3080 * Map from a packages canonical name to the current name in use on the device. 3081 * @param names Array of new names to be mapped. 3082 * @return Returns an array of the same size as the original, containing 3083 * the current name for each package. 3084 */ 3085 public abstract String[] canonicalToCurrentPackageNames(String[] names); 3086 3087 /** 3088 * Returns a "good" intent to launch a front-door activity in a package. 3089 * This is used, for example, to implement an "open" button when browsing 3090 * through packages. The current implementation looks first for a main 3091 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 3092 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 3093 * <code>null</code> if neither are found. 3094 * 3095 * @param packageName The name of the package to inspect. 3096 * 3097 * @return A fully-qualified {@link Intent} that can be used to launch the 3098 * main activity in the package. Returns <code>null</code> if the package 3099 * does not contain such an activity, or if <em>packageName</em> is not 3100 * recognized. 3101 */ 3102 public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName); 3103 3104 /** 3105 * Return a "good" intent to launch a front-door Leanback activity in a 3106 * package, for use for example to implement an "open" button when browsing 3107 * through packages. The current implementation will look for a main 3108 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 3109 * return null if no main leanback activities are found. 3110 * 3111 * @param packageName The name of the package to inspect. 3112 * @return Returns either a fully-qualified Intent that can be used to launch 3113 * the main Leanback activity in the package, or null if the package 3114 * does not contain such an activity. 3115 */ 3116 public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName); 3117 3118 /** 3119 * Return a "good" intent to launch a front-door Car activity in a 3120 * package, for use for example to implement an "open" button when browsing 3121 * through packages. The current implementation will look for a main 3122 * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or 3123 * return null if no main car activities are found. 3124 * 3125 * @param packageName The name of the package to inspect. 3126 * @return Returns either a fully-qualified Intent that can be used to launch 3127 * the main Car activity in the package, or null if the package 3128 * does not contain such an activity. 3129 * @hide 3130 */ 3131 public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName); 3132 3133 /** 3134 * Return an array of all of the POSIX secondary group IDs that have been 3135 * assigned to the given package. 3136 * <p> 3137 * Note that the same package may have different GIDs under different 3138 * {@link UserHandle} on the same device. 3139 * 3140 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3141 * desired package. 3142 * @return Returns an int array of the assigned GIDs, or null if there are 3143 * none. 3144 * @throws NameNotFoundException if a package with the given name cannot be 3145 * found on the system. 3146 */ 3147 public abstract int[] getPackageGids(@NonNull String packageName) 3148 throws NameNotFoundException; 3149 3150 /** 3151 * Return an array of all of the POSIX secondary group IDs that have been 3152 * assigned to the given package. 3153 * <p> 3154 * Note that the same package may have different GIDs under different 3155 * {@link UserHandle} on the same device. 3156 * 3157 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3158 * desired package. 3159 * @return Returns an int array of the assigned gids, or null if there are 3160 * none. 3161 * @throws NameNotFoundException if a package with the given name cannot be 3162 * found on the system. 3163 */ 3164 public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags) 3165 throws NameNotFoundException; 3166 3167 /** 3168 * Return the UID associated with the given package name. 3169 * <p> 3170 * Note that the same package will have different UIDs under different 3171 * {@link UserHandle} on the same device. 3172 * 3173 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3174 * desired package. 3175 * @return Returns an integer UID who owns the given package name. 3176 * @throws NameNotFoundException if a package with the given name can not be 3177 * found on the system. 3178 */ 3179 public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags) 3180 throws NameNotFoundException; 3181 3182 /** 3183 * Return the UID associated with the given package name. 3184 * <p> 3185 * Note that the same package will have different UIDs under different 3186 * {@link UserHandle} on the same device. 3187 * 3188 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3189 * desired package. 3190 * @param userId The user handle identifier to look up the package under. 3191 * @return Returns an integer UID who owns the given package name. 3192 * @throws NameNotFoundException if a package with the given name can not be 3193 * found on the system. 3194 * @hide 3195 */ 3196 public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId) 3197 throws NameNotFoundException; 3198 3199 /** 3200 * Return the UID associated with the given package name. 3201 * <p> 3202 * Note that the same package will have different UIDs under different 3203 * {@link UserHandle} on the same device. 3204 * 3205 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3206 * desired package. 3207 * @param userId The user handle identifier to look up the package under. 3208 * @return Returns an integer UID who owns the given package name. 3209 * @throws NameNotFoundException if a package with the given name can not be 3210 * found on the system. 3211 * @hide 3212 */ 3213 public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags, 3214 @UserIdInt int userId) throws NameNotFoundException; 3215 3216 /** 3217 * Retrieve all of the information we know about a particular permission. 3218 * 3219 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 3220 * of the permission you are interested in. 3221 * @param flags Additional option flags to modify the data returned. 3222 * @return Returns a {@link PermissionInfo} containing information about the 3223 * permission. 3224 * @throws NameNotFoundException if a package with the given name cannot be 3225 * found on the system. 3226 */ 3227 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags) 3228 throws NameNotFoundException; 3229 3230 /** 3231 * Query for all of the permissions associated with a particular group. 3232 * 3233 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 3234 * of the permission group you are interested in. Use null to 3235 * find all of the permissions not associated with a group. 3236 * @param flags Additional option flags to modify the data returned. 3237 * @return Returns a list of {@link PermissionInfo} containing information 3238 * about all of the permissions in the given group. 3239 * @throws NameNotFoundException if a package with the given name cannot be 3240 * found on the system. 3241 */ 3242 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 3243 @PermissionInfoFlags int flags) throws NameNotFoundException; 3244 3245 /** 3246 * Returns true if Permission Review Mode is enabled, false otherwise. 3247 * 3248 * @hide 3249 */ 3250 @TestApi 3251 public abstract boolean isPermissionReviewModeEnabled(); 3252 3253 /** 3254 * Retrieve all of the information we know about a particular group of 3255 * permissions. 3256 * 3257 * @param name The fully qualified name (i.e. 3258 * com.google.permission_group.APPS) of the permission you are 3259 * interested in. 3260 * @param flags Additional option flags to modify the data returned. 3261 * @return Returns a {@link PermissionGroupInfo} containing information 3262 * about the permission. 3263 * @throws NameNotFoundException if a package with the given name cannot be 3264 * found on the system. 3265 */ 3266 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 3267 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 3268 3269 /** 3270 * Retrieve all of the known permission groups in the system. 3271 * 3272 * @param flags Additional option flags to modify the data returned. 3273 * @return Returns a list of {@link PermissionGroupInfo} containing 3274 * information about all of the known permission groups. 3275 */ 3276 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 3277 @PermissionGroupInfoFlags int flags); 3278 3279 /** 3280 * Retrieve all of the information we know about a particular 3281 * package/application. 3282 * 3283 * @param packageName The full name (i.e. com.google.apps.contacts) of an 3284 * application. 3285 * @param flags Additional option flags to modify the data returned. 3286 * @return An {@link ApplicationInfo} containing information about the 3287 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if 3288 * the package is not found in the list of installed applications, 3289 * the application information is retrieved from the list of 3290 * uninstalled applications (which includes installed applications 3291 * as well as applications with data directory i.e. applications 3292 * which had been deleted with {@code DONT_DELETE_DATA} flag set). 3293 * @throws NameNotFoundException if a package with the given name cannot be 3294 * found on the system. 3295 */ 3296 public abstract ApplicationInfo getApplicationInfo(String packageName, 3297 @ApplicationInfoFlags int flags) throws NameNotFoundException; 3298 3299 /** {@hide} */ 3300 public abstract ApplicationInfo getApplicationInfoAsUser(String packageName, 3301 @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 3302 3303 /** 3304 * Retrieve all of the information we know about a particular activity 3305 * class. 3306 * 3307 * @param component The full component name (i.e. 3308 * com.google.apps.contacts/com.google.apps.contacts. 3309 * ContactsList) of an Activity class. 3310 * @param flags Additional option flags to modify the data returned. 3311 * @return An {@link ActivityInfo} containing information about the 3312 * activity. 3313 * @throws NameNotFoundException if a package with the given name cannot be 3314 * found on the system. 3315 */ 3316 public abstract ActivityInfo getActivityInfo(ComponentName component, 3317 @ComponentInfoFlags int flags) throws NameNotFoundException; 3318 3319 /** 3320 * Retrieve all of the information we know about a particular receiver 3321 * class. 3322 * 3323 * @param component The full component name (i.e. 3324 * com.google.apps.calendar/com.google.apps.calendar. 3325 * CalendarAlarm) of a Receiver class. 3326 * @param flags Additional option flags to modify the data returned. 3327 * @return An {@link ActivityInfo} containing information about the 3328 * receiver. 3329 * @throws NameNotFoundException if a package with the given name cannot be 3330 * found on the system. 3331 */ 3332 public abstract ActivityInfo getReceiverInfo(ComponentName component, 3333 @ComponentInfoFlags int flags) throws NameNotFoundException; 3334 3335 /** 3336 * Retrieve all of the information we know about a particular service class. 3337 * 3338 * @param component The full component name (i.e. 3339 * com.google.apps.media/com.google.apps.media. 3340 * BackgroundPlayback) of a Service class. 3341 * @param flags Additional option flags to modify the data returned. 3342 * @return A {@link ServiceInfo} object containing information about the 3343 * service. 3344 * @throws NameNotFoundException if a package with the given name cannot be 3345 * found on the system. 3346 */ 3347 public abstract ServiceInfo getServiceInfo(ComponentName component, 3348 @ComponentInfoFlags int flags) throws NameNotFoundException; 3349 3350 /** 3351 * Retrieve all of the information we know about a particular content 3352 * provider class. 3353 * 3354 * @param component The full component name (i.e. 3355 * com.google.providers.media/com.google.providers.media. 3356 * MediaProvider) of a ContentProvider class. 3357 * @param flags Additional option flags to modify the data returned. 3358 * @return A {@link ProviderInfo} object containing information about the 3359 * provider. 3360 * @throws NameNotFoundException if a package with the given name cannot be 3361 * found on the system. 3362 */ 3363 public abstract ProviderInfo getProviderInfo(ComponentName component, 3364 @ComponentInfoFlags int flags) throws NameNotFoundException; 3365 3366 /** 3367 * Return a List of all packages that are installed for the current user. 3368 * 3369 * @param flags Additional option flags to modify the data returned. 3370 * @return A List of PackageInfo objects, one for each installed package, 3371 * containing information about the package. In the unlikely case 3372 * there are no installed packages, an empty list is returned. If 3373 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3374 * information is retrieved from the list of uninstalled 3375 * applications (which includes installed applications as well as 3376 * applications with data directory i.e. applications which had been 3377 * deleted with {@code DONT_DELETE_DATA} flag set). 3378 */ 3379 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags); 3380 3381 /** 3382 * Return a List of all installed packages that are currently holding any of 3383 * the given permissions. 3384 * 3385 * @param flags Additional option flags to modify the data returned. 3386 * @return A List of PackageInfo objects, one for each installed package 3387 * that holds any of the permissions that were provided, containing 3388 * information about the package. If no installed packages hold any 3389 * of the permissions, an empty list is returned. If flag 3390 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3391 * information is retrieved from the list of uninstalled 3392 * applications (which includes installed applications as well as 3393 * applications with data directory i.e. applications which had been 3394 * deleted with {@code DONT_DELETE_DATA} flag set). 3395 */ 3396 public abstract List<PackageInfo> getPackagesHoldingPermissions( 3397 String[] permissions, @PackageInfoFlags int flags); 3398 3399 /** 3400 * Return a List of all packages that are installed on the device, for a 3401 * specific user. 3402 * 3403 * @param flags Additional option flags to modify the data returned. 3404 * @param userId The user for whom the installed packages are to be listed 3405 * @return A List of PackageInfo objects, one for each installed package, 3406 * containing information about the package. In the unlikely case 3407 * there are no installed packages, an empty list is returned. If 3408 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3409 * information is retrieved from the list of uninstalled 3410 * applications (which includes installed applications as well as 3411 * applications with data directory i.e. applications which had been 3412 * deleted with {@code DONT_DELETE_DATA} flag set). 3413 * @hide 3414 */ 3415 @SystemApi 3416 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) 3417 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags, 3418 @UserIdInt int userId); 3419 3420 /** 3421 * Check whether a particular package has been granted a particular 3422 * permission. 3423 * 3424 * @param permName The name of the permission you are checking for. 3425 * @param pkgName The name of the package you are checking against. 3426 * 3427 * @return If the package has the permission, PERMISSION_GRANTED is 3428 * returned. If it does not have the permission, PERMISSION_DENIED 3429 * is returned. 3430 * 3431 * @see #PERMISSION_GRANTED 3432 * @see #PERMISSION_DENIED 3433 */ 3434 @CheckResult 3435 public abstract @PermissionResult int checkPermission(String permName, String pkgName); 3436 3437 /** 3438 * Checks whether a particular permissions has been revoked for a 3439 * package by policy. Typically the device owner or the profile owner 3440 * may apply such a policy. The user cannot grant policy revoked 3441 * permissions, hence the only way for an app to get such a permission 3442 * is by a policy change. 3443 * 3444 * @param permName The name of the permission you are checking for. 3445 * @param pkgName The name of the package you are checking against. 3446 * 3447 * @return Whether the permission is restricted by policy. 3448 */ 3449 @CheckResult 3450 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 3451 @NonNull String pkgName); 3452 3453 /** 3454 * Gets the package name of the component controlling runtime permissions. 3455 * 3456 * @return The package name. 3457 * 3458 * @hide 3459 */ 3460 @TestApi 3461 public abstract String getPermissionControllerPackageName(); 3462 3463 /** 3464 * Add a new dynamic permission to the system. For this to work, your 3465 * package must have defined a permission tree through the 3466 * {@link android.R.styleable#AndroidManifestPermissionTree 3467 * <permission-tree>} tag in its manifest. A package can only add 3468 * permissions to trees that were defined by either its own package or 3469 * another with the same user id; a permission is in a tree if it 3470 * matches the name of the permission tree + ".": for example, 3471 * "com.foo.bar" is a member of the permission tree "com.foo". 3472 * 3473 * <p>It is good to make your permission tree name descriptive, because you 3474 * are taking possession of that entire set of permission names. Thus, it 3475 * must be under a domain you control, with a suffix that will not match 3476 * any normal permissions that may be declared in any applications that 3477 * are part of that domain. 3478 * 3479 * <p>New permissions must be added before 3480 * any .apks are installed that use those permissions. Permissions you 3481 * add through this method are remembered across reboots of the device. 3482 * If the given permission already exists, the info you supply here 3483 * will be used to update it. 3484 * 3485 * @param info Description of the permission to be added. 3486 * 3487 * @return Returns true if a new permission was created, false if an 3488 * existing one was updated. 3489 * 3490 * @throws SecurityException if you are not allowed to add the 3491 * given permission name. 3492 * 3493 * @see #removePermission(String) 3494 */ 3495 public abstract boolean addPermission(PermissionInfo info); 3496 3497 /** 3498 * Like {@link #addPermission(PermissionInfo)} but asynchronously 3499 * persists the package manager state after returning from the call, 3500 * allowing it to return quicker and batch a series of adds at the 3501 * expense of no guarantee the added permission will be retained if 3502 * the device is rebooted before it is written. 3503 */ 3504 public abstract boolean addPermissionAsync(PermissionInfo info); 3505 3506 /** 3507 * Removes a permission that was previously added with 3508 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 3509 * -- you are only allowed to remove permissions that you are allowed 3510 * to add. 3511 * 3512 * @param name The name of the permission to remove. 3513 * 3514 * @throws SecurityException if you are not allowed to remove the 3515 * given permission name. 3516 * 3517 * @see #addPermission(PermissionInfo) 3518 */ 3519 public abstract void removePermission(String name); 3520 3521 /** 3522 * Permission flags set when granting or revoking a permission. 3523 * 3524 * @hide 3525 */ 3526 @SystemApi 3527 @IntDef(prefix = { "FLAG_PERMISSION_" }, value = { 3528 FLAG_PERMISSION_USER_SET, 3529 FLAG_PERMISSION_USER_FIXED, 3530 FLAG_PERMISSION_POLICY_FIXED, 3531 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 3532 FLAG_PERMISSION_SYSTEM_FIXED, 3533 FLAG_PERMISSION_GRANTED_BY_DEFAULT 3534 }) 3535 @Retention(RetentionPolicy.SOURCE) 3536 public @interface PermissionFlags {} 3537 3538 /** 3539 * Grant a runtime permission to an application which the application does not 3540 * already have. The permission must have been requested by the application. 3541 * If the application is not allowed to hold the permission, a {@link 3542 * java.lang.SecurityException} is thrown. If the package or permission is 3543 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 3544 * <p> 3545 * <strong>Note: </strong>Using this API requires holding 3546 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is 3547 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3548 * </p> 3549 * 3550 * @param packageName The package to which to grant the permission. 3551 * @param permissionName The permission name to grant. 3552 * @param user The user for which to grant the permission. 3553 * 3554 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 3555 * 3556 * @hide 3557 */ 3558 @SystemApi 3559 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 3560 public abstract void grantRuntimePermission(@NonNull String packageName, 3561 @NonNull String permissionName, @NonNull UserHandle user); 3562 3563 /** 3564 * Revoke a runtime permission that was previously granted by {@link 3565 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 3566 * permission must have been requested by and granted to the application. 3567 * If the application is not allowed to hold the permission, a {@link 3568 * java.lang.SecurityException} is thrown. If the package or permission is 3569 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 3570 * <p> 3571 * <strong>Note: </strong>Using this API requires holding 3572 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 3573 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3574 * </p> 3575 * 3576 * @param packageName The package from which to revoke the permission. 3577 * @param permissionName The permission name to revoke. 3578 * @param user The user for which to revoke the permission. 3579 * 3580 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 3581 * 3582 * @hide 3583 */ 3584 @SystemApi 3585 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS) 3586 public abstract void revokeRuntimePermission(@NonNull String packageName, 3587 @NonNull String permissionName, @NonNull UserHandle user); 3588 3589 /** 3590 * Gets the state flags associated with a permission. 3591 * 3592 * @param permissionName The permission for which to get the flags. 3593 * @param packageName The package name for which to get the flags. 3594 * @param user The user for which to get permission flags. 3595 * @return The permission flags. 3596 * 3597 * @hide 3598 */ 3599 @SystemApi 3600 @RequiresPermission(anyOf = { 3601 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, 3602 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS 3603 }) 3604 public abstract @PermissionFlags int getPermissionFlags(String permissionName, 3605 String packageName, @NonNull UserHandle user); 3606 3607 /** 3608 * Updates the flags associated with a permission by replacing the flags in 3609 * the specified mask with the provided flag values. 3610 * 3611 * @param permissionName The permission for which to update the flags. 3612 * @param packageName The package name for which to update the flags. 3613 * @param flagMask The flags which to replace. 3614 * @param flagValues The flags with which to replace. 3615 * @param user The user for which to update the permission flags. 3616 * 3617 * @hide 3618 */ 3619 @SystemApi 3620 @RequiresPermission(anyOf = { 3621 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, 3622 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS 3623 }) 3624 public abstract void updatePermissionFlags(String permissionName, 3625 String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues, 3626 @NonNull UserHandle user); 3627 3628 /** 3629 * Gets whether you should show UI with rationale for requesting a permission. 3630 * You should do this only if you do not have the permission and the context in 3631 * which the permission is requested does not clearly communicate to the user 3632 * what would be the benefit from grating this permission. 3633 * 3634 * @param permission A permission your app wants to request. 3635 * @return Whether you can show permission rationale UI. 3636 * 3637 * @hide 3638 */ 3639 public abstract boolean shouldShowRequestPermissionRationale(String permission); 3640 3641 /** 3642 * Returns an {@link android.content.Intent} suitable for passing to 3643 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 3644 * which prompts the user to grant permissions to this application. 3645 * 3646 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 3647 * 3648 * @hide 3649 */ 3650 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 3651 if (ArrayUtils.isEmpty(permissions)) { 3652 throw new IllegalArgumentException("permission cannot be null or empty"); 3653 } 3654 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 3655 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 3656 intent.setPackage(getPermissionControllerPackageName()); 3657 return intent; 3658 } 3659 3660 /** 3661 * Compare the signatures of two packages to determine if the same 3662 * signature appears in both of them. If they do contain the same 3663 * signature, then they are allowed special privileges when working 3664 * with each other: they can share the same user-id, run instrumentation 3665 * against each other, etc. 3666 * 3667 * @param pkg1 First package name whose signature will be compared. 3668 * @param pkg2 Second package name whose signature will be compared. 3669 * 3670 * @return Returns an integer indicating whether all signatures on the 3671 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3672 * all signatures match or < 0 if there is not a match ({@link 3673 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3674 * 3675 * @see #checkSignatures(int, int) 3676 */ 3677 @CheckResult 3678 public abstract @SignatureResult int checkSignatures(String pkg1, String pkg2); 3679 3680 /** 3681 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 3682 * the two packages to be checked. This can be useful, for example, 3683 * when doing the check in an IPC, where the UID is the only identity 3684 * available. It is functionally identical to determining the package 3685 * associated with the UIDs and checking their signatures. 3686 * 3687 * @param uid1 First UID whose signature will be compared. 3688 * @param uid2 Second UID whose signature will be compared. 3689 * 3690 * @return Returns an integer indicating whether all signatures on the 3691 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3692 * all signatures match or < 0 if there is not a match ({@link 3693 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3694 * 3695 * @see #checkSignatures(String, String) 3696 */ 3697 @CheckResult 3698 public abstract @SignatureResult int checkSignatures(int uid1, int uid2); 3699 3700 /** 3701 * Retrieve the names of all packages that are associated with a particular 3702 * user id. In most cases, this will be a single package name, the package 3703 * that has been assigned that user id. Where there are multiple packages 3704 * sharing the same user id through the "sharedUserId" mechanism, all 3705 * packages with that id will be returned. 3706 * 3707 * @param uid The user id for which you would like to retrieve the 3708 * associated packages. 3709 * 3710 * @return Returns an array of one or more packages assigned to the user 3711 * id, or null if there are no known packages with the given id. 3712 */ 3713 public abstract @Nullable String[] getPackagesForUid(int uid); 3714 3715 /** 3716 * Retrieve the official name associated with a uid. This name is 3717 * guaranteed to never change, though it is possible for the underlying 3718 * uid to be changed. That is, if you are storing information about 3719 * uids in persistent storage, you should use the string returned 3720 * by this function instead of the raw uid. 3721 * 3722 * @param uid The uid for which you would like to retrieve a name. 3723 * @return Returns a unique name for the given uid, or null if the 3724 * uid is not currently assigned. 3725 */ 3726 public abstract @Nullable String getNameForUid(int uid); 3727 3728 /** 3729 * Retrieves the official names associated with each given uid. 3730 * @see #getNameForUid(int) 3731 * 3732 * @hide 3733 */ 3734 @TestApi 3735 public abstract @Nullable String[] getNamesForUids(int[] uids); 3736 3737 /** 3738 * Return the user id associated with a shared user name. Multiple 3739 * applications can specify a shared user name in their manifest and thus 3740 * end up using a common uid. This might be used for new applications 3741 * that use an existing shared user name and need to know the uid of the 3742 * shared user. 3743 * 3744 * @param sharedUserName The shared user name whose uid is to be retrieved. 3745 * @return Returns the UID associated with the shared user. 3746 * @throws NameNotFoundException if a package with the given name cannot be 3747 * found on the system. 3748 * @hide 3749 */ 3750 public abstract int getUidForSharedUser(String sharedUserName) 3751 throws NameNotFoundException; 3752 3753 /** 3754 * Return a List of all application packages that are installed for the 3755 * current user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 3756 * applications including those deleted with {@code DONT_DELETE_DATA} 3757 * (partially installed apps with data directory) will be returned. 3758 * 3759 * @param flags Additional option flags to modify the data returned. 3760 * @return A List of ApplicationInfo objects, one for each installed 3761 * application. In the unlikely case there are no installed 3762 * packages, an empty list is returned. If flag 3763 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application 3764 * information is retrieved from the list of uninstalled 3765 * applications (which includes installed applications as well as 3766 * applications with data directory i.e. applications which had been 3767 * deleted with {@code DONT_DELETE_DATA} flag set). 3768 */ 3769 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags); 3770 3771 /** 3772 * Return a List of all application packages that are installed on the 3773 * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been 3774 * set, a list of all applications including those deleted with 3775 * {@code DONT_DELETE_DATA} (partially installed apps with data directory) 3776 * will be returned. 3777 * 3778 * @param flags Additional option flags to modify the data returned. 3779 * @param userId The user for whom the installed applications are to be 3780 * listed 3781 * @return A List of ApplicationInfo objects, one for each installed 3782 * application. In the unlikely case there are no installed 3783 * packages, an empty list is returned. If flag 3784 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application 3785 * information is retrieved from the list of uninstalled 3786 * applications (which includes installed applications as well as 3787 * applications with data directory i.e. applications which had been 3788 * deleted with {@code DONT_DELETE_DATA} flag set). 3789 * @hide 3790 */ 3791 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser( 3792 @ApplicationInfoFlags int flags, @UserIdInt int userId); 3793 3794 /** 3795 * Gets the instant applications the user recently used. 3796 * 3797 * @return The instant app list. 3798 * 3799 * @hide 3800 */ 3801 @SystemApi 3802 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) 3803 public abstract @NonNull List<InstantAppInfo> getInstantApps(); 3804 3805 /** 3806 * Gets the icon for an instant application. 3807 * 3808 * @param packageName The app package name. 3809 * 3810 * @hide 3811 */ 3812 @SystemApi 3813 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) 3814 public abstract @Nullable Drawable getInstantAppIcon(String packageName); 3815 3816 /** 3817 * Gets whether this application is an instant app. 3818 * 3819 * @return Whether caller is an instant app. 3820 * 3821 * @see #isInstantApp(String) 3822 * @see #updateInstantAppCookie(byte[]) 3823 * @see #getInstantAppCookie() 3824 * @see #getInstantAppCookieMaxBytes() 3825 */ 3826 public abstract boolean isInstantApp(); 3827 3828 /** 3829 * Gets whether the given package is an instant app. 3830 * 3831 * @param packageName The package to check 3832 * @return Whether the given package is an instant app. 3833 * 3834 * @see #isInstantApp() 3835 * @see #updateInstantAppCookie(byte[]) 3836 * @see #getInstantAppCookie() 3837 * @see #getInstantAppCookieMaxBytes() 3838 * @see #clearInstantAppCookie() 3839 */ 3840 public abstract boolean isInstantApp(String packageName); 3841 3842 /** 3843 * Gets the maximum size in bytes of the cookie data an instant app 3844 * can store on the device. 3845 * 3846 * @return The max cookie size in bytes. 3847 * 3848 * @see #isInstantApp() 3849 * @see #isInstantApp(String) 3850 * @see #updateInstantAppCookie(byte[]) 3851 * @see #getInstantAppCookie() 3852 * @see #clearInstantAppCookie() 3853 */ 3854 public abstract int getInstantAppCookieMaxBytes(); 3855 3856 /** 3857 * deprecated 3858 * @hide 3859 */ 3860 public abstract int getInstantAppCookieMaxSize(); 3861 3862 /** 3863 * Gets the instant application cookie for this app. Non 3864 * instant apps and apps that were instant but were upgraded 3865 * to normal apps can still access this API. For instant apps 3866 * this cookie is cached for some time after uninstall while for 3867 * normal apps the cookie is deleted after the app is uninstalled. 3868 * The cookie is always present while the app is installed. 3869 * 3870 * @return The cookie. 3871 * 3872 * @see #isInstantApp() 3873 * @see #isInstantApp(String) 3874 * @see #updateInstantAppCookie(byte[]) 3875 * @see #getInstantAppCookieMaxBytes() 3876 * @see #clearInstantAppCookie() 3877 */ 3878 public abstract @NonNull byte[] getInstantAppCookie(); 3879 3880 /** 3881 * Clears the instant application cookie for the calling app. 3882 * 3883 * @see #isInstantApp() 3884 * @see #isInstantApp(String) 3885 * @see #getInstantAppCookieMaxBytes() 3886 * @see #getInstantAppCookie() 3887 * @see #clearInstantAppCookie() 3888 */ 3889 public abstract void clearInstantAppCookie(); 3890 3891 /** 3892 * Updates the instant application cookie for the calling app. Non 3893 * instant apps and apps that were instant but were upgraded 3894 * to normal apps can still access this API. For instant apps 3895 * this cookie is cached for some time after uninstall while for 3896 * normal apps the cookie is deleted after the app is uninstalled. 3897 * The cookie is always present while the app is installed. The 3898 * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}. 3899 * Passing <code>null</code> or an empty array clears the cookie. 3900 * </p> 3901 * 3902 * @param cookie The cookie data. 3903 * 3904 * @see #isInstantApp() 3905 * @see #isInstantApp(String) 3906 * @see #getInstantAppCookieMaxBytes() 3907 * @see #getInstantAppCookie() 3908 * @see #clearInstantAppCookie() 3909 * 3910 * @throws IllegalArgumentException if the array exceeds max cookie size. 3911 */ 3912 public abstract void updateInstantAppCookie(@Nullable byte[] cookie); 3913 3914 /** 3915 * @removed 3916 */ 3917 public abstract boolean setInstantAppCookie(@Nullable byte[] cookie); 3918 3919 /** 3920 * Get a list of shared libraries that are available on the 3921 * system. 3922 * 3923 * @return An array of shared library names that are 3924 * available on the system, or null if none are installed. 3925 * 3926 */ 3927 public abstract String[] getSystemSharedLibraryNames(); 3928 3929 /** 3930 * Get a list of shared libraries on the device. 3931 * 3932 * @param flags To filter the libraries to return. 3933 * @return The shared library list. 3934 * 3935 * @see #MATCH_UNINSTALLED_PACKAGES 3936 */ 3937 public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries( 3938 @InstallFlags int flags); 3939 3940 /** 3941 * Get a list of shared libraries on the device. 3942 * 3943 * @param flags To filter the libraries to return. 3944 * @param userId The user to query for. 3945 * @return The shared library list. 3946 * 3947 * @see #MATCH_FACTORY_ONLY 3948 * @see #MATCH_KNOWN_PACKAGES 3949 * @see #MATCH_ANY_USER 3950 * @see #MATCH_UNINSTALLED_PACKAGES 3951 * 3952 * @hide 3953 */ 3954 public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser( 3955 @InstallFlags int flags, @UserIdInt int userId); 3956 3957 /** 3958 * Get the name of the package hosting the services shared library. 3959 * 3960 * @return The library host package. 3961 * 3962 * @hide 3963 */ 3964 @TestApi 3965 public abstract @NonNull String getServicesSystemSharedLibraryPackageName(); 3966 3967 /** 3968 * Get the name of the package hosting the shared components shared library. 3969 * 3970 * @return The library host package. 3971 * 3972 * @hide 3973 */ 3974 @TestApi 3975 public abstract @NonNull String getSharedSystemSharedLibraryPackageName(); 3976 3977 /** 3978 * Returns the names of the packages that have been changed 3979 * [eg. added, removed or updated] since the given sequence 3980 * number. 3981 * <p>If no packages have been changed, returns <code>null</code>. 3982 * <p>The sequence number starts at <code>0</code> and is 3983 * reset every boot. 3984 * @param sequenceNumber The first sequence number for which to retrieve package changes. 3985 * @see Settings.Global#BOOT_COUNT 3986 */ 3987 public abstract @Nullable ChangedPackages getChangedPackages( 3988 @IntRange(from=0) int sequenceNumber); 3989 3990 /** 3991 * Get a list of features that are available on the 3992 * system. 3993 * 3994 * @return An array of FeatureInfo classes describing the features 3995 * that are available on the system, or null if there are none(!!). 3996 */ 3997 public abstract FeatureInfo[] getSystemAvailableFeatures(); 3998 3999 /** 4000 * Check whether the given feature name is one of the available features as 4001 * returned by {@link #getSystemAvailableFeatures()}. This tests for the 4002 * presence of <em>any</em> version of the given feature name; use 4003 * {@link #hasSystemFeature(String, int)} to check for a minimum version. 4004 * 4005 * @return Returns true if the devices supports the feature, else false. 4006 */ 4007 public abstract boolean hasSystemFeature(String name); 4008 4009 /** 4010 * Check whether the given feature name and version is one of the available 4011 * features as returned by {@link #getSystemAvailableFeatures()}. Since 4012 * features are defined to always be backwards compatible, this returns true 4013 * if the available feature version is greater than or equal to the 4014 * requested version. 4015 * 4016 * @return Returns true if the devices supports the feature, else false. 4017 */ 4018 public abstract boolean hasSystemFeature(String name, int version); 4019 4020 /** 4021 * Determine the best action to perform for a given Intent. This is how 4022 * {@link Intent#resolveActivity} finds an activity if a class has not been 4023 * explicitly specified. 4024 * <p> 4025 * <em>Note:</em> if using an implicit Intent (without an explicit 4026 * ComponentName specified), be sure to consider whether to set the 4027 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 4028 * activity in the same way that 4029 * {@link android.content.Context#startActivity(Intent)} and 4030 * {@link android.content.Intent#resolveActivity(PackageManager) 4031 * Intent.resolveActivity(PackageManager)} do. 4032 * </p> 4033 * 4034 * @param intent An intent containing all of the desired specification 4035 * (action, data, type, category, and/or component). 4036 * @param flags Additional option flags to modify the data returned. The 4037 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 4038 * resolution to only those activities that support the 4039 * {@link android.content.Intent#CATEGORY_DEFAULT}. 4040 * @return Returns a ResolveInfo object containing the final activity intent 4041 * that was determined to be the best action. Returns null if no 4042 * matching activity was found. If multiple matching activities are 4043 * found and there is no default set, returns a ResolveInfo object 4044 * containing something else, such as the activity resolver. 4045 */ 4046 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags); 4047 4048 /** 4049 * Determine the best action to perform for a given Intent for a given user. 4050 * This is how {@link Intent#resolveActivity} finds an activity if a class 4051 * has not been explicitly specified. 4052 * <p> 4053 * <em>Note:</em> if using an implicit Intent (without an explicit 4054 * ComponentName specified), be sure to consider whether to set the 4055 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 4056 * activity in the same way that 4057 * {@link android.content.Context#startActivity(Intent)} and 4058 * {@link android.content.Intent#resolveActivity(PackageManager) 4059 * Intent.resolveActivity(PackageManager)} do. 4060 * </p> 4061 * 4062 * @param intent An intent containing all of the desired specification 4063 * (action, data, type, category, and/or component). 4064 * @param flags Additional option flags to modify the data returned. The 4065 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 4066 * resolution to only those activities that support the 4067 * {@link android.content.Intent#CATEGORY_DEFAULT}. 4068 * @param userId The user id. 4069 * @return Returns a ResolveInfo object containing the final activity intent 4070 * that was determined to be the best action. Returns null if no 4071 * matching activity was found. If multiple matching activities are 4072 * found and there is no default set, returns a ResolveInfo object 4073 * containing something else, such as the activity resolver. 4074 * @hide 4075 */ 4076 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags, 4077 @UserIdInt int userId); 4078 4079 /** 4080 * Retrieve all activities that can be performed for the given intent. 4081 * 4082 * @param intent The desired intent as per resolveActivity(). 4083 * @param flags Additional option flags to modify the data returned. The 4084 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 4085 * resolution to only those activities that support the 4086 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 4087 * {@link #MATCH_ALL} to prevent any filtering of the results. 4088 * @return Returns a List of ResolveInfo objects containing one entry for 4089 * each matching activity, ordered from best to worst. In other 4090 * words, the first item is what would be returned by 4091 * {@link #resolveActivity}. If there are no matching activities, an 4092 * empty list is returned. 4093 */ 4094 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 4095 @ResolveInfoFlags int flags); 4096 4097 /** 4098 * Retrieve all activities that can be performed for the given intent, for a 4099 * specific user. 4100 * 4101 * @param intent The desired intent as per resolveActivity(). 4102 * @param flags Additional option flags to modify the data returned. The 4103 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 4104 * resolution to only those activities that support the 4105 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 4106 * {@link #MATCH_ALL} to prevent any filtering of the results. 4107 * @return Returns a List of ResolveInfo objects containing one entry for 4108 * each matching activity, ordered from best to worst. In other 4109 * words, the first item is what would be returned by 4110 * {@link #resolveActivity}. If there are no matching activities, an 4111 * empty list is returned. 4112 * @hide 4113 */ 4114 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 4115 @ResolveInfoFlags int flags, @UserIdInt int userId); 4116 4117 /** 4118 * Retrieve a set of activities that should be presented to the user as 4119 * similar options. This is like {@link #queryIntentActivities}, except it 4120 * also allows you to supply a list of more explicit Intents that you would 4121 * like to resolve to particular options, and takes care of returning the 4122 * final ResolveInfo list in a reasonable order, with no duplicates, based 4123 * on those inputs. 4124 * 4125 * @param caller The class name of the activity that is making the request. 4126 * This activity will never appear in the output list. Can be 4127 * null. 4128 * @param specifics An array of Intents that should be resolved to the first 4129 * specific results. Can be null. 4130 * @param intent The desired intent as per resolveActivity(). 4131 * @param flags Additional option flags to modify the data returned. The 4132 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 4133 * resolution to only those activities that support the 4134 * {@link android.content.Intent#CATEGORY_DEFAULT}. 4135 * @return Returns a List of ResolveInfo objects containing one entry for 4136 * each matching activity. The list is ordered first by all of the 4137 * intents resolved in <var>specifics</var> and then any additional 4138 * activities that can handle <var>intent</var> but did not get 4139 * included by one of the <var>specifics</var> intents. If there are 4140 * no matching activities, an empty list is returned. 4141 */ 4142 public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller, 4143 @Nullable Intent[] specifics, Intent intent, @ResolveInfoFlags int flags); 4144 4145 /** 4146 * Retrieve all receivers that can handle a broadcast of the given intent. 4147 * 4148 * @param intent The desired intent as per resolveActivity(). 4149 * @param flags Additional option flags to modify the data returned. 4150 * @return Returns a List of ResolveInfo objects containing one entry for 4151 * each matching receiver, ordered from best to worst. If there are 4152 * no matching receivers, an empty list or null is returned. 4153 */ 4154 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 4155 @ResolveInfoFlags int flags); 4156 4157 /** 4158 * Retrieve all receivers that can handle a broadcast of the given intent, 4159 * for a specific user. 4160 * 4161 * @param intent The desired intent as per resolveActivity(). 4162 * @param flags Additional option flags to modify the data returned. 4163 * @param userHandle UserHandle of the user being queried. 4164 * @return Returns a List of ResolveInfo objects containing one entry for 4165 * each matching receiver, ordered from best to worst. If there are 4166 * no matching receivers, an empty list or null is returned. 4167 * @hide 4168 */ 4169 @SystemApi 4170 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 4171 public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 4172 @ResolveInfoFlags int flags, UserHandle userHandle) { 4173 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 4174 } 4175 4176 /** 4177 * @hide 4178 */ 4179 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 4180 @ResolveInfoFlags int flags, @UserIdInt int userId); 4181 4182 4183 /** {@hide} */ 4184 @Deprecated 4185 public List<ResolveInfo> queryBroadcastReceivers(Intent intent, 4186 @ResolveInfoFlags int flags, @UserIdInt int userId) { 4187 final String msg = "Shame on you for calling the hidden API " 4188 + "queryBroadcastReceivers(). Shame!"; 4189 if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) { 4190 throw new UnsupportedOperationException(msg); 4191 } else { 4192 Log.d(TAG, msg); 4193 return queryBroadcastReceiversAsUser(intent, flags, userId); 4194 } 4195 } 4196 4197 /** 4198 * Determine the best service to handle for a given Intent. 4199 * 4200 * @param intent An intent containing all of the desired specification 4201 * (action, data, type, category, and/or component). 4202 * @param flags Additional option flags to modify the data returned. 4203 * @return Returns a ResolveInfo object containing the final service intent 4204 * that was determined to be the best action. Returns null if no 4205 * matching service was found. 4206 */ 4207 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags); 4208 4209 /** 4210 * @hide 4211 */ 4212 public abstract ResolveInfo resolveServiceAsUser(Intent intent, @ResolveInfoFlags int flags, 4213 @UserIdInt int userId); 4214 4215 /** 4216 * Retrieve all services that can match the given intent. 4217 * 4218 * @param intent The desired intent as per resolveService(). 4219 * @param flags Additional option flags to modify the data returned. 4220 * @return Returns a List of ResolveInfo objects containing one entry for 4221 * each matching service, ordered from best to worst. In other 4222 * words, the first item is what would be returned by 4223 * {@link #resolveService}. If there are no matching services, an 4224 * empty list or null is returned. 4225 */ 4226 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 4227 @ResolveInfoFlags int flags); 4228 4229 /** 4230 * Retrieve all services that can match the given intent for a given user. 4231 * 4232 * @param intent The desired intent as per resolveService(). 4233 * @param flags Additional option flags to modify the data returned. 4234 * @param userId The user id. 4235 * @return Returns a List of ResolveInfo objects containing one entry for 4236 * each matching service, ordered from best to worst. In other 4237 * words, the first item is what would be returned by 4238 * {@link #resolveService}. If there are no matching services, an 4239 * empty list or null is returned. 4240 * @hide 4241 */ 4242 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 4243 @ResolveInfoFlags int flags, @UserIdInt int userId); 4244 4245 /** 4246 * Retrieve all providers that can match the given intent. 4247 * 4248 * @param intent An intent containing all of the desired specification 4249 * (action, data, type, category, and/or component). 4250 * @param flags Additional option flags to modify the data returned. 4251 * @param userId The user id. 4252 * @return Returns a List of ResolveInfo objects containing one entry for 4253 * each matching provider, ordered from best to worst. If there are 4254 * no matching services, an empty list or null is returned. 4255 * @hide 4256 */ 4257 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 4258 Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId); 4259 4260 /** 4261 * Retrieve all providers that can match the given intent. 4262 * 4263 * @param intent An intent containing all of the desired specification 4264 * (action, data, type, category, and/or component). 4265 * @param flags Additional option flags to modify the data returned. 4266 * @return Returns a List of ResolveInfo objects containing one entry for 4267 * each matching provider, ordered from best to worst. If there are 4268 * no matching services, an empty list or null is returned. 4269 */ 4270 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, 4271 @ResolveInfoFlags int flags); 4272 4273 /** 4274 * Find a single content provider by its base path name. 4275 * 4276 * @param name The name of the provider to find. 4277 * @param flags Additional option flags to modify the data returned. 4278 * @return A {@link ProviderInfo} object containing information about the 4279 * provider. If a provider was not found, returns null. 4280 */ 4281 public abstract ProviderInfo resolveContentProvider(String name, 4282 @ComponentInfoFlags int flags); 4283 4284 /** 4285 * Find a single content provider by its base path name. 4286 * 4287 * @param name The name of the provider to find. 4288 * @param flags Additional option flags to modify the data returned. 4289 * @param userId The user id. 4290 * @return A {@link ProviderInfo} object containing information about the 4291 * provider. If a provider was not found, returns null. 4292 * @hide 4293 */ 4294 public abstract ProviderInfo resolveContentProviderAsUser(String name, 4295 @ComponentInfoFlags int flags, @UserIdInt int userId); 4296 4297 /** 4298 * Retrieve content provider information. 4299 * <p> 4300 * <em>Note: unlike most other methods, an empty result set is indicated 4301 * by a null return instead of an empty list.</em> 4302 * 4303 * @param processName If non-null, limits the returned providers to only 4304 * those that are hosted by the given process. If null, all 4305 * content providers are returned. 4306 * @param uid If <var>processName</var> is non-null, this is the required 4307 * uid owning the requested content providers. 4308 * @param flags Additional option flags to modify the data returned. 4309 * @return A list of {@link ProviderInfo} objects containing one entry for 4310 * each provider either matching <var>processName</var> or, if 4311 * <var>processName</var> is null, all known content providers. 4312 * <em>If there are no matching providers, null is returned.</em> 4313 */ 4314 public abstract List<ProviderInfo> queryContentProviders( 4315 String processName, int uid, @ComponentInfoFlags int flags); 4316 4317 /** 4318 * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null, 4319 * it only returns providers which have metadata with the {@code metaDataKey} key. 4320 * 4321 * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider. 4322 * You really shouldn't need it. Other apps should use {@link #queryIntentContentProviders} 4323 * instead. 4324 * 4325 * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly 4326 * scan the GAL providers on the device. Unfortunately the discovery protocol used metadata 4327 * to mark GAL providers, rather than intent filters, so we can't use 4328 * {@link #queryIntentContentProviders} for that. 4329 * 4330 * @hide 4331 */ 4332 public List<ProviderInfo> queryContentProviders( 4333 String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey) { 4334 // Provide the default implementation for mocks. 4335 return queryContentProviders(processName, uid, flags); 4336 } 4337 4338 /** 4339 * Retrieve all of the information we know about a particular 4340 * instrumentation class. 4341 * 4342 * @param className The full name (i.e. 4343 * com.google.apps.contacts.InstrumentList) of an Instrumentation 4344 * class. 4345 * @param flags Additional option flags to modify the data returned. 4346 * @return An {@link InstrumentationInfo} object containing information 4347 * about the instrumentation. 4348 * @throws NameNotFoundException if a package with the given name cannot be 4349 * found on the system. 4350 */ 4351 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className, 4352 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 4353 4354 /** 4355 * Retrieve information about available instrumentation code. May be used to 4356 * retrieve either all instrumentation code, or only the code targeting a 4357 * particular package. 4358 * 4359 * @param targetPackage If null, all instrumentation is returned; only the 4360 * instrumentation targeting this package name is returned. 4361 * @param flags Additional option flags to modify the data returned. 4362 * @return A list of {@link InstrumentationInfo} objects containing one 4363 * entry for each matching instrumentation. If there are no 4364 * instrumentation available, returns an empty list. 4365 */ 4366 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage, 4367 @InstrumentationInfoFlags int flags); 4368 4369 /** 4370 * Retrieve an image from a package. This is a low-level API used by 4371 * the various package manager info structures (such as 4372 * {@link ComponentInfo} to implement retrieval of their associated 4373 * icon. 4374 * 4375 * @param packageName The name of the package that this icon is coming from. 4376 * Cannot be null. 4377 * @param resid The resource identifier of the desired image. Cannot be 0. 4378 * @param appInfo Overall information about <var>packageName</var>. This 4379 * may be null, in which case the application information will be retrieved 4380 * for you if needed; if you already have this information around, it can 4381 * be much more efficient to supply it here. 4382 * 4383 * @return Returns a Drawable holding the requested image. Returns null if 4384 * an image could not be found for any reason. 4385 */ 4386 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid, 4387 ApplicationInfo appInfo); 4388 4389 /** 4390 * Retrieve the icon associated with an activity. Given the full name of 4391 * an activity, retrieves the information about it and calls 4392 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 4393 * If the activity cannot be found, NameNotFoundException is thrown. 4394 * 4395 * @param activityName Name of the activity whose icon is to be retrieved. 4396 * 4397 * @return Returns the image of the icon, or the default activity icon if 4398 * it could not be found. Does not return null. 4399 * @throws NameNotFoundException Thrown if the resources for the given 4400 * activity could not be loaded. 4401 * 4402 * @see #getActivityIcon(Intent) 4403 */ 4404 public abstract Drawable getActivityIcon(ComponentName activityName) 4405 throws NameNotFoundException; 4406 4407 /** 4408 * Retrieve the icon associated with an Intent. If intent.getClassName() is 4409 * set, this simply returns the result of 4410 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 4411 * component and returns the icon associated with the resolved component. 4412 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4413 * to a component, NameNotFoundException is thrown. 4414 * 4415 * @param intent The intent for which you would like to retrieve an icon. 4416 * 4417 * @return Returns the image of the icon, or the default activity icon if 4418 * it could not be found. Does not return null. 4419 * @throws NameNotFoundException Thrown if the resources for application 4420 * matching the given intent could not be loaded. 4421 * 4422 * @see #getActivityIcon(ComponentName) 4423 */ 4424 public abstract Drawable getActivityIcon(Intent intent) 4425 throws NameNotFoundException; 4426 4427 /** 4428 * Retrieve the banner associated with an activity. Given the full name of 4429 * an activity, retrieves the information about it and calls 4430 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 4431 * banner. If the activity cannot be found, NameNotFoundException is thrown. 4432 * 4433 * @param activityName Name of the activity whose banner is to be retrieved. 4434 * @return Returns the image of the banner, or null if the activity has no 4435 * banner specified. 4436 * @throws NameNotFoundException Thrown if the resources for the given 4437 * activity could not be loaded. 4438 * @see #getActivityBanner(Intent) 4439 */ 4440 public abstract Drawable getActivityBanner(ComponentName activityName) 4441 throws NameNotFoundException; 4442 4443 /** 4444 * Retrieve the banner associated with an Intent. If intent.getClassName() 4445 * is set, this simply returns the result of 4446 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 4447 * intent's component and returns the banner associated with the resolved 4448 * component. If intent.getClassName() cannot be found or the Intent cannot 4449 * be resolved to a component, NameNotFoundException is thrown. 4450 * 4451 * @param intent The intent for which you would like to retrieve a banner. 4452 * @return Returns the image of the banner, or null if the activity has no 4453 * banner specified. 4454 * @throws NameNotFoundException Thrown if the resources for application 4455 * matching the given intent could not be loaded. 4456 * @see #getActivityBanner(ComponentName) 4457 */ 4458 public abstract Drawable getActivityBanner(Intent intent) 4459 throws NameNotFoundException; 4460 4461 /** 4462 * Return the generic icon for an activity that is used when no specific 4463 * icon is defined. 4464 * 4465 * @return Drawable Image of the icon. 4466 */ 4467 public abstract Drawable getDefaultActivityIcon(); 4468 4469 /** 4470 * Retrieve the icon associated with an application. If it has not defined 4471 * an icon, the default app icon is returned. Does not return null. 4472 * 4473 * @param info Information about application being queried. 4474 * 4475 * @return Returns the image of the icon, or the default application icon 4476 * if it could not be found. 4477 * 4478 * @see #getApplicationIcon(String) 4479 */ 4480 public abstract Drawable getApplicationIcon(ApplicationInfo info); 4481 4482 /** 4483 * Retrieve the icon associated with an application. Given the name of the 4484 * application's package, retrieves the information about it and calls 4485 * getApplicationIcon() to return its icon. If the application cannot be 4486 * found, NameNotFoundException is thrown. 4487 * 4488 * @param packageName Name of the package whose application icon is to be 4489 * retrieved. 4490 * 4491 * @return Returns the image of the icon, or the default application icon 4492 * if it could not be found. Does not return null. 4493 * @throws NameNotFoundException Thrown if the resources for the given 4494 * application could not be loaded. 4495 * 4496 * @see #getApplicationIcon(ApplicationInfo) 4497 */ 4498 public abstract Drawable getApplicationIcon(String packageName) 4499 throws NameNotFoundException; 4500 4501 /** 4502 * Retrieve the banner associated with an application. 4503 * 4504 * @param info Information about application being queried. 4505 * @return Returns the image of the banner or null if the application has no 4506 * banner specified. 4507 * @see #getApplicationBanner(String) 4508 */ 4509 public abstract Drawable getApplicationBanner(ApplicationInfo info); 4510 4511 /** 4512 * Retrieve the banner associated with an application. Given the name of the 4513 * application's package, retrieves the information about it and calls 4514 * getApplicationIcon() to return its banner. If the application cannot be 4515 * found, NameNotFoundException is thrown. 4516 * 4517 * @param packageName Name of the package whose application banner is to be 4518 * retrieved. 4519 * @return Returns the image of the banner or null if the application has no 4520 * banner specified. 4521 * @throws NameNotFoundException Thrown if the resources for the given 4522 * application could not be loaded. 4523 * @see #getApplicationBanner(ApplicationInfo) 4524 */ 4525 public abstract Drawable getApplicationBanner(String packageName) 4526 throws NameNotFoundException; 4527 4528 /** 4529 * Retrieve the logo associated with an activity. Given the full name of an 4530 * activity, retrieves the information about it and calls 4531 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 4532 * logo. If the activity cannot be found, NameNotFoundException is thrown. 4533 * 4534 * @param activityName Name of the activity whose logo is to be retrieved. 4535 * @return Returns the image of the logo or null if the activity has no logo 4536 * specified. 4537 * @throws NameNotFoundException Thrown if the resources for the given 4538 * activity could not be loaded. 4539 * @see #getActivityLogo(Intent) 4540 */ 4541 public abstract Drawable getActivityLogo(ComponentName activityName) 4542 throws NameNotFoundException; 4543 4544 /** 4545 * Retrieve the logo associated with an Intent. If intent.getClassName() is 4546 * set, this simply returns the result of 4547 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 4548 * component and returns the logo associated with the resolved component. 4549 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4550 * to a component, NameNotFoundException is thrown. 4551 * 4552 * @param intent The intent for which you would like to retrieve a logo. 4553 * 4554 * @return Returns the image of the logo, or null if the activity has no 4555 * logo specified. 4556 * 4557 * @throws NameNotFoundException Thrown if the resources for application 4558 * matching the given intent could not be loaded. 4559 * 4560 * @see #getActivityLogo(ComponentName) 4561 */ 4562 public abstract Drawable getActivityLogo(Intent intent) 4563 throws NameNotFoundException; 4564 4565 /** 4566 * Retrieve the logo associated with an application. If it has not specified 4567 * a logo, this method returns null. 4568 * 4569 * @param info Information about application being queried. 4570 * 4571 * @return Returns the image of the logo, or null if no logo is specified 4572 * by the application. 4573 * 4574 * @see #getApplicationLogo(String) 4575 */ 4576 public abstract Drawable getApplicationLogo(ApplicationInfo info); 4577 4578 /** 4579 * Retrieve the logo associated with an application. Given the name of the 4580 * application's package, retrieves the information about it and calls 4581 * getApplicationLogo() to return its logo. If the application cannot be 4582 * found, NameNotFoundException is thrown. 4583 * 4584 * @param packageName Name of the package whose application logo is to be 4585 * retrieved. 4586 * 4587 * @return Returns the image of the logo, or null if no application logo 4588 * has been specified. 4589 * 4590 * @throws NameNotFoundException Thrown if the resources for the given 4591 * application could not be loaded. 4592 * 4593 * @see #getApplicationLogo(ApplicationInfo) 4594 */ 4595 public abstract Drawable getApplicationLogo(String packageName) 4596 throws NameNotFoundException; 4597 4598 /** 4599 * If the target user is a managed profile, then this returns a badged copy of the given icon 4600 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use 4601 * {@link #getUserBadgedDrawableForDensity( 4602 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 4603 * <p> 4604 * If the original drawable is a BitmapDrawable and the backing bitmap is 4605 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 4606 * is performed in place and the original drawable is returned. 4607 * </p> 4608 * 4609 * @param icon The icon to badge. 4610 * @param user The target user. 4611 * @return A drawable that combines the original icon and a badge as 4612 * determined by the system. 4613 */ 4614 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 4615 4616 /** 4617 * If the target user is a managed profile of the calling user or the caller 4618 * is itself a managed profile, then this returns a badged copy of the given 4619 * drawable allowing the user to distinguish it from the original drawable. 4620 * The caller can specify the location in the bounds of the drawable to be 4621 * badged where the badge should be applied as well as the density of the 4622 * badge to be used. 4623 * <p> 4624 * If the original drawable is a BitmapDrawable and the backing bitmap is 4625 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 4626 * is performed in place and the original drawable is returned. 4627 * </p> 4628 * 4629 * @param drawable The drawable to badge. 4630 * @param user The target user. 4631 * @param badgeLocation Where in the bounds of the badged drawable to place 4632 * the badge. If it's {@code null}, the badge is applied on top of the entire 4633 * drawable being badged. 4634 * @param badgeDensity The optional desired density for the badge as per 4635 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive, 4636 * the density of the display is used. 4637 * @return A drawable that combines the original drawable and a badge as 4638 * determined by the system. 4639 */ 4640 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 4641 UserHandle user, Rect badgeLocation, int badgeDensity); 4642 4643 /** 4644 * If the target user is a managed profile of the calling user or the caller 4645 * is itself a managed profile, then this returns a drawable to use as a small 4646 * icon to include in a view to distinguish it from the original icon. 4647 * 4648 * @param user The target user. 4649 * @param density The optional desired density for the badge as per 4650 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4651 * the density of the current display is used. 4652 * @return the drawable or null if no drawable is required. 4653 * @hide 4654 */ 4655 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 4656 4657 /** 4658 * If the target user is a managed profile of the calling user or the caller 4659 * is itself a managed profile, then this returns a drawable to use as a small 4660 * icon to include in a view to distinguish it from the original icon. This version 4661 * doesn't have background protection and should be used over a light background instead of 4662 * a badge. 4663 * 4664 * @param user The target user. 4665 * @param density The optional desired density for the badge as per 4666 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4667 * the density of the current display is used. 4668 * @return the drawable or null if no drawable is required. 4669 * @hide 4670 */ 4671 public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density); 4672 4673 /** 4674 * If the target user is a managed profile of the calling user or the caller 4675 * is itself a managed profile, then this returns a copy of the label with 4676 * badging for accessibility services like talkback. E.g. passing in "Email" 4677 * and it might return "Work Email" for Email in the work profile. 4678 * 4679 * @param label The label to change. 4680 * @param user The target user. 4681 * @return A label that combines the original label and a badge as 4682 * determined by the system. 4683 */ 4684 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 4685 4686 /** 4687 * Retrieve text from a package. This is a low-level API used by 4688 * the various package manager info structures (such as 4689 * {@link ComponentInfo} to implement retrieval of their associated 4690 * labels and other text. 4691 * 4692 * @param packageName The name of the package that this text is coming from. 4693 * Cannot be null. 4694 * @param resid The resource identifier of the desired text. Cannot be 0. 4695 * @param appInfo Overall information about <var>packageName</var>. This 4696 * may be null, in which case the application information will be retrieved 4697 * for you if needed; if you already have this information around, it can 4698 * be much more efficient to supply it here. 4699 * 4700 * @return Returns a CharSequence holding the requested text. Returns null 4701 * if the text could not be found for any reason. 4702 */ 4703 public abstract CharSequence getText(String packageName, @StringRes int resid, 4704 ApplicationInfo appInfo); 4705 4706 /** 4707 * Retrieve an XML file from a package. This is a low-level API used to 4708 * retrieve XML meta data. 4709 * 4710 * @param packageName The name of the package that this xml is coming from. 4711 * Cannot be null. 4712 * @param resid The resource identifier of the desired xml. Cannot be 0. 4713 * @param appInfo Overall information about <var>packageName</var>. This 4714 * may be null, in which case the application information will be retrieved 4715 * for you if needed; if you already have this information around, it can 4716 * be much more efficient to supply it here. 4717 * 4718 * @return Returns an XmlPullParser allowing you to parse out the XML 4719 * data. Returns null if the xml resource could not be found for any 4720 * reason. 4721 */ 4722 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid, 4723 ApplicationInfo appInfo); 4724 4725 /** 4726 * Return the label to use for this application. 4727 * 4728 * @return Returns the label associated with this application, or null if 4729 * it could not be found for any reason. 4730 * @param info The application to get the label of. 4731 */ 4732 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 4733 4734 /** 4735 * Retrieve the resources associated with an activity. Given the full 4736 * name of an activity, retrieves the information about it and calls 4737 * getResources() to return its application's resources. If the activity 4738 * cannot be found, NameNotFoundException is thrown. 4739 * 4740 * @param activityName Name of the activity whose resources are to be 4741 * retrieved. 4742 * 4743 * @return Returns the application's Resources. 4744 * @throws NameNotFoundException Thrown if the resources for the given 4745 * application could not be loaded. 4746 * 4747 * @see #getResourcesForApplication(ApplicationInfo) 4748 */ 4749 public abstract Resources getResourcesForActivity(ComponentName activityName) 4750 throws NameNotFoundException; 4751 4752 /** 4753 * Retrieve the resources for an application. Throws NameNotFoundException 4754 * if the package is no longer installed. 4755 * 4756 * @param app Information about the desired application. 4757 * 4758 * @return Returns the application's Resources. 4759 * @throws NameNotFoundException Thrown if the resources for the given 4760 * application could not be loaded (most likely because it was uninstalled). 4761 */ 4762 public abstract Resources getResourcesForApplication(ApplicationInfo app) 4763 throws NameNotFoundException; 4764 4765 /** 4766 * Retrieve the resources associated with an application. Given the full 4767 * package name of an application, retrieves the information about it and 4768 * calls getResources() to return its application's resources. If the 4769 * appPackageName cannot be found, NameNotFoundException is thrown. 4770 * 4771 * @param appPackageName Package name of the application whose resources 4772 * are to be retrieved. 4773 * 4774 * @return Returns the application's Resources. 4775 * @throws NameNotFoundException Thrown if the resources for the given 4776 * application could not be loaded. 4777 * 4778 * @see #getResourcesForApplication(ApplicationInfo) 4779 */ 4780 public abstract Resources getResourcesForApplication(String appPackageName) 4781 throws NameNotFoundException; 4782 4783 /** @hide */ 4784 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, 4785 @UserIdInt int userId) throws NameNotFoundException; 4786 4787 /** 4788 * Retrieve overall information about an application package defined in a 4789 * package archive file 4790 * 4791 * @param archiveFilePath The path to the archive file 4792 * @param flags Additional option flags to modify the data returned. 4793 * @return A PackageInfo object containing information about the package 4794 * archive. If the package could not be parsed, returns null. 4795 */ 4796 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) { 4797 final PackageParser parser = new PackageParser(); 4798 parser.setCallback(new PackageParser.CallbackImpl(this)); 4799 final File apkFile = new File(archiveFilePath); 4800 try { 4801 if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) { 4802 // Caller expressed an explicit opinion about what encryption 4803 // aware/unaware components they want to see, so fall through and 4804 // give them what they want 4805 } else { 4806 // Caller expressed no opinion, so match everything 4807 flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE; 4808 } 4809 4810 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 4811 if ((flags & GET_SIGNATURES) != 0) { 4812 PackageParser.collectCertificates(pkg, false /* skipVerify */); 4813 } 4814 PackageUserState state = new PackageUserState(); 4815 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 4816 } catch (PackageParserException e) { 4817 return null; 4818 } 4819 } 4820 4821 /** 4822 * If there is already an application with the given package name installed 4823 * on the system for other users, also install it for the calling user. 4824 * @hide 4825 */ 4826 @SystemApi 4827 public abstract int installExistingPackage(String packageName) throws NameNotFoundException; 4828 4829 /** 4830 * If there is already an application with the given package name installed 4831 * on the system for other users, also install it for the calling user. 4832 * @hide 4833 */ 4834 @SystemApi 4835 public abstract int installExistingPackage(String packageName, @InstallReason int installReason) 4836 throws NameNotFoundException; 4837 4838 /** 4839 * If there is already an application with the given package name installed 4840 * on the system for other users, also install it for the specified user. 4841 * @hide 4842 */ 4843 @RequiresPermission(anyOf = { 4844 Manifest.permission.INSTALL_PACKAGES, 4845 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4846 public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId) 4847 throws NameNotFoundException; 4848 4849 /** 4850 * Allows a package listening to the 4851 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4852 * broadcast} to respond to the package manager. The response must include 4853 * the {@code verificationCode} which is one of 4854 * {@link PackageManager#VERIFICATION_ALLOW} or 4855 * {@link PackageManager#VERIFICATION_REJECT}. 4856 * 4857 * @param id pending package identifier as passed via the 4858 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4859 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 4860 * or {@link PackageManager#VERIFICATION_REJECT}. 4861 * @throws SecurityException if the caller does not have the 4862 * PACKAGE_VERIFICATION_AGENT permission. 4863 */ 4864 public abstract void verifyPendingInstall(int id, int verificationCode); 4865 4866 /** 4867 * Allows a package listening to the 4868 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4869 * broadcast} to extend the default timeout for a response and declare what 4870 * action to perform after the timeout occurs. The response must include 4871 * the {@code verificationCodeAtTimeout} which is one of 4872 * {@link PackageManager#VERIFICATION_ALLOW} or 4873 * {@link PackageManager#VERIFICATION_REJECT}. 4874 * 4875 * This method may only be called once per package id. Additional calls 4876 * will have no effect. 4877 * 4878 * @param id pending package identifier as passed via the 4879 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4880 * @param verificationCodeAtTimeout either 4881 * {@link PackageManager#VERIFICATION_ALLOW} or 4882 * {@link PackageManager#VERIFICATION_REJECT}. If 4883 * {@code verificationCodeAtTimeout} is neither 4884 * {@link PackageManager#VERIFICATION_ALLOW} or 4885 * {@link PackageManager#VERIFICATION_REJECT}, then 4886 * {@code verificationCodeAtTimeout} will default to 4887 * {@link PackageManager#VERIFICATION_REJECT}. 4888 * @param millisecondsToDelay the amount of time requested for the timeout. 4889 * Must be positive and less than 4890 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 4891 * {@code millisecondsToDelay} is out of bounds, 4892 * {@code millisecondsToDelay} will be set to the closest in 4893 * bounds value; namely, 0 or 4894 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 4895 * @throws SecurityException if the caller does not have the 4896 * PACKAGE_VERIFICATION_AGENT permission. 4897 */ 4898 public abstract void extendVerificationTimeout(int id, 4899 int verificationCodeAtTimeout, long millisecondsToDelay); 4900 4901 /** 4902 * Allows a package listening to the 4903 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification 4904 * broadcast to respond to the package manager. The response must include 4905 * the {@code verificationCode} which is one of 4906 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 4907 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4908 * 4909 * @param verificationId pending package identifier as passed via the 4910 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4911 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 4912 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4913 * @param failedDomains a list of failed domains if the verificationCode is 4914 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 4915 * @throws SecurityException if the caller does not have the 4916 * INTENT_FILTER_VERIFICATION_AGENT permission. 4917 * 4918 * @hide 4919 */ 4920 @SystemApi 4921 @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT) 4922 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 4923 List<String> failedDomains); 4924 4925 /** 4926 * Get the status of a Domain Verification Result for an IntentFilter. This is 4927 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4928 * {@link android.content.IntentFilter#getAutoVerify()} 4929 * 4930 * This is used by the ResolverActivity to change the status depending on what the User select 4931 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4932 * for a domain. 4933 * 4934 * @param packageName The package name of the Activity associated with the IntentFilter. 4935 * @param userId The user id. 4936 * 4937 * @return The status to set to. This can be 4938 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4939 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4940 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 4941 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 4942 * 4943 * @hide 4944 */ 4945 @SystemApi 4946 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL) 4947 public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId); 4948 4949 /** 4950 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 4951 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4952 * {@link android.content.IntentFilter#getAutoVerify()} 4953 * 4954 * This is used by the ResolverActivity to change the status depending on what the User select 4955 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4956 * for a domain. 4957 * 4958 * @param packageName The package name of the Activity associated with the IntentFilter. 4959 * @param status The status to set to. This can be 4960 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4961 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4962 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 4963 * @param userId The user id. 4964 * 4965 * @return true if the status has been set. False otherwise. 4966 * 4967 * @hide 4968 */ 4969 @SystemApi 4970 @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS) 4971 public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status, 4972 @UserIdInt int userId); 4973 4974 /** 4975 * Get the list of IntentFilterVerificationInfo for a specific package and User. 4976 * 4977 * @param packageName the package name. When this parameter is set to a non null value, 4978 * the results will be filtered by the package name provided. 4979 * Otherwise, there will be no filtering and it will return a list 4980 * corresponding for all packages 4981 * 4982 * @return a list of IntentFilterVerificationInfo for a specific package. 4983 * 4984 * @hide 4985 */ 4986 @SystemApi 4987 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 4988 String packageName); 4989 4990 /** 4991 * Get the list of IntentFilter for a specific package. 4992 * 4993 * @param packageName the package name. This parameter is set to a non null value, 4994 * the list will contain all the IntentFilter for that package. 4995 * Otherwise, the list will be empty. 4996 * 4997 * @return a list of IntentFilter for a specific package. 4998 * 4999 * @hide 5000 */ 5001 @SystemApi 5002 public abstract List<IntentFilter> getAllIntentFilters(String packageName); 5003 5004 /** 5005 * Get the default Browser package name for a specific user. 5006 * 5007 * @param userId The user id. 5008 * 5009 * @return the package name of the default Browser for the specified user. If the user id passed 5010 * is -1 (all users) it will return a null value. 5011 * 5012 * @hide 5013 */ 5014 @TestApi 5015 @SystemApi 5016 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL) 5017 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId); 5018 5019 /** 5020 * Set the default Browser package name for a specific user. 5021 * 5022 * @param packageName The package name of the default Browser. 5023 * @param userId The user id. 5024 * 5025 * @return true if the default Browser for the specified user has been set, 5026 * otherwise return false. If the user id passed is -1 (all users) this call will not 5027 * do anything and just return false. 5028 * 5029 * @hide 5030 */ 5031 @SystemApi 5032 @RequiresPermission(allOf = { 5033 Manifest.permission.SET_PREFERRED_APPLICATIONS, 5034 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 5035 public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName, 5036 @UserIdInt int userId); 5037 5038 /** 5039 * Change the installer associated with a given package. There are limitations 5040 * on how the installer package can be changed; in particular: 5041 * <ul> 5042 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 5043 * is not signed with the same certificate as the calling application. 5044 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 5045 * has an installer package, and that installer package is not signed with 5046 * the same certificate as the calling application. 5047 * </ul> 5048 * 5049 * @param targetPackage The installed package whose installer will be changed. 5050 * @param installerPackageName The package name of the new installer. May be 5051 * null to clear the association. 5052 */ 5053 public abstract void setInstallerPackageName(String targetPackage, 5054 String installerPackageName); 5055 5056 /** @hide */ 5057 @SystemApi 5058 @RequiresPermission(Manifest.permission.INSTALL_PACKAGES) 5059 public abstract void setUpdateAvailable(String packageName, boolean updateAvaialble); 5060 5061 /** 5062 * Attempts to delete a package. Since this may take a little while, the 5063 * result will be posted back to the given observer. A deletion will fail if 5064 * the calling context lacks the 5065 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 5066 * named package cannot be found, or if the named package is a system 5067 * package. 5068 * 5069 * @param packageName The name of the package to delete 5070 * @param observer An observer callback to get notified when the package 5071 * deletion is complete. 5072 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 5073 * will be called when that happens. observer may be null to 5074 * indicate that no callback is desired. 5075 * @hide 5076 */ 5077 @RequiresPermission(Manifest.permission.DELETE_PACKAGES) 5078 public abstract void deletePackage(String packageName, IPackageDeleteObserver observer, 5079 @DeleteFlags int flags); 5080 5081 /** 5082 * Attempts to delete a package. Since this may take a little while, the 5083 * result will be posted back to the given observer. A deletion will fail if 5084 * the named package cannot be found, or if the named package is a system 5085 * package. 5086 * 5087 * @param packageName The name of the package to delete 5088 * @param observer An observer callback to get notified when the package 5089 * deletion is complete. 5090 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 5091 * will be called when that happens. observer may be null to 5092 * indicate that no callback is desired. 5093 * @param userId The user Id 5094 * @hide 5095 */ 5096 @RequiresPermission(anyOf = { 5097 Manifest.permission.DELETE_PACKAGES, 5098 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 5099 public abstract void deletePackageAsUser(@NonNull String packageName, 5100 IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId); 5101 5102 /** 5103 * Retrieve the package name of the application that installed a package. This identifies 5104 * which market the package came from. 5105 * 5106 * @param packageName The name of the package to query 5107 * @throws IllegalArgumentException if the given package name is not installed 5108 */ 5109 public abstract String getInstallerPackageName(String packageName); 5110 5111 /** 5112 * Attempts to clear the user data directory of an application. 5113 * Since this may take a little while, the result will 5114 * be posted back to the given observer. A deletion will fail if the 5115 * named package cannot be found, or if the named package is a "system package". 5116 * 5117 * @param packageName The name of the package 5118 * @param observer An observer callback to get notified when the operation is finished 5119 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5120 * will be called when that happens. observer may be null to indicate that 5121 * no callback is desired. 5122 * 5123 * @hide 5124 */ 5125 public abstract void clearApplicationUserData(String packageName, 5126 IPackageDataObserver observer); 5127 /** 5128 * Attempts to delete the cache files associated with an application. 5129 * Since this may take a little while, the result will 5130 * be posted back to the given observer. A deletion will fail if the calling context 5131 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 5132 * named package cannot be found, or if the named package is a "system package". 5133 * 5134 * @param packageName The name of the package to delete 5135 * @param observer An observer callback to get notified when the cache file deletion 5136 * is complete. 5137 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5138 * will be called when that happens. observer may be null to indicate that 5139 * no callback is desired. 5140 * 5141 * @hide 5142 */ 5143 public abstract void deleteApplicationCacheFiles(String packageName, 5144 IPackageDataObserver observer); 5145 5146 /** 5147 * Attempts to delete the cache files associated with an application for a given user. Since 5148 * this may take a little while, the result will be posted back to the given observer. A 5149 * deletion will fail if the calling context lacks the 5150 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package 5151 * cannot be found, or if the named package is a "system package". If {@code userId} does not 5152 * belong to the calling user, the caller must have 5153 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission. 5154 * 5155 * @param packageName The name of the package to delete 5156 * @param userId the user for which the cache files needs to be deleted 5157 * @param observer An observer callback to get notified when the cache file deletion is 5158 * complete. 5159 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5160 * will be called when that happens. observer may be null to indicate that no 5161 * callback is desired. 5162 * @hide 5163 */ 5164 public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId, 5165 IPackageDataObserver observer); 5166 5167 /** 5168 * Free storage by deleting LRU sorted list of cache files across 5169 * all applications. If the currently available free storage 5170 * on the device is greater than or equal to the requested 5171 * free storage, no cache files are cleared. If the currently 5172 * available storage on the device is less than the requested 5173 * free storage, some or all of the cache files across 5174 * all applications are deleted (based on last accessed time) 5175 * to increase the free storage space on the device to 5176 * the requested value. There is no guarantee that clearing all 5177 * the cache files from all applications will clear up 5178 * enough storage to achieve the desired value. 5179 * @param freeStorageSize The number of bytes of storage to be 5180 * freed by the system. Say if freeStorageSize is XX, 5181 * and the current free storage is YY, 5182 * if XX is less than YY, just return. if not free XX-YY number 5183 * of bytes if possible. 5184 * @param observer call back used to notify when 5185 * the operation is completed 5186 * 5187 * @hide 5188 */ 5189 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) { 5190 freeStorageAndNotify(null, freeStorageSize, observer); 5191 } 5192 5193 /** {@hide} */ 5194 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize, 5195 IPackageDataObserver observer); 5196 5197 /** 5198 * Free storage by deleting LRU sorted list of cache files across 5199 * all applications. If the currently available free storage 5200 * on the device is greater than or equal to the requested 5201 * free storage, no cache files are cleared. If the currently 5202 * available storage on the device is less than the requested 5203 * free storage, some or all of the cache files across 5204 * all applications are deleted (based on last accessed time) 5205 * to increase the free storage space on the device to 5206 * the requested value. There is no guarantee that clearing all 5207 * the cache files from all applications will clear up 5208 * enough storage to achieve the desired value. 5209 * @param freeStorageSize The number of bytes of storage to be 5210 * freed by the system. Say if freeStorageSize is XX, 5211 * and the current free storage is YY, 5212 * if XX is less than YY, just return. if not free XX-YY number 5213 * of bytes if possible. 5214 * @param pi IntentSender call back used to 5215 * notify when the operation is completed.May be null 5216 * to indicate that no call back is desired. 5217 * 5218 * @hide 5219 */ 5220 public void freeStorage(long freeStorageSize, IntentSender pi) { 5221 freeStorage(null, freeStorageSize, pi); 5222 } 5223 5224 /** {@hide} */ 5225 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi); 5226 5227 /** 5228 * Retrieve the size information for a package. 5229 * Since this may take a little while, the result will 5230 * be posted back to the given observer. The calling context 5231 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 5232 * 5233 * @param packageName The name of the package whose size information is to be retrieved 5234 * @param userId The user whose size information should be retrieved. 5235 * @param observer An observer callback to get notified when the operation 5236 * is complete. 5237 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 5238 * The observer's callback is invoked with a PackageStats object(containing the 5239 * code, data and cache sizes of the package) and a boolean value representing 5240 * the status of the operation. observer may be null to indicate that 5241 * no callback is desired. 5242 * 5243 * @deprecated use {@link StorageStatsManager} instead. 5244 * @hide 5245 */ 5246 @Deprecated 5247 public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId, 5248 IPackageStatsObserver observer); 5249 5250 /** 5251 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but 5252 * returns the size for the calling user. 5253 * 5254 * @deprecated use {@link StorageStatsManager} instead. 5255 * @hide 5256 */ 5257 @Deprecated 5258 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 5259 getPackageSizeInfoAsUser(packageName, getUserId(), observer); 5260 } 5261 5262 /** 5263 * @deprecated This function no longer does anything; it was an old 5264 * approach to managing preferred activities, which has been superseded 5265 * by (and conflicts with) the modern activity-based preferences. 5266 */ 5267 @Deprecated 5268 public abstract void addPackageToPreferred(String packageName); 5269 5270 /** 5271 * @deprecated This function no longer does anything; it was an old 5272 * approach to managing preferred activities, which has been superseded 5273 * by (and conflicts with) the modern activity-based preferences. 5274 */ 5275 @Deprecated 5276 public abstract void removePackageFromPreferred(String packageName); 5277 5278 /** 5279 * Retrieve the list of all currently configured preferred packages. The 5280 * first package on the list is the most preferred, the last is the least 5281 * preferred. 5282 * 5283 * @param flags Additional option flags to modify the data returned. 5284 * @return A List of PackageInfo objects, one for each preferred 5285 * application, in order of preference. 5286 */ 5287 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags); 5288 5289 /** 5290 * @deprecated This is a protected API that should not have been available 5291 * to third party applications. It is the platform's responsibility for 5292 * assigning preferred activities and this cannot be directly modified. 5293 * 5294 * Add a new preferred activity mapping to the system. This will be used 5295 * to automatically select the given activity component when 5296 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5297 * multiple matching activities and also matches the given filter. 5298 * 5299 * @param filter The set of intents under which this activity will be 5300 * made preferred. 5301 * @param match The IntentFilter match category that this preference 5302 * applies to. 5303 * @param set The set of activities that the user was picking from when 5304 * this preference was made. 5305 * @param activity The component name of the activity that is to be 5306 * preferred. 5307 */ 5308 @Deprecated 5309 public abstract void addPreferredActivity(IntentFilter filter, int match, 5310 ComponentName[] set, ComponentName activity); 5311 5312 /** 5313 * Same as {@link #addPreferredActivity(IntentFilter, int, 5314 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 5315 to. 5316 * @hide 5317 */ 5318 public void addPreferredActivityAsUser(IntentFilter filter, int match, 5319 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5320 throw new RuntimeException("Not implemented. Must override in a subclass."); 5321 } 5322 5323 /** 5324 * @deprecated This is a protected API that should not have been available 5325 * to third party applications. It is the platform's responsibility for 5326 * assigning preferred activities and this cannot be directly modified. 5327 * 5328 * Replaces an existing preferred activity mapping to the system, and if that were not present 5329 * adds a new preferred activity. This will be used 5330 * to automatically select the given activity component when 5331 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5332 * multiple matching activities and also matches the given filter. 5333 * 5334 * @param filter The set of intents under which this activity will be 5335 * made preferred. 5336 * @param match The IntentFilter match category that this preference 5337 * applies to. 5338 * @param set The set of activities that the user was picking from when 5339 * this preference was made. 5340 * @param activity The component name of the activity that is to be 5341 * preferred. 5342 * @hide 5343 */ 5344 @Deprecated 5345 public abstract void replacePreferredActivity(IntentFilter filter, int match, 5346 ComponentName[] set, ComponentName activity); 5347 5348 /** 5349 * @hide 5350 */ 5351 @Deprecated 5352 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 5353 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5354 throw new RuntimeException("Not implemented. Must override in a subclass."); 5355 } 5356 5357 /** 5358 * Remove all preferred activity mappings, previously added with 5359 * {@link #addPreferredActivity}, from the 5360 * system whose activities are implemented in the given package name. 5361 * An application can only clear its own package(s). 5362 * 5363 * @param packageName The name of the package whose preferred activity 5364 * mappings are to be removed. 5365 */ 5366 public abstract void clearPackagePreferredActivities(String packageName); 5367 5368 /** 5369 * Retrieve all preferred activities, previously added with 5370 * {@link #addPreferredActivity}, that are 5371 * currently registered with the system. 5372 * 5373 * @param outFilters A required list in which to place the filters of all of the 5374 * preferred activities. 5375 * @param outActivities A required list in which to place the component names of 5376 * all of the preferred activities. 5377 * @param packageName An optional package in which you would like to limit 5378 * the list. If null, all activities will be returned; if non-null, only 5379 * those activities in the given package are returned. 5380 * 5381 * @return Returns the total number of registered preferred activities 5382 * (the number of distinct IntentFilter records, not the number of unique 5383 * activity components) that were found. 5384 */ 5385 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 5386 @NonNull List<ComponentName> outActivities, String packageName); 5387 5388 /** 5389 * Ask for the set of available 'home' activities and the current explicit 5390 * default, if any. 5391 * @hide 5392 */ 5393 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 5394 5395 /** 5396 * Set the enabled setting for a package component (activity, receiver, service, provider). 5397 * This setting will override any enabled state which may have been set by the component in its 5398 * manifest. 5399 * 5400 * @param componentName The component to enable 5401 * @param newState The new enabled state for the component. 5402 * @param flags Optional behavior flags. 5403 */ 5404 public abstract void setComponentEnabledSetting(ComponentName componentName, 5405 @EnabledState int newState, @EnabledFlags int flags); 5406 5407 /** 5408 * Return the enabled setting for a package component (activity, 5409 * receiver, service, provider). This returns the last value set by 5410 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 5411 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5412 * the value originally specified in the manifest has not been modified. 5413 * 5414 * @param componentName The component to retrieve. 5415 * @return Returns the current enabled state for the component. 5416 */ 5417 public abstract @EnabledState int getComponentEnabledSetting( 5418 ComponentName componentName); 5419 5420 /** 5421 * Set the enabled setting for an application 5422 * This setting will override any enabled state which may have been set by the application in 5423 * its manifest. It also overrides the enabled state set in the manifest for any of the 5424 * application's components. It does not override any enabled state set by 5425 * {@link #setComponentEnabledSetting} for any of the application's components. 5426 * 5427 * @param packageName The package name of the application to enable 5428 * @param newState The new enabled state for the application. 5429 * @param flags Optional behavior flags. 5430 */ 5431 public abstract void setApplicationEnabledSetting(String packageName, 5432 @EnabledState int newState, @EnabledFlags int flags); 5433 5434 /** 5435 * Return the enabled setting for an application. This returns 5436 * the last value set by 5437 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 5438 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5439 * the value originally specified in the manifest has not been modified. 5440 * 5441 * @param packageName The package name of the application to retrieve. 5442 * @return Returns the current enabled state for the application. 5443 * @throws IllegalArgumentException if the named package does not exist. 5444 */ 5445 public abstract @EnabledState int getApplicationEnabledSetting(String packageName); 5446 5447 /** 5448 * Flush the package restrictions for a given user to disk. This forces the package restrictions 5449 * like component and package enabled settings to be written to disk and avoids the delay that 5450 * is otherwise present when changing those settings. 5451 * 5452 * @param userId Ther userId of the user whose restrictions are to be flushed. 5453 * @hide 5454 */ 5455 public abstract void flushPackageRestrictionsAsUser(int userId); 5456 5457 /** 5458 * Puts the package in a hidden state, which is almost like an uninstalled state, 5459 * making the package unavailable, but it doesn't remove the data or the actual 5460 * package file. Application can be unhidden by either resetting the hidden state 5461 * or by installing it, such as with {@link #installExistingPackage(String)} 5462 * @hide 5463 */ 5464 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 5465 UserHandle userHandle); 5466 5467 /** 5468 * Returns the hidden state of a package. 5469 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 5470 * @hide 5471 */ 5472 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 5473 UserHandle userHandle); 5474 5475 /** 5476 * Return whether the device has been booted into safe mode. 5477 */ 5478 public abstract boolean isSafeMode(); 5479 5480 /** 5481 * Adds a listener for permission changes for installed packages. 5482 * 5483 * @param listener The listener to add. 5484 * 5485 * @hide 5486 */ 5487 @SystemApi 5488 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 5489 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5490 5491 /** 5492 * Remvoes a listener for permission changes for installed packages. 5493 * 5494 * @param listener The listener to remove. 5495 * 5496 * @hide 5497 */ 5498 @SystemApi 5499 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 5500 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5501 5502 /** 5503 * Return the {@link KeySet} associated with the String alias for this 5504 * application. 5505 * 5506 * @param alias The alias for a given {@link KeySet} as defined in the 5507 * application's AndroidManifest.xml. 5508 * @hide 5509 */ 5510 public abstract KeySet getKeySetByAlias(String packageName, String alias); 5511 5512 /** Return the signing {@link KeySet} for this application. 5513 * @hide 5514 */ 5515 public abstract KeySet getSigningKeySet(String packageName); 5516 5517 /** 5518 * Return whether the package denoted by packageName has been signed by all 5519 * of the keys specified by the {@link KeySet} ks. This will return true if 5520 * the package has been signed by additional keys (a superset) as well. 5521 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 5522 * @hide 5523 */ 5524 public abstract boolean isSignedBy(String packageName, KeySet ks); 5525 5526 /** 5527 * Return whether the package denoted by packageName has been signed by all 5528 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 5529 * {@link #isSignedBy(String packageName, KeySet ks)}. 5530 * @hide 5531 */ 5532 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 5533 5534 /** 5535 * Puts the package in a suspended state, where attempts at starting activities are denied. 5536 * 5537 * <p>It doesn't remove the data or the actual package file. The application's notifications 5538 * will be hidden, any of its started activities will be stopped and it will not be able to 5539 * show toasts or system alert windows or ring the device. 5540 * 5541 * <p>When the user tries to launch a suspended app, a system dialog with the given 5542 * {@code dialogMessage} will be shown instead. Since the message is supplied to the system as 5543 * a {@link String}, the caller needs to take care of localization as needed. 5544 * The dialog message can optionally contain a placeholder for the name of the suspended app. 5545 * The system uses {@link String#format(Locale, String, Object...) String.format} to insert the 5546 * app name into the message, so an example format string could be {@code "The app %1$s is 5547 * currently suspended"}. This makes it easier for callers to provide a single message which 5548 * works for all the packages being suspended in a single call. 5549 * 5550 * <p>The package must already be installed. If the package is uninstalled while suspended 5551 * the package will no longer be suspended. </p> 5552 * 5553 * <p>Optionally, the suspending app can provide extra information in the form of 5554 * {@link PersistableBundle} objects to be shared with the apps being suspended and the 5555 * launcher to support customization that they might need to handle the suspended state. 5556 * 5557 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} or 5558 * {@link Manifest.permission#MANAGE_USERS} to use this api.</p> 5559 * 5560 * @param packageNames The names of the packages to set the suspended status. 5561 * @param suspended If set to {@code true} than the packages will be suspended, if set to 5562 * {@code false}, the packages will be unsuspended. 5563 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide 5564 * which will be shared with the apps being suspended. Ignored if 5565 * {@code suspended} is false. 5566 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can 5567 * provide which will be shared with the launcher. Ignored if 5568 * {@code suspended} is false. 5569 * @param dialogMessage The message to be displayed to the user, when they try to launch a 5570 * suspended app. 5571 * 5572 * @return an array of package names for which the suspended status could not be set as 5573 * requested in this method. 5574 * 5575 * @hide 5576 */ 5577 @SystemApi 5578 @RequiresPermission(anyOf = {Manifest.permission.SUSPEND_APPS, 5579 Manifest.permission.MANAGE_USERS}) 5580 public String[] setPackagesSuspended(String[] packageNames, boolean suspended, 5581 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, 5582 String dialogMessage) { 5583 throw new UnsupportedOperationException("setPackagesSuspended not implemented"); 5584 } 5585 5586 /** 5587 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) 5588 * @param packageName The name of the package to get the suspended status of. 5589 * @param userId The user id. 5590 * @return {@code true} if the package is suspended or {@code false} if the package is not 5591 * suspended. 5592 * @throws IllegalArgumentException if the package was not found. 5593 * @hide 5594 */ 5595 public abstract boolean isPackageSuspendedForUser(String packageName, int userId); 5596 5597 /** 5598 * Query if an app is currently suspended. 5599 * 5600 * @return {@code true} if the given package is suspended, {@code false} otherwise 5601 * @throws NameNotFoundException if the package could not be found. 5602 * 5603 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) 5604 * @hide 5605 */ 5606 @SystemApi 5607 public boolean isPackageSuspended(String packageName) throws NameNotFoundException { 5608 throw new UnsupportedOperationException("isPackageSuspended not implemented"); 5609 } 5610 5611 /** 5612 * Apps can query this to know if they have been suspended. A system app with the permission 5613 * {@code android.permission.SUSPEND_APPS} can put any app on the device into a suspended state. 5614 * 5615 * <p>While in this state, the application's notifications will be hidden, any of its started 5616 * activities will be stopped and it will not be able to show toasts or dialogs or ring the 5617 * device. When the user tries to launch a suspended app, the system will, instead, show a 5618 * dialog to the user informing them that they cannot use this app while it is suspended. 5619 * 5620 * <p>When an app is put into this state, the broadcast action 5621 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED} will be delivered to any of its broadcast 5622 * receivers that included this action in their intent-filters, <em>including manifest 5623 * receivers.</em> Similarly, a broadcast action {@link Intent#ACTION_MY_PACKAGE_UNSUSPENDED} 5624 * is delivered when a previously suspended app is taken out of this state. 5625 * </p> 5626 * 5627 * @return {@code true} if the calling package has been suspended, {@code false} otherwise. 5628 * 5629 * @see #getSuspendedPackageAppExtras() 5630 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED 5631 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED 5632 */ 5633 public boolean isPackageSuspended() { 5634 throw new UnsupportedOperationException("isPackageSuspended not implemented"); 5635 } 5636 5637 /** 5638 * Returns a {@link Bundle} of extras that was meant to be sent to the calling app when it was 5639 * suspended. An app with the permission {@code android.permission.SUSPEND_APPS} can supply this 5640 * to the system at the time of suspending an app. 5641 * 5642 * <p>This is the same {@link Bundle} that is sent along with the broadcast 5643 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED}, whenever the app is suspended. The contents of 5644 * this {@link Bundle} are a contract between the suspended app and the suspending app. 5645 * 5646 * <p>Note: These extras are optional, so if no extras were supplied to the system, this method 5647 * will return {@code null}, even when the calling app has been suspended. 5648 * 5649 * @return A {@link Bundle} containing the extras for the app, or {@code null} if the 5650 * package is not currently suspended. 5651 * 5652 * @see #isPackageSuspended() 5653 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED 5654 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED 5655 * @see Intent#EXTRA_SUSPENDED_PACKAGE_EXTRAS 5656 */ 5657 public @Nullable Bundle getSuspendedPackageAppExtras() { 5658 throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented"); 5659 } 5660 5661 /** 5662 * Provide a hint of what the {@link ApplicationInfo#category} value should 5663 * be for the given package. 5664 * <p> 5665 * This hint can only be set by the app which installed this package, as 5666 * determined by {@link #getInstallerPackageName(String)}. 5667 * 5668 * @param packageName the package to change the category hint for. 5669 * @param categoryHint the category hint to set. 5670 */ 5671 public abstract void setApplicationCategoryHint(@NonNull String packageName, 5672 @ApplicationInfo.Category int categoryHint); 5673 5674 /** {@hide} */ 5675 public static boolean isMoveStatusFinished(int status) { 5676 return (status < 0 || status > 100); 5677 } 5678 5679 /** {@hide} */ 5680 public static abstract class MoveCallback { 5681 public void onCreated(int moveId, Bundle extras) {} 5682 public abstract void onStatusChanged(int moveId, int status, long estMillis); 5683 } 5684 5685 /** {@hide} */ 5686 public abstract int getMoveStatus(int moveId); 5687 5688 /** {@hide} */ 5689 public abstract void registerMoveCallback(MoveCallback callback, Handler handler); 5690 /** {@hide} */ 5691 public abstract void unregisterMoveCallback(MoveCallback callback); 5692 5693 /** {@hide} */ 5694 public abstract int movePackage(String packageName, VolumeInfo vol); 5695 /** {@hide} */ 5696 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app); 5697 /** {@hide} */ 5698 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app); 5699 5700 /** {@hide} */ 5701 public abstract int movePrimaryStorage(VolumeInfo vol); 5702 /** {@hide} */ 5703 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 5704 /** {@hide} */ 5705 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 5706 5707 /** 5708 * Returns the device identity that verifiers can use to associate their scheme to a particular 5709 * device. This should not be used by anything other than a package verifier. 5710 * 5711 * @return identity that uniquely identifies current device 5712 * @hide 5713 */ 5714 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 5715 5716 /** 5717 * Returns true if the device is upgrading, such as first boot after OTA. 5718 * 5719 * @hide 5720 */ 5721 public abstract boolean isUpgrade(); 5722 5723 /** 5724 * Return interface that offers the ability to install, upgrade, and remove 5725 * applications on the device. 5726 */ 5727 public abstract @NonNull PackageInstaller getPackageInstaller(); 5728 5729 /** 5730 * Adds a {@code CrossProfileIntentFilter}. After calling this method all 5731 * intents sent from the user with id sourceUserId can also be be resolved 5732 * by activities in the user with id targetUserId if they match the 5733 * specified intent filter. 5734 * 5735 * @param filter The {@link IntentFilter} the intent has to match 5736 * @param sourceUserId The source user id. 5737 * @param targetUserId The target user id. 5738 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 5739 * {@link #ONLY_IF_NO_MATCH_FOUND}. 5740 * @hide 5741 */ 5742 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 5743 int targetUserId, int flags); 5744 5745 /** 5746 * Clearing {@code CrossProfileIntentFilter}s which have the specified user 5747 * as their source, and have been set by the app calling this method. 5748 * 5749 * @param sourceUserId The source user id. 5750 * @hide 5751 */ 5752 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 5753 5754 /** 5755 * @hide 5756 */ 5757 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 5758 5759 /** 5760 * @hide 5761 */ 5762 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 5763 5764 /** {@hide} */ 5765 public abstract boolean isPackageAvailable(String packageName); 5766 5767 /** {@hide} */ 5768 public static String installStatusToString(int status, String msg) { 5769 final String str = installStatusToString(status); 5770 if (msg != null) { 5771 return str + ": " + msg; 5772 } else { 5773 return str; 5774 } 5775 } 5776 5777 /** {@hide} */ 5778 public static String installStatusToString(int status) { 5779 switch (status) { 5780 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 5781 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 5782 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 5783 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 5784 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 5785 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 5786 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 5787 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 5788 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 5789 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 5790 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 5791 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 5792 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 5793 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 5794 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 5795 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 5796 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 5797 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 5798 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 5799 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 5800 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 5801 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 5802 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 5803 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 5804 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 5805 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 5806 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 5807 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 5808 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 5809 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 5810 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 5811 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 5812 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 5813 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 5814 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 5815 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 5816 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 5817 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 5818 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 5819 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 5820 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 5821 case INSTALL_FAILED_BAD_DEX_METADATA: 5822 return "INSTALL_FAILED_BAD_DEX_METADATA"; 5823 default: return Integer.toString(status); 5824 } 5825 } 5826 5827 /** {@hide} */ 5828 public static int installStatusToPublicStatus(int status) { 5829 switch (status) { 5830 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5831 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5832 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5833 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 5834 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5835 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5836 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5837 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5838 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5839 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5840 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5841 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 5842 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5843 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5844 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5845 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 5846 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5847 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5848 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 5849 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 5850 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5851 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 5852 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 5853 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5854 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5855 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5856 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5857 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5858 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 5859 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 5860 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5861 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5862 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 5863 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 5864 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 5865 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 5866 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 5867 case INSTALL_FAILED_BAD_DEX_METADATA: return PackageInstaller.STATUS_FAILURE_INVALID; 5868 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5869 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5870 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5871 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5872 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5873 default: return PackageInstaller.STATUS_FAILURE; 5874 } 5875 } 5876 5877 /** {@hide} */ 5878 public static String deleteStatusToString(int status, String msg) { 5879 final String str = deleteStatusToString(status); 5880 if (msg != null) { 5881 return str + ": " + msg; 5882 } else { 5883 return str; 5884 } 5885 } 5886 5887 /** {@hide} */ 5888 public static String deleteStatusToString(int status) { 5889 switch (status) { 5890 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 5891 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 5892 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 5893 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 5894 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 5895 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 5896 case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY"; 5897 default: return Integer.toString(status); 5898 } 5899 } 5900 5901 /** {@hide} */ 5902 public static int deleteStatusToPublicStatus(int status) { 5903 switch (status) { 5904 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5905 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5906 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5907 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5908 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5909 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5910 case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5911 default: return PackageInstaller.STATUS_FAILURE; 5912 } 5913 } 5914 5915 /** {@hide} */ 5916 public static String permissionFlagToString(int flag) { 5917 switch (flag) { 5918 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 5919 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 5920 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 5921 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 5922 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE"; 5923 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 5924 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 5925 default: return Integer.toString(flag); 5926 } 5927 } 5928 5929 /** {@hide} */ 5930 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 5931 private final IPackageDeleteObserver mLegacy; 5932 5933 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 5934 mLegacy = legacy; 5935 } 5936 5937 @Override 5938 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 5939 if (mLegacy == null) return; 5940 try { 5941 mLegacy.packageDeleted(basePackageName, returnCode); 5942 } catch (RemoteException ignored) { 5943 } 5944 } 5945 } 5946 5947 /** 5948 * Return the install reason that was recorded when a package was first 5949 * installed for a specific user. Requesting the install reason for another 5950 * user will require the permission INTERACT_ACROSS_USERS_FULL. 5951 * 5952 * @param packageName The package for which to retrieve the install reason 5953 * @param user The user for whom to retrieve the install reason 5954 * @return The install reason. If the package is not installed for the given 5955 * user, {@code INSTALL_REASON_UNKNOWN} is returned. 5956 * @hide 5957 */ 5958 @TestApi 5959 public abstract @InstallReason int getInstallReason(String packageName, 5960 @NonNull UserHandle user); 5961 5962 /** 5963 * Checks whether the calling package is allowed to request package installs through package 5964 * installer. Apps are encouraged to call this API before launching the package installer via 5965 * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the 5966 * user can explicitly choose what external sources they trust to install apps on the device. 5967 * If this API returns false, the install request will be blocked by the package installer and 5968 * a dialog will be shown to the user with an option to launch settings to change their 5969 * preference. An application must target Android O or higher and declare permission 5970 * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API. 5971 * 5972 * @return true if the calling package is trusted by the user to request install packages on 5973 * the device, false otherwise. 5974 * @see android.content.Intent#ACTION_INSTALL_PACKAGE 5975 * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES 5976 */ 5977 public abstract boolean canRequestPackageInstalls(); 5978 5979 /** 5980 * Return the {@link ComponentName} of the activity providing Settings for the Instant App 5981 * resolver. 5982 * 5983 * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS} 5984 * @hide 5985 */ 5986 @SystemApi 5987 public abstract ComponentName getInstantAppResolverSettingsComponent(); 5988 5989 /** 5990 * Return the {@link ComponentName} of the activity responsible for installing instant 5991 * applications. 5992 * 5993 * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE} 5994 * @hide 5995 */ 5996 @SystemApi 5997 public abstract ComponentName getInstantAppInstallerComponent(); 5998 5999 /** 6000 * Return the Android Id for a given Instant App. 6001 * 6002 * @see {@link android.provider.Settings.Secure#ANDROID_ID} 6003 * @hide 6004 */ 6005 public abstract String getInstantAppAndroidId(String packageName, @NonNull UserHandle user); 6006 6007 /** 6008 * Callback use to notify the callers of module registration that the operation 6009 * has finished. 6010 * 6011 * @hide 6012 */ 6013 @SystemApi 6014 public static abstract class DexModuleRegisterCallback { 6015 public abstract void onDexModuleRegistered(String dexModulePath, boolean success, 6016 String message); 6017 } 6018 6019 /** 6020 * Register an application dex module with the package manager. 6021 * The package manager will keep track of the given module for future optimizations. 6022 * 6023 * Dex module optimizations will disable the classpath checking at runtime. The client bares 6024 * the responsibility to ensure that the static assumptions on classes in the optimized code 6025 * hold at runtime (e.g. there's no duplicate classes in the classpath). 6026 * 6027 * Note that the package manager already keeps track of dex modules loaded with 6028 * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}. 6029 * This can be called for an eager registration. 6030 * 6031 * The call might take a while and the results will be posted on the main thread, using 6032 * the given callback. 6033 * 6034 * If the module is intended to be shared with other apps, make sure that the file 6035 * permissions allow for it. 6036 * If at registration time the permissions allow for others to read it, the module would 6037 * be marked as a shared module which might undergo a different optimization strategy. 6038 * (usually shared modules will generated larger optimizations artifacts, 6039 * taking more disk space). 6040 * 6041 * @param dexModulePath the absolute path of the dex module. 6042 * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will 6043 * be called once the registration finishes. 6044 * 6045 * @hide 6046 */ 6047 @SystemApi 6048 public abstract void registerDexModule(String dexModulePath, 6049 @Nullable DexModuleRegisterCallback callback); 6050 6051 /** 6052 * Returns the {@link ArtManager} associated with this package manager. 6053 * 6054 * @hide 6055 */ 6056 @SystemApi 6057 public @NonNull ArtManager getArtManager() { 6058 throw new UnsupportedOperationException("getArtManager not implemented in subclass"); 6059 } 6060 6061 /** 6062 * Sets or clears the harmful app warning details for the given app. 6063 * 6064 * When set, any attempt to launch an activity in this package will be intercepted and a 6065 * warning dialog will be shown to the user instead, with the given warning. The user 6066 * will have the option to proceed with the activity launch, or to uninstall the application. 6067 * 6068 * @param packageName The full name of the package to warn on. 6069 * @param warning A warning string to display to the user describing the threat posed by the 6070 * application, or null to clear the warning. 6071 * 6072 * @hide 6073 */ 6074 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS) 6075 @SystemApi 6076 public void setHarmfulAppWarning(@NonNull String packageName, @Nullable CharSequence warning) { 6077 throw new UnsupportedOperationException("setHarmfulAppWarning not implemented in subclass"); 6078 } 6079 6080 /** 6081 * Returns the harmful app warning string for the given app, or null if there is none set. 6082 * 6083 * @param packageName The full name of the desired package. 6084 * 6085 * @hide 6086 */ 6087 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS) 6088 @Nullable 6089 @SystemApi 6090 public CharSequence getHarmfulAppWarning(@NonNull String packageName) { 6091 throw new UnsupportedOperationException("getHarmfulAppWarning not implemented in subclass"); 6092 } 6093 6094 /** @hide */ 6095 @IntDef(prefix = { "CERT_INPUT_" }, value = { 6096 CERT_INPUT_RAW_X509, 6097 CERT_INPUT_SHA256 6098 }) 6099 @Retention(RetentionPolicy.SOURCE) 6100 public @interface CertificateInputType {} 6101 6102 /** 6103 * Certificate input bytes: the input bytes represent an encoded X.509 Certificate which could 6104 * be generated using an {@code CertificateFactory} 6105 */ 6106 public static final int CERT_INPUT_RAW_X509 = 0; 6107 6108 /** 6109 * Certificate input bytes: the input bytes represent the SHA256 output of an encoded X.509 6110 * Certificate. 6111 */ 6112 public static final int CERT_INPUT_SHA256 = 1; 6113 6114 /** 6115 * Searches the set of signing certificates by which the given package has proven to have been 6116 * signed. This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES} 6117 * since it takes into account the possibility of signing certificate rotation, except in the 6118 * case of packages that are signed by multiple certificates, for which signing certificate 6119 * rotation is not supported. This method is analogous to using {@code getPackageInfo} with 6120 * {@code GET_SIGNING_CERTIFICATES} and then searching through the resulting {@code 6121 * signingInfo} field to see if the desired certificate is present. 6122 * 6123 * @param packageName package whose signing certificates to check 6124 * @param certificate signing certificate for which to search 6125 * @param type representation of the {@code certificate} 6126 * @return true if this package was or is signed by exactly the certificate {@code certificate} 6127 */ 6128 public boolean hasSigningCertificate( 6129 String packageName, byte[] certificate, @CertificateInputType int type) { 6130 throw new UnsupportedOperationException( 6131 "hasSigningCertificate not implemented in subclass"); 6132 } 6133 6134 /** 6135 * Searches the set of signing certificates by which the package(s) for the given uid has proven 6136 * to have been signed. For multiple packages sharing the same uid, this will return the 6137 * signing certificates found in the signing history of the "newest" package, where "newest" 6138 * indicates the package with the newest signing certificate in the shared uid group. This 6139 * method should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES} 6140 * since it takes into account the possibility of signing certificate rotation, except in the 6141 * case of packages that are signed by multiple certificates, for which signing certificate 6142 * rotation is not supported. This method is analogous to using {@code getPackagesForUid} 6143 * followed by {@code getPackageInfo} with {@code GET_SIGNING_CERTIFICATES}, selecting the 6144 * {@code PackageInfo} of the newest-signed bpackage , and finally searching through the 6145 * resulting {@code signingInfo} field to see if the desired certificate is there. 6146 * 6147 * @param uid uid whose signing certificates to check 6148 * @param certificate signing certificate for which to search 6149 * @param type representation of the {@code certificate} 6150 * @return true if this package was or is signed by exactly the certificate {@code certificate} 6151 */ 6152 public boolean hasSigningCertificate( 6153 int uid, byte[] certificate, @CertificateInputType int type) { 6154 throw new UnsupportedOperationException( 6155 "hasSigningCertificate not implemented in subclass"); 6156 } 6157 6158 /** 6159 * @return the system defined text classifier package name, or null if there's none. 6160 * 6161 * @hide 6162 */ 6163 public String getSystemTextClassifierPackageName() { 6164 throw new UnsupportedOperationException( 6165 "getSystemTextClassifierPackageName not implemented in subclass"); 6166 } 6167 6168 /** 6169 * @return whether a given package's state is protected, e.g. package cannot be disabled, 6170 * suspended, hidden or force stopped. 6171 * 6172 * @hide 6173 */ 6174 public boolean isPackageStateProtected(String packageName, int userId) { 6175 throw new UnsupportedOperationException( 6176 "isPackageStateProtected not implemented in subclass"); 6177 } 6178 6179} 6180