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