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