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