PackageManager.java revision f80809ffd7b6ea8eb120ce5ccb343582c2757ea0
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 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2633 * The device has a Keymaster implementation that supports Device ID attestation. 2634 * 2635 * @see DevicePolicyManager#isDeviceIdAttestationSupported 2636 * @hide 2637 */ 2638 @SdkConstant(SdkConstantType.FEATURE) 2639 public static final String FEATURE_DEVICE_ID_ATTESTATION = 2640 "android.software.device_id_attestation"; 2641 2642 /** 2643 * Action to external storage service to clean out removed apps. 2644 * @hide 2645 */ 2646 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 2647 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 2648 2649 /** 2650 * Extra field name for the URI to a verification file. Passed to a package 2651 * verifier. 2652 * 2653 * @hide 2654 */ 2655 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 2656 2657 /** 2658 * Extra field name for the ID of a package pending verification. Passed to 2659 * a package verifier and is used to call back to 2660 * {@link PackageManager#verifyPendingInstall(int, int)} 2661 */ 2662 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 2663 2664 /** 2665 * Extra field name for the package identifier which is trying to install 2666 * the package. 2667 * 2668 * @hide 2669 */ 2670 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 2671 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 2672 2673 /** 2674 * Extra field name for the requested install flags for a package pending 2675 * verification. Passed to a package verifier. 2676 * 2677 * @hide 2678 */ 2679 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 2680 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 2681 2682 /** 2683 * Extra field name for the uid of who is requesting to install 2684 * the package. 2685 * 2686 * @hide 2687 */ 2688 public static final String EXTRA_VERIFICATION_INSTALLER_UID 2689 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 2690 2691 /** 2692 * Extra field name for the package name of a package pending verification. 2693 * 2694 * @hide 2695 */ 2696 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 2697 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 2698 /** 2699 * Extra field name for the result of a verification, either 2700 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 2701 * Passed to package verifiers after a package is verified. 2702 */ 2703 public static final String EXTRA_VERIFICATION_RESULT 2704 = "android.content.pm.extra.VERIFICATION_RESULT"; 2705 2706 /** 2707 * Extra field name for the version code of a package pending verification. 2708 * @deprecated Use {@link #EXTRA_VERIFICATION_LONG_VERSION_CODE} instead. 2709 * @hide 2710 */ 2711 @Deprecated 2712 public static final String EXTRA_VERIFICATION_VERSION_CODE 2713 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 2714 2715 /** 2716 * Extra field name for the long version code of a package pending verification. 2717 * 2718 * @hide 2719 */ 2720 public static final String EXTRA_VERIFICATION_LONG_VERSION_CODE = 2721 "android.content.pm.extra.VERIFICATION_LONG_VERSION_CODE"; 2722 2723 /** 2724 * Extra field name for the ID of a intent filter pending verification. 2725 * Passed to an intent filter verifier and is used to call back to 2726 * {@link #verifyIntentFilter} 2727 * 2728 * @hide 2729 */ 2730 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 2731 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 2732 2733 /** 2734 * Extra field name for the scheme used for an intent filter pending verification. Passed to 2735 * an intent filter verifier and is used to construct the URI to verify against. 2736 * 2737 * Usually this is "https" 2738 * 2739 * @hide 2740 */ 2741 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 2742 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 2743 2744 /** 2745 * Extra field name for the host names to be used for an intent filter pending verification. 2746 * Passed to an intent filter verifier and is used to construct the URI to verify the 2747 * intent filter. 2748 * 2749 * This is a space delimited list of hosts. 2750 * 2751 * @hide 2752 */ 2753 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 2754 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 2755 2756 /** 2757 * Extra field name for the package name to be used for an intent filter pending verification. 2758 * Passed to an intent filter verifier and is used to check the verification responses coming 2759 * from the hosts. Each host response will need to include the package name of APK containing 2760 * the intent filter. 2761 * 2762 * @hide 2763 */ 2764 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 2765 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 2766 2767 /** 2768 * The action used to request that the user approve a permission request 2769 * from the application. 2770 * 2771 * @hide 2772 */ 2773 @SystemApi 2774 public static final String ACTION_REQUEST_PERMISSIONS = 2775 "android.content.pm.action.REQUEST_PERMISSIONS"; 2776 2777 /** 2778 * The names of the requested permissions. 2779 * <p> 2780 * <strong>Type:</strong> String[] 2781 * </p> 2782 * 2783 * @hide 2784 */ 2785 @SystemApi 2786 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 2787 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 2788 2789 /** 2790 * The results from the permissions request. 2791 * <p> 2792 * <strong>Type:</strong> int[] of #PermissionResult 2793 * </p> 2794 * 2795 * @hide 2796 */ 2797 @SystemApi 2798 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 2799 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 2800 2801 /** 2802 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2803 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 2804 * the existing definition for the permission. 2805 * @hide 2806 */ 2807 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 2808 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 2809 2810 /** 2811 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2812 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 2813 * being redundantly defined by the package being installed. 2814 * @hide 2815 */ 2816 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 2817 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 2818 2819 /** 2820 * Permission flag: The permission is set in its current state 2821 * by the user and apps can still request it at runtime. 2822 * 2823 * @hide 2824 */ 2825 @SystemApi 2826 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 2827 2828 /** 2829 * Permission flag: The permission is set in its current state 2830 * by the user and it is fixed, i.e. apps can no longer request 2831 * this permission. 2832 * 2833 * @hide 2834 */ 2835 @SystemApi 2836 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 2837 2838 /** 2839 * Permission flag: The permission is set in its current state 2840 * by device policy and neither apps nor the user can change 2841 * its state. 2842 * 2843 * @hide 2844 */ 2845 @SystemApi 2846 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 2847 2848 /** 2849 * Permission flag: The permission is set in a granted state but 2850 * access to resources it guards is restricted by other means to 2851 * enable revoking a permission on legacy apps that do not support 2852 * runtime permissions. If this permission is upgraded to runtime 2853 * because the app was updated to support runtime permissions, the 2854 * the permission will be revoked in the upgrade process. 2855 * 2856 * @hide 2857 */ 2858 @SystemApi 2859 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 2860 2861 /** 2862 * Permission flag: The permission is set in its current state 2863 * because the app is a component that is a part of the system. 2864 * 2865 * @hide 2866 */ 2867 @SystemApi 2868 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 2869 2870 /** 2871 * Permission flag: The permission is granted by default because it 2872 * enables app functionality that is expected to work out-of-the-box 2873 * for providing a smooth user experience. For example, the phone app 2874 * is expected to have the phone permission. 2875 * 2876 * @hide 2877 */ 2878 @SystemApi 2879 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 2880 2881 /** 2882 * Permission flag: The permission has to be reviewed before any of 2883 * the app components can run. 2884 * 2885 * @hide 2886 */ 2887 @SystemApi 2888 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 2889 2890 /** 2891 * Mask for all permission flags. 2892 * 2893 * @hide 2894 */ 2895 @SystemApi 2896 public static final int MASK_PERMISSION_FLAGS = 0xFF; 2897 2898 /** 2899 * This is a library that contains components apps can invoke. For 2900 * example, a services for apps to bind to, or standard chooser UI, 2901 * etc. This library is versioned and backwards compatible. Clients 2902 * should check its version via {@link android.ext.services.Version 2903 * #getVersionCode()} and avoid calling APIs added in later versions. 2904 * 2905 * @hide 2906 */ 2907 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services"; 2908 2909 /** 2910 * This is a library that contains components apps can dynamically 2911 * load. For example, new widgets, helper classes, etc. This library 2912 * is versioned and backwards compatible. Clients should check its 2913 * version via {@link android.ext.shared.Version#getVersionCode()} 2914 * and avoid calling APIs added in later versions. 2915 * 2916 * @hide 2917 */ 2918 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared"; 2919 2920 /** 2921 * Used when starting a process for an Activity. 2922 * 2923 * @hide 2924 */ 2925 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0; 2926 2927 /** 2928 * Used when starting a process for a Service. 2929 * 2930 * @hide 2931 */ 2932 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1; 2933 2934 /** 2935 * Used when moving a Service to the foreground. 2936 * 2937 * @hide 2938 */ 2939 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2; 2940 2941 /** 2942 * Used when starting a process for a BroadcastReceiver. 2943 * 2944 * @hide 2945 */ 2946 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3; 2947 2948 /** 2949 * Used when starting a process for a ContentProvider. 2950 * 2951 * @hide 2952 */ 2953 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4; 2954 2955 /** 2956 * Used when starting a process for a BroadcastReceiver. 2957 * 2958 * @hide 2959 */ 2960 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5; 2961 2962 /** 2963 * Used with Context.getClassLoader() across Android packages. 2964 * 2965 * @hide 2966 */ 2967 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6; 2968 2969 /** 2970 * Used when starting a package within a process for Instrumentation. 2971 * 2972 * @hide 2973 */ 2974 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7; 2975 2976 /** 2977 * Total number of usage reasons. 2978 * 2979 * @hide 2980 */ 2981 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8; 2982 2983 /** 2984 * Constant for specifying the highest installed package version code. 2985 */ 2986 public static final int VERSION_CODE_HIGHEST = -1; 2987 2988 /** {@hide} */ 2989 public int getUserId() { 2990 return UserHandle.myUserId(); 2991 } 2992 2993 /** 2994 * Retrieve overall information about an application package that is 2995 * installed on the system. 2996 * 2997 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2998 * desired package. 2999 * @param flags Additional option flags to modify the data returned. 3000 * @return A PackageInfo object containing information about the package. If 3001 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 3002 * is not found in the list of installed applications, the package 3003 * information is retrieved from the list of uninstalled 3004 * applications (which includes installed applications as well as 3005 * applications with data directory i.e. applications which had been 3006 * deleted with {@code DONT_DELETE_DATA} flag set). 3007 * @throws NameNotFoundException if a package with the given name cannot be 3008 * found on the system. 3009 */ 3010 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) 3011 throws NameNotFoundException; 3012 3013 /** 3014 * Retrieve overall information about an application package that is 3015 * installed on the system. This method can be used for retrieving 3016 * information about packages for which multiple versions can be installed 3017 * at the time. Currently only packages hosting static shared libraries can 3018 * have multiple installed versions. The method can also be used to get info 3019 * for a package that has a single version installed by passing 3020 * {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage} 3021 * constructor. 3022 * 3023 * @param versionedPackage The versioned package for which to query. 3024 * @param flags Additional option flags to modify the data returned. 3025 * @return A PackageInfo object containing information about the package. If 3026 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 3027 * is not found in the list of installed applications, the package 3028 * information is retrieved from the list of uninstalled 3029 * applications (which includes installed applications as well as 3030 * applications with data directory i.e. applications which had been 3031 * deleted with {@code DONT_DELETE_DATA} flag set). 3032 * @throws NameNotFoundException if a package with the given name cannot be 3033 * found on the system. 3034 */ 3035 public abstract PackageInfo getPackageInfo(VersionedPackage versionedPackage, 3036 @PackageInfoFlags int flags) throws NameNotFoundException; 3037 3038 /** 3039 * Retrieve overall information about an application package that is 3040 * installed on the system. 3041 * 3042 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3043 * desired package. 3044 * @param flags Additional option flags to modify the data returned. 3045 * @param userId The user id. 3046 * @return A PackageInfo object containing information about the package. If 3047 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the package 3048 * is not found in the list of installed applications, the package 3049 * information is retrieved from the list of uninstalled 3050 * applications (which includes installed applications as well as 3051 * applications with data directory i.e. applications which had been 3052 * deleted with {@code DONT_DELETE_DATA} flag set). 3053 * @throws NameNotFoundException if a package with the given name cannot be 3054 * found on the system. 3055 * @hide 3056 */ 3057 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 3058 public abstract PackageInfo getPackageInfoAsUser(String packageName, 3059 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 3060 3061 /** 3062 * Map from the current package names in use on the device to whatever 3063 * the current canonical name of that package is. 3064 * @param names Array of current names to be mapped. 3065 * @return Returns an array of the same size as the original, containing 3066 * the canonical name for each package. 3067 */ 3068 public abstract String[] currentToCanonicalPackageNames(String[] names); 3069 3070 /** 3071 * Map from a packages canonical name to the current name in use on the device. 3072 * @param names Array of new names to be mapped. 3073 * @return Returns an array of the same size as the original, containing 3074 * the current name for each package. 3075 */ 3076 public abstract String[] canonicalToCurrentPackageNames(String[] names); 3077 3078 /** 3079 * Returns a "good" intent to launch a front-door activity in a package. 3080 * This is used, for example, to implement an "open" button when browsing 3081 * through packages. The current implementation looks first for a main 3082 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 3083 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 3084 * <code>null</code> if neither are found. 3085 * 3086 * @param packageName The name of the package to inspect. 3087 * 3088 * @return A fully-qualified {@link Intent} that can be used to launch the 3089 * main activity in the package. Returns <code>null</code> if the package 3090 * does not contain such an activity, or if <em>packageName</em> is not 3091 * recognized. 3092 */ 3093 public abstract @Nullable Intent getLaunchIntentForPackage(@NonNull String packageName); 3094 3095 /** 3096 * Return a "good" intent to launch a front-door Leanback activity in a 3097 * package, for use for example to implement an "open" button when browsing 3098 * through packages. The current implementation will look for a main 3099 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 3100 * return null if no main leanback activities are found. 3101 * 3102 * @param packageName The name of the package to inspect. 3103 * @return Returns either a fully-qualified Intent that can be used to launch 3104 * the main Leanback activity in the package, or null if the package 3105 * does not contain such an activity. 3106 */ 3107 public abstract @Nullable Intent getLeanbackLaunchIntentForPackage(@NonNull String packageName); 3108 3109 /** 3110 * Return a "good" intent to launch a front-door Car activity in a 3111 * package, for use for example to implement an "open" button when browsing 3112 * through packages. The current implementation will look for a main 3113 * activity in the category {@link Intent#CATEGORY_CAR_LAUNCHER}, or 3114 * return null if no main car activities are found. 3115 * 3116 * @param packageName The name of the package to inspect. 3117 * @return Returns either a fully-qualified Intent that can be used to launch 3118 * the main Car activity in the package, or null if the package 3119 * does not contain such an activity. 3120 * @hide 3121 */ 3122 public abstract @Nullable Intent getCarLaunchIntentForPackage(@NonNull String packageName); 3123 3124 /** 3125 * Return an array of all of the POSIX secondary group IDs that have been 3126 * assigned to the given package. 3127 * <p> 3128 * Note that the same package may have different GIDs under different 3129 * {@link UserHandle} on the same device. 3130 * 3131 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3132 * desired package. 3133 * @return Returns an int array of the assigned GIDs, or null if there are 3134 * none. 3135 * @throws NameNotFoundException if a package with the given name cannot be 3136 * found on the system. 3137 */ 3138 public abstract int[] getPackageGids(@NonNull String packageName) 3139 throws NameNotFoundException; 3140 3141 /** 3142 * Return an array of all of the POSIX secondary group IDs that have been 3143 * assigned to the given package. 3144 * <p> 3145 * Note that the same package may have different GIDs under different 3146 * {@link UserHandle} on the same device. 3147 * 3148 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3149 * desired package. 3150 * @return Returns an int array of the assigned gids, or null if there are 3151 * none. 3152 * @throws NameNotFoundException if a package with the given name cannot be 3153 * found on the system. 3154 */ 3155 public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags) 3156 throws NameNotFoundException; 3157 3158 /** 3159 * Return the UID associated with the given package name. 3160 * <p> 3161 * Note that the same package will have different UIDs under different 3162 * {@link UserHandle} on the same device. 3163 * 3164 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3165 * desired package. 3166 * @return Returns an integer UID who owns the given package name. 3167 * @throws NameNotFoundException if a package with the given name can not be 3168 * found on the system. 3169 */ 3170 public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags) 3171 throws NameNotFoundException; 3172 3173 /** 3174 * Return the UID associated with the given package name. 3175 * <p> 3176 * Note that the same package will have different UIDs under different 3177 * {@link UserHandle} on the same device. 3178 * 3179 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3180 * desired package. 3181 * @param userId The user handle identifier to look up the package under. 3182 * @return Returns an integer UID who owns the given package name. 3183 * @throws NameNotFoundException if a package with the given name can not be 3184 * found on the system. 3185 * @hide 3186 */ 3187 public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId) 3188 throws NameNotFoundException; 3189 3190 /** 3191 * Return the UID associated with the given package name. 3192 * <p> 3193 * Note that the same package will have different UIDs under different 3194 * {@link UserHandle} on the same device. 3195 * 3196 * @param packageName The full name (i.e. com.google.apps.contacts) of the 3197 * desired package. 3198 * @param userId The user handle identifier to look up the package under. 3199 * @return Returns an integer UID who owns the given package name. 3200 * @throws NameNotFoundException if a package with the given name can not be 3201 * found on the system. 3202 * @hide 3203 */ 3204 public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags, 3205 @UserIdInt int userId) throws NameNotFoundException; 3206 3207 /** 3208 * Retrieve all of the information we know about a particular permission. 3209 * 3210 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 3211 * of the permission you are interested in. 3212 * @param flags Additional option flags to modify the data returned. 3213 * @return Returns a {@link PermissionInfo} containing information about the 3214 * permission. 3215 * @throws NameNotFoundException if a package with the given name cannot be 3216 * found on the system. 3217 */ 3218 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags) 3219 throws NameNotFoundException; 3220 3221 /** 3222 * Query for all of the permissions associated with a particular group. 3223 * 3224 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 3225 * of the permission group you are interested in. Use null to 3226 * find all of the permissions not associated with a group. 3227 * @param flags Additional option flags to modify the data returned. 3228 * @return Returns a list of {@link PermissionInfo} containing information 3229 * about all of the permissions in the given group. 3230 * @throws NameNotFoundException if a package with the given name cannot be 3231 * found on the system. 3232 */ 3233 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 3234 @PermissionInfoFlags int flags) throws NameNotFoundException; 3235 3236 /** 3237 * Returns true if Permission Review Mode is enabled, false otherwise. 3238 * 3239 * @hide 3240 */ 3241 @TestApi 3242 public abstract boolean isPermissionReviewModeEnabled(); 3243 3244 /** 3245 * Retrieve all of the information we know about a particular group of 3246 * permissions. 3247 * 3248 * @param name The fully qualified name (i.e. 3249 * com.google.permission_group.APPS) of the permission you are 3250 * interested in. 3251 * @param flags Additional option flags to modify the data returned. 3252 * @return Returns a {@link PermissionGroupInfo} containing information 3253 * about the permission. 3254 * @throws NameNotFoundException if a package with the given name cannot be 3255 * found on the system. 3256 */ 3257 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 3258 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 3259 3260 /** 3261 * Retrieve all of the known permission groups in the system. 3262 * 3263 * @param flags Additional option flags to modify the data returned. 3264 * @return Returns a list of {@link PermissionGroupInfo} containing 3265 * information about all of the known permission groups. 3266 */ 3267 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 3268 @PermissionGroupInfoFlags int flags); 3269 3270 /** 3271 * Retrieve all of the information we know about a particular 3272 * package/application. 3273 * 3274 * @param packageName The full name (i.e. com.google.apps.contacts) of an 3275 * application. 3276 * @param flags Additional option flags to modify the data returned. 3277 * @return An {@link ApplicationInfo} containing information about the 3278 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if 3279 * the package is not found in the list of installed applications, 3280 * the application information is retrieved from the list of 3281 * uninstalled applications (which includes installed applications 3282 * as well as applications with data directory i.e. applications 3283 * which had been deleted with {@code DONT_DELETE_DATA} flag set). 3284 * @throws NameNotFoundException if a package with the given name cannot be 3285 * found on the system. 3286 */ 3287 public abstract ApplicationInfo getApplicationInfo(String packageName, 3288 @ApplicationInfoFlags int flags) throws NameNotFoundException; 3289 3290 /** {@hide} */ 3291 public abstract ApplicationInfo getApplicationInfoAsUser(String packageName, 3292 @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 3293 3294 /** 3295 * Retrieve all of the information we know about a particular activity 3296 * class. 3297 * 3298 * @param component The full component name (i.e. 3299 * com.google.apps.contacts/com.google.apps.contacts. 3300 * ContactsList) of an Activity class. 3301 * @param flags Additional option flags to modify the data returned. 3302 * @return An {@link ActivityInfo} containing information about the 3303 * activity. 3304 * @throws NameNotFoundException if a package with the given name cannot be 3305 * found on the system. 3306 */ 3307 public abstract ActivityInfo getActivityInfo(ComponentName component, 3308 @ComponentInfoFlags int flags) throws NameNotFoundException; 3309 3310 /** 3311 * Retrieve all of the information we know about a particular receiver 3312 * class. 3313 * 3314 * @param component The full component name (i.e. 3315 * com.google.apps.calendar/com.google.apps.calendar. 3316 * CalendarAlarm) of a Receiver class. 3317 * @param flags Additional option flags to modify the data returned. 3318 * @return An {@link ActivityInfo} containing information about the 3319 * receiver. 3320 * @throws NameNotFoundException if a package with the given name cannot be 3321 * found on the system. 3322 */ 3323 public abstract ActivityInfo getReceiverInfo(ComponentName component, 3324 @ComponentInfoFlags int flags) throws NameNotFoundException; 3325 3326 /** 3327 * Retrieve all of the information we know about a particular service class. 3328 * 3329 * @param component The full component name (i.e. 3330 * com.google.apps.media/com.google.apps.media. 3331 * BackgroundPlayback) of a Service class. 3332 * @param flags Additional option flags to modify the data returned. 3333 * @return A {@link ServiceInfo} object containing information about the 3334 * service. 3335 * @throws NameNotFoundException if a package with the given name cannot be 3336 * found on the system. 3337 */ 3338 public abstract ServiceInfo getServiceInfo(ComponentName component, 3339 @ComponentInfoFlags int flags) throws NameNotFoundException; 3340 3341 /** 3342 * Retrieve all of the information we know about a particular content 3343 * provider class. 3344 * 3345 * @param component The full component name (i.e. 3346 * com.google.providers.media/com.google.providers.media. 3347 * MediaProvider) of a ContentProvider class. 3348 * @param flags Additional option flags to modify the data returned. 3349 * @return A {@link ProviderInfo} object containing information about the 3350 * provider. 3351 * @throws NameNotFoundException if a package with the given name cannot be 3352 * found on the system. 3353 */ 3354 public abstract ProviderInfo getProviderInfo(ComponentName component, 3355 @ComponentInfoFlags int flags) throws NameNotFoundException; 3356 3357 /** 3358 * Return a List of all packages that are installed on the device. 3359 * 3360 * @param flags Additional option flags to modify the data returned. 3361 * @return A List of PackageInfo objects, one for each installed package, 3362 * containing information about the package. In the unlikely case 3363 * there are no installed packages, an empty list is returned. If 3364 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3365 * information is retrieved from the list of uninstalled 3366 * applications (which includes installed applications as well as 3367 * applications with data directory i.e. applications which had been 3368 * deleted with {@code DONT_DELETE_DATA} flag set). 3369 */ 3370 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags); 3371 3372 /** 3373 * Return a List of all installed packages that are currently holding any of 3374 * the given permissions. 3375 * 3376 * @param flags Additional option flags to modify the data returned. 3377 * @return A List of PackageInfo objects, one for each installed package 3378 * that holds any of the permissions that were provided, containing 3379 * information about the package. If no installed packages hold any 3380 * of the permissions, an empty list is returned. If flag 3381 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3382 * information is retrieved from the list of uninstalled 3383 * applications (which includes installed applications as well as 3384 * applications with data directory i.e. applications which had been 3385 * deleted with {@code DONT_DELETE_DATA} flag set). 3386 */ 3387 public abstract List<PackageInfo> getPackagesHoldingPermissions( 3388 String[] permissions, @PackageInfoFlags int flags); 3389 3390 /** 3391 * Return a List of all packages that are installed on the device, for a 3392 * specific user. 3393 * 3394 * @param flags Additional option flags to modify the data returned. 3395 * @param userId The user for whom the installed packages are to be listed 3396 * @return A List of PackageInfo objects, one for each installed package, 3397 * containing information about the package. In the unlikely case 3398 * there are no installed packages, an empty list is returned. If 3399 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3400 * information is retrieved from the list of uninstalled 3401 * applications (which includes installed applications as well as 3402 * applications with data directory i.e. applications which had been 3403 * deleted with {@code DONT_DELETE_DATA} flag set). 3404 * @hide 3405 */ 3406 @SystemApi 3407 @RequiresPermission(android.Manifest.permission.INTERACT_ACROSS_USERS_FULL) 3408 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags, 3409 @UserIdInt int userId); 3410 3411 /** 3412 * Check whether a particular package has been granted a particular 3413 * permission. 3414 * 3415 * @param permName The name of the permission you are checking for. 3416 * @param pkgName The name of the package you are checking against. 3417 * 3418 * @return If the package has the permission, PERMISSION_GRANTED is 3419 * returned. If it does not have the permission, PERMISSION_DENIED 3420 * is returned. 3421 * 3422 * @see #PERMISSION_GRANTED 3423 * @see #PERMISSION_DENIED 3424 */ 3425 @CheckResult 3426 public abstract @PermissionResult int checkPermission(String permName, String pkgName); 3427 3428 /** 3429 * Checks whether a particular permissions has been revoked for a 3430 * package by policy. Typically the device owner or the profile owner 3431 * may apply such a policy. The user cannot grant policy revoked 3432 * permissions, hence the only way for an app to get such a permission 3433 * is by a policy change. 3434 * 3435 * @param permName The name of the permission you are checking for. 3436 * @param pkgName The name of the package you are checking against. 3437 * 3438 * @return Whether the permission is restricted by policy. 3439 */ 3440 @CheckResult 3441 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 3442 @NonNull String pkgName); 3443 3444 /** 3445 * Gets the package name of the component controlling runtime permissions. 3446 * 3447 * @return The package name. 3448 * 3449 * @hide 3450 */ 3451 @TestApi 3452 public abstract String getPermissionControllerPackageName(); 3453 3454 /** 3455 * Add a new dynamic permission to the system. For this to work, your 3456 * package must have defined a permission tree through the 3457 * {@link android.R.styleable#AndroidManifestPermissionTree 3458 * <permission-tree>} tag in its manifest. A package can only add 3459 * permissions to trees that were defined by either its own package or 3460 * another with the same user id; a permission is in a tree if it 3461 * matches the name of the permission tree + ".": for example, 3462 * "com.foo.bar" is a member of the permission tree "com.foo". 3463 * 3464 * <p>It is good to make your permission tree name descriptive, because you 3465 * are taking possession of that entire set of permission names. Thus, it 3466 * must be under a domain you control, with a suffix that will not match 3467 * any normal permissions that may be declared in any applications that 3468 * are part of that domain. 3469 * 3470 * <p>New permissions must be added before 3471 * any .apks are installed that use those permissions. Permissions you 3472 * add through this method are remembered across reboots of the device. 3473 * If the given permission already exists, the info you supply here 3474 * will be used to update it. 3475 * 3476 * @param info Description of the permission to be added. 3477 * 3478 * @return Returns true if a new permission was created, false if an 3479 * existing one was updated. 3480 * 3481 * @throws SecurityException if you are not allowed to add the 3482 * given permission name. 3483 * 3484 * @see #removePermission(String) 3485 */ 3486 public abstract boolean addPermission(PermissionInfo info); 3487 3488 /** 3489 * Like {@link #addPermission(PermissionInfo)} but asynchronously 3490 * persists the package manager state after returning from the call, 3491 * allowing it to return quicker and batch a series of adds at the 3492 * expense of no guarantee the added permission will be retained if 3493 * the device is rebooted before it is written. 3494 */ 3495 public abstract boolean addPermissionAsync(PermissionInfo info); 3496 3497 /** 3498 * Removes a permission that was previously added with 3499 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 3500 * -- you are only allowed to remove permissions that you are allowed 3501 * to add. 3502 * 3503 * @param name The name of the permission to remove. 3504 * 3505 * @throws SecurityException if you are not allowed to remove the 3506 * given permission name. 3507 * 3508 * @see #addPermission(PermissionInfo) 3509 */ 3510 public abstract void removePermission(String name); 3511 3512 /** 3513 * Permission flags set when granting or revoking a permission. 3514 * 3515 * @hide 3516 */ 3517 @SystemApi 3518 @IntDef(prefix = { "FLAG_PERMISSION_" }, value = { 3519 FLAG_PERMISSION_USER_SET, 3520 FLAG_PERMISSION_USER_FIXED, 3521 FLAG_PERMISSION_POLICY_FIXED, 3522 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 3523 FLAG_PERMISSION_SYSTEM_FIXED, 3524 FLAG_PERMISSION_GRANTED_BY_DEFAULT 3525 }) 3526 @Retention(RetentionPolicy.SOURCE) 3527 public @interface PermissionFlags {} 3528 3529 /** 3530 * Grant a runtime permission to an application which the application does not 3531 * already have. The permission must have been requested by the application. 3532 * If the application is not allowed to hold the permission, a {@link 3533 * java.lang.SecurityException} is thrown. If the package or permission is 3534 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 3535 * <p> 3536 * <strong>Note: </strong>Using this API requires holding 3537 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is 3538 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3539 * </p> 3540 * 3541 * @param packageName The package to which to grant the permission. 3542 * @param permissionName The permission name to grant. 3543 * @param user The user for which to grant the permission. 3544 * 3545 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 3546 * 3547 * @hide 3548 */ 3549 @SystemApi 3550 @RequiresPermission(android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS) 3551 public abstract void grantRuntimePermission(@NonNull String packageName, 3552 @NonNull String permissionName, @NonNull UserHandle user); 3553 3554 /** 3555 * Revoke a runtime permission that was previously granted by {@link 3556 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 3557 * permission must have been requested by and granted to the application. 3558 * If the application is not allowed to hold the permission, a {@link 3559 * java.lang.SecurityException} is thrown. If the package or permission is 3560 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 3561 * <p> 3562 * <strong>Note: </strong>Using this API requires holding 3563 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 3564 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3565 * </p> 3566 * 3567 * @param packageName The package from which to revoke the permission. 3568 * @param permissionName The permission name to revoke. 3569 * @param user The user for which to revoke the permission. 3570 * 3571 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 3572 * 3573 * @hide 3574 */ 3575 @SystemApi 3576 @RequiresPermission(android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS) 3577 public abstract void revokeRuntimePermission(@NonNull String packageName, 3578 @NonNull String permissionName, @NonNull UserHandle user); 3579 3580 /** 3581 * Gets the state flags associated with a permission. 3582 * 3583 * @param permissionName The permission for which to get the flags. 3584 * @param packageName The package name for which to get the flags. 3585 * @param user The user for which to get permission flags. 3586 * @return The permission flags. 3587 * 3588 * @hide 3589 */ 3590 @SystemApi 3591 @RequiresPermission(anyOf = { 3592 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, 3593 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS 3594 }) 3595 public abstract @PermissionFlags int getPermissionFlags(String permissionName, 3596 String packageName, @NonNull UserHandle user); 3597 3598 /** 3599 * Updates the flags associated with a permission by replacing the flags in 3600 * the specified mask with the provided flag values. 3601 * 3602 * @param permissionName The permission for which to update the flags. 3603 * @param packageName The package name for which to update the flags. 3604 * @param flagMask The flags which to replace. 3605 * @param flagValues The flags with which to replace. 3606 * @param user The user for which to update the permission flags. 3607 * 3608 * @hide 3609 */ 3610 @SystemApi 3611 @RequiresPermission(anyOf = { 3612 android.Manifest.permission.GRANT_RUNTIME_PERMISSIONS, 3613 android.Manifest.permission.REVOKE_RUNTIME_PERMISSIONS 3614 }) 3615 public abstract void updatePermissionFlags(String permissionName, 3616 String packageName, @PermissionFlags int flagMask, @PermissionFlags int flagValues, 3617 @NonNull UserHandle user); 3618 3619 /** 3620 * Gets whether you should show UI with rationale for requesting a permission. 3621 * You should do this only if you do not have the permission and the context in 3622 * which the permission is requested does not clearly communicate to the user 3623 * what would be the benefit from grating this permission. 3624 * 3625 * @param permission A permission your app wants to request. 3626 * @return Whether you can show permission rationale UI. 3627 * 3628 * @hide 3629 */ 3630 public abstract boolean shouldShowRequestPermissionRationale(String permission); 3631 3632 /** 3633 * Returns an {@link android.content.Intent} suitable for passing to 3634 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 3635 * which prompts the user to grant permissions to this application. 3636 * 3637 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 3638 * 3639 * @hide 3640 */ 3641 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 3642 if (ArrayUtils.isEmpty(permissions)) { 3643 throw new IllegalArgumentException("permission cannot be null or empty"); 3644 } 3645 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 3646 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 3647 intent.setPackage(getPermissionControllerPackageName()); 3648 return intent; 3649 } 3650 3651 /** 3652 * Compare the signatures of two packages to determine if the same 3653 * signature appears in both of them. If they do contain the same 3654 * signature, then they are allowed special privileges when working 3655 * with each other: they can share the same user-id, run instrumentation 3656 * against each other, etc. 3657 * 3658 * @param pkg1 First package name whose signature will be compared. 3659 * @param pkg2 Second package name whose signature will be compared. 3660 * 3661 * @return Returns an integer indicating whether all signatures on the 3662 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3663 * all signatures match or < 0 if there is not a match ({@link 3664 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3665 * 3666 * @see #checkSignatures(int, int) 3667 */ 3668 @CheckResult 3669 public abstract @SignatureResult int checkSignatures(String pkg1, String pkg2); 3670 3671 /** 3672 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 3673 * the two packages to be checked. This can be useful, for example, 3674 * when doing the check in an IPC, where the UID is the only identity 3675 * available. It is functionally identical to determining the package 3676 * associated with the UIDs and checking their signatures. 3677 * 3678 * @param uid1 First UID whose signature will be compared. 3679 * @param uid2 Second UID whose signature will be compared. 3680 * 3681 * @return Returns an integer indicating whether all signatures on the 3682 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3683 * all signatures match or < 0 if there is not a match ({@link 3684 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3685 * 3686 * @see #checkSignatures(String, String) 3687 */ 3688 @CheckResult 3689 public abstract @SignatureResult int checkSignatures(int uid1, int uid2); 3690 3691 /** 3692 * Retrieve the names of all packages that are associated with a particular 3693 * user id. In most cases, this will be a single package name, the package 3694 * that has been assigned that user id. Where there are multiple packages 3695 * sharing the same user id through the "sharedUserId" mechanism, all 3696 * packages with that id will be returned. 3697 * 3698 * @param uid The user id for which you would like to retrieve the 3699 * associated packages. 3700 * 3701 * @return Returns an array of one or more packages assigned to the user 3702 * id, or null if there are no known packages with the given id. 3703 */ 3704 public abstract @Nullable String[] getPackagesForUid(int uid); 3705 3706 /** 3707 * Retrieve the official name associated with a uid. This name is 3708 * guaranteed to never change, though it is possible for the underlying 3709 * uid to be changed. That is, if you are storing information about 3710 * uids in persistent storage, you should use the string returned 3711 * by this function instead of the raw uid. 3712 * 3713 * @param uid The uid for which you would like to retrieve a name. 3714 * @return Returns a unique name for the given uid, or null if the 3715 * uid is not currently assigned. 3716 */ 3717 public abstract @Nullable String getNameForUid(int uid); 3718 3719 /** 3720 * Retrieves the official names associated with each given uid. 3721 * @see #getNameForUid(int) 3722 * 3723 * @hide 3724 */ 3725 @TestApi 3726 public abstract @Nullable String[] getNamesForUids(int[] uids); 3727 3728 /** 3729 * Return the user id associated with a shared user name. Multiple 3730 * applications can specify a shared user name in their manifest and thus 3731 * end up using a common uid. This might be used for new applications 3732 * that use an existing shared user name and need to know the uid of the 3733 * shared user. 3734 * 3735 * @param sharedUserName The shared user name whose uid is to be retrieved. 3736 * @return Returns the UID associated with the shared user. 3737 * @throws NameNotFoundException if a package with the given name cannot be 3738 * found on the system. 3739 * @hide 3740 */ 3741 public abstract int getUidForSharedUser(String sharedUserName) 3742 throws NameNotFoundException; 3743 3744 /** 3745 * Return a List of all application packages that are installed on the 3746 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 3747 * applications including those deleted with {@code DONT_DELETE_DATA} 3748 * (partially installed apps with data directory) will be returned. 3749 * 3750 * @param flags Additional option flags to modify the data returned. 3751 * @return A List of ApplicationInfo objects, one for each installed 3752 * application. In the unlikely case there are no installed 3753 * packages, an empty list is returned. If flag 3754 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application 3755 * information is retrieved from the list of uninstalled 3756 * applications (which includes installed applications as well as 3757 * applications with data directory i.e. applications which had been 3758 * deleted with {@code DONT_DELETE_DATA} flag set). 3759 */ 3760 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags); 3761 3762 /** 3763 * Return a List of all application packages that are installed on the 3764 * device, for a specific user. If flag GET_UNINSTALLED_PACKAGES has been 3765 * set, a list of all applications including those deleted with 3766 * {@code DONT_DELETE_DATA} (partially installed apps with data directory) 3767 * will be returned. 3768 * 3769 * @param flags Additional option flags to modify the data returned. 3770 * @param userId The user for whom the installed applications are to be 3771 * listed 3772 * @return A List of ApplicationInfo objects, one for each installed 3773 * application. In the unlikely case there are no installed 3774 * packages, an empty list is returned. If flag 3775 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the application 3776 * information is retrieved from the list of uninstalled 3777 * applications (which includes installed applications as well as 3778 * applications with data directory i.e. applications which had been 3779 * deleted with {@code DONT_DELETE_DATA} flag set). 3780 * @hide 3781 */ 3782 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser( 3783 @ApplicationInfoFlags int flags, @UserIdInt int userId); 3784 3785 /** 3786 * Gets the instant applications the user recently used. 3787 * 3788 * @return The instant app list. 3789 * 3790 * @hide 3791 */ 3792 @SystemApi 3793 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) 3794 public abstract @NonNull List<InstantAppInfo> getInstantApps(); 3795 3796 /** 3797 * Gets the icon for an instant application. 3798 * 3799 * @param packageName The app package name. 3800 * 3801 * @hide 3802 */ 3803 @SystemApi 3804 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) 3805 public abstract @Nullable Drawable getInstantAppIcon(String packageName); 3806 3807 /** 3808 * Gets whether this application is an instant app. 3809 * 3810 * @return Whether caller is an instant app. 3811 * 3812 * @see #isInstantApp(String) 3813 * @see #updateInstantAppCookie(byte[]) 3814 * @see #getInstantAppCookie() 3815 * @see #getInstantAppCookieMaxBytes() 3816 */ 3817 public abstract boolean isInstantApp(); 3818 3819 /** 3820 * Gets whether the given package is an instant app. 3821 * 3822 * @param packageName The package to check 3823 * @return Whether the given package is an instant app. 3824 * 3825 * @see #isInstantApp() 3826 * @see #updateInstantAppCookie(byte[]) 3827 * @see #getInstantAppCookie() 3828 * @see #getInstantAppCookieMaxBytes() 3829 * @see #clearInstantAppCookie() 3830 */ 3831 public abstract boolean isInstantApp(String packageName); 3832 3833 /** 3834 * Gets the maximum size in bytes of the cookie data an instant app 3835 * can store on the device. 3836 * 3837 * @return The max cookie size in bytes. 3838 * 3839 * @see #isInstantApp() 3840 * @see #isInstantApp(String) 3841 * @see #updateInstantAppCookie(byte[]) 3842 * @see #getInstantAppCookie() 3843 * @see #clearInstantAppCookie() 3844 */ 3845 public abstract int getInstantAppCookieMaxBytes(); 3846 3847 /** 3848 * deprecated 3849 * @hide 3850 */ 3851 public abstract int getInstantAppCookieMaxSize(); 3852 3853 /** 3854 * Gets the instant application cookie for this app. Non 3855 * instant apps and apps that were instant but were upgraded 3856 * to normal apps can still access this API. For instant apps 3857 * this cookie is cached for some time after uninstall while for 3858 * normal apps the cookie is deleted after the app is uninstalled. 3859 * The cookie is always present while the app is installed. 3860 * 3861 * @return The cookie. 3862 * 3863 * @see #isInstantApp() 3864 * @see #isInstantApp(String) 3865 * @see #updateInstantAppCookie(byte[]) 3866 * @see #getInstantAppCookieMaxBytes() 3867 * @see #clearInstantAppCookie() 3868 */ 3869 public abstract @NonNull byte[] getInstantAppCookie(); 3870 3871 /** 3872 * Clears the instant application cookie for the calling app. 3873 * 3874 * @see #isInstantApp() 3875 * @see #isInstantApp(String) 3876 * @see #getInstantAppCookieMaxBytes() 3877 * @see #getInstantAppCookie() 3878 * @see #clearInstantAppCookie() 3879 */ 3880 public abstract void clearInstantAppCookie(); 3881 3882 /** 3883 * Updates the instant application cookie for the calling app. Non 3884 * instant apps and apps that were instant but were upgraded 3885 * to normal apps can still access this API. For instant apps 3886 * this cookie is cached for some time after uninstall while for 3887 * normal apps the cookie is deleted after the app is uninstalled. 3888 * The cookie is always present while the app is installed. The 3889 * cookie size is limited by {@link #getInstantAppCookieMaxBytes()}. 3890 * Passing <code>null</code> or an empty array clears the cookie. 3891 * </p> 3892 * 3893 * @param cookie The cookie data. 3894 * 3895 * @see #isInstantApp() 3896 * @see #isInstantApp(String) 3897 * @see #getInstantAppCookieMaxBytes() 3898 * @see #getInstantAppCookie() 3899 * @see #clearInstantAppCookie() 3900 * 3901 * @throws IllegalArgumentException if the array exceeds max cookie size. 3902 */ 3903 public abstract void updateInstantAppCookie(@Nullable byte[] cookie); 3904 3905 /** 3906 * @removed 3907 */ 3908 public abstract boolean setInstantAppCookie(@Nullable byte[] cookie); 3909 3910 /** 3911 * Get a list of shared libraries that are available on the 3912 * system. 3913 * 3914 * @return An array of shared library names that are 3915 * available on the system, or null if none are installed. 3916 * 3917 */ 3918 public abstract String[] getSystemSharedLibraryNames(); 3919 3920 /** 3921 * Get a list of shared libraries on the device. 3922 * 3923 * @param flags To filter the libraries to return. 3924 * @return The shared library list. 3925 * 3926 * @see #MATCH_UNINSTALLED_PACKAGES 3927 */ 3928 public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries( 3929 @InstallFlags int flags); 3930 3931 /** 3932 * Get a list of shared libraries on the device. 3933 * 3934 * @param flags To filter the libraries to return. 3935 * @param userId The user to query for. 3936 * @return The shared library list. 3937 * 3938 * @see #MATCH_FACTORY_ONLY 3939 * @see #MATCH_KNOWN_PACKAGES 3940 * @see #MATCH_ANY_USER 3941 * @see #MATCH_UNINSTALLED_PACKAGES 3942 * 3943 * @hide 3944 */ 3945 public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser( 3946 @InstallFlags int flags, @UserIdInt int userId); 3947 3948 /** 3949 * Get the name of the package hosting the services shared library. 3950 * 3951 * @return The library host package. 3952 * 3953 * @hide 3954 */ 3955 @TestApi 3956 public abstract @NonNull String getServicesSystemSharedLibraryPackageName(); 3957 3958 /** 3959 * Get the name of the package hosting the shared components shared library. 3960 * 3961 * @return The library host package. 3962 * 3963 * @hide 3964 */ 3965 @TestApi 3966 public abstract @NonNull String getSharedSystemSharedLibraryPackageName(); 3967 3968 /** 3969 * Returns the names of the packages that have been changed 3970 * [eg. added, removed or updated] since the given sequence 3971 * number. 3972 * <p>If no packages have been changed, returns <code>null</code>. 3973 * <p>The sequence number starts at <code>0</code> and is 3974 * reset every boot. 3975 * @param sequenceNumber The first sequence number for which to retrieve package changes. 3976 * @see Settings.Global#BOOT_COUNT 3977 */ 3978 public abstract @Nullable ChangedPackages getChangedPackages( 3979 @IntRange(from=0) int sequenceNumber); 3980 3981 /** 3982 * Get a list of features that are available on the 3983 * system. 3984 * 3985 * @return An array of FeatureInfo classes describing the features 3986 * that are available on the system, or null if there are none(!!). 3987 */ 3988 public abstract FeatureInfo[] getSystemAvailableFeatures(); 3989 3990 /** 3991 * Check whether the given feature name is one of the available features as 3992 * returned by {@link #getSystemAvailableFeatures()}. This tests for the 3993 * presence of <em>any</em> version of the given feature name; use 3994 * {@link #hasSystemFeature(String, int)} to check for a minimum version. 3995 * 3996 * @return Returns true if the devices supports the feature, else false. 3997 */ 3998 public abstract boolean hasSystemFeature(String name); 3999 4000 /** 4001 * Check whether the given feature name and version is one of the available 4002 * features as returned by {@link #getSystemAvailableFeatures()}. Since 4003 * features are defined to always be backwards compatible, this returns true 4004 * if the available feature version is greater than or equal to the 4005 * requested version. 4006 * 4007 * @return Returns true if the devices supports the feature, else false. 4008 */ 4009 public abstract boolean hasSystemFeature(String name, int version); 4010 4011 /** 4012 * Determine the best action to perform for a given Intent. This is how 4013 * {@link Intent#resolveActivity} finds an activity if a class has not been 4014 * explicitly specified. 4015 * <p> 4016 * <em>Note:</em> if using an implicit Intent (without an explicit 4017 * ComponentName specified), be sure to consider whether to set the 4018 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 4019 * activity in the same way that 4020 * {@link android.content.Context#startActivity(Intent)} and 4021 * {@link android.content.Intent#resolveActivity(PackageManager) 4022 * Intent.resolveActivity(PackageManager)} do. 4023 * </p> 4024 * 4025 * @param intent An intent containing all of the desired specification 4026 * (action, data, type, category, and/or component). 4027 * @param flags Additional option flags to modify the data returned. The 4028 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 4029 * resolution to only those activities that support the 4030 * {@link android.content.Intent#CATEGORY_DEFAULT}. 4031 * @return Returns a ResolveInfo object containing the final activity intent 4032 * that was determined to be the best action. Returns null if no 4033 * matching activity was found. If multiple matching activities are 4034 * found and there is no default set, returns a ResolveInfo object 4035 * containing something else, such as the activity resolver. 4036 */ 4037 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags); 4038 4039 /** 4040 * Determine the best action to perform for a given Intent for a given user. 4041 * This is how {@link Intent#resolveActivity} finds an activity if a class 4042 * has not been explicitly specified. 4043 * <p> 4044 * <em>Note:</em> if using an implicit Intent (without an explicit 4045 * ComponentName specified), be sure to consider whether to set the 4046 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 4047 * activity in the same way that 4048 * {@link android.content.Context#startActivity(Intent)} and 4049 * {@link android.content.Intent#resolveActivity(PackageManager) 4050 * Intent.resolveActivity(PackageManager)} do. 4051 * </p> 4052 * 4053 * @param intent An intent containing all of the desired specification 4054 * (action, data, type, category, and/or component). 4055 * @param flags Additional option flags to modify the data returned. The 4056 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 4057 * resolution to only those activities that support the 4058 * {@link android.content.Intent#CATEGORY_DEFAULT}. 4059 * @param userId The user id. 4060 * @return Returns a ResolveInfo object containing the final activity intent 4061 * that was determined to be the best action. Returns null if no 4062 * matching activity was found. If multiple matching activities are 4063 * found and there is no default set, returns a ResolveInfo object 4064 * containing something else, such as the activity resolver. 4065 * @hide 4066 */ 4067 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags, 4068 @UserIdInt int userId); 4069 4070 /** 4071 * Retrieve all activities that can be performed for the given intent. 4072 * 4073 * @param intent The desired intent as per resolveActivity(). 4074 * @param flags Additional option flags to modify the data returned. The 4075 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 4076 * resolution to only those activities that support the 4077 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 4078 * {@link #MATCH_ALL} to prevent any filtering of the results. 4079 * @return Returns a List of ResolveInfo objects containing one entry for 4080 * each matching activity, ordered from best to worst. In other 4081 * words, the first item is what would be returned by 4082 * {@link #resolveActivity}. If there are no matching activities, an 4083 * empty list is returned. 4084 */ 4085 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 4086 @ResolveInfoFlags int flags); 4087 4088 /** 4089 * Retrieve all activities that can be performed for the given intent, for a 4090 * specific user. 4091 * 4092 * @param intent The desired intent as per resolveActivity(). 4093 * @param flags Additional option flags to modify the data returned. The 4094 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 4095 * resolution to only those activities that support the 4096 * {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 4097 * {@link #MATCH_ALL} to prevent any filtering of the results. 4098 * @return Returns a List of ResolveInfo objects containing one entry for 4099 * each matching activity, ordered from best to worst. In other 4100 * words, the first item is what would be returned by 4101 * {@link #resolveActivity}. If there are no matching activities, an 4102 * empty list is returned. 4103 * @hide 4104 */ 4105 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 4106 @ResolveInfoFlags int flags, @UserIdInt int userId); 4107 4108 /** 4109 * Retrieve a set of activities that should be presented to the user as 4110 * similar options. This is like {@link #queryIntentActivities}, except it 4111 * also allows you to supply a list of more explicit Intents that you would 4112 * like to resolve to particular options, and takes care of returning the 4113 * final ResolveInfo list in a reasonable order, with no duplicates, based 4114 * on those inputs. 4115 * 4116 * @param caller The class name of the activity that is making the request. 4117 * This activity will never appear in the output list. Can be 4118 * null. 4119 * @param specifics An array of Intents that should be resolved to the first 4120 * specific results. Can be null. 4121 * @param intent The desired intent as per resolveActivity(). 4122 * @param flags Additional option flags to modify the data returned. The 4123 * most important is {@link #MATCH_DEFAULT_ONLY}, to limit the 4124 * resolution to only those activities that support the 4125 * {@link android.content.Intent#CATEGORY_DEFAULT}. 4126 * @return Returns a List of ResolveInfo objects containing one entry for 4127 * each matching activity. The list is ordered first by all of the 4128 * intents resolved in <var>specifics</var> and then any additional 4129 * activities that can handle <var>intent</var> but did not get 4130 * included by one of the <var>specifics</var> intents. If there are 4131 * no matching activities, an empty list is returned. 4132 */ 4133 public abstract List<ResolveInfo> queryIntentActivityOptions(@Nullable ComponentName caller, 4134 @Nullable Intent[] specifics, Intent intent, @ResolveInfoFlags int flags); 4135 4136 /** 4137 * Retrieve all receivers that can handle a broadcast of the given intent. 4138 * 4139 * @param intent The desired intent as per resolveActivity(). 4140 * @param flags Additional option flags to modify the data returned. 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 */ 4145 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 4146 @ResolveInfoFlags int flags); 4147 4148 /** 4149 * Retrieve all receivers that can handle a broadcast of the given intent, 4150 * for a specific user. 4151 * 4152 * @param intent The desired intent as per resolveActivity(). 4153 * @param flags Additional option flags to modify the data returned. 4154 * @param userHandle UserHandle of the user being queried. 4155 * @return Returns a List of ResolveInfo objects containing one entry for 4156 * each matching receiver, ordered from best to worst. If there are 4157 * no matching receivers, an empty list or null is returned. 4158 * @hide 4159 */ 4160 @SystemApi 4161 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 4162 public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 4163 @ResolveInfoFlags int flags, UserHandle userHandle) { 4164 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 4165 } 4166 4167 /** 4168 * @hide 4169 */ 4170 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 4171 @ResolveInfoFlags int flags, @UserIdInt int userId); 4172 4173 4174 /** {@hide} */ 4175 @Deprecated 4176 public List<ResolveInfo> queryBroadcastReceivers(Intent intent, 4177 @ResolveInfoFlags int flags, @UserIdInt int userId) { 4178 final String msg = "Shame on you for calling the hidden API " 4179 + "queryBroadcastReceivers(). Shame!"; 4180 if (VMRuntime.getRuntime().getTargetSdkVersion() >= Build.VERSION_CODES.O) { 4181 throw new UnsupportedOperationException(msg); 4182 } else { 4183 Log.d(TAG, msg); 4184 return queryBroadcastReceiversAsUser(intent, flags, userId); 4185 } 4186 } 4187 4188 /** 4189 * Determine the best service to handle for a given Intent. 4190 * 4191 * @param intent An intent containing all of the desired specification 4192 * (action, data, type, category, and/or component). 4193 * @param flags Additional option flags to modify the data returned. 4194 * @return Returns a ResolveInfo object containing the final service intent 4195 * that was determined to be the best action. Returns null if no 4196 * matching service was found. 4197 */ 4198 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags); 4199 4200 /** 4201 * @hide 4202 */ 4203 public abstract ResolveInfo resolveServiceAsUser(Intent intent, @ResolveInfoFlags int flags, 4204 @UserIdInt int userId); 4205 4206 /** 4207 * Retrieve all services that can match the given intent. 4208 * 4209 * @param intent The desired intent as per resolveService(). 4210 * @param flags Additional option flags to modify the data returned. 4211 * @return Returns a List of ResolveInfo objects containing one entry for 4212 * each matching service, ordered from best to worst. In other 4213 * words, the first item is what would be returned by 4214 * {@link #resolveService}. If there are no matching services, an 4215 * empty list or null is returned. 4216 */ 4217 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 4218 @ResolveInfoFlags int flags); 4219 4220 /** 4221 * Retrieve all services that can match the given intent for a given user. 4222 * 4223 * @param intent The desired intent as per resolveService(). 4224 * @param flags Additional option flags to modify the data returned. 4225 * @param userId The user id. 4226 * @return Returns a List of ResolveInfo objects containing one entry for 4227 * each matching service, ordered from best to worst. In other 4228 * words, the first item is what would be returned by 4229 * {@link #resolveService}. If there are no matching services, an 4230 * empty list or null is returned. 4231 * @hide 4232 */ 4233 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 4234 @ResolveInfoFlags int flags, @UserIdInt int userId); 4235 4236 /** 4237 * Retrieve all providers that can match the given intent. 4238 * 4239 * @param intent An intent containing all of the desired specification 4240 * (action, data, type, category, and/or component). 4241 * @param flags Additional option flags to modify the data returned. 4242 * @param userId The user id. 4243 * @return Returns a List of ResolveInfo objects containing one entry for 4244 * each matching provider, ordered from best to worst. If there are 4245 * no matching services, an empty list or null is returned. 4246 * @hide 4247 */ 4248 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 4249 Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId); 4250 4251 /** 4252 * Retrieve all providers that can match the given intent. 4253 * 4254 * @param intent An intent containing all of the desired specification 4255 * (action, data, type, category, and/or component). 4256 * @param flags Additional option flags to modify the data returned. 4257 * @return Returns a List of ResolveInfo objects containing one entry for 4258 * each matching provider, ordered from best to worst. If there are 4259 * no matching services, an empty list or null is returned. 4260 */ 4261 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, 4262 @ResolveInfoFlags int flags); 4263 4264 /** 4265 * Find a single content provider by its base path name. 4266 * 4267 * @param name The name of the provider to find. 4268 * @param flags Additional option flags to modify the data returned. 4269 * @return A {@link ProviderInfo} object containing information about the 4270 * provider. If a provider was not found, returns null. 4271 */ 4272 public abstract ProviderInfo resolveContentProvider(String name, 4273 @ComponentInfoFlags int flags); 4274 4275 /** 4276 * Find a single content provider by its base path name. 4277 * 4278 * @param name The name of the provider to find. 4279 * @param flags Additional option flags to modify the data returned. 4280 * @param userId The user id. 4281 * @return A {@link ProviderInfo} object containing information about the 4282 * provider. If a provider was not found, returns null. 4283 * @hide 4284 */ 4285 public abstract ProviderInfo resolveContentProviderAsUser(String name, 4286 @ComponentInfoFlags int flags, @UserIdInt int userId); 4287 4288 /** 4289 * Retrieve content provider information. 4290 * <p> 4291 * <em>Note: unlike most other methods, an empty result set is indicated 4292 * by a null return instead of an empty list.</em> 4293 * 4294 * @param processName If non-null, limits the returned providers to only 4295 * those that are hosted by the given process. If null, all 4296 * content providers are returned. 4297 * @param uid If <var>processName</var> is non-null, this is the required 4298 * uid owning the requested content providers. 4299 * @param flags Additional option flags to modify the data returned. 4300 * @return A list of {@link ProviderInfo} objects containing one entry for 4301 * each provider either matching <var>processName</var> or, if 4302 * <var>processName</var> is null, all known content providers. 4303 * <em>If there are no matching providers, null is returned.</em> 4304 */ 4305 public abstract List<ProviderInfo> queryContentProviders( 4306 String processName, int uid, @ComponentInfoFlags int flags); 4307 4308 /** 4309 * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null, 4310 * it only returns providers which have metadata with the {@code metaDataKey} key. 4311 * 4312 * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider. 4313 * You really shouldn't need it. Other apps should use {@link #queryIntentContentProviders} 4314 * instead. 4315 * 4316 * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly 4317 * scan the GAL providers on the device. Unfortunately the discovery protocol used metadata 4318 * to mark GAL providers, rather than intent filters, so we can't use 4319 * {@link #queryIntentContentProviders} for that. 4320 * 4321 * @hide 4322 */ 4323 public List<ProviderInfo> queryContentProviders( 4324 String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey) { 4325 // Provide the default implementation for mocks. 4326 return queryContentProviders(processName, uid, flags); 4327 } 4328 4329 /** 4330 * Retrieve all of the information we know about a particular 4331 * instrumentation class. 4332 * 4333 * @param className The full name (i.e. 4334 * com.google.apps.contacts.InstrumentList) of an Instrumentation 4335 * class. 4336 * @param flags Additional option flags to modify the data returned. 4337 * @return An {@link InstrumentationInfo} object containing information 4338 * about the instrumentation. 4339 * @throws NameNotFoundException if a package with the given name cannot be 4340 * found on the system. 4341 */ 4342 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className, 4343 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 4344 4345 /** 4346 * Retrieve information about available instrumentation code. May be used to 4347 * retrieve either all instrumentation code, or only the code targeting a 4348 * particular package. 4349 * 4350 * @param targetPackage If null, all instrumentation is returned; only the 4351 * instrumentation targeting this package name is returned. 4352 * @param flags Additional option flags to modify the data returned. 4353 * @return A list of {@link InstrumentationInfo} objects containing one 4354 * entry for each matching instrumentation. If there are no 4355 * instrumentation available, returns an empty list. 4356 */ 4357 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage, 4358 @InstrumentationInfoFlags int flags); 4359 4360 /** 4361 * Retrieve an image from a package. This is a low-level API used by 4362 * the various package manager info structures (such as 4363 * {@link ComponentInfo} to implement retrieval of their associated 4364 * icon. 4365 * 4366 * @param packageName The name of the package that this icon is coming from. 4367 * Cannot be null. 4368 * @param resid The resource identifier of the desired image. Cannot be 0. 4369 * @param appInfo Overall information about <var>packageName</var>. This 4370 * may be null, in which case the application information will be retrieved 4371 * for you if needed; if you already have this information around, it can 4372 * be much more efficient to supply it here. 4373 * 4374 * @return Returns a Drawable holding the requested image. Returns null if 4375 * an image could not be found for any reason. 4376 */ 4377 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid, 4378 ApplicationInfo appInfo); 4379 4380 /** 4381 * Retrieve the icon associated with an activity. Given the full name of 4382 * an activity, retrieves the information about it and calls 4383 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 4384 * If the activity cannot be found, NameNotFoundException is thrown. 4385 * 4386 * @param activityName Name of the activity whose icon is to be retrieved. 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 the given 4391 * activity could not be loaded. 4392 * 4393 * @see #getActivityIcon(Intent) 4394 */ 4395 public abstract Drawable getActivityIcon(ComponentName activityName) 4396 throws NameNotFoundException; 4397 4398 /** 4399 * Retrieve the icon associated with an Intent. If intent.getClassName() is 4400 * set, this simply returns the result of 4401 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 4402 * component and returns the icon associated with the resolved component. 4403 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4404 * to a component, NameNotFoundException is thrown. 4405 * 4406 * @param intent The intent for which you would like to retrieve an icon. 4407 * 4408 * @return Returns the image of the icon, or the default activity icon if 4409 * it could not be found. Does not return null. 4410 * @throws NameNotFoundException Thrown if the resources for application 4411 * matching the given intent could not be loaded. 4412 * 4413 * @see #getActivityIcon(ComponentName) 4414 */ 4415 public abstract Drawable getActivityIcon(Intent intent) 4416 throws NameNotFoundException; 4417 4418 /** 4419 * Retrieve the banner associated with an activity. Given the full name of 4420 * an activity, retrieves the information about it and calls 4421 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 4422 * banner. If the activity cannot be found, NameNotFoundException is thrown. 4423 * 4424 * @param activityName Name of the activity whose banner is to be retrieved. 4425 * @return Returns the image of the banner, or null if the activity has no 4426 * banner specified. 4427 * @throws NameNotFoundException Thrown if the resources for the given 4428 * activity could not be loaded. 4429 * @see #getActivityBanner(Intent) 4430 */ 4431 public abstract Drawable getActivityBanner(ComponentName activityName) 4432 throws NameNotFoundException; 4433 4434 /** 4435 * Retrieve the banner associated with an Intent. If intent.getClassName() 4436 * is set, this simply returns the result of 4437 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 4438 * intent's component and returns the banner associated with the resolved 4439 * component. If intent.getClassName() cannot be found or the Intent cannot 4440 * be resolved to a component, NameNotFoundException is thrown. 4441 * 4442 * @param intent The intent for which you would like to retrieve a banner. 4443 * @return Returns the image of the banner, or null if the activity has no 4444 * banner specified. 4445 * @throws NameNotFoundException Thrown if the resources for application 4446 * matching the given intent could not be loaded. 4447 * @see #getActivityBanner(ComponentName) 4448 */ 4449 public abstract Drawable getActivityBanner(Intent intent) 4450 throws NameNotFoundException; 4451 4452 /** 4453 * Return the generic icon for an activity that is used when no specific 4454 * icon is defined. 4455 * 4456 * @return Drawable Image of the icon. 4457 */ 4458 public abstract Drawable getDefaultActivityIcon(); 4459 4460 /** 4461 * Retrieve the icon associated with an application. If it has not defined 4462 * an icon, the default app icon is returned. Does not return null. 4463 * 4464 * @param info Information about application being queried. 4465 * 4466 * @return Returns the image of the icon, or the default application icon 4467 * if it could not be found. 4468 * 4469 * @see #getApplicationIcon(String) 4470 */ 4471 public abstract Drawable getApplicationIcon(ApplicationInfo info); 4472 4473 /** 4474 * Retrieve the icon associated with an application. Given the name of the 4475 * application's package, retrieves the information about it and calls 4476 * getApplicationIcon() to return its icon. If the application cannot be 4477 * found, NameNotFoundException is thrown. 4478 * 4479 * @param packageName Name of the package whose application icon is to be 4480 * retrieved. 4481 * 4482 * @return Returns the image of the icon, or the default application icon 4483 * if it could not be found. Does not return null. 4484 * @throws NameNotFoundException Thrown if the resources for the given 4485 * application could not be loaded. 4486 * 4487 * @see #getApplicationIcon(ApplicationInfo) 4488 */ 4489 public abstract Drawable getApplicationIcon(String packageName) 4490 throws NameNotFoundException; 4491 4492 /** 4493 * Retrieve the banner associated with an application. 4494 * 4495 * @param info Information about application being queried. 4496 * @return Returns the image of the banner or null if the application has no 4497 * banner specified. 4498 * @see #getApplicationBanner(String) 4499 */ 4500 public abstract Drawable getApplicationBanner(ApplicationInfo info); 4501 4502 /** 4503 * Retrieve the banner associated with an application. Given the name of the 4504 * application's package, retrieves the information about it and calls 4505 * getApplicationIcon() to return its banner. If the application cannot be 4506 * found, NameNotFoundException is thrown. 4507 * 4508 * @param packageName Name of the package whose application banner is to be 4509 * retrieved. 4510 * @return Returns the image of the banner or null if the application has no 4511 * banner specified. 4512 * @throws NameNotFoundException Thrown if the resources for the given 4513 * application could not be loaded. 4514 * @see #getApplicationBanner(ApplicationInfo) 4515 */ 4516 public abstract Drawable getApplicationBanner(String packageName) 4517 throws NameNotFoundException; 4518 4519 /** 4520 * Retrieve the logo associated with an activity. Given the full name of an 4521 * activity, retrieves the information about it and calls 4522 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 4523 * logo. If the activity cannot be found, NameNotFoundException is thrown. 4524 * 4525 * @param activityName Name of the activity whose logo is to be retrieved. 4526 * @return Returns the image of the logo or null if the activity has no logo 4527 * specified. 4528 * @throws NameNotFoundException Thrown if the resources for the given 4529 * activity could not be loaded. 4530 * @see #getActivityLogo(Intent) 4531 */ 4532 public abstract Drawable getActivityLogo(ComponentName activityName) 4533 throws NameNotFoundException; 4534 4535 /** 4536 * Retrieve the logo associated with an Intent. If intent.getClassName() is 4537 * set, this simply returns the result of 4538 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 4539 * component and returns the logo associated with the resolved component. 4540 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4541 * to a component, NameNotFoundException is thrown. 4542 * 4543 * @param intent The intent for which you would like to retrieve a logo. 4544 * 4545 * @return Returns the image of the logo, or null if the activity has no 4546 * logo specified. 4547 * 4548 * @throws NameNotFoundException Thrown if the resources for application 4549 * matching the given intent could not be loaded. 4550 * 4551 * @see #getActivityLogo(ComponentName) 4552 */ 4553 public abstract Drawable getActivityLogo(Intent intent) 4554 throws NameNotFoundException; 4555 4556 /** 4557 * Retrieve the logo associated with an application. If it has not specified 4558 * a logo, this method returns null. 4559 * 4560 * @param info Information about application being queried. 4561 * 4562 * @return Returns the image of the logo, or null if no logo is specified 4563 * by the application. 4564 * 4565 * @see #getApplicationLogo(String) 4566 */ 4567 public abstract Drawable getApplicationLogo(ApplicationInfo info); 4568 4569 /** 4570 * Retrieve the logo associated with an application. Given the name of the 4571 * application's package, retrieves the information about it and calls 4572 * getApplicationLogo() to return its logo. If the application cannot be 4573 * found, NameNotFoundException is thrown. 4574 * 4575 * @param packageName Name of the package whose application logo is to be 4576 * retrieved. 4577 * 4578 * @return Returns the image of the logo, or null if no application logo 4579 * has been specified. 4580 * 4581 * @throws NameNotFoundException Thrown if the resources for the given 4582 * application could not be loaded. 4583 * 4584 * @see #getApplicationLogo(ApplicationInfo) 4585 */ 4586 public abstract Drawable getApplicationLogo(String packageName) 4587 throws NameNotFoundException; 4588 4589 /** 4590 * If the target user is a managed profile, then this returns a badged copy of the given icon 4591 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use 4592 * {@link #getUserBadgedDrawableForDensity( 4593 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 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 icon The icon to badge. 4601 * @param user The target user. 4602 * @return A drawable that combines the original icon and a badge as 4603 * determined by the system. 4604 */ 4605 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 4606 4607 /** 4608 * If the target user is a managed profile of the calling user or the caller 4609 * is itself a managed profile, then this returns a badged copy of the given 4610 * drawable allowing the user to distinguish it from the original drawable. 4611 * The caller can specify the location in the bounds of the drawable to be 4612 * badged where the badge should be applied as well as the density of the 4613 * badge to be used. 4614 * <p> 4615 * If the original drawable is a BitmapDrawable and the backing bitmap is 4616 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 4617 * is performed in place and the original drawable is returned. 4618 * </p> 4619 * 4620 * @param drawable The drawable to badge. 4621 * @param user The target user. 4622 * @param badgeLocation Where in the bounds of the badged drawable to place 4623 * the badge. If it's {@code null}, the badge is applied on top of the entire 4624 * drawable being badged. 4625 * @param badgeDensity The optional desired density for the badge as per 4626 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive, 4627 * the density of the display is used. 4628 * @return A drawable that combines the original drawable and a badge as 4629 * determined by the system. 4630 */ 4631 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 4632 UserHandle user, Rect badgeLocation, int badgeDensity); 4633 4634 /** 4635 * If the target user is a managed profile of the calling user or the caller 4636 * is itself a managed profile, then this returns a drawable to use as a small 4637 * icon to include in a view to distinguish it from the original icon. 4638 * 4639 * @param user The target user. 4640 * @param density The optional desired density for the badge as per 4641 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4642 * the density of the current display is used. 4643 * @return the drawable or null if no drawable is required. 4644 * @hide 4645 */ 4646 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 4647 4648 /** 4649 * If the target user is a managed profile of the calling user or the caller 4650 * is itself a managed profile, then this returns a drawable to use as a small 4651 * icon to include in a view to distinguish it from the original icon. This version 4652 * doesn't have background protection and should be used over a light background instead of 4653 * a badge. 4654 * 4655 * @param user The target user. 4656 * @param density The optional desired density for the badge as per 4657 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4658 * the density of the current display is used. 4659 * @return the drawable or null if no drawable is required. 4660 * @hide 4661 */ 4662 public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density); 4663 4664 /** 4665 * If the target user is a managed profile of the calling user or the caller 4666 * is itself a managed profile, then this returns a copy of the label with 4667 * badging for accessibility services like talkback. E.g. passing in "Email" 4668 * and it might return "Work Email" for Email in the work profile. 4669 * 4670 * @param label The label to change. 4671 * @param user The target user. 4672 * @return A label that combines the original label and a badge as 4673 * determined by the system. 4674 */ 4675 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 4676 4677 /** 4678 * Retrieve text from a package. This is a low-level API used by 4679 * the various package manager info structures (such as 4680 * {@link ComponentInfo} to implement retrieval of their associated 4681 * labels and other text. 4682 * 4683 * @param packageName The name of the package that this text is coming from. 4684 * Cannot be null. 4685 * @param resid The resource identifier of the desired text. Cannot be 0. 4686 * @param appInfo Overall information about <var>packageName</var>. This 4687 * may be null, in which case the application information will be retrieved 4688 * for you if needed; if you already have this information around, it can 4689 * be much more efficient to supply it here. 4690 * 4691 * @return Returns a CharSequence holding the requested text. Returns null 4692 * if the text could not be found for any reason. 4693 */ 4694 public abstract CharSequence getText(String packageName, @StringRes int resid, 4695 ApplicationInfo appInfo); 4696 4697 /** 4698 * Retrieve an XML file from a package. This is a low-level API used to 4699 * retrieve XML meta data. 4700 * 4701 * @param packageName The name of the package that this xml is coming from. 4702 * Cannot be null. 4703 * @param resid The resource identifier of the desired xml. Cannot be 0. 4704 * @param appInfo Overall information about <var>packageName</var>. This 4705 * may be null, in which case the application information will be retrieved 4706 * for you if needed; if you already have this information around, it can 4707 * be much more efficient to supply it here. 4708 * 4709 * @return Returns an XmlPullParser allowing you to parse out the XML 4710 * data. Returns null if the xml resource could not be found for any 4711 * reason. 4712 */ 4713 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid, 4714 ApplicationInfo appInfo); 4715 4716 /** 4717 * Return the label to use for this application. 4718 * 4719 * @return Returns the label associated with this application, or null if 4720 * it could not be found for any reason. 4721 * @param info The application to get the label of. 4722 */ 4723 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 4724 4725 /** 4726 * Retrieve the resources associated with an activity. Given the full 4727 * name of an activity, retrieves the information about it and calls 4728 * getResources() to return its application's resources. If the activity 4729 * cannot be found, NameNotFoundException is thrown. 4730 * 4731 * @param activityName Name of the activity whose resources are to be 4732 * retrieved. 4733 * 4734 * @return Returns the application's Resources. 4735 * @throws NameNotFoundException Thrown if the resources for the given 4736 * application could not be loaded. 4737 * 4738 * @see #getResourcesForApplication(ApplicationInfo) 4739 */ 4740 public abstract Resources getResourcesForActivity(ComponentName activityName) 4741 throws NameNotFoundException; 4742 4743 /** 4744 * Retrieve the resources for an application. Throws NameNotFoundException 4745 * if the package is no longer installed. 4746 * 4747 * @param app Information about the desired application. 4748 * 4749 * @return Returns the application's Resources. 4750 * @throws NameNotFoundException Thrown if the resources for the given 4751 * application could not be loaded (most likely because it was uninstalled). 4752 */ 4753 public abstract Resources getResourcesForApplication(ApplicationInfo app) 4754 throws NameNotFoundException; 4755 4756 /** 4757 * Retrieve the resources associated with an application. Given the full 4758 * package name of an application, retrieves the information about it and 4759 * calls getResources() to return its application's resources. If the 4760 * appPackageName cannot be found, NameNotFoundException is thrown. 4761 * 4762 * @param appPackageName Package name of the application whose resources 4763 * are to be retrieved. 4764 * 4765 * @return Returns the application's Resources. 4766 * @throws NameNotFoundException Thrown if the resources for the given 4767 * application could not be loaded. 4768 * 4769 * @see #getResourcesForApplication(ApplicationInfo) 4770 */ 4771 public abstract Resources getResourcesForApplication(String appPackageName) 4772 throws NameNotFoundException; 4773 4774 /** @hide */ 4775 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, 4776 @UserIdInt int userId) throws NameNotFoundException; 4777 4778 /** 4779 * Retrieve overall information about an application package defined in a 4780 * package archive file 4781 * 4782 * @param archiveFilePath The path to the archive file 4783 * @param flags Additional option flags to modify the data returned. 4784 * @return A PackageInfo object containing information about the package 4785 * archive. If the package could not be parsed, returns null. 4786 */ 4787 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) { 4788 final PackageParser parser = new PackageParser(); 4789 parser.setCallback(new PackageParser.CallbackImpl(this)); 4790 final File apkFile = new File(archiveFilePath); 4791 try { 4792 if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) { 4793 // Caller expressed an explicit opinion about what encryption 4794 // aware/unaware components they want to see, so fall through and 4795 // give them what they want 4796 } else { 4797 // Caller expressed no opinion, so match everything 4798 flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE; 4799 } 4800 4801 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 4802 if ((flags & GET_SIGNATURES) != 0) { 4803 PackageParser.collectCertificates(pkg, false /* skipVerify */); 4804 } 4805 PackageUserState state = new PackageUserState(); 4806 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 4807 } catch (PackageParserException e) { 4808 return null; 4809 } 4810 } 4811 4812 /** 4813 * If there is already an application with the given package name installed 4814 * on the system for other users, also install it for the calling user. 4815 * @hide 4816 */ 4817 @SystemApi 4818 public abstract int installExistingPackage(String packageName) throws NameNotFoundException; 4819 4820 /** 4821 * If there is already an application with the given package name installed 4822 * on the system for other users, also install it for the calling user. 4823 * @hide 4824 */ 4825 @SystemApi 4826 public abstract int installExistingPackage(String packageName, @InstallReason int installReason) 4827 throws NameNotFoundException; 4828 4829 /** 4830 * If there is already an application with the given package name installed 4831 * on the system for other users, also install it for the specified user. 4832 * @hide 4833 */ 4834 @RequiresPermission(anyOf = { 4835 Manifest.permission.INSTALL_PACKAGES, 4836 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4837 public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId) 4838 throws NameNotFoundException; 4839 4840 /** 4841 * Allows a package listening to the 4842 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4843 * broadcast} to respond to the package manager. The response must include 4844 * the {@code verificationCode} which is one of 4845 * {@link PackageManager#VERIFICATION_ALLOW} or 4846 * {@link PackageManager#VERIFICATION_REJECT}. 4847 * 4848 * @param id pending package identifier as passed via the 4849 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4850 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 4851 * or {@link PackageManager#VERIFICATION_REJECT}. 4852 * @throws SecurityException if the caller does not have the 4853 * PACKAGE_VERIFICATION_AGENT permission. 4854 */ 4855 public abstract void verifyPendingInstall(int id, int verificationCode); 4856 4857 /** 4858 * Allows a package listening to the 4859 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4860 * broadcast} to extend the default timeout for a response and declare what 4861 * action to perform after the timeout occurs. The response must include 4862 * the {@code verificationCodeAtTimeout} which is one of 4863 * {@link PackageManager#VERIFICATION_ALLOW} or 4864 * {@link PackageManager#VERIFICATION_REJECT}. 4865 * 4866 * This method may only be called once per package id. Additional calls 4867 * will have no effect. 4868 * 4869 * @param id pending package identifier as passed via the 4870 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4871 * @param verificationCodeAtTimeout either 4872 * {@link PackageManager#VERIFICATION_ALLOW} or 4873 * {@link PackageManager#VERIFICATION_REJECT}. If 4874 * {@code verificationCodeAtTimeout} is neither 4875 * {@link PackageManager#VERIFICATION_ALLOW} or 4876 * {@link PackageManager#VERIFICATION_REJECT}, then 4877 * {@code verificationCodeAtTimeout} will default to 4878 * {@link PackageManager#VERIFICATION_REJECT}. 4879 * @param millisecondsToDelay the amount of time requested for the timeout. 4880 * Must be positive and less than 4881 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 4882 * {@code millisecondsToDelay} is out of bounds, 4883 * {@code millisecondsToDelay} will be set to the closest in 4884 * bounds value; namely, 0 or 4885 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 4886 * @throws SecurityException if the caller does not have the 4887 * PACKAGE_VERIFICATION_AGENT permission. 4888 */ 4889 public abstract void extendVerificationTimeout(int id, 4890 int verificationCodeAtTimeout, long millisecondsToDelay); 4891 4892 /** 4893 * Allows a package listening to the 4894 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification 4895 * broadcast to respond to the package manager. The response must include 4896 * the {@code verificationCode} which is one of 4897 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 4898 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4899 * 4900 * @param verificationId pending package identifier as passed via the 4901 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4902 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 4903 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4904 * @param failedDomains a list of failed domains if the verificationCode is 4905 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 4906 * @throws SecurityException if the caller does not have the 4907 * INTENT_FILTER_VERIFICATION_AGENT permission. 4908 * 4909 * @hide 4910 */ 4911 @SystemApi 4912 @RequiresPermission(android.Manifest.permission.INTENT_FILTER_VERIFICATION_AGENT) 4913 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 4914 List<String> failedDomains); 4915 4916 /** 4917 * Get the status of a Domain Verification Result for an IntentFilter. This is 4918 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4919 * {@link android.content.IntentFilter#getAutoVerify()} 4920 * 4921 * This is used by the ResolverActivity to change the status depending on what the User select 4922 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4923 * for a domain. 4924 * 4925 * @param packageName The package name of the Activity associated with the IntentFilter. 4926 * @param userId The user id. 4927 * 4928 * @return The status to set to. This can be 4929 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4930 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4931 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 4932 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 4933 * 4934 * @hide 4935 */ 4936 @SystemApi 4937 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL) 4938 public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId); 4939 4940 /** 4941 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 4942 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4943 * {@link android.content.IntentFilter#getAutoVerify()} 4944 * 4945 * This is used by the ResolverActivity to change the status depending on what the User select 4946 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4947 * for a domain. 4948 * 4949 * @param packageName The package name of the Activity associated with the IntentFilter. 4950 * @param status The status to set to. This can be 4951 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4952 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4953 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 4954 * @param userId The user id. 4955 * 4956 * @return true if the status has been set. False otherwise. 4957 * 4958 * @hide 4959 */ 4960 @SystemApi 4961 @RequiresPermission(android.Manifest.permission.SET_PREFERRED_APPLICATIONS) 4962 public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status, 4963 @UserIdInt int userId); 4964 4965 /** 4966 * Get the list of IntentFilterVerificationInfo for a specific package and User. 4967 * 4968 * @param packageName the package name. When this parameter is set to a non null value, 4969 * the results will be filtered by the package name provided. 4970 * Otherwise, there will be no filtering and it will return a list 4971 * corresponding for all packages 4972 * 4973 * @return a list of IntentFilterVerificationInfo for a specific package. 4974 * 4975 * @hide 4976 */ 4977 @SystemApi 4978 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 4979 String packageName); 4980 4981 /** 4982 * Get the list of IntentFilter for a specific package. 4983 * 4984 * @param packageName the package name. This parameter is set to a non null value, 4985 * the list will contain all the IntentFilter for that package. 4986 * Otherwise, the list will be empty. 4987 * 4988 * @return a list of IntentFilter for a specific package. 4989 * 4990 * @hide 4991 */ 4992 @SystemApi 4993 public abstract List<IntentFilter> getAllIntentFilters(String packageName); 4994 4995 /** 4996 * Get the default Browser package name for a specific user. 4997 * 4998 * @param userId The user id. 4999 * 5000 * @return the package name of the default Browser for the specified user. If the user id passed 5001 * is -1 (all users) it will return a null value. 5002 * 5003 * @hide 5004 */ 5005 @TestApi 5006 @SystemApi 5007 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS_FULL) 5008 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId); 5009 5010 /** 5011 * Set the default Browser package name for a specific user. 5012 * 5013 * @param packageName The package name of the default Browser. 5014 * @param userId The user id. 5015 * 5016 * @return true if the default Browser for the specified user has been set, 5017 * otherwise return false. If the user id passed is -1 (all users) this call will not 5018 * do anything and just return false. 5019 * 5020 * @hide 5021 */ 5022 @SystemApi 5023 @RequiresPermission(allOf = { 5024 Manifest.permission.SET_PREFERRED_APPLICATIONS, 5025 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 5026 public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName, 5027 @UserIdInt int userId); 5028 5029 /** 5030 * Change the installer associated with a given package. There are limitations 5031 * on how the installer package can be changed; in particular: 5032 * <ul> 5033 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 5034 * is not signed with the same certificate as the calling application. 5035 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 5036 * has an installer package, and that installer package is not signed with 5037 * the same certificate as the calling application. 5038 * </ul> 5039 * 5040 * @param targetPackage The installed package whose installer will be changed. 5041 * @param installerPackageName The package name of the new installer. May be 5042 * null to clear the association. 5043 */ 5044 public abstract void setInstallerPackageName(String targetPackage, 5045 String installerPackageName); 5046 5047 /** @hide */ 5048 @SystemApi 5049 @RequiresPermission(Manifest.permission.INSTALL_PACKAGES) 5050 public abstract void setUpdateAvailable(String packageName, boolean updateAvaialble); 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 calling context lacks the 5056 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 5057 * named package cannot be found, or if the named package is a system 5058 * package. 5059 * 5060 * @param packageName The name of the package to delete 5061 * @param observer An observer callback to get notified when the package 5062 * deletion is complete. 5063 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 5064 * will be called when that happens. observer may be null to 5065 * indicate that no callback is desired. 5066 * @hide 5067 */ 5068 @RequiresPermission(Manifest.permission.DELETE_PACKAGES) 5069 public abstract void deletePackage(String packageName, IPackageDeleteObserver observer, 5070 @DeleteFlags int flags); 5071 5072 /** 5073 * Attempts to delete a package. Since this may take a little while, the 5074 * result will be posted back to the given observer. A deletion will fail if 5075 * the named package cannot be found, or if the named package is a system 5076 * package. 5077 * 5078 * @param packageName The name of the package to delete 5079 * @param observer An observer callback to get notified when the package 5080 * deletion is complete. 5081 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 5082 * will be called when that happens. observer may be null to 5083 * indicate that no callback is desired. 5084 * @param userId The user Id 5085 * @hide 5086 */ 5087 @RequiresPermission(anyOf = { 5088 Manifest.permission.DELETE_PACKAGES, 5089 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 5090 public abstract void deletePackageAsUser(@NonNull String packageName, 5091 IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId); 5092 5093 /** 5094 * Retrieve the package name of the application that installed a package. This identifies 5095 * which market the package came from. 5096 * 5097 * @param packageName The name of the package to query 5098 * @throws IllegalArgumentException if the given package name is not installed 5099 */ 5100 public abstract String getInstallerPackageName(String packageName); 5101 5102 /** 5103 * Attempts to clear the user data directory of an application. 5104 * Since this may take a little while, the result will 5105 * be posted back to the given observer. A deletion will fail if the 5106 * named package cannot be found, or if the named package is a "system package". 5107 * 5108 * @param packageName The name of the package 5109 * @param observer An observer callback to get notified when the operation is finished 5110 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5111 * will be called when that happens. observer may be null to indicate that 5112 * no callback is desired. 5113 * 5114 * @hide 5115 */ 5116 public abstract void clearApplicationUserData(String packageName, 5117 IPackageDataObserver observer); 5118 /** 5119 * Attempts to delete the cache files associated with an application. 5120 * Since this may take a little while, the result will 5121 * be posted back to the given observer. A deletion will fail if the calling context 5122 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 5123 * named package cannot be found, or if the named package is a "system package". 5124 * 5125 * @param packageName The name of the package to delete 5126 * @param observer An observer callback to get notified when the cache file deletion 5127 * is complete. 5128 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5129 * will be called when that happens. observer may be null to indicate that 5130 * no callback is desired. 5131 * 5132 * @hide 5133 */ 5134 public abstract void deleteApplicationCacheFiles(String packageName, 5135 IPackageDataObserver observer); 5136 5137 /** 5138 * Attempts to delete the cache files associated with an application for a given user. Since 5139 * this may take a little while, the result will be posted back to the given observer. A 5140 * deletion will fail if the calling context lacks the 5141 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package 5142 * cannot be found, or if the named package is a "system package". If {@code userId} does not 5143 * belong to the calling user, the caller must have 5144 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission. 5145 * 5146 * @param packageName The name of the package to delete 5147 * @param userId the user for which the cache files needs to be deleted 5148 * @param observer An observer callback to get notified when the cache file deletion is 5149 * complete. 5150 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5151 * will be called when that happens. observer may be null to indicate that no 5152 * callback is desired. 5153 * @hide 5154 */ 5155 public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId, 5156 IPackageDataObserver observer); 5157 5158 /** 5159 * Free storage by deleting LRU sorted list of cache files across 5160 * all applications. If the currently available free storage 5161 * on the device is greater than or equal to the requested 5162 * free storage, no cache files are cleared. If the currently 5163 * available storage on the device is less than the requested 5164 * free storage, some or all of the cache files across 5165 * all applications are deleted (based on last accessed time) 5166 * to increase the free storage space on the device to 5167 * the requested value. There is no guarantee that clearing all 5168 * the cache files from all applications will clear up 5169 * enough storage to achieve the desired value. 5170 * @param freeStorageSize The number of bytes of storage to be 5171 * freed by the system. Say if freeStorageSize is XX, 5172 * and the current free storage is YY, 5173 * if XX is less than YY, just return. if not free XX-YY number 5174 * of bytes if possible. 5175 * @param observer call back used to notify when 5176 * the operation is completed 5177 * 5178 * @hide 5179 */ 5180 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) { 5181 freeStorageAndNotify(null, freeStorageSize, observer); 5182 } 5183 5184 /** {@hide} */ 5185 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize, 5186 IPackageDataObserver observer); 5187 5188 /** 5189 * Free storage by deleting LRU sorted list of cache files across 5190 * all applications. If the currently available free storage 5191 * on the device is greater than or equal to the requested 5192 * free storage, no cache files are cleared. If the currently 5193 * available storage on the device is less than the requested 5194 * free storage, some or all of the cache files across 5195 * all applications are deleted (based on last accessed time) 5196 * to increase the free storage space on the device to 5197 * the requested value. There is no guarantee that clearing all 5198 * the cache files from all applications will clear up 5199 * enough storage to achieve the desired value. 5200 * @param freeStorageSize The number of bytes of storage to be 5201 * freed by the system. Say if freeStorageSize is XX, 5202 * and the current free storage is YY, 5203 * if XX is less than YY, just return. if not free XX-YY number 5204 * of bytes if possible. 5205 * @param pi IntentSender call back used to 5206 * notify when the operation is completed.May be null 5207 * to indicate that no call back is desired. 5208 * 5209 * @hide 5210 */ 5211 public void freeStorage(long freeStorageSize, IntentSender pi) { 5212 freeStorage(null, freeStorageSize, pi); 5213 } 5214 5215 /** {@hide} */ 5216 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi); 5217 5218 /** 5219 * Retrieve the size information for a package. 5220 * Since this may take a little while, the result will 5221 * be posted back to the given observer. The calling context 5222 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 5223 * 5224 * @param packageName The name of the package whose size information is to be retrieved 5225 * @param userId The user whose size information should be retrieved. 5226 * @param observer An observer callback to get notified when the operation 5227 * is complete. 5228 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 5229 * The observer's callback is invoked with a PackageStats object(containing the 5230 * code, data and cache sizes of the package) and a boolean value representing 5231 * the status of the operation. observer may be null to indicate that 5232 * no callback is desired. 5233 * 5234 * @deprecated use {@link StorageStatsManager} instead. 5235 * @hide 5236 */ 5237 @Deprecated 5238 public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId, 5239 IPackageStatsObserver observer); 5240 5241 /** 5242 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but 5243 * returns the size for the calling user. 5244 * 5245 * @deprecated use {@link StorageStatsManager} instead. 5246 * @hide 5247 */ 5248 @Deprecated 5249 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 5250 getPackageSizeInfoAsUser(packageName, getUserId(), observer); 5251 } 5252 5253 /** 5254 * @deprecated This function no longer does anything; it was an old 5255 * approach to managing preferred activities, which has been superseded 5256 * by (and conflicts with) the modern activity-based preferences. 5257 */ 5258 @Deprecated 5259 public abstract void addPackageToPreferred(String packageName); 5260 5261 /** 5262 * @deprecated This function no longer does anything; it was an old 5263 * approach to managing preferred activities, which has been superseded 5264 * by (and conflicts with) the modern activity-based preferences. 5265 */ 5266 @Deprecated 5267 public abstract void removePackageFromPreferred(String packageName); 5268 5269 /** 5270 * Retrieve the list of all currently configured preferred packages. The 5271 * first package on the list is the most preferred, the last is the least 5272 * preferred. 5273 * 5274 * @param flags Additional option flags to modify the data returned. 5275 * @return A List of PackageInfo objects, one for each preferred 5276 * application, in order of preference. 5277 */ 5278 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags); 5279 5280 /** 5281 * @deprecated This is a protected API that should not have been available 5282 * to third party applications. It is the platform's responsibility for 5283 * assigning preferred activities and this cannot be directly modified. 5284 * 5285 * Add a new preferred activity mapping to the system. This will be used 5286 * to automatically select the given activity component when 5287 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5288 * multiple matching activities and also matches the given filter. 5289 * 5290 * @param filter The set of intents under which this activity will be 5291 * made preferred. 5292 * @param match The IntentFilter match category that this preference 5293 * applies to. 5294 * @param set The set of activities that the user was picking from when 5295 * this preference was made. 5296 * @param activity The component name of the activity that is to be 5297 * preferred. 5298 */ 5299 @Deprecated 5300 public abstract void addPreferredActivity(IntentFilter filter, int match, 5301 ComponentName[] set, ComponentName activity); 5302 5303 /** 5304 * Same as {@link #addPreferredActivity(IntentFilter, int, 5305 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 5306 to. 5307 * @hide 5308 */ 5309 public void addPreferredActivityAsUser(IntentFilter filter, int match, 5310 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5311 throw new RuntimeException("Not implemented. Must override in a subclass."); 5312 } 5313 5314 /** 5315 * @deprecated This is a protected API that should not have been available 5316 * to third party applications. It is the platform's responsibility for 5317 * assigning preferred activities and this cannot be directly modified. 5318 * 5319 * Replaces an existing preferred activity mapping to the system, and if that were not present 5320 * adds a new preferred activity. This will be used 5321 * to automatically select the given activity component when 5322 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5323 * multiple matching activities and also matches the given filter. 5324 * 5325 * @param filter The set of intents under which this activity will be 5326 * made preferred. 5327 * @param match The IntentFilter match category that this preference 5328 * applies to. 5329 * @param set The set of activities that the user was picking from when 5330 * this preference was made. 5331 * @param activity The component name of the activity that is to be 5332 * preferred. 5333 * @hide 5334 */ 5335 @Deprecated 5336 public abstract void replacePreferredActivity(IntentFilter filter, int match, 5337 ComponentName[] set, ComponentName activity); 5338 5339 /** 5340 * @hide 5341 */ 5342 @Deprecated 5343 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 5344 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5345 throw new RuntimeException("Not implemented. Must override in a subclass."); 5346 } 5347 5348 /** 5349 * Remove all preferred activity mappings, previously added with 5350 * {@link #addPreferredActivity}, from the 5351 * system whose activities are implemented in the given package name. 5352 * An application can only clear its own package(s). 5353 * 5354 * @param packageName The name of the package whose preferred activity 5355 * mappings are to be removed. 5356 */ 5357 public abstract void clearPackagePreferredActivities(String packageName); 5358 5359 /** 5360 * Retrieve all preferred activities, previously added with 5361 * {@link #addPreferredActivity}, that are 5362 * currently registered with the system. 5363 * 5364 * @param outFilters A required list in which to place the filters of all of the 5365 * preferred activities. 5366 * @param outActivities A required list in which to place the component names of 5367 * all of the preferred activities. 5368 * @param packageName An optional package in which you would like to limit 5369 * the list. If null, all activities will be returned; if non-null, only 5370 * those activities in the given package are returned. 5371 * 5372 * @return Returns the total number of registered preferred activities 5373 * (the number of distinct IntentFilter records, not the number of unique 5374 * activity components) that were found. 5375 */ 5376 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 5377 @NonNull List<ComponentName> outActivities, String packageName); 5378 5379 /** 5380 * Ask for the set of available 'home' activities and the current explicit 5381 * default, if any. 5382 * @hide 5383 */ 5384 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 5385 5386 /** 5387 * Set the enabled setting for a package component (activity, receiver, service, provider). 5388 * This setting will override any enabled state which may have been set by the component in its 5389 * manifest. 5390 * 5391 * @param componentName The component to enable 5392 * @param newState The new enabled state for the component. 5393 * @param flags Optional behavior flags. 5394 */ 5395 public abstract void setComponentEnabledSetting(ComponentName componentName, 5396 @EnabledState int newState, @EnabledFlags int flags); 5397 5398 /** 5399 * Return the enabled setting for a package component (activity, 5400 * receiver, service, provider). This returns the last value set by 5401 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 5402 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5403 * the value originally specified in the manifest has not been modified. 5404 * 5405 * @param componentName The component to retrieve. 5406 * @return Returns the current enabled state for the component. 5407 */ 5408 public abstract @EnabledState int getComponentEnabledSetting( 5409 ComponentName componentName); 5410 5411 /** 5412 * Set the enabled setting for an application 5413 * This setting will override any enabled state which may have been set by the application in 5414 * its manifest. It also overrides the enabled state set in the manifest for any of the 5415 * application's components. It does not override any enabled state set by 5416 * {@link #setComponentEnabledSetting} for any of the application's components. 5417 * 5418 * @param packageName The package name of the application to enable 5419 * @param newState The new enabled state for the application. 5420 * @param flags Optional behavior flags. 5421 */ 5422 public abstract void setApplicationEnabledSetting(String packageName, 5423 @EnabledState int newState, @EnabledFlags int flags); 5424 5425 /** 5426 * Return the enabled setting for an application. This returns 5427 * the last value set by 5428 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 5429 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5430 * the value originally specified in the manifest has not been modified. 5431 * 5432 * @param packageName The package name of the application to retrieve. 5433 * @return Returns the current enabled state for the application. 5434 * @throws IllegalArgumentException if the named package does not exist. 5435 */ 5436 public abstract @EnabledState int getApplicationEnabledSetting(String packageName); 5437 5438 /** 5439 * Flush the package restrictions for a given user to disk. This forces the package restrictions 5440 * like component and package enabled settings to be written to disk and avoids the delay that 5441 * is otherwise present when changing those settings. 5442 * 5443 * @param userId Ther userId of the user whose restrictions are to be flushed. 5444 * @hide 5445 */ 5446 public abstract void flushPackageRestrictionsAsUser(int userId); 5447 5448 /** 5449 * Puts the package in a hidden state, which is almost like an uninstalled state, 5450 * making the package unavailable, but it doesn't remove the data or the actual 5451 * package file. Application can be unhidden by either resetting the hidden state 5452 * or by installing it, such as with {@link #installExistingPackage(String)} 5453 * @hide 5454 */ 5455 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 5456 UserHandle userHandle); 5457 5458 /** 5459 * Returns the hidden state of a package. 5460 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 5461 * @hide 5462 */ 5463 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 5464 UserHandle userHandle); 5465 5466 /** 5467 * Return whether the device has been booted into safe mode. 5468 */ 5469 public abstract boolean isSafeMode(); 5470 5471 /** 5472 * Adds a listener for permission changes for installed packages. 5473 * 5474 * @param listener The listener to add. 5475 * 5476 * @hide 5477 */ 5478 @SystemApi 5479 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 5480 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5481 5482 /** 5483 * Remvoes a listener for permission changes for installed packages. 5484 * 5485 * @param listener The listener to remove. 5486 * 5487 * @hide 5488 */ 5489 @SystemApi 5490 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 5491 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5492 5493 /** 5494 * Return the {@link KeySet} associated with the String alias for this 5495 * application. 5496 * 5497 * @param alias The alias for a given {@link KeySet} as defined in the 5498 * application's AndroidManifest.xml. 5499 * @hide 5500 */ 5501 public abstract KeySet getKeySetByAlias(String packageName, String alias); 5502 5503 /** Return the signing {@link KeySet} for this application. 5504 * @hide 5505 */ 5506 public abstract KeySet getSigningKeySet(String packageName); 5507 5508 /** 5509 * Return whether the package denoted by packageName has been signed by all 5510 * of the keys specified by the {@link KeySet} ks. This will return true if 5511 * the package has been signed by additional keys (a superset) as well. 5512 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 5513 * @hide 5514 */ 5515 public abstract boolean isSignedBy(String packageName, KeySet ks); 5516 5517 /** 5518 * Return whether the package denoted by packageName has been signed by all 5519 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 5520 * {@link #isSignedBy(String packageName, KeySet ks)}. 5521 * @hide 5522 */ 5523 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 5524 5525 /** 5526 * Puts the package in a suspended state, where attempts at starting activities are denied. 5527 * 5528 * <p>It doesn't remove the data or the actual package file. The application's notifications 5529 * will be hidden, any of its started activities will be stopped and it will not be able to 5530 * show toasts or dialogs or ring the device. When the user tries to launch a suspended app, a 5531 * system dialog with the given {@code dialogMessage} will be shown instead.</p> 5532 * 5533 * <p>The package must already be installed. If the package is uninstalled while suspended 5534 * the package will no longer be suspended. </p> 5535 * 5536 * <p>Optionally, the suspending app can provide extra information in the form of 5537 * {@link PersistableBundle} objects to be shared with the apps being suspended and the 5538 * launcher to support customization that they might need to handle the suspended state. </p> 5539 * 5540 * <p>The caller must hold {@link Manifest.permission#SUSPEND_APPS} or 5541 * {@link Manifest.permission#MANAGE_USERS} to use this api.</p> 5542 * 5543 * @param packageNames The names of the packages to set the suspended status. 5544 * @param suspended If set to {@code true} than the packages will be suspended, if set to 5545 * {@code false}, the packages will be unsuspended. 5546 * @param appExtras An optional {@link PersistableBundle} that the suspending app can provide 5547 * which will be shared with the apps being suspended. Ignored if 5548 * {@code suspended} is false. 5549 * @param launcherExtras An optional {@link PersistableBundle} that the suspending app can 5550 * provide which will be shared with the launcher. Ignored if 5551 * {@code suspended} is false. 5552 * @param dialogMessage The message to be displayed to the user, when they try to launch a 5553 * suspended app. 5554 * 5555 * @return an array of package names for which the suspended status is not set as requested in 5556 * this method. 5557 * 5558 * @hide 5559 */ 5560 @SystemApi 5561 @RequiresPermission(anyOf = {Manifest.permission.SUSPEND_APPS, 5562 Manifest.permission.MANAGE_USERS}) 5563 public String[] setPackagesSuspended(String[] packageNames, boolean suspended, 5564 @Nullable PersistableBundle appExtras, @Nullable PersistableBundle launcherExtras, 5565 String dialogMessage) { 5566 throw new UnsupportedOperationException("setPackagesSuspended not implemented"); 5567 } 5568 5569 /** 5570 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) 5571 * @param packageName The name of the package to get the suspended status of. 5572 * @param userId The user id. 5573 * @return {@code true} if the package is suspended or {@code false} if the package is not 5574 * suspended or could not be found. 5575 * @hide 5576 */ 5577 public abstract boolean isPackageSuspendedForUser(String packageName, int userId); 5578 5579 /** 5580 * Query if an app is currently suspended. 5581 * 5582 * @return {@code true} if the given package is suspended, {@code false} otherwise 5583 * 5584 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) 5585 * @hide 5586 */ 5587 @SystemApi 5588 public boolean isPackageSuspended(String packageName) { 5589 throw new UnsupportedOperationException("isPackageSuspended not implemented"); 5590 } 5591 5592 /** 5593 * Apps can query this to know if they have been suspended. A system app with the permission 5594 * {@code android.permission.SUSPEND_APPS} can put any app on the device into a suspended state. 5595 * 5596 * <p>While in this state, the application's notifications will be hidden, any of its started 5597 * activities will be stopped and it will not be able to show toasts or dialogs or ring the 5598 * device. When the user tries to launch a suspended app, the system will, instead, show a 5599 * dialog to the user informing them that they cannot use this app while it is suspended. 5600 * 5601 * <p>When an app is put into this state, the broadcast action 5602 * {@link Intent#ACTION_MY_PACKAGE_SUSPENDED} will be delivered to any of its broadcast 5603 * receivers that included this action in their intent-filters, <em>including manifest 5604 * receivers.</em> Similarly, a broadcast action {@link Intent#ACTION_MY_PACKAGE_UNSUSPENDED} 5605 * is delivered when a previously suspended app is taken out of this state. 5606 * </p> 5607 * 5608 * @return {@code true} if the calling package has been suspended, {@code false} otherwise. 5609 * 5610 * @see #getSuspendedPackageAppExtras() 5611 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED 5612 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED 5613 */ 5614 public boolean isPackageSuspended() { 5615 throw new UnsupportedOperationException("isPackageSuspended not implemented"); 5616 } 5617 5618 /** 5619 * Retrieve the {@link PersistableBundle} that was passed as {@code appExtras} when the given 5620 * package was suspended. 5621 * 5622 * <p> The caller must hold permission {@link Manifest.permission#SUSPEND_APPS} to use this 5623 * api.</p> 5624 * 5625 * @param packageName The package to retrieve extras for. 5626 * @return The {@code appExtras} for the suspended package. 5627 * 5628 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) 5629 * @hide 5630 */ 5631 @SystemApi 5632 @RequiresPermission(Manifest.permission.SUSPEND_APPS) 5633 public @Nullable PersistableBundle getSuspendedPackageAppExtras(String packageName) { 5634 throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented"); 5635 } 5636 5637 /** 5638 * Set the app extras for a suspended package. This method can be used to update the appExtras 5639 * for a package that was earlier suspended using 5640 * {@link #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, 5641 * String)} 5642 * Does nothing if the given package is not already in a suspended state. 5643 * 5644 * @param packageName The package for which the appExtras need to be updated 5645 * @param appExtras The new appExtras for the given package 5646 * 5647 * @see #setPackagesSuspended(String[], boolean, PersistableBundle, PersistableBundle, String) 5648 * 5649 * @hide 5650 */ 5651 @SystemApi 5652 @RequiresPermission(Manifest.permission.SUSPEND_APPS) 5653 public void setSuspendedPackageAppExtras(String packageName, 5654 @Nullable PersistableBundle appExtras) { 5655 throw new UnsupportedOperationException("setSuspendedPackageAppExtras not implemented"); 5656 } 5657 5658 /** 5659 * Returns any extra information supplied as {@code appExtras} to the system when the calling 5660 * app was suspended. 5661 * 5662 * <p>Note: If no extras were supplied to the system, this method will return {@code null}, even 5663 * when the calling app has been suspended.</p> 5664 * 5665 * @return A {@link Bundle} containing the extras for the app, or {@code null} if the 5666 * package is not currently suspended. 5667 * 5668 * @see #isPackageSuspended() 5669 * @see Intent#ACTION_MY_PACKAGE_UNSUSPENDED 5670 * @see Intent#ACTION_MY_PACKAGE_SUSPENDED 5671 */ 5672 public @Nullable Bundle getSuspendedPackageAppExtras() { 5673 throw new UnsupportedOperationException("getSuspendedPackageAppExtras not implemented"); 5674 } 5675 5676 /** 5677 * Provide a hint of what the {@link ApplicationInfo#category} value should 5678 * be for the given package. 5679 * <p> 5680 * This hint can only be set by the app which installed this package, as 5681 * determined by {@link #getInstallerPackageName(String)}. 5682 * 5683 * @param packageName the package to change the category hint for. 5684 * @param categoryHint the category hint to set. 5685 */ 5686 public abstract void setApplicationCategoryHint(@NonNull String packageName, 5687 @ApplicationInfo.Category int categoryHint); 5688 5689 /** {@hide} */ 5690 public static boolean isMoveStatusFinished(int status) { 5691 return (status < 0 || status > 100); 5692 } 5693 5694 /** {@hide} */ 5695 public static abstract class MoveCallback { 5696 public void onCreated(int moveId, Bundle extras) {} 5697 public abstract void onStatusChanged(int moveId, int status, long estMillis); 5698 } 5699 5700 /** {@hide} */ 5701 public abstract int getMoveStatus(int moveId); 5702 5703 /** {@hide} */ 5704 public abstract void registerMoveCallback(MoveCallback callback, Handler handler); 5705 /** {@hide} */ 5706 public abstract void unregisterMoveCallback(MoveCallback callback); 5707 5708 /** {@hide} */ 5709 public abstract int movePackage(String packageName, VolumeInfo vol); 5710 /** {@hide} */ 5711 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app); 5712 /** {@hide} */ 5713 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app); 5714 5715 /** {@hide} */ 5716 public abstract int movePrimaryStorage(VolumeInfo vol); 5717 /** {@hide} */ 5718 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 5719 /** {@hide} */ 5720 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 5721 5722 /** 5723 * Returns the device identity that verifiers can use to associate their scheme to a particular 5724 * device. This should not be used by anything other than a package verifier. 5725 * 5726 * @return identity that uniquely identifies current device 5727 * @hide 5728 */ 5729 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 5730 5731 /** 5732 * Returns true if the device is upgrading, such as first boot after OTA. 5733 * 5734 * @hide 5735 */ 5736 public abstract boolean isUpgrade(); 5737 5738 /** 5739 * Return interface that offers the ability to install, upgrade, and remove 5740 * applications on the device. 5741 */ 5742 public abstract @NonNull PackageInstaller getPackageInstaller(); 5743 5744 /** 5745 * Adds a {@code CrossProfileIntentFilter}. After calling this method all 5746 * intents sent from the user with id sourceUserId can also be be resolved 5747 * by activities in the user with id targetUserId if they match the 5748 * specified intent filter. 5749 * 5750 * @param filter The {@link IntentFilter} the intent has to match 5751 * @param sourceUserId The source user id. 5752 * @param targetUserId The target user id. 5753 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 5754 * {@link #ONLY_IF_NO_MATCH_FOUND}. 5755 * @hide 5756 */ 5757 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 5758 int targetUserId, int flags); 5759 5760 /** 5761 * Clearing {@code CrossProfileIntentFilter}s which have the specified user 5762 * as their source, and have been set by the app calling this method. 5763 * 5764 * @param sourceUserId The source user id. 5765 * @hide 5766 */ 5767 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 5768 5769 /** 5770 * @hide 5771 */ 5772 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 5773 5774 /** 5775 * @hide 5776 */ 5777 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 5778 5779 /** {@hide} */ 5780 public abstract boolean isPackageAvailable(String packageName); 5781 5782 /** {@hide} */ 5783 public static String installStatusToString(int status, String msg) { 5784 final String str = installStatusToString(status); 5785 if (msg != null) { 5786 return str + ": " + msg; 5787 } else { 5788 return str; 5789 } 5790 } 5791 5792 /** {@hide} */ 5793 public static String installStatusToString(int status) { 5794 switch (status) { 5795 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 5796 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 5797 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 5798 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 5799 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 5800 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 5801 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 5802 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 5803 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 5804 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 5805 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 5806 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 5807 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 5808 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 5809 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 5810 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 5811 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 5812 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 5813 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 5814 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 5815 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 5816 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 5817 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 5818 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 5819 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 5820 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 5821 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 5822 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 5823 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 5824 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 5825 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 5826 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 5827 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 5828 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 5829 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 5830 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 5831 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 5832 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 5833 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 5834 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 5835 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 5836 case INSTALL_FAILED_BAD_DEX_METADATA: 5837 return "INSTALL_FAILED_BAD_DEX_METADATA"; 5838 default: return Integer.toString(status); 5839 } 5840 } 5841 5842 /** {@hide} */ 5843 public static int installStatusToPublicStatus(int status) { 5844 switch (status) { 5845 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5846 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5847 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5848 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 5849 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5850 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5851 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5852 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5853 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5854 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5855 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5856 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 5857 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5858 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5859 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5860 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 5861 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5862 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5863 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 5864 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 5865 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5866 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 5867 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 5868 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5869 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5870 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5871 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5872 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5873 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 5874 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 5875 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5876 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5877 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 5878 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 5879 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 5880 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 5881 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 5882 case INSTALL_FAILED_BAD_DEX_METADATA: return PackageInstaller.STATUS_FAILURE_INVALID; 5883 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5884 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5885 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5886 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5887 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5888 default: return PackageInstaller.STATUS_FAILURE; 5889 } 5890 } 5891 5892 /** {@hide} */ 5893 public static String deleteStatusToString(int status, String msg) { 5894 final String str = deleteStatusToString(status); 5895 if (msg != null) { 5896 return str + ": " + msg; 5897 } else { 5898 return str; 5899 } 5900 } 5901 5902 /** {@hide} */ 5903 public static String deleteStatusToString(int status) { 5904 switch (status) { 5905 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 5906 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 5907 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 5908 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 5909 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 5910 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 5911 case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY"; 5912 default: return Integer.toString(status); 5913 } 5914 } 5915 5916 /** {@hide} */ 5917 public static int deleteStatusToPublicStatus(int status) { 5918 switch (status) { 5919 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5920 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5921 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5922 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5923 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5924 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5925 case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5926 default: return PackageInstaller.STATUS_FAILURE; 5927 } 5928 } 5929 5930 /** {@hide} */ 5931 public static String permissionFlagToString(int flag) { 5932 switch (flag) { 5933 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 5934 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 5935 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 5936 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 5937 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE"; 5938 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 5939 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 5940 default: return Integer.toString(flag); 5941 } 5942 } 5943 5944 /** {@hide} */ 5945 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 5946 private final IPackageDeleteObserver mLegacy; 5947 5948 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 5949 mLegacy = legacy; 5950 } 5951 5952 @Override 5953 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 5954 if (mLegacy == null) return; 5955 try { 5956 mLegacy.packageDeleted(basePackageName, returnCode); 5957 } catch (RemoteException ignored) { 5958 } 5959 } 5960 } 5961 5962 /** 5963 * Return the install reason that was recorded when a package was first 5964 * installed for a specific user. Requesting the install reason for another 5965 * user will require the permission INTERACT_ACROSS_USERS_FULL. 5966 * 5967 * @param packageName The package for which to retrieve the install reason 5968 * @param user The user for whom to retrieve the install reason 5969 * @return The install reason. If the package is not installed for the given 5970 * user, {@code INSTALL_REASON_UNKNOWN} is returned. 5971 * @hide 5972 */ 5973 @TestApi 5974 public abstract @InstallReason int getInstallReason(String packageName, 5975 @NonNull UserHandle user); 5976 5977 /** 5978 * Checks whether the calling package is allowed to request package installs through package 5979 * installer. Apps are encouraged to call this API before launching the package installer via 5980 * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the 5981 * user can explicitly choose what external sources they trust to install apps on the device. 5982 * If this API returns false, the install request will be blocked by the package installer and 5983 * a dialog will be shown to the user with an option to launch settings to change their 5984 * preference. An application must target Android O or higher and declare permission 5985 * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this API. 5986 * 5987 * @return true if the calling package is trusted by the user to request install packages on 5988 * the device, false otherwise. 5989 * @see android.content.Intent#ACTION_INSTALL_PACKAGE 5990 * @see android.provider.Settings#ACTION_MANAGE_UNKNOWN_APP_SOURCES 5991 */ 5992 public abstract boolean canRequestPackageInstalls(); 5993 5994 /** 5995 * Return the {@link ComponentName} of the activity providing Settings for the Instant App 5996 * resolver. 5997 * 5998 * @see {@link android.content.Intent#ACTION_INSTANT_APP_RESOLVER_SETTINGS} 5999 * @hide 6000 */ 6001 @SystemApi 6002 public abstract ComponentName getInstantAppResolverSettingsComponent(); 6003 6004 /** 6005 * Return the {@link ComponentName} of the activity responsible for installing instant 6006 * applications. 6007 * 6008 * @see {@link android.content.Intent#ACTION_INSTALL_INSTANT_APP_PACKAGE} 6009 * @hide 6010 */ 6011 @SystemApi 6012 public abstract ComponentName getInstantAppInstallerComponent(); 6013 6014 /** 6015 * Return the Android Id for a given Instant App. 6016 * 6017 * @see {@link android.provider.Settings.Secure#ANDROID_ID} 6018 * @hide 6019 */ 6020 public abstract String getInstantAppAndroidId(String packageName, @NonNull UserHandle user); 6021 6022 /** 6023 * Callback use to notify the callers of module registration that the operation 6024 * has finished. 6025 * 6026 * @hide 6027 */ 6028 @SystemApi 6029 public static abstract class DexModuleRegisterCallback { 6030 public abstract void onDexModuleRegistered(String dexModulePath, boolean success, 6031 String message); 6032 } 6033 6034 /** 6035 * Register an application dex module with the package manager. 6036 * The package manager will keep track of the given module for future optimizations. 6037 * 6038 * Dex module optimizations will disable the classpath checking at runtime. The client bares 6039 * the responsibility to ensure that the static assumptions on classes in the optimized code 6040 * hold at runtime (e.g. there's no duplicate classes in the classpath). 6041 * 6042 * Note that the package manager already keeps track of dex modules loaded with 6043 * {@link dalvik.system.DexClassLoader} and {@link dalvik.system.PathClassLoader}. 6044 * This can be called for an eager registration. 6045 * 6046 * The call might take a while and the results will be posted on the main thread, using 6047 * the given callback. 6048 * 6049 * If the module is intended to be shared with other apps, make sure that the file 6050 * permissions allow for it. 6051 * If at registration time the permissions allow for others to read it, the module would 6052 * be marked as a shared module which might undergo a different optimization strategy. 6053 * (usually shared modules will generated larger optimizations artifacts, 6054 * taking more disk space). 6055 * 6056 * @param dexModulePath the absolute path of the dex module. 6057 * @param callback if not null, {@link DexModuleRegisterCallback#onDexModuleRegistered} will 6058 * be called once the registration finishes. 6059 * 6060 * @hide 6061 */ 6062 @SystemApi 6063 public abstract void registerDexModule(String dexModulePath, 6064 @Nullable DexModuleRegisterCallback callback); 6065 6066 /** 6067 * Returns the {@link ArtManager} associated with this package manager. 6068 * 6069 * @hide 6070 */ 6071 @SystemApi 6072 public @NonNull ArtManager getArtManager() { 6073 throw new UnsupportedOperationException("getArtManager not implemented in subclass"); 6074 } 6075 6076 /** 6077 * Sets or clears the harmful app warning details for the given app. 6078 * 6079 * When set, any attempt to launch an activity in this package will be intercepted and a 6080 * warning dialog will be shown to the user instead, with the given warning. The user 6081 * will have the option to proceed with the activity launch, or to uninstall the application. 6082 * 6083 * @param packageName The full name of the package to warn on. 6084 * @param warning A warning string to display to the user describing the threat posed by the 6085 * application, or null to clear the warning. 6086 * 6087 * @hide 6088 */ 6089 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS) 6090 @SystemApi 6091 public void setHarmfulAppWarning(@NonNull String packageName, @Nullable CharSequence warning) { 6092 throw new UnsupportedOperationException("setHarmfulAppWarning not implemented in subclass"); 6093 } 6094 6095 /** 6096 * Returns the harmful app warning string for the given app, or null if there is none set. 6097 * 6098 * @param packageName The full name of the desired package. 6099 * 6100 * @hide 6101 */ 6102 @RequiresPermission(Manifest.permission.SET_HARMFUL_APP_WARNINGS) 6103 @Nullable 6104 @SystemApi 6105 public CharSequence getHarmfulAppWarning(@NonNull String packageName) { 6106 throw new UnsupportedOperationException("getHarmfulAppWarning not implemented in subclass"); 6107 } 6108 6109 /** @hide */ 6110 @IntDef(prefix = { "CERT_INPUT_" }, value = { 6111 CERT_INPUT_RAW_X509, 6112 CERT_INPUT_SHA256 6113 }) 6114 @Retention(RetentionPolicy.SOURCE) 6115 public @interface CertificateInputType {} 6116 6117 /** 6118 * Certificate input bytes: the input bytes represent an encoded X.509 Certificate which could 6119 * be generated using an {@code CertificateFactory} 6120 */ 6121 public static final int CERT_INPUT_RAW_X509 = 0; 6122 6123 /** 6124 * Certificate input bytes: the input bytes represent the SHA256 output of an encoded X.509 6125 * Certificate. 6126 */ 6127 public static final int CERT_INPUT_SHA256 = 1; 6128 6129 /** 6130 * Searches the set of signing certificates by which the given package has proven to have been 6131 * signed. This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES} 6132 * since it takes into account the possibility of signing certificate rotation, except in the 6133 * case of packages that are signed by multiple certificates, for which signing certificate 6134 * rotation is not supported. 6135 * 6136 * @param packageName package whose signing certificates to check 6137 * @param certificate signing certificate for which to search 6138 * @param type representation of the {@code certificate} 6139 * @return true if this package was or is signed by exactly the certificate {@code certificate} 6140 */ 6141 public boolean hasSigningCertificate( 6142 String packageName, byte[] certificate, @CertificateInputType int type) { 6143 throw new UnsupportedOperationException( 6144 "hasSigningCertificate not implemented in subclass"); 6145 } 6146 6147 /** 6148 * Searches the set of signing certificates by which the given uid has proven to have been 6149 * signed. This should be used instead of {@code getPackageInfo} with {@code GET_SIGNATURES} 6150 * since it takes into account the possibility of signing certificate rotation, except in the 6151 * case of packages that are signed by multiple certificates, for which signing certificate 6152 * rotation is not supported. 6153 * 6154 * @param uid package whose signing certificates to check 6155 * @param certificate signing certificate for which to search 6156 * @param type representation of the {@code certificate} 6157 * @return true if this package was or is signed by exactly the certificate {@code certificate} 6158 */ 6159 public boolean hasSigningCertificate( 6160 int uid, byte[] certificate, @CertificateInputType int type) { 6161 throw new UnsupportedOperationException( 6162 "hasSigningCertificate not implemented in subclass"); 6163 } 6164 6165 /** 6166 * @return the system defined text classifier package name, or null if there's none. 6167 * 6168 * @hide 6169 */ 6170 public String getSystemTextClassifierPackageName() { 6171 throw new UnsupportedOperationException( 6172 "getSystemTextClassifierPackageName not implemented in subclass"); 6173 } 6174 6175 /** 6176 * @return whether a given package's state is protected, e.g. package cannot be disabled, 6177 * suspended, hidden or force stopped. 6178 * 6179 * @hide 6180 */ 6181 public boolean isPackageStateProtected(String packageName, int userId) { 6182 throw new UnsupportedOperationException( 6183 "isPackageStateProtected not implemented in subclass"); 6184 } 6185 6186} 6187