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