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