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