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