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