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