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