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