PackageManager.java revision 022b8eaa1def76dca0ac9b409065588f55c71597
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 * Error code that is passed to the {@link IPackageMoveObserver} if system does not allow 1349 * non-system apps to be moved to internal storage. 1350 * 1351 * @hide 1352 */ 1353 public static final int MOVE_FAILED_3RD_PARTY_NOT_ALLOWED_ON_INTERNAL = -9; 1354 1355 /** 1356 * Flag parameter for {@link #movePackage} to indicate that 1357 * the package should be moved to internal storage if its 1358 * been installed on external media. 1359 * @hide 1360 */ 1361 @Deprecated 1362 public static final int MOVE_INTERNAL = 0x00000001; 1363 1364 /** 1365 * Flag parameter for {@link #movePackage} to indicate that 1366 * the package should be moved to external media. 1367 * @hide 1368 */ 1369 @Deprecated 1370 public static final int MOVE_EXTERNAL_MEDIA = 0x00000002; 1371 1372 /** {@hide} */ 1373 public static final String EXTRA_MOVE_ID = "android.content.pm.extra.MOVE_ID"; 1374 1375 /** 1376 * Usable by the required verifier as the {@code verificationCode} argument 1377 * for {@link PackageManager#verifyPendingInstall} to indicate that it will 1378 * allow the installation to proceed without any of the optional verifiers 1379 * needing to vote. 1380 * 1381 * @hide 1382 */ 1383 public static final int VERIFICATION_ALLOW_WITHOUT_SUFFICIENT = 2; 1384 1385 /** 1386 * Used as the {@code verificationCode} argument for 1387 * {@link PackageManager#verifyPendingInstall} to indicate that the calling 1388 * package verifier allows the installation to proceed. 1389 */ 1390 public static final int VERIFICATION_ALLOW = 1; 1391 1392 /** 1393 * Used as the {@code verificationCode} argument for 1394 * {@link PackageManager#verifyPendingInstall} to indicate the calling 1395 * package verifier does not vote to allow the installation to proceed. 1396 */ 1397 public static final int VERIFICATION_REJECT = -1; 1398 1399 /** 1400 * Used as the {@code verificationCode} argument for 1401 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 1402 * IntentFilter Verifier confirms that the IntentFilter is verified. 1403 * 1404 * @hide 1405 */ 1406 @SystemApi 1407 public static final int INTENT_FILTER_VERIFICATION_SUCCESS = 1; 1408 1409 /** 1410 * Used as the {@code verificationCode} argument for 1411 * {@link PackageManager#verifyIntentFilter} to indicate that the calling 1412 * IntentFilter Verifier confirms that the IntentFilter is NOT verified. 1413 * 1414 * @hide 1415 */ 1416 @SystemApi 1417 public static final int INTENT_FILTER_VERIFICATION_FAILURE = -1; 1418 1419 /** 1420 * Internal status code to indicate that an IntentFilter verification result is not specified. 1421 * 1422 * @hide 1423 */ 1424 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED = 0; 1425 1426 /** 1427 * Used as the {@code status} argument for 1428 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User 1429 * will always be prompted the Intent Disambiguation Dialog if there are two 1430 * or more Intent resolved for the IntentFilter's domain(s). 1431 * 1432 * @hide 1433 */ 1434 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK = 1; 1435 1436 /** 1437 * Used as the {@code status} argument for 1438 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User 1439 * will never be prompted the Intent Disambiguation Dialog if there are two 1440 * or more resolution of the Intent. The default App for the domain(s) 1441 * specified in the IntentFilter will also ALWAYS be used. 1442 * 1443 * @hide 1444 */ 1445 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS = 2; 1446 1447 /** 1448 * Used as the {@code status} argument for 1449 * {@link #updateIntentVerificationStatusAsUser} to indicate that the User 1450 * may be prompted the Intent Disambiguation Dialog if there are two or more 1451 * Intent resolved. The default App for the domain(s) specified in the 1452 * IntentFilter will also NEVER be presented to the User. 1453 * 1454 * @hide 1455 */ 1456 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER = 3; 1457 1458 /** 1459 * Used as the {@code status} argument for 1460 * {@link #updateIntentVerificationStatusAsUser} to indicate that this app 1461 * should always be considered as an ambiguous candidate for handling the 1462 * matching Intent even if there are other candidate apps in the "always" 1463 * state. Put another way: if there are any 'always ask' apps in a set of 1464 * more than one candidate app, then a disambiguation is *always* presented 1465 * even if there is another candidate app with the 'always' state. 1466 * 1467 * @hide 1468 */ 1469 public static final int INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS_ASK = 4; 1470 1471 /** 1472 * Can be used as the {@code millisecondsToDelay} argument for 1473 * {@link PackageManager#extendVerificationTimeout}. This is the 1474 * maximum time {@code PackageManager} waits for the verification 1475 * agent to return (in milliseconds). 1476 */ 1477 public static final long MAXIMUM_VERIFICATION_TIMEOUT = 60*60*1000; 1478 1479 /** 1480 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: The device's 1481 * audio pipeline is low-latency, more suitable for audio applications sensitive to delays or 1482 * lag in sound input or output. 1483 */ 1484 @SdkConstant(SdkConstantType.FEATURE) 1485 public static final String FEATURE_AUDIO_LOW_LATENCY = "android.hardware.audio.low_latency"; 1486 1487 /** 1488 * Feature for {@link #getSystemAvailableFeatures} and 1489 * {@link #hasSystemFeature}: The device includes at least one form of audio 1490 * output, such as speakers, audio jack or streaming over bluetooth 1491 */ 1492 @SdkConstant(SdkConstantType.FEATURE) 1493 public static final String FEATURE_AUDIO_OUTPUT = "android.hardware.audio.output"; 1494 1495 /** 1496 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1497 * The device has professional audio level of functionality and performance. 1498 */ 1499 @SdkConstant(SdkConstantType.FEATURE) 1500 public static final String FEATURE_AUDIO_PRO = "android.hardware.audio.pro"; 1501 1502 /** 1503 * Feature for {@link #getSystemAvailableFeatures} and 1504 * {@link #hasSystemFeature}: The device is capable of communicating with 1505 * other devices via Bluetooth. 1506 */ 1507 @SdkConstant(SdkConstantType.FEATURE) 1508 public static final String FEATURE_BLUETOOTH = "android.hardware.bluetooth"; 1509 1510 /** 1511 * Feature for {@link #getSystemAvailableFeatures} and 1512 * {@link #hasSystemFeature}: The device is capable of communicating with 1513 * other devices via Bluetooth Low Energy radio. 1514 */ 1515 @SdkConstant(SdkConstantType.FEATURE) 1516 public static final String FEATURE_BLUETOOTH_LE = "android.hardware.bluetooth_le"; 1517 1518 /** 1519 * Feature for {@link #getSystemAvailableFeatures} and 1520 * {@link #hasSystemFeature}: The device has a camera facing away 1521 * from the screen. 1522 */ 1523 @SdkConstant(SdkConstantType.FEATURE) 1524 public static final String FEATURE_CAMERA = "android.hardware.camera"; 1525 1526 /** 1527 * Feature for {@link #getSystemAvailableFeatures} and 1528 * {@link #hasSystemFeature}: The device's camera supports auto-focus. 1529 */ 1530 @SdkConstant(SdkConstantType.FEATURE) 1531 public static final String FEATURE_CAMERA_AUTOFOCUS = "android.hardware.camera.autofocus"; 1532 1533 /** 1534 * Feature for {@link #getSystemAvailableFeatures} and 1535 * {@link #hasSystemFeature}: The device has at least one camera pointing in 1536 * some direction, or can support an external camera being connected to it. 1537 */ 1538 @SdkConstant(SdkConstantType.FEATURE) 1539 public static final String FEATURE_CAMERA_ANY = "android.hardware.camera.any"; 1540 1541 /** 1542 * Feature for {@link #getSystemAvailableFeatures} and 1543 * {@link #hasSystemFeature}: The device can support having an external camera connected to it. 1544 * The external camera may not always be connected or available to applications to use. 1545 */ 1546 @SdkConstant(SdkConstantType.FEATURE) 1547 public static final String FEATURE_CAMERA_EXTERNAL = "android.hardware.camera.external"; 1548 1549 /** 1550 * Feature for {@link #getSystemAvailableFeatures} and 1551 * {@link #hasSystemFeature}: The device's camera supports flash. 1552 */ 1553 @SdkConstant(SdkConstantType.FEATURE) 1554 public static final String FEATURE_CAMERA_FLASH = "android.hardware.camera.flash"; 1555 1556 /** 1557 * Feature for {@link #getSystemAvailableFeatures} and 1558 * {@link #hasSystemFeature}: The device has a front facing camera. 1559 */ 1560 @SdkConstant(SdkConstantType.FEATURE) 1561 public static final String FEATURE_CAMERA_FRONT = "android.hardware.camera.front"; 1562 1563 /** 1564 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1565 * of the cameras on the device supports the 1566 * {@link android.hardware.camera2.CameraCharacteristics#INFO_SUPPORTED_HARDWARE_LEVEL full hardware} 1567 * capability level. 1568 */ 1569 @SdkConstant(SdkConstantType.FEATURE) 1570 public static final String FEATURE_CAMERA_LEVEL_FULL = "android.hardware.camera.level.full"; 1571 1572 /** 1573 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1574 * of the cameras on the device supports the 1575 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR manual sensor} 1576 * capability level. 1577 */ 1578 @SdkConstant(SdkConstantType.FEATURE) 1579 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR = 1580 "android.hardware.camera.capability.manual_sensor"; 1581 1582 /** 1583 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1584 * of the cameras on the device supports the 1585 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING manual post-processing} 1586 * capability level. 1587 */ 1588 @SdkConstant(SdkConstantType.FEATURE) 1589 public static final String FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING = 1590 "android.hardware.camera.capability.manual_post_processing"; 1591 1592 /** 1593 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: At least one 1594 * of the cameras on the device supports the 1595 * {@link android.hardware.camera2.CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_RAW RAW} 1596 * capability level. 1597 */ 1598 @SdkConstant(SdkConstantType.FEATURE) 1599 public static final String FEATURE_CAMERA_CAPABILITY_RAW = 1600 "android.hardware.camera.capability.raw"; 1601 1602 /** 1603 * Feature for {@link #getSystemAvailableFeatures} and 1604 * {@link #hasSystemFeature}: The device is capable of communicating with 1605 * consumer IR devices. 1606 */ 1607 @SdkConstant(SdkConstantType.FEATURE) 1608 public static final String FEATURE_CONSUMER_IR = "android.hardware.consumerir"; 1609 1610 /** 1611 * Feature for {@link #getSystemAvailableFeatures} and 1612 * {@link #hasSystemFeature}: The device supports one or more methods of 1613 * reporting current location. 1614 */ 1615 @SdkConstant(SdkConstantType.FEATURE) 1616 public static final String FEATURE_LOCATION = "android.hardware.location"; 1617 1618 /** 1619 * Feature for {@link #getSystemAvailableFeatures} and 1620 * {@link #hasSystemFeature}: The device has a Global Positioning System 1621 * receiver and can report precise location. 1622 */ 1623 @SdkConstant(SdkConstantType.FEATURE) 1624 public static final String FEATURE_LOCATION_GPS = "android.hardware.location.gps"; 1625 1626 /** 1627 * Feature for {@link #getSystemAvailableFeatures} and 1628 * {@link #hasSystemFeature}: The device can report location with coarse 1629 * accuracy using a network-based geolocation system. 1630 */ 1631 @SdkConstant(SdkConstantType.FEATURE) 1632 public static final String FEATURE_LOCATION_NETWORK = "android.hardware.location.network"; 1633 1634 /** 1635 * Feature for {@link #getSystemAvailableFeatures} and 1636 * {@link #hasSystemFeature}: The device can record audio via a 1637 * microphone. 1638 */ 1639 @SdkConstant(SdkConstantType.FEATURE) 1640 public static final String FEATURE_MICROPHONE = "android.hardware.microphone"; 1641 1642 /** 1643 * Feature for {@link #getSystemAvailableFeatures} and 1644 * {@link #hasSystemFeature}: The device can communicate using Near-Field 1645 * Communications (NFC). 1646 */ 1647 @SdkConstant(SdkConstantType.FEATURE) 1648 public static final String FEATURE_NFC = "android.hardware.nfc"; 1649 1650 /** 1651 * Feature for {@link #getSystemAvailableFeatures} and 1652 * {@link #hasSystemFeature}: The device supports host- 1653 * based NFC card emulation. 1654 * 1655 * TODO remove when depending apps have moved to new constant. 1656 * @hide 1657 * @deprecated 1658 */ 1659 @Deprecated 1660 @SdkConstant(SdkConstantType.FEATURE) 1661 public static final String FEATURE_NFC_HCE = "android.hardware.nfc.hce"; 1662 1663 /** 1664 * Feature for {@link #getSystemAvailableFeatures} and 1665 * {@link #hasSystemFeature}: The device supports host- 1666 * based NFC card emulation. 1667 */ 1668 @SdkConstant(SdkConstantType.FEATURE) 1669 public static final String FEATURE_NFC_HOST_CARD_EMULATION = "android.hardware.nfc.hce"; 1670 1671 /** 1672 * Feature for {@link #getSystemAvailableFeatures} and 1673 * {@link #hasSystemFeature}: The device supports host- 1674 * based NFC-F card emulation. 1675 */ 1676 @SdkConstant(SdkConstantType.FEATURE) 1677 public static final String FEATURE_NFC_HOST_CARD_EMULATION_NFCF = "android.hardware.nfc.hcef"; 1678 1679 /** 1680 * Feature for {@link #getSystemAvailableFeatures} and 1681 * {@link #hasSystemFeature}: The device supports the OpenGL ES 1682 * <a href="http://www.khronos.org/registry/gles/extensions/ANDROID/ANDROID_extension_pack_es31a.txt"> 1683 * Android Extension Pack</a>. 1684 */ 1685 @SdkConstant(SdkConstantType.FEATURE) 1686 public static final String FEATURE_OPENGLES_EXTENSION_PACK = "android.hardware.opengles.aep"; 1687 1688 /** 1689 * Feature for {@link #getSystemAvailableFeatures} and 1690 * {@link #hasSystemFeature(String, int)}: If this feature is supported, the Vulkan native API 1691 * will enumerate at least one {@code VkPhysicalDevice}, and the feature version will indicate 1692 * what level of optional hardware features limits it supports. 1693 * <p> 1694 * Level 0 includes the base Vulkan requirements as well as: 1695 * <ul><li>{@code VkPhysicalDeviceFeatures::textureCompressionETC2}</li></ul> 1696 * <p> 1697 * Level 1 additionally includes: 1698 * <ul> 1699 * <li>{@code VkPhysicalDeviceFeatures::fullDrawIndexUint32}</li> 1700 * <li>{@code VkPhysicalDeviceFeatures::imageCubeArray}</li> 1701 * <li>{@code VkPhysicalDeviceFeatures::independentBlend}</li> 1702 * <li>{@code VkPhysicalDeviceFeatures::geometryShader}</li> 1703 * <li>{@code VkPhysicalDeviceFeatures::tessellationShader}</li> 1704 * <li>{@code VkPhysicalDeviceFeatures::sampleRateShading}</li> 1705 * <li>{@code VkPhysicalDeviceFeatures::textureCompressionASTC_LDR}</li> 1706 * <li>{@code VkPhysicalDeviceFeatures::fragmentStoresAndAtomics}</li> 1707 * <li>{@code VkPhysicalDeviceFeatures::shaderImageGatherExtended}</li> 1708 * <li>{@code VkPhysicalDeviceFeatures::shaderUniformBufferArrayDynamicIndexing}</li> 1709 * <li>{@code VkPhysicalDeviceFeatures::shaderSampledImageArrayDynamicIndexing}</li> 1710 * </ul> 1711 */ 1712 @SdkConstant(SdkConstantType.FEATURE) 1713 public static final String FEATURE_VULKAN_HARDWARE_LEVEL = "android.hardware.vulkan.level"; 1714 1715 /** 1716 * Feature for {@link #getSystemAvailableFeatures} and 1717 * {@link #hasSystemFeature(String, int)}: The version of this feature indicates the highest 1718 * {@code VkPhysicalDeviceProperties::apiVersion} supported by the physical devices that support 1719 * the hardware level indicated by {@link #FEATURE_VULKAN_HARDWARE_LEVEL}. The feature version 1720 * uses the same encoding as Vulkan version numbers: 1721 * <ul> 1722 * <li>Major version number in bits 31-22</li> 1723 * <li>Minor version number in bits 21-12</li> 1724 * <li>Patch version number in bits 11-0</li> 1725 * </ul> 1726 */ 1727 @SdkConstant(SdkConstantType.FEATURE) 1728 public static final String FEATURE_VULKAN_HARDWARE_VERSION = "android.hardware.vulkan.version"; 1729 1730 /** 1731 * Feature for {@link #getSystemAvailableFeatures} and 1732 * {@link #hasSystemFeature}: The device includes an accelerometer. 1733 */ 1734 @SdkConstant(SdkConstantType.FEATURE) 1735 public static final String FEATURE_SENSOR_ACCELEROMETER = "android.hardware.sensor.accelerometer"; 1736 1737 /** 1738 * Feature for {@link #getSystemAvailableFeatures} and 1739 * {@link #hasSystemFeature}: The device includes a barometer (air 1740 * pressure sensor.) 1741 */ 1742 @SdkConstant(SdkConstantType.FEATURE) 1743 public static final String FEATURE_SENSOR_BAROMETER = "android.hardware.sensor.barometer"; 1744 1745 /** 1746 * Feature for {@link #getSystemAvailableFeatures} and 1747 * {@link #hasSystemFeature}: The device includes a magnetometer (compass). 1748 */ 1749 @SdkConstant(SdkConstantType.FEATURE) 1750 public static final String FEATURE_SENSOR_COMPASS = "android.hardware.sensor.compass"; 1751 1752 /** 1753 * Feature for {@link #getSystemAvailableFeatures} and 1754 * {@link #hasSystemFeature}: The device includes a gyroscope. 1755 */ 1756 @SdkConstant(SdkConstantType.FEATURE) 1757 public static final String FEATURE_SENSOR_GYROSCOPE = "android.hardware.sensor.gyroscope"; 1758 1759 /** 1760 * Feature for {@link #getSystemAvailableFeatures} and 1761 * {@link #hasSystemFeature}: The device includes a light sensor. 1762 */ 1763 @SdkConstant(SdkConstantType.FEATURE) 1764 public static final String FEATURE_SENSOR_LIGHT = "android.hardware.sensor.light"; 1765 1766 /** 1767 * Feature for {@link #getSystemAvailableFeatures} and 1768 * {@link #hasSystemFeature}: The device includes a proximity sensor. 1769 */ 1770 @SdkConstant(SdkConstantType.FEATURE) 1771 public static final String FEATURE_SENSOR_PROXIMITY = "android.hardware.sensor.proximity"; 1772 1773 /** 1774 * Feature for {@link #getSystemAvailableFeatures} and 1775 * {@link #hasSystemFeature}: The device includes a hardware step counter. 1776 */ 1777 @SdkConstant(SdkConstantType.FEATURE) 1778 public static final String FEATURE_SENSOR_STEP_COUNTER = "android.hardware.sensor.stepcounter"; 1779 1780 /** 1781 * Feature for {@link #getSystemAvailableFeatures} and 1782 * {@link #hasSystemFeature}: The device includes a hardware step detector. 1783 */ 1784 @SdkConstant(SdkConstantType.FEATURE) 1785 public static final String FEATURE_SENSOR_STEP_DETECTOR = "android.hardware.sensor.stepdetector"; 1786 1787 /** 1788 * Feature for {@link #getSystemAvailableFeatures} and 1789 * {@link #hasSystemFeature}: The device includes a heart rate monitor. 1790 */ 1791 @SdkConstant(SdkConstantType.FEATURE) 1792 public static final String FEATURE_SENSOR_HEART_RATE = "android.hardware.sensor.heartrate"; 1793 1794 /** 1795 * Feature for {@link #getSystemAvailableFeatures} and 1796 * {@link #hasSystemFeature}: The heart rate sensor on this device is an Electrocardiogram. 1797 */ 1798 @SdkConstant(SdkConstantType.FEATURE) 1799 public static final String FEATURE_SENSOR_HEART_RATE_ECG = 1800 "android.hardware.sensor.heartrate.ecg"; 1801 1802 /** 1803 * Feature for {@link #getSystemAvailableFeatures} and 1804 * {@link #hasSystemFeature}: The device includes a relative humidity sensor. 1805 */ 1806 @SdkConstant(SdkConstantType.FEATURE) 1807 public static final String FEATURE_SENSOR_RELATIVE_HUMIDITY = 1808 "android.hardware.sensor.relative_humidity"; 1809 1810 /** 1811 * Feature for {@link #getSystemAvailableFeatures} and 1812 * {@link #hasSystemFeature}: The device includes an ambient temperature sensor. 1813 */ 1814 @SdkConstant(SdkConstantType.FEATURE) 1815 public static final String FEATURE_SENSOR_AMBIENT_TEMPERATURE = 1816 "android.hardware.sensor.ambient_temperature"; 1817 1818 /** 1819 * Feature for {@link #getSystemAvailableFeatures} and 1820 * {@link #hasSystemFeature}: The device supports high fidelity sensor processing 1821 * capabilities. 1822 */ 1823 @SdkConstant(SdkConstantType.FEATURE) 1824 public static final String FEATURE_HIFI_SENSORS = 1825 "android.hardware.sensor.hifi_sensors"; 1826 1827 /** 1828 * Feature for {@link #getSystemAvailableFeatures} and 1829 * {@link #hasSystemFeature}: The device has a telephony radio with data 1830 * communication support. 1831 */ 1832 @SdkConstant(SdkConstantType.FEATURE) 1833 public static final String FEATURE_TELEPHONY = "android.hardware.telephony"; 1834 1835 /** 1836 * Feature for {@link #getSystemAvailableFeatures} and 1837 * {@link #hasSystemFeature}: The device has a CDMA telephony stack. 1838 */ 1839 @SdkConstant(SdkConstantType.FEATURE) 1840 public static final String FEATURE_TELEPHONY_CDMA = "android.hardware.telephony.cdma"; 1841 1842 /** 1843 * Feature for {@link #getSystemAvailableFeatures} and 1844 * {@link #hasSystemFeature}: The device has a GSM telephony stack. 1845 */ 1846 @SdkConstant(SdkConstantType.FEATURE) 1847 public static final String FEATURE_TELEPHONY_GSM = "android.hardware.telephony.gsm"; 1848 1849 /** 1850 * Feature for {@link #getSystemAvailableFeatures} and 1851 * {@link #hasSystemFeature}: The device supports connecting to USB devices 1852 * as the USB host. 1853 */ 1854 @SdkConstant(SdkConstantType.FEATURE) 1855 public static final String FEATURE_USB_HOST = "android.hardware.usb.host"; 1856 1857 /** 1858 * Feature for {@link #getSystemAvailableFeatures} and 1859 * {@link #hasSystemFeature}: The device supports connecting to USB accessories. 1860 */ 1861 @SdkConstant(SdkConstantType.FEATURE) 1862 public static final String FEATURE_USB_ACCESSORY = "android.hardware.usb.accessory"; 1863 1864 /** 1865 * Feature for {@link #getSystemAvailableFeatures} and 1866 * {@link #hasSystemFeature}: The SIP API is enabled on the device. 1867 */ 1868 @SdkConstant(SdkConstantType.FEATURE) 1869 public static final String FEATURE_SIP = "android.software.sip"; 1870 1871 /** 1872 * Feature for {@link #getSystemAvailableFeatures} and 1873 * {@link #hasSystemFeature}: The device supports SIP-based VOIP. 1874 */ 1875 @SdkConstant(SdkConstantType.FEATURE) 1876 public static final String FEATURE_SIP_VOIP = "android.software.sip.voip"; 1877 1878 /** 1879 * Feature for {@link #getSystemAvailableFeatures} and 1880 * {@link #hasSystemFeature}: The Connection Service API is enabled on the device. 1881 */ 1882 @SdkConstant(SdkConstantType.FEATURE) 1883 public static final String FEATURE_CONNECTION_SERVICE = "android.software.connectionservice"; 1884 1885 /** 1886 * Feature for {@link #getSystemAvailableFeatures} and 1887 * {@link #hasSystemFeature}: The device's display has a touch screen. 1888 */ 1889 @SdkConstant(SdkConstantType.FEATURE) 1890 public static final String FEATURE_TOUCHSCREEN = "android.hardware.touchscreen"; 1891 1892 /** 1893 * Feature for {@link #getSystemAvailableFeatures} and 1894 * {@link #hasSystemFeature}: The device's touch screen supports 1895 * multitouch sufficient for basic two-finger gesture detection. 1896 */ 1897 @SdkConstant(SdkConstantType.FEATURE) 1898 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH = "android.hardware.touchscreen.multitouch"; 1899 1900 /** 1901 * Feature for {@link #getSystemAvailableFeatures} and 1902 * {@link #hasSystemFeature}: The device's touch screen is capable of 1903 * tracking two or more fingers fully independently. 1904 */ 1905 @SdkConstant(SdkConstantType.FEATURE) 1906 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT = "android.hardware.touchscreen.multitouch.distinct"; 1907 1908 /** 1909 * Feature for {@link #getSystemAvailableFeatures} and 1910 * {@link #hasSystemFeature}: The device's touch screen is capable of 1911 * tracking a full hand of fingers fully independently -- that is, 5 or 1912 * more simultaneous independent pointers. 1913 */ 1914 @SdkConstant(SdkConstantType.FEATURE) 1915 public static final String FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND = "android.hardware.touchscreen.multitouch.jazzhand"; 1916 1917 /** 1918 * Feature for {@link #getSystemAvailableFeatures} and 1919 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1920 * does support touch emulation for basic events. For instance, the 1921 * device might use a mouse or remote control to drive a cursor, and 1922 * emulate basic touch pointer events like down, up, drag, etc. All 1923 * devices that support android.hardware.touchscreen or a sub-feature are 1924 * presumed to also support faketouch. 1925 */ 1926 @SdkConstant(SdkConstantType.FEATURE) 1927 public static final String FEATURE_FAKETOUCH = "android.hardware.faketouch"; 1928 1929 /** 1930 * Feature for {@link #getSystemAvailableFeatures} and 1931 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1932 * does support touch emulation for basic events that supports distinct 1933 * tracking of two or more fingers. This is an extension of 1934 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1935 * that unlike a distinct multitouch screen as defined by 1936 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT}, these kinds of input 1937 * devices will not actually provide full two-finger gestures since the 1938 * input is being transformed to cursor movement on the screen. That is, 1939 * single finger gestures will move a cursor; two-finger swipes will 1940 * result in single-finger touch events; other two-finger gestures will 1941 * result in the corresponding two-finger touch event. 1942 */ 1943 @SdkConstant(SdkConstantType.FEATURE) 1944 public static final String FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT = "android.hardware.faketouch.multitouch.distinct"; 1945 1946 /** 1947 * Feature for {@link #getSystemAvailableFeatures} and 1948 * {@link #hasSystemFeature}: The device does not have a touch screen, but 1949 * does support touch emulation for basic events that supports tracking 1950 * a hand of fingers (5 or more fingers) fully independently. 1951 * This is an extension of 1952 * {@link #FEATURE_FAKETOUCH} for input devices with this capability. Note 1953 * that unlike a multitouch screen as defined by 1954 * {@link #FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND}, not all two finger 1955 * gestures can be detected due to the limitations described for 1956 * {@link #FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT}. 1957 */ 1958 @SdkConstant(SdkConstantType.FEATURE) 1959 public static final String FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND = "android.hardware.faketouch.multitouch.jazzhand"; 1960 1961 /** 1962 * Feature for {@link #getSystemAvailableFeatures} and 1963 * {@link #hasSystemFeature}: The device has biometric hardware to detect a fingerprint. 1964 */ 1965 @SdkConstant(SdkConstantType.FEATURE) 1966 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; 1967 1968 /** 1969 * Feature for {@link #getSystemAvailableFeatures} and 1970 * {@link #hasSystemFeature}: The device supports portrait orientation 1971 * screens. For backwards compatibility, you can assume that if neither 1972 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 1973 * both portrait and landscape. 1974 */ 1975 @SdkConstant(SdkConstantType.FEATURE) 1976 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 1977 1978 /** 1979 * Feature for {@link #getSystemAvailableFeatures} and 1980 * {@link #hasSystemFeature}: The device supports landscape orientation 1981 * screens. For backwards compatibility, you can assume that if neither 1982 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 1983 * both portrait and landscape. 1984 */ 1985 @SdkConstant(SdkConstantType.FEATURE) 1986 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 1987 1988 /** 1989 * Feature for {@link #getSystemAvailableFeatures} and 1990 * {@link #hasSystemFeature}: The device supports live wallpapers. 1991 */ 1992 @SdkConstant(SdkConstantType.FEATURE) 1993 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 1994 /** 1995 * Feature for {@link #getSystemAvailableFeatures} and 1996 * {@link #hasSystemFeature}: The device supports app widgets. 1997 */ 1998 @SdkConstant(SdkConstantType.FEATURE) 1999 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 2000 2001 /** 2002 * @hide 2003 * Feature for {@link #getSystemAvailableFeatures} and 2004 * {@link #hasSystemFeature}: The device supports 2005 * {@link android.service.voice.VoiceInteractionService} and 2006 * {@link android.app.VoiceInteractor}. 2007 */ 2008 @SdkConstant(SdkConstantType.FEATURE) 2009 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 2010 2011 2012 /** 2013 * Feature for {@link #getSystemAvailableFeatures} and 2014 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 2015 * by third party applications. 2016 */ 2017 @SdkConstant(SdkConstantType.FEATURE) 2018 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 2019 2020 /** 2021 * Feature for {@link #getSystemAvailableFeatures} and 2022 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 2023 * with the {@link android.inputmethodservice.InputMethodService} API. 2024 */ 2025 @SdkConstant(SdkConstantType.FEATURE) 2026 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 2027 2028 /** 2029 * Feature for {@link #getSystemAvailableFeatures} and 2030 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 2031 */ 2032 @SdkConstant(SdkConstantType.FEATURE) 2033 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 2034 2035 /** 2036 * Feature for {@link #getSystemAvailableFeatures} and 2037 * {@link #hasSystemFeature}: The device supports leanback UI. This is 2038 * typically used in a living room television experience, but is a software 2039 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 2040 * feature will use resources associated with the "television" UI mode. 2041 */ 2042 @SdkConstant(SdkConstantType.FEATURE) 2043 public static final String FEATURE_LEANBACK = "android.software.leanback"; 2044 2045 /** 2046 * Feature for {@link #getSystemAvailableFeatures} and 2047 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 2048 * applications designed for this experience should be run, though this is 2049 * not enforced by the system. 2050 * @hide 2051 */ 2052 @SdkConstant(SdkConstantType.FEATURE) 2053 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 2054 2055 /** 2056 * Feature for {@link #getSystemAvailableFeatures} and 2057 * {@link #hasSystemFeature}: The device supports live TV and can display 2058 * contents from TV inputs implemented with the 2059 * {@link android.media.tv.TvInputService} API. 2060 */ 2061 @SdkConstant(SdkConstantType.FEATURE) 2062 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 2063 2064 /** 2065 * Feature for {@link #getSystemAvailableFeatures} and 2066 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 2067 */ 2068 @SdkConstant(SdkConstantType.FEATURE) 2069 public static final String FEATURE_WIFI = "android.hardware.wifi"; 2070 2071 /** 2072 * Feature for {@link #getSystemAvailableFeatures} and 2073 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 2074 */ 2075 @SdkConstant(SdkConstantType.FEATURE) 2076 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 2077 2078 /** 2079 * Feature for {@link #getSystemAvailableFeatures} and 2080 * {@link #hasSystemFeature}: The device supports Wi-Fi Aware. 2081 * 2082 * @hide PROPOSED_AWARE_API 2083 */ 2084 @SdkConstant(SdkConstantType.FEATURE) 2085 public static final String FEATURE_WIFI_AWARE = "android.hardware.wifi.aware"; 2086 2087 /** 2088 * Feature for {@link #getSystemAvailableFeatures} and 2089 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 2090 * on a vehicle headunit. A headunit here is defined to be inside a 2091 * vehicle that may or may not be moving. A headunit uses either a 2092 * primary display in the center console and/or additional displays in 2093 * the instrument cluster or elsewhere in the vehicle. Headunit display(s) 2094 * have limited size and resolution. The user will likely be focused on 2095 * driving so limiting driver distraction is a primary concern. User input 2096 * can be a variety of hard buttons, touch, rotary controllers and even mouse- 2097 * like interfaces. 2098 */ 2099 @SdkConstant(SdkConstantType.FEATURE) 2100 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive"; 2101 2102 /** 2103 * Feature for {@link #getSystemAvailableFeatures} and 2104 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 2105 * on a television. Television here is defined to be a typical living 2106 * room television experience: displayed on a big screen, where the user 2107 * is sitting far away from it, and the dominant form of input will be 2108 * something like a DPAD, not through touch or mouse. 2109 * @deprecated use {@link #FEATURE_LEANBACK} instead. 2110 */ 2111 @Deprecated 2112 @SdkConstant(SdkConstantType.FEATURE) 2113 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 2114 2115 /** 2116 * Feature for {@link #getSystemAvailableFeatures} and 2117 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 2118 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 2119 * the wrist. The user is very close when interacting with the device. 2120 */ 2121 @SdkConstant(SdkConstantType.FEATURE) 2122 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 2123 2124 /** 2125 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2126 * The device supports printing. 2127 */ 2128 @SdkConstant(SdkConstantType.FEATURE) 2129 public static final String FEATURE_PRINTING = "android.software.print"; 2130 2131 /** 2132 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2133 * The device can perform backup and restore operations on installed applications. 2134 */ 2135 @SdkConstant(SdkConstantType.FEATURE) 2136 public static final String FEATURE_BACKUP = "android.software.backup"; 2137 2138 /** 2139 * Feature for {@link #getSystemAvailableFeatures} and 2140 * {@link #hasSystemFeature}: The device supports freeform window management. 2141 * Windows have title bars and can be moved and resized. 2142 */ 2143 // If this feature is present, you also need to set 2144 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay. 2145 @SdkConstant(SdkConstantType.FEATURE) 2146 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT 2147 = "android.software.freeform_window_management"; 2148 2149 /** 2150 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2151 * The device supports picture-in-picture multi-window mode. 2152 */ 2153 @SdkConstant(SdkConstantType.FEATURE) 2154 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; 2155 2156 /** 2157 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2158 * The device supports creating secondary users and managed profiles via 2159 * {@link DevicePolicyManager}. 2160 */ 2161 @SdkConstant(SdkConstantType.FEATURE) 2162 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 2163 2164 /** 2165 * @hide 2166 * TODO: Remove after dependencies updated b/17392243 2167 */ 2168 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 2169 2170 /** 2171 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2172 * The device supports verified boot. 2173 */ 2174 @SdkConstant(SdkConstantType.FEATURE) 2175 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 2176 2177 /** 2178 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2179 * The device supports secure removal of users. When a user is deleted the data associated 2180 * with that user is securely deleted and no longer available. 2181 */ 2182 @SdkConstant(SdkConstantType.FEATURE) 2183 public static final String FEATURE_SECURELY_REMOVES_USERS 2184 = "android.software.securely_removes_users"; 2185 2186 /** {@hide} */ 2187 @SdkConstant(SdkConstantType.FEATURE) 2188 public static final String FEATURE_FILE_BASED_ENCRYPTION 2189 = "android.software.file_based_encryption"; 2190 2191 /** 2192 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2193 * The device has a full implementation of the android.webkit.* APIs. Devices 2194 * lacking this feature will not have a functioning WebView implementation. 2195 */ 2196 @SdkConstant(SdkConstantType.FEATURE) 2197 public static final String FEATURE_WEBVIEW = "android.software.webview"; 2198 2199 /** 2200 * Feature for {@link #getSystemAvailableFeatures} and 2201 * {@link #hasSystemFeature}: This device supports ethernet. 2202 */ 2203 @SdkConstant(SdkConstantType.FEATURE) 2204 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 2205 2206 /** 2207 * Feature for {@link #getSystemAvailableFeatures} and 2208 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 2209 * @hide 2210 */ 2211 @SdkConstant(SdkConstantType.FEATURE) 2212 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 2213 2214 /** 2215 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2216 * The device has all of the inputs necessary to be considered a compatible game controller, or 2217 * includes a compatible game controller in the box. 2218 */ 2219 @SdkConstant(SdkConstantType.FEATURE) 2220 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 2221 2222 /** 2223 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2224 * The device has a full implementation of the android.media.midi.* APIs. 2225 */ 2226 @SdkConstant(SdkConstantType.FEATURE) 2227 public static final String FEATURE_MIDI = "android.software.midi"; 2228 2229 /** 2230 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2231 * The device implements an optimized mode for virtual reality (VR) applications that handles 2232 * stereoscopic rendering of notifications, and disables most monocular system UI components 2233 * while a VR application has user focus. 2234 * Devices declaring this feature must include an application implementing a 2235 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 2236 * {@link android.app.Activity#setVrModeEnabled}. 2237 */ 2238 @SdkConstant(SdkConstantType.FEATURE) 2239 public static final String FEATURE_VR_MODE = "android.software.vr.mode"; 2240 2241 /** 2242 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2243 * The device implements {@link #FEATURE_VR_MODE} but additionally meets extra CDD requirements 2244 * to provide a high-quality VR experience. In general, devices declaring this feature will 2245 * additionally: 2246 * <ul> 2247 * <li>Deliver consistent performance at a high framerate over an extended period of time 2248 * for typical VR application CPU/GPU workloads with a minimal number of frame drops for VR 2249 * applications that have called 2250 * {@link android.view.Window#setSustainedPerformanceMode}.</li> 2251 * <li>Implement {@link #FEATURE_HIFI_SENSORS} and have a low sensor latency.</li> 2252 * <li>Include optimizations to lower display persistence while running VR applications.</li> 2253 * <li>Implement an optimized render path to minimize latency to draw to the device's main 2254 * display.</li> 2255 * <li>Include the following EGL extensions: EGL_ANDROID_create_native_client_buffer, 2256 * EGL_ANDROID_front_buffer_auto_refresh, EGL_EXT_protected_content, 2257 * EGL_KHR_mutable_render_buffer, EGL_KHR_reusable_sync, and EGL_KHR_wait_sync.</li> 2258 * <li>Provide at least one CPU core that is reserved for use solely by the top, foreground 2259 * VR application process for critical render threads while such an application is 2260 * running.</li> 2261 * </ul> 2262 */ 2263 @SdkConstant(SdkConstantType.FEATURE) 2264 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE 2265 = "android.hardware.vr.high_performance"; 2266 2267 /** 2268 * Action to external storage service to clean out removed apps. 2269 * @hide 2270 */ 2271 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 2272 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 2273 2274 /** 2275 * Extra field name for the URI to a verification file. Passed to a package 2276 * verifier. 2277 * 2278 * @hide 2279 */ 2280 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 2281 2282 /** 2283 * Extra field name for the ID of a package pending verification. Passed to 2284 * a package verifier and is used to call back to 2285 * {@link PackageManager#verifyPendingInstall(int, int)} 2286 */ 2287 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 2288 2289 /** 2290 * Extra field name for the package identifier which is trying to install 2291 * the package. 2292 * 2293 * @hide 2294 */ 2295 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 2296 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 2297 2298 /** 2299 * Extra field name for the requested install flags for a package pending 2300 * verification. Passed to a package verifier. 2301 * 2302 * @hide 2303 */ 2304 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 2305 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 2306 2307 /** 2308 * Extra field name for the uid of who is requesting to install 2309 * the package. 2310 * 2311 * @hide 2312 */ 2313 public static final String EXTRA_VERIFICATION_INSTALLER_UID 2314 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 2315 2316 /** 2317 * Extra field name for the package name of a package pending verification. 2318 * 2319 * @hide 2320 */ 2321 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 2322 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 2323 /** 2324 * Extra field name for the result of a verification, either 2325 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 2326 * Passed to package verifiers after a package is verified. 2327 */ 2328 public static final String EXTRA_VERIFICATION_RESULT 2329 = "android.content.pm.extra.VERIFICATION_RESULT"; 2330 2331 /** 2332 * Extra field name for the version code of a package pending verification. 2333 * 2334 * @hide 2335 */ 2336 public static final String EXTRA_VERIFICATION_VERSION_CODE 2337 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 2338 2339 /** 2340 * Extra field name for the ID of a intent filter pending verification. 2341 * Passed to an intent filter verifier and is used to call back to 2342 * {@link #verifyIntentFilter} 2343 * 2344 * @hide 2345 */ 2346 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 2347 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 2348 2349 /** 2350 * Extra field name for the scheme used for an intent filter pending verification. Passed to 2351 * an intent filter verifier and is used to construct the URI to verify against. 2352 * 2353 * Usually this is "https" 2354 * 2355 * @hide 2356 */ 2357 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 2358 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 2359 2360 /** 2361 * Extra field name for the host names to be used for an intent filter pending verification. 2362 * Passed to an intent filter verifier and is used to construct the URI to verify the 2363 * intent filter. 2364 * 2365 * This is a space delimited list of hosts. 2366 * 2367 * @hide 2368 */ 2369 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 2370 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 2371 2372 /** 2373 * Extra field name for the package name to be used for an intent filter pending verification. 2374 * Passed to an intent filter verifier and is used to check the verification responses coming 2375 * from the hosts. Each host response will need to include the package name of APK containing 2376 * the intent filter. 2377 * 2378 * @hide 2379 */ 2380 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 2381 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 2382 2383 /** 2384 * The action used to request that the user approve a permission request 2385 * from the application. 2386 * 2387 * @hide 2388 */ 2389 @SystemApi 2390 public static final String ACTION_REQUEST_PERMISSIONS = 2391 "android.content.pm.action.REQUEST_PERMISSIONS"; 2392 2393 /** 2394 * The names of the requested permissions. 2395 * <p> 2396 * <strong>Type:</strong> String[] 2397 * </p> 2398 * 2399 * @hide 2400 */ 2401 @SystemApi 2402 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 2403 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 2404 2405 /** 2406 * The results from the permissions request. 2407 * <p> 2408 * <strong>Type:</strong> int[] of #PermissionResult 2409 * </p> 2410 * 2411 * @hide 2412 */ 2413 @SystemApi 2414 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 2415 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 2416 2417 /** 2418 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2419 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 2420 * the existing definition for the permission. 2421 * @hide 2422 */ 2423 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 2424 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 2425 2426 /** 2427 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2428 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 2429 * being redundantly defined by the package being installed. 2430 * @hide 2431 */ 2432 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 2433 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 2434 2435 /** 2436 * Permission flag: The permission is set in its current state 2437 * by the user and apps can still request it at runtime. 2438 * 2439 * @hide 2440 */ 2441 @SystemApi 2442 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 2443 2444 /** 2445 * Permission flag: The permission is set in its current state 2446 * by the user and it is fixed, i.e. apps can no longer request 2447 * this permission. 2448 * 2449 * @hide 2450 */ 2451 @SystemApi 2452 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 2453 2454 /** 2455 * Permission flag: The permission is set in its current state 2456 * by device policy and neither apps nor the user can change 2457 * its state. 2458 * 2459 * @hide 2460 */ 2461 @SystemApi 2462 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 2463 2464 /** 2465 * Permission flag: The permission is set in a granted state but 2466 * access to resources it guards is restricted by other means to 2467 * enable revoking a permission on legacy apps that do not support 2468 * runtime permissions. If this permission is upgraded to runtime 2469 * because the app was updated to support runtime permissions, the 2470 * the permission will be revoked in the upgrade process. 2471 * 2472 * @hide 2473 */ 2474 @SystemApi 2475 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 2476 2477 /** 2478 * Permission flag: The permission is set in its current state 2479 * because the app is a component that is a part of the system. 2480 * 2481 * @hide 2482 */ 2483 @SystemApi 2484 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 2485 2486 /** 2487 * Permission flag: The permission is granted by default because it 2488 * enables app functionality that is expected to work out-of-the-box 2489 * for providing a smooth user experience. For example, the phone app 2490 * is expected to have the phone permission. 2491 * 2492 * @hide 2493 */ 2494 @SystemApi 2495 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 2496 2497 /** 2498 * Permission flag: The permission has to be reviewed before any of 2499 * the app components can run. 2500 * 2501 * @hide 2502 */ 2503 @SystemApi 2504 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 2505 2506 /** 2507 * Mask for all permission flags. 2508 * 2509 * @hide 2510 */ 2511 @SystemApi 2512 public static final int MASK_PERMISSION_FLAGS = 0xFF; 2513 2514 /** 2515 * This is a library that contains components apps can invoke. For 2516 * example, a services for apps to bind to, or standard chooser UI, 2517 * etc. This library is versioned and backwards compatible. Clients 2518 * should check its version via {@link android.ext.services.Version 2519 * #getVersionCode()} and avoid calling APIs added in later versions. 2520 * 2521 * @hide 2522 */ 2523 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services"; 2524 2525 /** 2526 * This is a library that contains components apps can dynamically 2527 * load. For example, new widgets, helper classes, etc. This library 2528 * is versioned and backwards compatible. Clients should check its 2529 * version via {@link android.ext.shared.Version#getVersionCode()} 2530 * and avoid calling APIs added in later versions. 2531 * 2532 * @hide 2533 */ 2534 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared"; 2535 2536 /** 2537 * Used when starting a process for an Activity. 2538 * 2539 * @hide 2540 */ 2541 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0; 2542 2543 /** 2544 * Used when starting a process for a Service. 2545 * 2546 * @hide 2547 */ 2548 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1; 2549 2550 /** 2551 * Used when moving a Service to the foreground. 2552 * 2553 * @hide 2554 */ 2555 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2; 2556 2557 /** 2558 * Used when starting a process for a BroadcastReceiver. 2559 * 2560 * @hide 2561 */ 2562 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3; 2563 2564 /** 2565 * Used when starting a process for a ContentProvider. 2566 * 2567 * @hide 2568 */ 2569 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4; 2570 2571 /** 2572 * Used when starting a process for a BroadcastReceiver. 2573 * 2574 * @hide 2575 */ 2576 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5; 2577 2578 /** 2579 * Used with Context.getClassLoader() across Android packages. 2580 * 2581 * @hide 2582 */ 2583 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6; 2584 2585 /** 2586 * Used when starting a package within a process for Instrumentation. 2587 * 2588 * @hide 2589 */ 2590 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7; 2591 2592 /** 2593 * Total number of usage reasons. 2594 * 2595 * @hide 2596 */ 2597 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8; 2598 2599 /** 2600 * Retrieve overall information about an application package that is 2601 * installed on the system. 2602 * 2603 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2604 * desired package. 2605 * @param flags Additional option flags. Use any combination of 2606 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2607 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2608 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2609 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2610 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2611 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2612 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2613 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2614 * {@link #MATCH_UNINSTALLED_PACKAGES} 2615 * to modify the data returned. 2616 * 2617 * @return A PackageInfo object containing information about the 2618 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2619 * package is not found in the list of installed applications, the 2620 * package information is retrieved from the list of uninstalled 2621 * applications (which includes installed applications as well as 2622 * applications with data directory i.e. applications which had been 2623 * deleted with {@code DONT_DELETE_DATA} flag set). 2624 * @throws NameNotFoundException if a package with the given name cannot be 2625 * found on the system. 2626 * @see #GET_ACTIVITIES 2627 * @see #GET_CONFIGURATIONS 2628 * @see #GET_GIDS 2629 * @see #GET_INSTRUMENTATION 2630 * @see #GET_INTENT_FILTERS 2631 * @see #GET_META_DATA 2632 * @see #GET_PERMISSIONS 2633 * @see #GET_PROVIDERS 2634 * @see #GET_RECEIVERS 2635 * @see #GET_SERVICES 2636 * @see #GET_SHARED_LIBRARY_FILES 2637 * @see #GET_SIGNATURES 2638 * @see #GET_URI_PERMISSION_PATTERNS 2639 * @see #MATCH_DISABLED_COMPONENTS 2640 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2641 * @see #MATCH_UNINSTALLED_PACKAGES 2642 */ 2643 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) 2644 throws NameNotFoundException; 2645 2646 /** 2647 * @hide 2648 * Retrieve overall information about an application package that is 2649 * installed on the system. 2650 * 2651 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2652 * desired package. 2653 * @param flags Additional option flags. Use any combination of 2654 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2655 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2656 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2657 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2658 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2659 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2660 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2661 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2662 * {@link #MATCH_UNINSTALLED_PACKAGES} 2663 * to modify the data returned. 2664 * @param userId The user id. 2665 * 2666 * @return A PackageInfo object containing information about the 2667 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2668 * package is not found in the list of installed applications, the 2669 * package information is retrieved from the list of uninstalled 2670 * applications (which includes installed applications as well as 2671 * applications with data directory i.e. applications which had been 2672 * deleted with {@code DONT_DELETE_DATA} flag set). 2673 * @throws NameNotFoundException if a package with the given name cannot be 2674 * found on the system. 2675 * @see #GET_ACTIVITIES 2676 * @see #GET_CONFIGURATIONS 2677 * @see #GET_GIDS 2678 * @see #GET_INSTRUMENTATION 2679 * @see #GET_INTENT_FILTERS 2680 * @see #GET_META_DATA 2681 * @see #GET_PERMISSIONS 2682 * @see #GET_PROVIDERS 2683 * @see #GET_RECEIVERS 2684 * @see #GET_SERVICES 2685 * @see #GET_SHARED_LIBRARY_FILES 2686 * @see #GET_SIGNATURES 2687 * @see #GET_URI_PERMISSION_PATTERNS 2688 * @see #MATCH_DISABLED_COMPONENTS 2689 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2690 * @see #MATCH_UNINSTALLED_PACKAGES 2691 */ 2692 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 2693 public abstract PackageInfo getPackageInfoAsUser(String packageName, 2694 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 2695 2696 /** 2697 * Map from the current package names in use on the device to whatever 2698 * the current canonical name of that package is. 2699 * @param names Array of current names to be mapped. 2700 * @return Returns an array of the same size as the original, containing 2701 * the canonical name for each package. 2702 */ 2703 public abstract String[] currentToCanonicalPackageNames(String[] names); 2704 2705 /** 2706 * Map from a packages canonical name to the current name in use on the device. 2707 * @param names Array of new names to be mapped. 2708 * @return Returns an array of the same size as the original, containing 2709 * the current name for each package. 2710 */ 2711 public abstract String[] canonicalToCurrentPackageNames(String[] names); 2712 2713 /** 2714 * Returns a "good" intent to launch a front-door activity in a package. 2715 * This is used, for example, to implement an "open" button when browsing 2716 * through packages. The current implementation looks first for a main 2717 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 2718 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 2719 * <code>null</code> if neither are found. 2720 * 2721 * @param packageName The name of the package to inspect. 2722 * 2723 * @return A fully-qualified {@link Intent} that can be used to launch the 2724 * main activity in the package. Returns <code>null</code> if the package 2725 * does not contain such an activity, or if <em>packageName</em> is not 2726 * recognized. 2727 */ 2728 public abstract Intent getLaunchIntentForPackage(String packageName); 2729 2730 /** 2731 * Return a "good" intent to launch a front-door Leanback activity in a 2732 * package, for use for example to implement an "open" button when browsing 2733 * through packages. The current implementation will look for a main 2734 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 2735 * return null if no main leanback activities are found. 2736 * 2737 * @param packageName The name of the package to inspect. 2738 * @return Returns either a fully-qualified Intent that can be used to launch 2739 * the main Leanback activity in the package, or null if the package 2740 * does not contain such an activity. 2741 */ 2742 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName); 2743 2744 /** 2745 * Return an array of all of the POSIX secondary group IDs that have been 2746 * assigned to the given package. 2747 * <p> 2748 * Note that the same package may have different GIDs under different 2749 * {@link UserHandle} on the same device. 2750 * 2751 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2752 * desired package. 2753 * @return Returns an int array of the assigned GIDs, or null if there are 2754 * none. 2755 * @throws NameNotFoundException if a package with the given name cannot be 2756 * found on the system. 2757 */ 2758 public abstract int[] getPackageGids(String packageName) 2759 throws NameNotFoundException; 2760 2761 /** 2762 * Return an array of all of the POSIX secondary group IDs that have been 2763 * assigned to the given package. 2764 * <p> 2765 * Note that the same package may have different GIDs under different 2766 * {@link UserHandle} on the same device. 2767 * 2768 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2769 * desired package. 2770 * @return Returns an int array of the assigned gids, or null if there are 2771 * none. 2772 * @throws NameNotFoundException if a package with the given name cannot be 2773 * found on the system. 2774 */ 2775 public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags) 2776 throws NameNotFoundException; 2777 2778 /** 2779 * Return the UID associated with the given package name. 2780 * <p> 2781 * Note that the same package will have different UIDs under different 2782 * {@link UserHandle} on the same device. 2783 * 2784 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2785 * desired package. 2786 * @return Returns an integer UID who owns the given package name. 2787 * @throws NameNotFoundException if a package with the given name can not be 2788 * found on the system. 2789 */ 2790 public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags) 2791 throws NameNotFoundException; 2792 2793 /** 2794 * Return the UID associated with the given package name. 2795 * <p> 2796 * Note that the same package will have different UIDs under different 2797 * {@link UserHandle} on the same device. 2798 * 2799 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2800 * desired package. 2801 * @param userId The user handle identifier to look up the package under. 2802 * @return Returns an integer UID who owns the given package name. 2803 * @throws NameNotFoundException if a package with the given name can not be 2804 * found on the system. 2805 * @hide 2806 */ 2807 public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId) 2808 throws NameNotFoundException; 2809 2810 /** 2811 * Return the UID associated with the given package name. 2812 * <p> 2813 * Note that the same package will have different UIDs under different 2814 * {@link UserHandle} on the same device. 2815 * 2816 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2817 * desired package. 2818 * @param userId The user handle identifier to look up the package under. 2819 * @return Returns an integer UID who owns the given package name. 2820 * @throws NameNotFoundException if a package with the given name can not be 2821 * found on the system. 2822 * @hide 2823 */ 2824 public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags, 2825 @UserIdInt int userId) throws NameNotFoundException; 2826 2827 /** 2828 * Retrieve all of the information we know about a particular permission. 2829 * 2830 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 2831 * of the permission you are interested in. 2832 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2833 * retrieve any meta-data associated with the permission. 2834 * 2835 * @return Returns a {@link PermissionInfo} containing information about the 2836 * permission. 2837 * @throws NameNotFoundException if a package with the given name cannot be 2838 * found on the system. 2839 * 2840 * @see #GET_META_DATA 2841 */ 2842 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags) 2843 throws NameNotFoundException; 2844 2845 /** 2846 * Query for all of the permissions associated with a particular group. 2847 * 2848 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 2849 * of the permission group you are interested in. Use null to 2850 * find all of the permissions not associated with a group. 2851 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2852 * retrieve any meta-data associated with the permissions. 2853 * 2854 * @return Returns a list of {@link PermissionInfo} containing information 2855 * about all of the permissions in the given group. 2856 * @throws NameNotFoundException if a package with the given name cannot be 2857 * found on the system. 2858 * 2859 * @see #GET_META_DATA 2860 */ 2861 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 2862 @PermissionInfoFlags int flags) throws NameNotFoundException; 2863 2864 /** 2865 * Retrieve all of the information we know about a particular group of 2866 * permissions. 2867 * 2868 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 2869 * of the permission you are interested in. 2870 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2871 * retrieve any meta-data associated with the permission group. 2872 * 2873 * @return Returns a {@link PermissionGroupInfo} containing information 2874 * about the permission. 2875 * @throws NameNotFoundException if a package with the given name cannot be 2876 * found on the system. 2877 * 2878 * @see #GET_META_DATA 2879 */ 2880 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 2881 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 2882 2883 /** 2884 * Retrieve all of the known permission groups in the system. 2885 * 2886 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2887 * retrieve any meta-data associated with the permission group. 2888 * 2889 * @return Returns a list of {@link PermissionGroupInfo} containing 2890 * information about all of the known permission groups. 2891 * 2892 * @see #GET_META_DATA 2893 */ 2894 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 2895 @PermissionGroupInfoFlags int flags); 2896 2897 /** 2898 * Retrieve all of the information we know about a particular 2899 * package/application. 2900 * 2901 * @param packageName The full name (i.e. com.google.apps.contacts) of an 2902 * application. 2903 * @param flags Additional option flags. Use any combination of 2904 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2905 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 2906 * to modify the data returned. 2907 * 2908 * @return An {@link ApplicationInfo} containing information about the 2909 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2910 * package is not found in the list of installed applications, the 2911 * application information is retrieved from the list of uninstalled 2912 * applications (which includes installed applications as well as 2913 * applications with data directory i.e. applications which had been 2914 * deleted with {@code DONT_DELETE_DATA} flag set). 2915 * @throws NameNotFoundException if a package with the given name cannot be 2916 * found on the system. 2917 * 2918 * @see #GET_META_DATA 2919 * @see #GET_SHARED_LIBRARY_FILES 2920 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2921 * @see #MATCH_SYSTEM_ONLY 2922 * @see #MATCH_UNINSTALLED_PACKAGES 2923 */ 2924 public abstract ApplicationInfo getApplicationInfo(String packageName, 2925 @ApplicationInfoFlags int flags) throws NameNotFoundException; 2926 2927 /** {@hide} */ 2928 public abstract ApplicationInfo getApplicationInfoAsUser(String packageName, 2929 @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 2930 2931 /** 2932 * Retrieve all of the information we know about a particular activity 2933 * class. 2934 * 2935 * @param component The full component name (i.e. 2936 * com.google.apps.contacts/com.google.apps.contacts. 2937 * ContactsList) of an Activity class. 2938 * @param flags Additional option flags. Use any combination of 2939 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2940 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 2941 * {@link #MATCH_DISABLED_COMPONENTS}, 2942 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2943 * {@link #MATCH_DIRECT_BOOT_AWARE}, 2944 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 2945 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 2946 * returned. 2947 * @return An {@link ActivityInfo} containing information about the 2948 * activity. 2949 * @throws NameNotFoundException if a package with the given name cannot be 2950 * found on the system. 2951 * @see #GET_META_DATA 2952 * @see #GET_SHARED_LIBRARY_FILES 2953 * @see #MATCH_ALL 2954 * @see #MATCH_DEBUG_TRIAGED_MISSING 2955 * @see #MATCH_DEFAULT_ONLY 2956 * @see #MATCH_DISABLED_COMPONENTS 2957 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2958 * @see #MATCH_DIRECT_BOOT_AWARE 2959 * @see #MATCH_DIRECT_BOOT_UNAWARE 2960 * @see #MATCH_SYSTEM_ONLY 2961 * @see #MATCH_UNINSTALLED_PACKAGES 2962 */ 2963 public abstract ActivityInfo getActivityInfo(ComponentName component, 2964 @ComponentInfoFlags int flags) throws NameNotFoundException; 2965 2966 /** 2967 * Retrieve all of the information we know about a particular receiver 2968 * class. 2969 * 2970 * @param component The full component name (i.e. 2971 * com.google.apps.calendar/com.google.apps.calendar. 2972 * CalendarAlarm) of a Receiver class. 2973 * @param flags Additional option flags. Use any combination of 2974 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2975 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 2976 * {@link #MATCH_DISABLED_COMPONENTS}, 2977 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2978 * {@link #MATCH_DIRECT_BOOT_AWARE}, 2979 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 2980 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 2981 * returned. 2982 * @return An {@link ActivityInfo} containing information about the 2983 * receiver. 2984 * @throws NameNotFoundException if a package with the given name cannot be 2985 * found on the system. 2986 * @see #GET_META_DATA 2987 * @see #GET_SHARED_LIBRARY_FILES 2988 * @see #MATCH_ALL 2989 * @see #MATCH_DEBUG_TRIAGED_MISSING 2990 * @see #MATCH_DEFAULT_ONLY 2991 * @see #MATCH_DISABLED_COMPONENTS 2992 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2993 * @see #MATCH_DIRECT_BOOT_AWARE 2994 * @see #MATCH_DIRECT_BOOT_UNAWARE 2995 * @see #MATCH_SYSTEM_ONLY 2996 * @see #MATCH_UNINSTALLED_PACKAGES 2997 */ 2998 public abstract ActivityInfo getReceiverInfo(ComponentName component, 2999 @ComponentInfoFlags int flags) throws NameNotFoundException; 3000 3001 /** 3002 * Retrieve all of the information we know about a particular service class. 3003 * 3004 * @param component The full component name (i.e. 3005 * com.google.apps.media/com.google.apps.media. 3006 * BackgroundPlayback) of a Service class. 3007 * @param flags Additional option flags. Use any combination of 3008 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3009 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3010 * {@link #MATCH_DISABLED_COMPONENTS}, 3011 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3012 * {@link #MATCH_DIRECT_BOOT_AWARE}, 3013 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3014 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3015 * returned. 3016 * @return A {@link ServiceInfo} object containing information about the 3017 * service. 3018 * @throws NameNotFoundException if a package with the given name cannot be 3019 * found on the system. 3020 * @see #GET_META_DATA 3021 * @see #GET_SHARED_LIBRARY_FILES 3022 * @see #MATCH_ALL 3023 * @see #MATCH_DEBUG_TRIAGED_MISSING 3024 * @see #MATCH_DEFAULT_ONLY 3025 * @see #MATCH_DISABLED_COMPONENTS 3026 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3027 * @see #MATCH_DIRECT_BOOT_AWARE 3028 * @see #MATCH_DIRECT_BOOT_UNAWARE 3029 * @see #MATCH_SYSTEM_ONLY 3030 * @see #MATCH_UNINSTALLED_PACKAGES 3031 */ 3032 public abstract ServiceInfo getServiceInfo(ComponentName component, 3033 @ComponentInfoFlags int flags) throws NameNotFoundException; 3034 3035 /** 3036 * Retrieve all of the information we know about a particular content 3037 * provider class. 3038 * 3039 * @param component The full component name (i.e. 3040 * com.google.providers.media/com.google.providers.media. 3041 * MediaProvider) of a ContentProvider class. 3042 * @param flags Additional option flags. Use any combination of 3043 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3044 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3045 * {@link #MATCH_DISABLED_COMPONENTS}, 3046 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3047 * {@link #MATCH_DIRECT_BOOT_AWARE}, 3048 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3049 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3050 * returned. 3051 * @return A {@link ProviderInfo} object containing information about the 3052 * provider. 3053 * @throws NameNotFoundException if a package with the given name cannot be 3054 * found on the system. 3055 * @see #GET_META_DATA 3056 * @see #GET_SHARED_LIBRARY_FILES 3057 * @see #MATCH_ALL 3058 * @see #MATCH_DEBUG_TRIAGED_MISSING 3059 * @see #MATCH_DEFAULT_ONLY 3060 * @see #MATCH_DISABLED_COMPONENTS 3061 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3062 * @see #MATCH_DIRECT_BOOT_AWARE 3063 * @see #MATCH_DIRECT_BOOT_UNAWARE 3064 * @see #MATCH_SYSTEM_ONLY 3065 * @see #MATCH_UNINSTALLED_PACKAGES 3066 */ 3067 public abstract ProviderInfo getProviderInfo(ComponentName component, 3068 @ComponentInfoFlags int flags) throws NameNotFoundException; 3069 3070 /** 3071 * Return a List of all packages that are installed 3072 * on the device. 3073 * 3074 * @param flags Additional option flags. Use any combination of 3075 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 3076 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 3077 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 3078 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 3079 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 3080 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 3081 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 3082 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3083 * {@link #MATCH_UNINSTALLED_PACKAGES} 3084 * to modify the data returned. 3085 * 3086 * @return A List of PackageInfo objects, one for each installed package, 3087 * containing information about the package. In the unlikely case 3088 * there are no installed packages, an empty list is returned. If 3089 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3090 * information is retrieved from the list of uninstalled 3091 * applications (which includes installed applications as well as 3092 * applications with data directory i.e. applications which had been 3093 * deleted with {@code DONT_DELETE_DATA} flag set). 3094 * 3095 * @see #GET_ACTIVITIES 3096 * @see #GET_CONFIGURATIONS 3097 * @see #GET_GIDS 3098 * @see #GET_INSTRUMENTATION 3099 * @see #GET_INTENT_FILTERS 3100 * @see #GET_META_DATA 3101 * @see #GET_PERMISSIONS 3102 * @see #GET_PROVIDERS 3103 * @see #GET_RECEIVERS 3104 * @see #GET_SERVICES 3105 * @see #GET_SHARED_LIBRARY_FILES 3106 * @see #GET_SIGNATURES 3107 * @see #GET_URI_PERMISSION_PATTERNS 3108 * @see #MATCH_DISABLED_COMPONENTS 3109 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3110 * @see #MATCH_UNINSTALLED_PACKAGES 3111 */ 3112 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags); 3113 3114 /** 3115 * Return a List of all installed packages that are currently 3116 * holding any of the given permissions. 3117 * 3118 * @param flags Additional option flags. Use any combination of 3119 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 3120 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 3121 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 3122 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 3123 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 3124 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 3125 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 3126 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3127 * {@link #MATCH_UNINSTALLED_PACKAGES} 3128 * to modify the data returned. 3129 * 3130 * @return A List of PackageInfo objects, one for each installed package 3131 * that holds any of the permissions that were provided, containing 3132 * information about the package. If no installed packages hold any 3133 * of the permissions, an empty list is returned. If flag 3134 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package information 3135 * is retrieved from the list of uninstalled applications (which 3136 * includes installed applications as well as applications with data 3137 * directory i.e. applications which had been deleted with 3138 * {@code DONT_DELETE_DATA} flag set). 3139 * 3140 * @see #GET_ACTIVITIES 3141 * @see #GET_CONFIGURATIONS 3142 * @see #GET_GIDS 3143 * @see #GET_INSTRUMENTATION 3144 * @see #GET_INTENT_FILTERS 3145 * @see #GET_META_DATA 3146 * @see #GET_PERMISSIONS 3147 * @see #GET_PROVIDERS 3148 * @see #GET_RECEIVERS 3149 * @see #GET_SERVICES 3150 * @see #GET_SHARED_LIBRARY_FILES 3151 * @see #GET_SIGNATURES 3152 * @see #GET_URI_PERMISSION_PATTERNS 3153 * @see #MATCH_DISABLED_COMPONENTS 3154 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3155 * @see #MATCH_UNINSTALLED_PACKAGES 3156 */ 3157 public abstract List<PackageInfo> getPackagesHoldingPermissions( 3158 String[] permissions, @PackageInfoFlags int flags); 3159 3160 /** 3161 * Return a List of all packages that are installed on the device, for a specific user. 3162 * Requesting a list of installed packages for another user 3163 * will require the permission INTERACT_ACROSS_USERS_FULL. 3164 * 3165 * @param flags Additional option flags. Use any combination of 3166 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 3167 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 3168 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 3169 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 3170 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 3171 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 3172 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 3173 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3174 * {@link #MATCH_UNINSTALLED_PACKAGES} 3175 * to modify the data returned. 3176 * @param userId The user for whom the installed packages are to be listed 3177 * 3178 * @return A List of PackageInfo objects, one for each installed package, 3179 * containing information about the package. In the unlikely case 3180 * there are no installed packages, an empty list is returned. If 3181 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3182 * information is retrieved from the list of uninstalled 3183 * applications (which includes installed applications as well as 3184 * applications with data directory i.e. applications which had been 3185 * deleted with {@code DONT_DELETE_DATA} flag set). 3186 * 3187 * @see #GET_ACTIVITIES 3188 * @see #GET_CONFIGURATIONS 3189 * @see #GET_GIDS 3190 * @see #GET_INSTRUMENTATION 3191 * @see #GET_INTENT_FILTERS 3192 * @see #GET_META_DATA 3193 * @see #GET_PERMISSIONS 3194 * @see #GET_PROVIDERS 3195 * @see #GET_RECEIVERS 3196 * @see #GET_SERVICES 3197 * @see #GET_SHARED_LIBRARY_FILES 3198 * @see #GET_SIGNATURES 3199 * @see #GET_URI_PERMISSION_PATTERNS 3200 * @see #MATCH_DISABLED_COMPONENTS 3201 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3202 * @see #MATCH_UNINSTALLED_PACKAGES 3203 * 3204 * @hide 3205 */ 3206 @SystemApi 3207 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags, 3208 @UserIdInt int userId); 3209 3210 /** 3211 * Check whether a particular package has been granted a particular 3212 * permission. 3213 * 3214 * @param permName The name of the permission you are checking for. 3215 * @param pkgName The name of the package you are checking against. 3216 * 3217 * @return If the package has the permission, PERMISSION_GRANTED is 3218 * returned. If it does not have the permission, PERMISSION_DENIED 3219 * is returned. 3220 * 3221 * @see #PERMISSION_GRANTED 3222 * @see #PERMISSION_DENIED 3223 */ 3224 @CheckResult 3225 public abstract int checkPermission(String permName, String pkgName); 3226 3227 /** 3228 * Checks whether a particular permissions has been revoked for a 3229 * package by policy. Typically the device owner or the profile owner 3230 * may apply such a policy. The user cannot grant policy revoked 3231 * permissions, hence the only way for an app to get such a permission 3232 * is by a policy change. 3233 * 3234 * @param permName The name of the permission you are checking for. 3235 * @param pkgName The name of the package you are checking against. 3236 * 3237 * @return Whether the permission is restricted by policy. 3238 */ 3239 @CheckResult 3240 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 3241 @NonNull String pkgName); 3242 3243 /** 3244 * Gets the package name of the component controlling runtime permissions. 3245 * 3246 * @return The package name. 3247 * 3248 * @hide 3249 */ 3250 public abstract String getPermissionControllerPackageName(); 3251 3252 /** 3253 * Add a new dynamic permission to the system. For this to work, your 3254 * package must have defined a permission tree through the 3255 * {@link android.R.styleable#AndroidManifestPermissionTree 3256 * <permission-tree>} tag in its manifest. A package can only add 3257 * permissions to trees that were defined by either its own package or 3258 * another with the same user id; a permission is in a tree if it 3259 * matches the name of the permission tree + ".": for example, 3260 * "com.foo.bar" is a member of the permission tree "com.foo". 3261 * 3262 * <p>It is good to make your permission tree name descriptive, because you 3263 * are taking possession of that entire set of permission names. Thus, it 3264 * must be under a domain you control, with a suffix that will not match 3265 * any normal permissions that may be declared in any applications that 3266 * are part of that domain. 3267 * 3268 * <p>New permissions must be added before 3269 * any .apks are installed that use those permissions. Permissions you 3270 * add through this method are remembered across reboots of the device. 3271 * If the given permission already exists, the info you supply here 3272 * will be used to update it. 3273 * 3274 * @param info Description of the permission to be added. 3275 * 3276 * @return Returns true if a new permission was created, false if an 3277 * existing one was updated. 3278 * 3279 * @throws SecurityException if you are not allowed to add the 3280 * given permission name. 3281 * 3282 * @see #removePermission(String) 3283 */ 3284 public abstract boolean addPermission(PermissionInfo info); 3285 3286 /** 3287 * Like {@link #addPermission(PermissionInfo)} but asynchronously 3288 * persists the package manager state after returning from the call, 3289 * allowing it to return quicker and batch a series of adds at the 3290 * expense of no guarantee the added permission will be retained if 3291 * the device is rebooted before it is written. 3292 */ 3293 public abstract boolean addPermissionAsync(PermissionInfo info); 3294 3295 /** 3296 * Removes a permission that was previously added with 3297 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 3298 * -- you are only allowed to remove permissions that you are allowed 3299 * to add. 3300 * 3301 * @param name The name of the permission to remove. 3302 * 3303 * @throws SecurityException if you are not allowed to remove the 3304 * given permission name. 3305 * 3306 * @see #addPermission(PermissionInfo) 3307 */ 3308 public abstract void removePermission(String name); 3309 3310 3311 /** 3312 * Permission flags set when granting or revoking a permission. 3313 * 3314 * @hide 3315 */ 3316 @SystemApi 3317 @IntDef({FLAG_PERMISSION_USER_SET, 3318 FLAG_PERMISSION_USER_FIXED, 3319 FLAG_PERMISSION_POLICY_FIXED, 3320 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 3321 FLAG_PERMISSION_SYSTEM_FIXED, 3322 FLAG_PERMISSION_GRANTED_BY_DEFAULT}) 3323 @Retention(RetentionPolicy.SOURCE) 3324 public @interface PermissionFlags {} 3325 3326 /** 3327 * Grant a runtime permission to an application which the application does not 3328 * already have. The permission must have been requested by the application. 3329 * If the application is not allowed to hold the permission, a {@link 3330 * java.lang.SecurityException} is thrown. If the package or permission is 3331 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 3332 * <p> 3333 * <strong>Note: </strong>Using this API requires holding 3334 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is 3335 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3336 * </p> 3337 * 3338 * @param packageName The package to which to grant the permission. 3339 * @param permissionName The permission name to grant. 3340 * @param user The user for which to grant the permission. 3341 * 3342 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 3343 * 3344 * @hide 3345 */ 3346 @SystemApi 3347 public abstract void grantRuntimePermission(@NonNull String packageName, 3348 @NonNull String permissionName, @NonNull UserHandle user); 3349 3350 /** 3351 * Revoke a runtime permission that was previously granted by {@link 3352 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 3353 * permission must have been requested by and granted to the application. 3354 * If the application is not allowed to hold the permission, a {@link 3355 * java.lang.SecurityException} is thrown. If the package or permission is 3356 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 3357 * <p> 3358 * <strong>Note: </strong>Using this API requires holding 3359 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 3360 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3361 * </p> 3362 * 3363 * @param packageName The package from which to revoke the permission. 3364 * @param permissionName The permission name to revoke. 3365 * @param user The user for which to revoke the permission. 3366 * 3367 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 3368 * 3369 * @hide 3370 */ 3371 @SystemApi 3372 public abstract void revokeRuntimePermission(@NonNull String packageName, 3373 @NonNull String permissionName, @NonNull UserHandle user); 3374 3375 /** 3376 * Gets the state flags associated with a permission. 3377 * 3378 * @param permissionName The permission for which to get the flags. 3379 * @param packageName The package name for which to get the flags. 3380 * @param user The user for which to get permission flags. 3381 * @return The permission flags. 3382 * 3383 * @hide 3384 */ 3385 @SystemApi 3386 public abstract @PermissionFlags int getPermissionFlags(String permissionName, 3387 String packageName, @NonNull UserHandle user); 3388 3389 /** 3390 * Updates the flags associated with a permission by replacing the flags in 3391 * the specified mask with the provided flag values. 3392 * 3393 * @param permissionName The permission for which to update the flags. 3394 * @param packageName The package name for which to update the flags. 3395 * @param flagMask The flags which to replace. 3396 * @param flagValues The flags with which to replace. 3397 * @param user The user for which to update the permission flags. 3398 * 3399 * @hide 3400 */ 3401 @SystemApi 3402 public abstract void updatePermissionFlags(String permissionName, 3403 String packageName, @PermissionFlags int flagMask, int flagValues, 3404 @NonNull UserHandle user); 3405 3406 /** 3407 * Gets whether you should show UI with rationale for requesting a permission. 3408 * You should do this only if you do not have the permission and the context in 3409 * which the permission is requested does not clearly communicate to the user 3410 * what would be the benefit from grating this permission. 3411 * 3412 * @param permission A permission your app wants to request. 3413 * @return Whether you can show permission rationale UI. 3414 * 3415 * @hide 3416 */ 3417 public abstract boolean shouldShowRequestPermissionRationale(String permission); 3418 3419 /** 3420 * Returns an {@link android.content.Intent} suitable for passing to 3421 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 3422 * which prompts the user to grant permissions to this application. 3423 * 3424 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 3425 * 3426 * @hide 3427 */ 3428 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 3429 if (ArrayUtils.isEmpty(permissions)) { 3430 throw new IllegalArgumentException("permission cannot be null or empty"); 3431 } 3432 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 3433 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 3434 intent.setPackage(getPermissionControllerPackageName()); 3435 return intent; 3436 } 3437 3438 /** 3439 * Compare the signatures of two packages to determine if the same 3440 * signature appears in both of them. If they do contain the same 3441 * signature, then they are allowed special privileges when working 3442 * with each other: they can share the same user-id, run instrumentation 3443 * against each other, etc. 3444 * 3445 * @param pkg1 First package name whose signature will be compared. 3446 * @param pkg2 Second package name whose signature will be compared. 3447 * 3448 * @return Returns an integer indicating whether all signatures on the 3449 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3450 * all signatures match or < 0 if there is not a match ({@link 3451 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3452 * 3453 * @see #checkSignatures(int, int) 3454 * @see #SIGNATURE_MATCH 3455 * @see #SIGNATURE_NO_MATCH 3456 * @see #SIGNATURE_UNKNOWN_PACKAGE 3457 */ 3458 @CheckResult 3459 public abstract int checkSignatures(String pkg1, String pkg2); 3460 3461 /** 3462 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 3463 * the two packages to be checked. This can be useful, for example, 3464 * when doing the check in an IPC, where the UID is the only identity 3465 * available. It is functionally identical to determining the package 3466 * associated with the UIDs and checking their signatures. 3467 * 3468 * @param uid1 First UID whose signature will be compared. 3469 * @param uid2 Second UID whose signature will be compared. 3470 * 3471 * @return Returns an integer indicating whether all signatures on the 3472 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3473 * all signatures match or < 0 if there is not a match ({@link 3474 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3475 * 3476 * @see #checkSignatures(String, String) 3477 * @see #SIGNATURE_MATCH 3478 * @see #SIGNATURE_NO_MATCH 3479 * @see #SIGNATURE_UNKNOWN_PACKAGE 3480 */ 3481 @CheckResult 3482 public abstract int checkSignatures(int uid1, int uid2); 3483 3484 /** 3485 * Retrieve the names of all packages that are associated with a particular 3486 * user id. In most cases, this will be a single package name, the package 3487 * that has been assigned that user id. Where there are multiple packages 3488 * sharing the same user id through the "sharedUserId" mechanism, all 3489 * packages with that id will be returned. 3490 * 3491 * @param uid The user id for which you would like to retrieve the 3492 * associated packages. 3493 * 3494 * @return Returns an array of one or more packages assigned to the user 3495 * id, or null if there are no known packages with the given id. 3496 */ 3497 public abstract @Nullable String[] getPackagesForUid(int uid); 3498 3499 /** 3500 * Retrieve the official name associated with a uid. This name is 3501 * guaranteed to never change, though it is possible for the underlying 3502 * uid to be changed. That is, if you are storing information about 3503 * uids in persistent storage, you should use the string returned 3504 * by this function instead of the raw uid. 3505 * 3506 * @param uid The uid for which you would like to retrieve a name. 3507 * @return Returns a unique name for the given uid, or null if the 3508 * uid is not currently assigned. 3509 */ 3510 public abstract @Nullable String getNameForUid(int uid); 3511 3512 /** 3513 * Return the user id associated with a shared user name. Multiple 3514 * applications can specify a shared user name in their manifest and thus 3515 * end up using a common uid. This might be used for new applications 3516 * that use an existing shared user name and need to know the uid of the 3517 * shared user. 3518 * 3519 * @param sharedUserName The shared user name whose uid is to be retrieved. 3520 * @return Returns the UID associated with the shared user. 3521 * @throws NameNotFoundException if a package with the given name cannot be 3522 * found on the system. 3523 * @hide 3524 */ 3525 public abstract int getUidForSharedUser(String sharedUserName) 3526 throws NameNotFoundException; 3527 3528 /** 3529 * Return a List of all application packages that are installed on the 3530 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 3531 * applications including those deleted with {@code DONT_DELETE_DATA} (partially 3532 * installed apps with data directory) will be returned. 3533 * 3534 * @param flags Additional option flags. Use any combination of 3535 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3536 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3537 * to modify the data returned. 3538 * 3539 * @return A List of ApplicationInfo objects, one for each installed application. 3540 * In the unlikely case there are no installed packages, an empty list 3541 * is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the 3542 * application information is retrieved from the list of uninstalled 3543 * applications (which includes installed applications as well as 3544 * applications with data directory i.e. applications which had been 3545 * deleted with {@code DONT_DELETE_DATA} flag set). 3546 * 3547 * @see #GET_META_DATA 3548 * @see #GET_SHARED_LIBRARY_FILES 3549 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3550 * @see #MATCH_SYSTEM_ONLY 3551 * @see #MATCH_UNINSTALLED_PACKAGES 3552 */ 3553 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags); 3554 3555 /** 3556 * Return a List of all application packages that are installed on the device, for a specific 3557 * user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all applications including 3558 * those deleted with {@code DONT_DELETE_DATA} (partially installed apps with data directory) 3559 * will be returned. 3560 * 3561 * @param flags Additional option flags. Use any combination of 3562 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3563 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3564 * to modify the data returned. 3565 * @param userId The user for whom the installed applications are to be listed 3566 * 3567 * @return A List of ApplicationInfo objects, one for each installed application. 3568 * In the unlikely case there are no installed packages, an empty list 3569 * is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the 3570 * application information is retrieved from the list of uninstalled 3571 * applications (which includes installed applications as well as 3572 * applications with data directory i.e. applications which had been 3573 * deleted with {@code DONT_DELETE_DATA} flag set). 3574 * @hide 3575 * 3576 * @see #GET_META_DATA 3577 * @see #GET_SHARED_LIBRARY_FILES 3578 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3579 * @see #MATCH_SYSTEM_ONLY 3580 * @see #MATCH_UNINSTALLED_PACKAGES 3581 */ 3582 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser( 3583 @ApplicationInfoFlags int flags, @UserIdInt int userId); 3584 3585 /** 3586 * Gets the ephemeral applications the user recently used. Requires 3587 * holding "android.permission.ACCESS_EPHEMERAL_APPS". 3588 * 3589 * @return The ephemeral app list. 3590 * 3591 * @hide 3592 */ 3593 @RequiresPermission(Manifest.permission.ACCESS_EPHEMERAL_APPS) 3594 public abstract List<EphemeralApplicationInfo> getEphemeralApplications(); 3595 3596 /** 3597 * Gets the icon for an ephemeral application. 3598 * 3599 * @param packageName The app package name. 3600 * 3601 * @hide 3602 */ 3603 public abstract Drawable getEphemeralApplicationIcon(String packageName); 3604 3605 /** 3606 * Gets whether the caller is an ephemeral app. 3607 * 3608 * @return Whether caller is an ephemeral app. 3609 * 3610 * @see #setEphemeralCookie(byte[]) 3611 * @see #getEphemeralCookie() 3612 * @see #getEphemeralCookieMaxSizeBytes() 3613 * 3614 * @hide 3615 */ 3616 public abstract boolean isEphemeralApplication(); 3617 3618 /** 3619 * Gets the maximum size in bytes of the cookie data an ephemeral app 3620 * can store on the device. 3621 * 3622 * @return The max cookie size in bytes. 3623 * 3624 * @see #isEphemeralApplication() 3625 * @see #setEphemeralCookie(byte[]) 3626 * @see #getEphemeralCookie() 3627 * 3628 * @hide 3629 */ 3630 public abstract int getEphemeralCookieMaxSizeBytes(); 3631 3632 /** 3633 * Gets the ephemeral application cookie for this app. Non 3634 * ephemeral apps and apps that were ephemeral but were upgraded 3635 * to non-ephemeral can still access this API. For ephemeral apps 3636 * this cooke is cached for some time after uninstall while for 3637 * normal apps the cookie is deleted after the app is uninstalled. 3638 * The cookie is always present while the app is installed. 3639 * 3640 * @return The cookie. 3641 * 3642 * @see #isEphemeralApplication() 3643 * @see #setEphemeralCookie(byte[]) 3644 * @see #getEphemeralCookieMaxSizeBytes() 3645 * 3646 * @hide 3647 */ 3648 public abstract @NonNull byte[] getEphemeralCookie(); 3649 3650 /** 3651 * Sets the ephemeral application cookie for the calling app. Non 3652 * ephemeral apps and apps that were ephemeral but were upgraded 3653 * to non-ephemeral can still access this API. For ephemeral apps 3654 * this cooke is cached for some time after uninstall while for 3655 * normal apps the cookie is deleted after the app is uninstalled. 3656 * The cookie is always present while the app is installed. The 3657 * cookie size is limited by {@link #getEphemeralCookieMaxSizeBytes()}. 3658 * 3659 * @param cookie The cookie data. 3660 * @return True if the cookie was set. 3661 * 3662 * @see #isEphemeralApplication() 3663 * @see #getEphemeralCookieMaxSizeBytes() 3664 * @see #getEphemeralCookie() 3665 * 3666 * @hide 3667 */ 3668 public abstract boolean setEphemeralCookie(@NonNull byte[] cookie); 3669 3670 /** 3671 * Get a list of shared libraries that are available on the 3672 * system. 3673 * 3674 * @return An array of shared library names that are 3675 * available on the system, or null if none are installed. 3676 * 3677 */ 3678 public abstract String[] getSystemSharedLibraryNames(); 3679 3680 /** 3681 * Get the name of the package hosting the services shared library. 3682 * 3683 * @return The library host package. 3684 * 3685 * @hide 3686 */ 3687 public abstract @NonNull String getServicesSystemSharedLibraryPackageName(); 3688 3689 /** 3690 * Get the name of the package hosting the shared components shared library. 3691 * 3692 * @return The library host package. 3693 * 3694 * @hide 3695 */ 3696 public abstract @NonNull String getSharedSystemSharedLibraryPackageName(); 3697 3698 /** 3699 * Get a list of features that are available on the 3700 * system. 3701 * 3702 * @return An array of FeatureInfo classes describing the features 3703 * that are available on the system, or null if there are none(!!). 3704 */ 3705 public abstract FeatureInfo[] getSystemAvailableFeatures(); 3706 3707 /** 3708 * Check whether the given feature name is one of the available features as 3709 * returned by {@link #getSystemAvailableFeatures()}. This tests for the 3710 * presence of <em>any</em> version of the given feature name; use 3711 * {@link #hasSystemFeature(String, int)} to check for a minimum version. 3712 * 3713 * @return Returns true if the devices supports the feature, else false. 3714 */ 3715 public abstract boolean hasSystemFeature(String name); 3716 3717 /** 3718 * Check whether the given feature name and version is one of the available 3719 * features as returned by {@link #getSystemAvailableFeatures()}. Since 3720 * features are defined to always be backwards compatible, this returns true 3721 * if the available feature version is greater than or equal to the 3722 * requested version. 3723 * 3724 * @return Returns true if the devices supports the feature, else false. 3725 */ 3726 public abstract boolean hasSystemFeature(String name, int version); 3727 3728 /** 3729 * Determine the best action to perform for a given Intent. This is how 3730 * {@link Intent#resolveActivity} finds an activity if a class has not been 3731 * explicitly specified. 3732 * <p> 3733 * <em>Note:</em> if using an implicit Intent (without an explicit 3734 * ComponentName specified), be sure to consider whether to set the 3735 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 3736 * activity in the same way that 3737 * {@link android.content.Context#startActivity(Intent)} and 3738 * {@link android.content.Intent#resolveActivity(PackageManager) 3739 * Intent.resolveActivity(PackageManager)} do. 3740 * </p> 3741 * 3742 * @param intent An intent containing all of the desired specification 3743 * (action, data, type, category, and/or component). 3744 * @param flags Additional option flags. Use any combination of 3745 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3746 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3747 * {@link #MATCH_DISABLED_COMPONENTS}, 3748 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3749 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 3750 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3751 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3752 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 3753 * to limit the resolution to only those activities that support 3754 * the {@link android.content.Intent#CATEGORY_DEFAULT}. 3755 * @return Returns a ResolveInfo object containing the final activity intent 3756 * that was determined to be the best action. Returns null if no 3757 * matching activity was found. If multiple matching activities are 3758 * found and there is no default set, returns a ResolveInfo object 3759 * containing something else, such as the activity resolver. 3760 * @see #GET_META_DATA 3761 * @see #GET_RESOLVED_FILTER 3762 * @see #GET_SHARED_LIBRARY_FILES 3763 * @see #MATCH_ALL 3764 * @see #MATCH_DISABLED_COMPONENTS 3765 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3766 * @see #MATCH_DEFAULT_ONLY 3767 * @see #MATCH_DIRECT_BOOT_AWARE 3768 * @see #MATCH_DIRECT_BOOT_UNAWARE 3769 * @see #MATCH_SYSTEM_ONLY 3770 * @see #MATCH_UNINSTALLED_PACKAGES 3771 */ 3772 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags); 3773 3774 /** 3775 * Determine the best action to perform for a given Intent for a given user. 3776 * This is how {@link Intent#resolveActivity} finds an activity if a class 3777 * has not been explicitly specified. 3778 * <p> 3779 * <em>Note:</em> if using an implicit Intent (without an explicit 3780 * ComponentName specified), be sure to consider whether to set the 3781 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 3782 * activity in the same way that 3783 * {@link android.content.Context#startActivity(Intent)} and 3784 * {@link android.content.Intent#resolveActivity(PackageManager) 3785 * Intent.resolveActivity(PackageManager)} do. 3786 * </p> 3787 * 3788 * @param intent An intent containing all of the desired specification 3789 * (action, data, type, category, and/or component). 3790 * @param flags Additional option flags. Use any combination of 3791 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3792 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3793 * {@link #MATCH_DISABLED_COMPONENTS}, 3794 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3795 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 3796 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3797 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3798 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 3799 * to limit the resolution to only those activities that support 3800 * the {@link android.content.Intent#CATEGORY_DEFAULT}. 3801 * @param userId The user id. 3802 * @return Returns a ResolveInfo object containing the final activity intent 3803 * that was determined to be the best action. Returns null if no 3804 * matching activity was found. If multiple matching activities are 3805 * found and there is no default set, returns a ResolveInfo object 3806 * containing something else, such as the activity resolver. 3807 * @see #GET_META_DATA 3808 * @see #GET_RESOLVED_FILTER 3809 * @see #GET_SHARED_LIBRARY_FILES 3810 * @see #MATCH_ALL 3811 * @see #MATCH_DISABLED_COMPONENTS 3812 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3813 * @see #MATCH_DEFAULT_ONLY 3814 * @see #MATCH_DIRECT_BOOT_AWARE 3815 * @see #MATCH_DIRECT_BOOT_UNAWARE 3816 * @see #MATCH_SYSTEM_ONLY 3817 * @see #MATCH_UNINSTALLED_PACKAGES 3818 * @hide 3819 */ 3820 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags, 3821 @UserIdInt int userId); 3822 3823 /** 3824 * Retrieve all activities that can be performed for the given intent. 3825 * 3826 * @param intent The desired intent as per resolveActivity(). 3827 * @param flags Additional option flags. Use any combination of 3828 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3829 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3830 * {@link #MATCH_DISABLED_COMPONENTS}, 3831 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3832 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 3833 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3834 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3835 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 3836 * to limit the resolution to only those activities that support 3837 * the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 3838 * {@link #MATCH_ALL} to prevent any filtering of the results. 3839 * @return Returns a List of ResolveInfo objects containing one entry for 3840 * each matching activity, ordered from best to worst. In other 3841 * words, the first item is what would be returned by 3842 * {@link #resolveActivity}. If there are no matching activities, an 3843 * empty list is returned. 3844 * @see #GET_META_DATA 3845 * @see #GET_RESOLVED_FILTER 3846 * @see #GET_SHARED_LIBRARY_FILES 3847 * @see #MATCH_ALL 3848 * @see #MATCH_DISABLED_COMPONENTS 3849 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3850 * @see #MATCH_DEFAULT_ONLY 3851 * @see #MATCH_DIRECT_BOOT_AWARE 3852 * @see #MATCH_DIRECT_BOOT_UNAWARE 3853 * @see #MATCH_SYSTEM_ONLY 3854 * @see #MATCH_UNINSTALLED_PACKAGES 3855 */ 3856 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 3857 @ResolveInfoFlags int flags); 3858 3859 /** 3860 * Retrieve all activities that can be performed for the given intent, for a 3861 * specific user. 3862 * 3863 * @param intent The desired intent as per resolveActivity(). 3864 * @param flags Additional option flags. Use any combination of 3865 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3866 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3867 * {@link #MATCH_DISABLED_COMPONENTS}, 3868 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3869 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 3870 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3871 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3872 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 3873 * to limit the resolution to only those activities that support 3874 * the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 3875 * {@link #MATCH_ALL} to prevent any filtering of the results. 3876 * @return Returns a List of ResolveInfo objects containing one entry for 3877 * each matching activity, ordered from best to worst. In other 3878 * words, the first item is what would be returned by 3879 * {@link #resolveActivity}. If there are no matching activities, an 3880 * empty list is returned. 3881 * @see #GET_META_DATA 3882 * @see #GET_RESOLVED_FILTER 3883 * @see #GET_SHARED_LIBRARY_FILES 3884 * @see #MATCH_ALL 3885 * @see #MATCH_DISABLED_COMPONENTS 3886 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3887 * @see #MATCH_DEFAULT_ONLY 3888 * @see #MATCH_DIRECT_BOOT_AWARE 3889 * @see #MATCH_DIRECT_BOOT_UNAWARE 3890 * @see #MATCH_SYSTEM_ONLY 3891 * @see #MATCH_UNINSTALLED_PACKAGES 3892 * @hide 3893 */ 3894 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 3895 @ResolveInfoFlags int flags, @UserIdInt int userId); 3896 3897 /** 3898 * Retrieve a set of activities that should be presented to the user as 3899 * similar options. This is like {@link #queryIntentActivities}, except it 3900 * also allows you to supply a list of more explicit Intents that you would 3901 * like to resolve to particular options, and takes care of returning the 3902 * final ResolveInfo list in a reasonable order, with no duplicates, based 3903 * on those inputs. 3904 * 3905 * @param caller The class name of the activity that is making the request. 3906 * This activity will never appear in the output list. Can be 3907 * null. 3908 * @param specifics An array of Intents that should be resolved to the first 3909 * specific results. Can be null. 3910 * @param intent The desired intent as per resolveActivity(). 3911 * @param flags Additional option flags. Use any combination of 3912 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3913 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3914 * {@link #MATCH_DISABLED_COMPONENTS}, 3915 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3916 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 3917 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3918 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3919 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 3920 * to limit the resolution to only those activities that support 3921 * the {@link android.content.Intent#CATEGORY_DEFAULT}. 3922 * @return Returns a List of ResolveInfo objects containing one entry for 3923 * each matching activity. The list is ordered first by all of the 3924 * intents resolved in <var>specifics</var> and then any additional 3925 * activities that can handle <var>intent</var> but did not get 3926 * included by one of the <var>specifics</var> intents. If there are 3927 * no matching activities, an empty list is returned. 3928 * @see #GET_META_DATA 3929 * @see #GET_RESOLVED_FILTER 3930 * @see #GET_SHARED_LIBRARY_FILES 3931 * @see #MATCH_ALL 3932 * @see #MATCH_DISABLED_COMPONENTS 3933 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3934 * @see #MATCH_DEFAULT_ONLY 3935 * @see #MATCH_DIRECT_BOOT_AWARE 3936 * @see #MATCH_DIRECT_BOOT_UNAWARE 3937 * @see #MATCH_SYSTEM_ONLY 3938 * @see #MATCH_UNINSTALLED_PACKAGES 3939 */ 3940 public abstract List<ResolveInfo> queryIntentActivityOptions( 3941 ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags); 3942 3943 /** 3944 * Retrieve all receivers that can handle a broadcast of the given intent. 3945 * 3946 * @param intent The desired intent as per resolveActivity(). 3947 * @param flags Additional option flags. Use any combination of 3948 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3949 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3950 * {@link #MATCH_DISABLED_COMPONENTS}, 3951 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3952 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 3953 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3954 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3955 * returned. 3956 * @return Returns a List of ResolveInfo objects containing one entry for 3957 * each matching receiver, ordered from best to worst. If there are 3958 * no matching receivers, an empty list or null is returned. 3959 * @see #GET_META_DATA 3960 * @see #GET_RESOLVED_FILTER 3961 * @see #GET_SHARED_LIBRARY_FILES 3962 * @see #MATCH_ALL 3963 * @see #MATCH_DISABLED_COMPONENTS 3964 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3965 * @see #MATCH_DEFAULT_ONLY 3966 * @see #MATCH_DIRECT_BOOT_AWARE 3967 * @see #MATCH_DIRECT_BOOT_UNAWARE 3968 * @see #MATCH_SYSTEM_ONLY 3969 * @see #MATCH_UNINSTALLED_PACKAGES 3970 */ 3971 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 3972 @ResolveInfoFlags int flags); 3973 3974 /** 3975 * Retrieve all receivers that can handle a broadcast of the given intent, 3976 * for a specific user. 3977 * 3978 * @param intent The desired intent as per resolveActivity(). 3979 * @param flags Additional option flags. Use any combination of 3980 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3981 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3982 * {@link #MATCH_DISABLED_COMPONENTS}, 3983 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3984 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 3985 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3986 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3987 * returned. 3988 * @param userHandle UserHandle of the user being queried. 3989 * @return Returns a List of ResolveInfo objects containing one entry for 3990 * each matching receiver, ordered from best to worst. If there are 3991 * no matching receivers, an empty list or null is returned. 3992 * @see #GET_META_DATA 3993 * @see #GET_RESOLVED_FILTER 3994 * @see #GET_SHARED_LIBRARY_FILES 3995 * @see #MATCH_ALL 3996 * @see #MATCH_DISABLED_COMPONENTS 3997 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3998 * @see #MATCH_DEFAULT_ONLY 3999 * @see #MATCH_DIRECT_BOOT_AWARE 4000 * @see #MATCH_DIRECT_BOOT_UNAWARE 4001 * @see #MATCH_SYSTEM_ONLY 4002 * @see #MATCH_UNINSTALLED_PACKAGES 4003 * @hide 4004 */ 4005 @SystemApi 4006 public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 4007 @ResolveInfoFlags int flags, UserHandle userHandle) { 4008 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 4009 } 4010 4011 /** 4012 * @hide 4013 */ 4014 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 4015 @ResolveInfoFlags int flags, @UserIdInt int userId); 4016 4017 4018 /** {@hide} */ 4019 @Deprecated 4020 public List<ResolveInfo> queryBroadcastReceivers(Intent intent, 4021 @ResolveInfoFlags int flags, @UserIdInt int userId) { 4022 Log.w(TAG, "STAHP USING HIDDEN APIS KTHX"); 4023 return queryBroadcastReceiversAsUser(intent, flags, userId); 4024 } 4025 4026 /** 4027 * Determine the best service to handle for a given Intent. 4028 * 4029 * @param intent An intent containing all of the desired specification 4030 * (action, data, type, category, and/or component). 4031 * @param flags Additional option flags. Use any combination of 4032 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4033 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4034 * {@link #MATCH_DISABLED_COMPONENTS}, 4035 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4036 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4037 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4038 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4039 * returned. 4040 * @return Returns a ResolveInfo object containing the final service intent 4041 * that was determined to be the best action. Returns null if no 4042 * matching service was found. 4043 * @see #GET_META_DATA 4044 * @see #GET_RESOLVED_FILTER 4045 * @see #GET_SHARED_LIBRARY_FILES 4046 * @see #MATCH_ALL 4047 * @see #MATCH_DISABLED_COMPONENTS 4048 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4049 * @see #MATCH_DEFAULT_ONLY 4050 * @see #MATCH_DIRECT_BOOT_AWARE 4051 * @see #MATCH_DIRECT_BOOT_UNAWARE 4052 * @see #MATCH_SYSTEM_ONLY 4053 * @see #MATCH_UNINSTALLED_PACKAGES 4054 */ 4055 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags); 4056 4057 /** 4058 * Retrieve all services that can match the given intent. 4059 * 4060 * @param intent The desired intent as per resolveService(). 4061 * @param flags Additional option flags. Use any combination of 4062 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4063 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4064 * {@link #MATCH_DISABLED_COMPONENTS}, 4065 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4066 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4067 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4068 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4069 * returned. 4070 * @return Returns a List of ResolveInfo objects containing one entry for 4071 * each matching service, ordered from best to worst. In other 4072 * words, the first item is what would be returned by 4073 * {@link #resolveService}. If there are no matching services, an 4074 * empty list or null is returned. 4075 * @see #GET_META_DATA 4076 * @see #GET_RESOLVED_FILTER 4077 * @see #GET_SHARED_LIBRARY_FILES 4078 * @see #MATCH_ALL 4079 * @see #MATCH_DISABLED_COMPONENTS 4080 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4081 * @see #MATCH_DEFAULT_ONLY 4082 * @see #MATCH_DIRECT_BOOT_AWARE 4083 * @see #MATCH_DIRECT_BOOT_UNAWARE 4084 * @see #MATCH_SYSTEM_ONLY 4085 * @see #MATCH_UNINSTALLED_PACKAGES 4086 */ 4087 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 4088 @ResolveInfoFlags int flags); 4089 4090 /** 4091 * Retrieve all services that can match the given intent for a given user. 4092 * 4093 * @param intent The desired intent as per resolveService(). 4094 * @param flags Additional option flags. Use any combination of 4095 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4096 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4097 * {@link #MATCH_DISABLED_COMPONENTS}, 4098 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4099 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4100 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4101 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4102 * returned. 4103 * @param userId The user id. 4104 * @return Returns a List of ResolveInfo objects containing one entry for 4105 * each matching service, ordered from best to worst. In other 4106 * words, the first item is what would be returned by 4107 * {@link #resolveService}. If there are no matching services, an 4108 * empty list or null is returned. 4109 * @see #GET_META_DATA 4110 * @see #GET_RESOLVED_FILTER 4111 * @see #GET_SHARED_LIBRARY_FILES 4112 * @see #MATCH_ALL 4113 * @see #MATCH_DISABLED_COMPONENTS 4114 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4115 * @see #MATCH_DEFAULT_ONLY 4116 * @see #MATCH_DIRECT_BOOT_AWARE 4117 * @see #MATCH_DIRECT_BOOT_UNAWARE 4118 * @see #MATCH_SYSTEM_ONLY 4119 * @see #MATCH_UNINSTALLED_PACKAGES 4120 * @hide 4121 */ 4122 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 4123 @ResolveInfoFlags int flags, @UserIdInt int userId); 4124 4125 /** 4126 * Retrieve all providers that can match the given intent. 4127 * 4128 * @param intent An intent containing all of the desired specification 4129 * (action, data, type, category, and/or component). 4130 * @param flags Additional option flags. Use any combination of 4131 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4132 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4133 * {@link #MATCH_DISABLED_COMPONENTS}, 4134 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4135 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4136 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4137 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4138 * returned. 4139 * @param userId The user id. 4140 * @return Returns a List of ResolveInfo objects containing one entry for 4141 * each matching provider, ordered from best to worst. If there are 4142 * no matching services, an empty list or null is returned. 4143 * @see #GET_META_DATA 4144 * @see #GET_RESOLVED_FILTER 4145 * @see #GET_SHARED_LIBRARY_FILES 4146 * @see #MATCH_ALL 4147 * @see #MATCH_DISABLED_COMPONENTS 4148 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4149 * @see #MATCH_DEFAULT_ONLY 4150 * @see #MATCH_DIRECT_BOOT_AWARE 4151 * @see #MATCH_DIRECT_BOOT_UNAWARE 4152 * @see #MATCH_SYSTEM_ONLY 4153 * @see #MATCH_UNINSTALLED_PACKAGES 4154 * @hide 4155 */ 4156 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 4157 Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId); 4158 4159 /** 4160 * Retrieve all providers that can match the given intent. 4161 * 4162 * @param intent An intent containing all of the desired specification 4163 * (action, data, type, category, and/or component). 4164 * @param flags Additional option flags. Use any combination of 4165 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4166 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4167 * {@link #MATCH_DISABLED_COMPONENTS}, 4168 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4169 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4170 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4171 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4172 * returned. 4173 * @return Returns a List of ResolveInfo objects containing one entry for 4174 * each matching provider, ordered from best to worst. If there are 4175 * no matching services, an empty list or null is returned. 4176 * @see #GET_META_DATA 4177 * @see #GET_RESOLVED_FILTER 4178 * @see #GET_SHARED_LIBRARY_FILES 4179 * @see #MATCH_ALL 4180 * @see #MATCH_DISABLED_COMPONENTS 4181 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4182 * @see #MATCH_DEFAULT_ONLY 4183 * @see #MATCH_DIRECT_BOOT_AWARE 4184 * @see #MATCH_DIRECT_BOOT_UNAWARE 4185 * @see #MATCH_SYSTEM_ONLY 4186 * @see #MATCH_UNINSTALLED_PACKAGES 4187 */ 4188 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, 4189 @ResolveInfoFlags int flags); 4190 4191 /** 4192 * Find a single content provider by its base path name. 4193 * 4194 * @param name The name of the provider to find. 4195 * @param flags Additional option flags. Use any combination of 4196 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 4197 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 4198 * {@link #MATCH_DISABLED_COMPONENTS}, 4199 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4200 * {@link #MATCH_DIRECT_BOOT_AWARE}, 4201 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4202 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4203 * returned. 4204 * @return A {@link ProviderInfo} object containing information about the 4205 * provider. If a provider was not found, returns null. 4206 * @see #GET_META_DATA 4207 * @see #GET_SHARED_LIBRARY_FILES 4208 * @see #MATCH_ALL 4209 * @see #MATCH_DEBUG_TRIAGED_MISSING 4210 * @see #MATCH_DEFAULT_ONLY 4211 * @see #MATCH_DISABLED_COMPONENTS 4212 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4213 * @see #MATCH_DIRECT_BOOT_AWARE 4214 * @see #MATCH_DIRECT_BOOT_UNAWARE 4215 * @see #MATCH_SYSTEM_ONLY 4216 * @see #MATCH_UNINSTALLED_PACKAGES 4217 */ 4218 public abstract ProviderInfo resolveContentProvider(String name, 4219 @ComponentInfoFlags int flags); 4220 4221 /** 4222 * Find a single content provider by its base path name. 4223 * 4224 * @param name The name of the provider to find. 4225 * @param flags Additional option flags. Use any combination of 4226 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 4227 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 4228 * {@link #MATCH_DISABLED_COMPONENTS}, 4229 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4230 * {@link #MATCH_DIRECT_BOOT_AWARE}, 4231 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4232 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4233 * returned. 4234 * @param userId The user id. 4235 * @return A {@link ProviderInfo} object containing information about the 4236 * provider. If a provider was not found, returns null. 4237 * @see #GET_META_DATA 4238 * @see #GET_SHARED_LIBRARY_FILES 4239 * @see #MATCH_ALL 4240 * @see #MATCH_DEBUG_TRIAGED_MISSING 4241 * @see #MATCH_DEFAULT_ONLY 4242 * @see #MATCH_DISABLED_COMPONENTS 4243 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4244 * @see #MATCH_DIRECT_BOOT_AWARE 4245 * @see #MATCH_DIRECT_BOOT_UNAWARE 4246 * @see #MATCH_SYSTEM_ONLY 4247 * @see #MATCH_UNINSTALLED_PACKAGES 4248 * @hide 4249 */ 4250 public abstract ProviderInfo resolveContentProviderAsUser(String name, 4251 @ComponentInfoFlags int flags, @UserIdInt int userId); 4252 4253 /** 4254 * Retrieve content provider information. 4255 * <p> 4256 * <em>Note: unlike most other methods, an empty result set is indicated 4257 * by a null return instead of an empty list.</em> 4258 * 4259 * @param processName If non-null, limits the returned providers to only 4260 * those that are hosted by the given process. If null, all 4261 * content providers are returned. 4262 * @param uid If <var>processName</var> is non-null, this is the required 4263 * uid owning the requested content providers. 4264 * @param flags Additional option flags. Use any combination of 4265 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 4266 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 4267 * {@link #MATCH_DISABLED_COMPONENTS}, 4268 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4269 * {@link #MATCH_DIRECT_BOOT_AWARE}, 4270 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4271 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4272 * returned. 4273 * @return A list of {@link ProviderInfo} objects containing one entry for 4274 * each provider either matching <var>processName</var> or, if 4275 * <var>processName</var> is null, all known content providers. 4276 * <em>If there are no matching providers, null is returned.</em> 4277 * @see #GET_META_DATA 4278 * @see #GET_SHARED_LIBRARY_FILES 4279 * @see #MATCH_ALL 4280 * @see #MATCH_DEBUG_TRIAGED_MISSING 4281 * @see #MATCH_DEFAULT_ONLY 4282 * @see #MATCH_DISABLED_COMPONENTS 4283 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4284 * @see #MATCH_DIRECT_BOOT_AWARE 4285 * @see #MATCH_DIRECT_BOOT_UNAWARE 4286 * @see #MATCH_SYSTEM_ONLY 4287 * @see #MATCH_UNINSTALLED_PACKAGES 4288 */ 4289 public abstract List<ProviderInfo> queryContentProviders( 4290 String processName, int uid, @ComponentInfoFlags int flags); 4291 4292 /** 4293 * Retrieve all of the information we know about a particular 4294 * instrumentation class. 4295 * 4296 * @param className The full name (i.e. 4297 * com.google.apps.contacts.InstrumentList) of an 4298 * Instrumentation class. 4299 * @param flags Additional option flags. Use any combination of 4300 * {@link #GET_META_DATA} 4301 * to modify the data returned. 4302 * 4303 * @return An {@link InstrumentationInfo} object containing information about the 4304 * instrumentation. 4305 * @throws NameNotFoundException if a package with the given name cannot be 4306 * found on the system. 4307 * 4308 * @see #GET_META_DATA 4309 */ 4310 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className, 4311 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 4312 4313 /** 4314 * Retrieve information about available instrumentation code. May be used 4315 * to retrieve either all instrumentation code, or only the code targeting 4316 * a particular package. 4317 * 4318 * @param targetPackage If null, all instrumentation is returned; only the 4319 * instrumentation targeting this package name is 4320 * returned. 4321 * @param flags Additional option flags. Use any combination of 4322 * {@link #GET_META_DATA} 4323 * to modify the data returned. 4324 * 4325 * @return A list of {@link InstrumentationInfo} objects containing one 4326 * entry for each matching instrumentation. If there are no 4327 * instrumentation available, returns an empty list. 4328 * 4329 * @see #GET_META_DATA 4330 */ 4331 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage, 4332 @InstrumentationInfoFlags int flags); 4333 4334 /** 4335 * Retrieve an image from a package. This is a low-level API used by 4336 * the various package manager info structures (such as 4337 * {@link ComponentInfo} to implement retrieval of their associated 4338 * icon. 4339 * 4340 * @param packageName The name of the package that this icon is coming from. 4341 * Cannot be null. 4342 * @param resid The resource identifier of the desired image. Cannot be 0. 4343 * @param appInfo Overall information about <var>packageName</var>. This 4344 * may be null, in which case the application information will be retrieved 4345 * for you if needed; if you already have this information around, it can 4346 * be much more efficient to supply it here. 4347 * 4348 * @return Returns a Drawable holding the requested image. Returns null if 4349 * an image could not be found for any reason. 4350 */ 4351 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid, 4352 ApplicationInfo appInfo); 4353 4354 /** 4355 * Retrieve the icon associated with an activity. Given the full name of 4356 * an activity, retrieves the information about it and calls 4357 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 4358 * If the activity cannot be found, NameNotFoundException is thrown. 4359 * 4360 * @param activityName Name of the activity whose icon is to be retrieved. 4361 * 4362 * @return Returns the image of the icon, or the default activity icon if 4363 * it could not be found. Does not return null. 4364 * @throws NameNotFoundException Thrown if the resources for the given 4365 * activity could not be loaded. 4366 * 4367 * @see #getActivityIcon(Intent) 4368 */ 4369 public abstract Drawable getActivityIcon(ComponentName activityName) 4370 throws NameNotFoundException; 4371 4372 /** 4373 * Retrieve the icon associated with an Intent. If intent.getClassName() is 4374 * set, this simply returns the result of 4375 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 4376 * component and returns the icon associated with the resolved component. 4377 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4378 * to a component, NameNotFoundException is thrown. 4379 * 4380 * @param intent The intent for which you would like to retrieve an icon. 4381 * 4382 * @return Returns the image of the icon, or the default activity icon if 4383 * it could not be found. Does not return null. 4384 * @throws NameNotFoundException Thrown if the resources for application 4385 * matching the given intent could not be loaded. 4386 * 4387 * @see #getActivityIcon(ComponentName) 4388 */ 4389 public abstract Drawable getActivityIcon(Intent intent) 4390 throws NameNotFoundException; 4391 4392 /** 4393 * Retrieve the banner associated with an activity. Given the full name of 4394 * an activity, retrieves the information about it and calls 4395 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 4396 * banner. If the activity cannot be found, NameNotFoundException is thrown. 4397 * 4398 * @param activityName Name of the activity whose banner is to be retrieved. 4399 * @return Returns the image of the banner, or null if the activity has no 4400 * banner specified. 4401 * @throws NameNotFoundException Thrown if the resources for the given 4402 * activity could not be loaded. 4403 * @see #getActivityBanner(Intent) 4404 */ 4405 public abstract Drawable getActivityBanner(ComponentName activityName) 4406 throws NameNotFoundException; 4407 4408 /** 4409 * Retrieve the banner associated with an Intent. If intent.getClassName() 4410 * is set, this simply returns the result of 4411 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 4412 * intent's component and returns the banner associated with the resolved 4413 * component. If intent.getClassName() cannot be found or the Intent cannot 4414 * be resolved to a component, NameNotFoundException is thrown. 4415 * 4416 * @param intent The intent for which you would like to retrieve a banner. 4417 * @return Returns the image of the banner, or null if the activity has no 4418 * banner specified. 4419 * @throws NameNotFoundException Thrown if the resources for application 4420 * matching the given intent could not be loaded. 4421 * @see #getActivityBanner(ComponentName) 4422 */ 4423 public abstract Drawable getActivityBanner(Intent intent) 4424 throws NameNotFoundException; 4425 4426 /** 4427 * Return the generic icon for an activity that is used when no specific 4428 * icon is defined. 4429 * 4430 * @return Drawable Image of the icon. 4431 */ 4432 public abstract Drawable getDefaultActivityIcon(); 4433 4434 /** 4435 * Retrieve the icon associated with an application. If it has not defined 4436 * an icon, the default app icon is returned. Does not return null. 4437 * 4438 * @param info Information about application being queried. 4439 * 4440 * @return Returns the image of the icon, or the default application icon 4441 * if it could not be found. 4442 * 4443 * @see #getApplicationIcon(String) 4444 */ 4445 public abstract Drawable getApplicationIcon(ApplicationInfo info); 4446 4447 /** 4448 * Retrieve the icon associated with an application. Given the name of the 4449 * application's package, retrieves the information about it and calls 4450 * getApplicationIcon() to return its icon. If the application cannot be 4451 * found, NameNotFoundException is thrown. 4452 * 4453 * @param packageName Name of the package whose application icon is to be 4454 * retrieved. 4455 * 4456 * @return Returns the image of the icon, or the default application icon 4457 * if it could not be found. Does not return null. 4458 * @throws NameNotFoundException Thrown if the resources for the given 4459 * application could not be loaded. 4460 * 4461 * @see #getApplicationIcon(ApplicationInfo) 4462 */ 4463 public abstract Drawable getApplicationIcon(String packageName) 4464 throws NameNotFoundException; 4465 4466 /** 4467 * Retrieve the banner associated with an application. 4468 * 4469 * @param info Information about application being queried. 4470 * @return Returns the image of the banner or null if the application has no 4471 * banner specified. 4472 * @see #getApplicationBanner(String) 4473 */ 4474 public abstract Drawable getApplicationBanner(ApplicationInfo info); 4475 4476 /** 4477 * Retrieve the banner associated with an application. Given the name of the 4478 * application's package, retrieves the information about it and calls 4479 * getApplicationIcon() to return its banner. If the application cannot be 4480 * found, NameNotFoundException is thrown. 4481 * 4482 * @param packageName Name of the package whose application banner is to be 4483 * retrieved. 4484 * @return Returns the image of the banner or null if the application has no 4485 * banner specified. 4486 * @throws NameNotFoundException Thrown if the resources for the given 4487 * application could not be loaded. 4488 * @see #getApplicationBanner(ApplicationInfo) 4489 */ 4490 public abstract Drawable getApplicationBanner(String packageName) 4491 throws NameNotFoundException; 4492 4493 /** 4494 * Retrieve the logo associated with an activity. Given the full name of an 4495 * activity, retrieves the information about it and calls 4496 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 4497 * logo. If the activity cannot be found, NameNotFoundException is thrown. 4498 * 4499 * @param activityName Name of the activity whose logo is to be retrieved. 4500 * @return Returns the image of the logo or null if the activity has no logo 4501 * specified. 4502 * @throws NameNotFoundException Thrown if the resources for the given 4503 * activity could not be loaded. 4504 * @see #getActivityLogo(Intent) 4505 */ 4506 public abstract Drawable getActivityLogo(ComponentName activityName) 4507 throws NameNotFoundException; 4508 4509 /** 4510 * Retrieve the logo associated with an Intent. If intent.getClassName() is 4511 * set, this simply returns the result of 4512 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 4513 * component and returns the logo associated with the resolved component. 4514 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4515 * to a component, NameNotFoundException is thrown. 4516 * 4517 * @param intent The intent for which you would like to retrieve a logo. 4518 * 4519 * @return Returns the image of the logo, or null if the activity has no 4520 * logo specified. 4521 * 4522 * @throws NameNotFoundException Thrown if the resources for application 4523 * matching the given intent could not be loaded. 4524 * 4525 * @see #getActivityLogo(ComponentName) 4526 */ 4527 public abstract Drawable getActivityLogo(Intent intent) 4528 throws NameNotFoundException; 4529 4530 /** 4531 * Retrieve the logo associated with an application. If it has not specified 4532 * a logo, this method returns null. 4533 * 4534 * @param info Information about application being queried. 4535 * 4536 * @return Returns the image of the logo, or null if no logo is specified 4537 * by the application. 4538 * 4539 * @see #getApplicationLogo(String) 4540 */ 4541 public abstract Drawable getApplicationLogo(ApplicationInfo info); 4542 4543 /** 4544 * Retrieve the logo associated with an application. Given the name of the 4545 * application's package, retrieves the information about it and calls 4546 * getApplicationLogo() to return its logo. If the application cannot be 4547 * found, NameNotFoundException is thrown. 4548 * 4549 * @param packageName Name of the package whose application logo is to be 4550 * retrieved. 4551 * 4552 * @return Returns the image of the logo, or null if no application logo 4553 * has been specified. 4554 * 4555 * @throws NameNotFoundException Thrown if the resources for the given 4556 * application could not be loaded. 4557 * 4558 * @see #getApplicationLogo(ApplicationInfo) 4559 */ 4560 public abstract Drawable getApplicationLogo(String packageName) 4561 throws NameNotFoundException; 4562 4563 /** 4564 * If the target user is a managed profile, then this returns a badged copy of the given icon 4565 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use 4566 * {@link #getUserBadgedDrawableForDensity( 4567 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 4568 * <p> 4569 * If the original drawable is a BitmapDrawable and the backing bitmap is 4570 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 4571 * is performed in place and the original drawable is returned. 4572 * </p> 4573 * 4574 * @param icon The icon to badge. 4575 * @param user The target user. 4576 * @return A drawable that combines the original icon and a badge as 4577 * determined by the system. 4578 */ 4579 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 4580 4581 /** 4582 * If the target user is a managed profile of the calling user or the caller 4583 * is itself a managed profile, then this returns a badged copy of the given 4584 * drawable allowing the user to distinguish it from the original drawable. 4585 * The caller can specify the location in the bounds of the drawable to be 4586 * badged where the badge should be applied as well as the density of the 4587 * badge to be used. 4588 * <p> 4589 * If the original drawable is a BitmapDrawable and the backing bitmap is 4590 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 4591 * is performed in place and the original drawable is returned. 4592 * </p> 4593 * 4594 * @param drawable The drawable to badge. 4595 * @param user The target user. 4596 * @param badgeLocation Where in the bounds of the badged drawable to place 4597 * the badge. If it's {@code null}, the badge is applied on top of the entire 4598 * drawable being badged. 4599 * @param badgeDensity The optional desired density for the badge as per 4600 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive, 4601 * the density of the display is used. 4602 * @return A drawable that combines the original drawable and a badge as 4603 * determined by the system. 4604 */ 4605 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 4606 UserHandle user, Rect badgeLocation, int badgeDensity); 4607 4608 /** 4609 * If the target user is a managed profile of the calling user or the caller 4610 * is itself a managed profile, then this returns a drawable to use as a small 4611 * icon to include in a view to distinguish it from the original icon. 4612 * 4613 * @param user The target user. 4614 * @param density The optional desired density for the badge as per 4615 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4616 * the density of the current display is used. 4617 * @return the drawable or null if no drawable is required. 4618 * @hide 4619 */ 4620 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 4621 4622 /** 4623 * If the target user is a managed profile of the calling user or the caller 4624 * is itself a managed profile, then this returns a drawable to use as a small 4625 * icon to include in a view to distinguish it from the original icon. This version 4626 * doesn't have background protection and should be used over a light background instead of 4627 * a badge. 4628 * 4629 * @param user The target user. 4630 * @param density The optional desired density for the badge as per 4631 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4632 * the density of the current display is used. 4633 * @return the drawable or null if no drawable is required. 4634 * @hide 4635 */ 4636 public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density); 4637 4638 /** 4639 * If the target user is a managed profile of the calling user or the caller 4640 * is itself a managed profile, then this returns a copy of the label with 4641 * badging for accessibility services like talkback. E.g. passing in "Email" 4642 * and it might return "Work Email" for Email in the work profile. 4643 * 4644 * @param label The label to change. 4645 * @param user The target user. 4646 * @return A label that combines the original label and a badge as 4647 * determined by the system. 4648 */ 4649 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 4650 4651 /** 4652 * Retrieve text from a package. This is a low-level API used by 4653 * the various package manager info structures (such as 4654 * {@link ComponentInfo} to implement retrieval of their associated 4655 * labels and other text. 4656 * 4657 * @param packageName The name of the package that this text is coming from. 4658 * Cannot be null. 4659 * @param resid The resource identifier of the desired text. Cannot be 0. 4660 * @param appInfo Overall information about <var>packageName</var>. This 4661 * may be null, in which case the application information will be retrieved 4662 * for you if needed; if you already have this information around, it can 4663 * be much more efficient to supply it here. 4664 * 4665 * @return Returns a CharSequence holding the requested text. Returns null 4666 * if the text could not be found for any reason. 4667 */ 4668 public abstract CharSequence getText(String packageName, @StringRes int resid, 4669 ApplicationInfo appInfo); 4670 4671 /** 4672 * Retrieve an XML file from a package. This is a low-level API used to 4673 * retrieve XML meta data. 4674 * 4675 * @param packageName The name of the package that this xml is coming from. 4676 * Cannot be null. 4677 * @param resid The resource identifier of the desired xml. Cannot be 0. 4678 * @param appInfo Overall information about <var>packageName</var>. This 4679 * may be null, in which case the application information will be retrieved 4680 * for you if needed; if you already have this information around, it can 4681 * be much more efficient to supply it here. 4682 * 4683 * @return Returns an XmlPullParser allowing you to parse out the XML 4684 * data. Returns null if the xml resource could not be found for any 4685 * reason. 4686 */ 4687 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid, 4688 ApplicationInfo appInfo); 4689 4690 /** 4691 * Return the label to use for this application. 4692 * 4693 * @return Returns the label associated with this application, or null if 4694 * it could not be found for any reason. 4695 * @param info The application to get the label of. 4696 */ 4697 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 4698 4699 /** 4700 * Retrieve the resources associated with an activity. Given the full 4701 * name of an activity, retrieves the information about it and calls 4702 * getResources() to return its application's resources. If the activity 4703 * cannot be found, NameNotFoundException is thrown. 4704 * 4705 * @param activityName Name of the activity whose resources are to be 4706 * retrieved. 4707 * 4708 * @return Returns the application's Resources. 4709 * @throws NameNotFoundException Thrown if the resources for the given 4710 * application could not be loaded. 4711 * 4712 * @see #getResourcesForApplication(ApplicationInfo) 4713 */ 4714 public abstract Resources getResourcesForActivity(ComponentName activityName) 4715 throws NameNotFoundException; 4716 4717 /** 4718 * Retrieve the resources for an application. Throws NameNotFoundException 4719 * if the package is no longer installed. 4720 * 4721 * @param app Information about the desired application. 4722 * 4723 * @return Returns the application's Resources. 4724 * @throws NameNotFoundException Thrown if the resources for the given 4725 * application could not be loaded (most likely because it was uninstalled). 4726 */ 4727 public abstract Resources getResourcesForApplication(ApplicationInfo app) 4728 throws NameNotFoundException; 4729 4730 /** 4731 * Retrieve the resources associated with an application. Given the full 4732 * package name of an application, retrieves the information about it and 4733 * calls getResources() to return its application's resources. If the 4734 * appPackageName cannot be found, NameNotFoundException is thrown. 4735 * 4736 * @param appPackageName Package name of the application whose resources 4737 * are to be retrieved. 4738 * 4739 * @return Returns the application's Resources. 4740 * @throws NameNotFoundException Thrown if the resources for the given 4741 * application could not be loaded. 4742 * 4743 * @see #getResourcesForApplication(ApplicationInfo) 4744 */ 4745 public abstract Resources getResourcesForApplication(String appPackageName) 4746 throws NameNotFoundException; 4747 4748 /** @hide */ 4749 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, 4750 @UserIdInt int userId) throws NameNotFoundException; 4751 4752 /** 4753 * Retrieve overall information about an application package defined 4754 * in a package archive file 4755 * 4756 * @param archiveFilePath The path to the archive file 4757 * @param flags Additional option flags. Use any combination of 4758 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 4759 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 4760 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 4761 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 4762 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 4763 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 4764 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 4765 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4766 * {@link #MATCH_UNINSTALLED_PACKAGES} 4767 * to modify the data returned. 4768 * 4769 * @return A PackageInfo object containing information about the 4770 * package archive. If the package could not be parsed, 4771 * returns null. 4772 * 4773 * @see #GET_ACTIVITIES 4774 * @see #GET_CONFIGURATIONS 4775 * @see #GET_GIDS 4776 * @see #GET_INSTRUMENTATION 4777 * @see #GET_INTENT_FILTERS 4778 * @see #GET_META_DATA 4779 * @see #GET_PERMISSIONS 4780 * @see #GET_PROVIDERS 4781 * @see #GET_RECEIVERS 4782 * @see #GET_SERVICES 4783 * @see #GET_SHARED_LIBRARY_FILES 4784 * @see #GET_SIGNATURES 4785 * @see #GET_URI_PERMISSION_PATTERNS 4786 * @see #MATCH_DISABLED_COMPONENTS 4787 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4788 * @see #MATCH_UNINSTALLED_PACKAGES 4789 * 4790 */ 4791 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) { 4792 final PackageParser parser = new PackageParser(); 4793 final File apkFile = new File(archiveFilePath); 4794 try { 4795 if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) { 4796 // Caller expressed an explicit opinion about what encryption 4797 // aware/unaware components they want to see, so fall through and 4798 // give them what they want 4799 } else { 4800 // Caller expressed no opinion, so match everything 4801 flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE; 4802 } 4803 4804 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 4805 if ((flags & GET_SIGNATURES) != 0) { 4806 PackageParser.collectCertificates(pkg, 0); 4807 } 4808 PackageUserState state = new PackageUserState(); 4809 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 4810 } catch (PackageParserException e) { 4811 return null; 4812 } 4813 } 4814 4815 /** 4816 * @deprecated replaced by {@link PackageInstaller} 4817 * @hide 4818 */ 4819 @Deprecated 4820 public abstract void installPackage( 4821 Uri packageURI, 4822 IPackageInstallObserver observer, 4823 @InstallFlags int flags, 4824 String installerPackageName); 4825 /** 4826 * @deprecated replaced by {@link PackageInstaller} 4827 * @hide 4828 */ 4829 @Deprecated 4830 public abstract void installPackage( 4831 Uri packageURI, 4832 PackageInstallObserver observer, 4833 @InstallFlags int flags, 4834 String installerPackageName); 4835 4836 /** 4837 * If there is already an application with the given package name installed 4838 * on the system for other users, also install it for the calling user. 4839 * @hide 4840 */ 4841 public abstract int installExistingPackage(String packageName) throws NameNotFoundException; 4842 4843 /** 4844 * If there is already an application with the given package name installed 4845 * on the system for other users, also install it for the specified user. 4846 * @hide 4847 */ 4848 @RequiresPermission(anyOf = { 4849 Manifest.permission.INSTALL_PACKAGES, 4850 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 4851 public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId) 4852 throws NameNotFoundException; 4853 4854 /** 4855 * Allows a package listening to the 4856 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4857 * broadcast} to respond to the package manager. The response must include 4858 * the {@code verificationCode} which is one of 4859 * {@link PackageManager#VERIFICATION_ALLOW} or 4860 * {@link PackageManager#VERIFICATION_REJECT}. 4861 * 4862 * @param id pending package identifier as passed via the 4863 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4864 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 4865 * or {@link PackageManager#VERIFICATION_REJECT}. 4866 * @throws SecurityException if the caller does not have the 4867 * PACKAGE_VERIFICATION_AGENT permission. 4868 */ 4869 public abstract void verifyPendingInstall(int id, int verificationCode); 4870 4871 /** 4872 * Allows a package listening to the 4873 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 4874 * broadcast} to extend the default timeout for a response and declare what 4875 * action to perform after the timeout occurs. The response must include 4876 * the {@code verificationCodeAtTimeout} which is one of 4877 * {@link PackageManager#VERIFICATION_ALLOW} or 4878 * {@link PackageManager#VERIFICATION_REJECT}. 4879 * 4880 * This method may only be called once per package id. Additional calls 4881 * will have no effect. 4882 * 4883 * @param id pending package identifier as passed via the 4884 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4885 * @param verificationCodeAtTimeout either 4886 * {@link PackageManager#VERIFICATION_ALLOW} or 4887 * {@link PackageManager#VERIFICATION_REJECT}. If 4888 * {@code verificationCodeAtTimeout} is neither 4889 * {@link PackageManager#VERIFICATION_ALLOW} or 4890 * {@link PackageManager#VERIFICATION_REJECT}, then 4891 * {@code verificationCodeAtTimeout} will default to 4892 * {@link PackageManager#VERIFICATION_REJECT}. 4893 * @param millisecondsToDelay the amount of time requested for the timeout. 4894 * Must be positive and less than 4895 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 4896 * {@code millisecondsToDelay} is out of bounds, 4897 * {@code millisecondsToDelay} will be set to the closest in 4898 * bounds value; namely, 0 or 4899 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 4900 * @throws SecurityException if the caller does not have the 4901 * PACKAGE_VERIFICATION_AGENT permission. 4902 */ 4903 public abstract void extendVerificationTimeout(int id, 4904 int verificationCodeAtTimeout, long millisecondsToDelay); 4905 4906 /** 4907 * Allows a package listening to the 4908 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification 4909 * broadcast to respond to the package manager. The response must include 4910 * the {@code verificationCode} which is one of 4911 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 4912 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4913 * 4914 * @param verificationId pending package identifier as passed via the 4915 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 4916 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 4917 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 4918 * @param failedDomains a list of failed domains if the verificationCode is 4919 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 4920 * @throws SecurityException if the caller does not have the 4921 * INTENT_FILTER_VERIFICATION_AGENT permission. 4922 * 4923 * @hide 4924 */ 4925 @SystemApi 4926 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 4927 List<String> failedDomains); 4928 4929 /** 4930 * Get the status of a Domain Verification Result for an IntentFilter. This is 4931 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4932 * {@link android.content.IntentFilter#getAutoVerify()} 4933 * 4934 * This is used by the ResolverActivity to change the status depending on what the User select 4935 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4936 * for a domain. 4937 * 4938 * @param packageName The package name of the Activity associated with the IntentFilter. 4939 * @param userId The user id. 4940 * 4941 * @return The status to set to. This can be 4942 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4943 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4944 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 4945 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 4946 * 4947 * @hide 4948 */ 4949 public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId); 4950 4951 /** 4952 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 4953 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 4954 * {@link android.content.IntentFilter#getAutoVerify()} 4955 * 4956 * This is used by the ResolverActivity to change the status depending on what the User select 4957 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 4958 * for a domain. 4959 * 4960 * @param packageName The package name of the Activity associated with the IntentFilter. 4961 * @param status The status to set to. This can be 4962 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 4963 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 4964 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 4965 * @param userId The user id. 4966 * 4967 * @return true if the status has been set. False otherwise. 4968 * 4969 * @hide 4970 */ 4971 public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status, 4972 @UserIdInt int userId); 4973 4974 /** 4975 * Get the list of IntentFilterVerificationInfo for a specific package and User. 4976 * 4977 * @param packageName the package name. When this parameter is set to a non null value, 4978 * the results will be filtered by the package name provided. 4979 * Otherwise, there will be no filtering and it will return a list 4980 * corresponding for all packages 4981 * 4982 * @return a list of IntentFilterVerificationInfo for a specific package. 4983 * 4984 * @hide 4985 */ 4986 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 4987 String packageName); 4988 4989 /** 4990 * Get the list of IntentFilter for a specific package. 4991 * 4992 * @param packageName the package name. This parameter is set to a non null value, 4993 * the list will contain all the IntentFilter for that package. 4994 * Otherwise, the list will be empty. 4995 * 4996 * @return a list of IntentFilter for a specific package. 4997 * 4998 * @hide 4999 */ 5000 public abstract List<IntentFilter> getAllIntentFilters(String packageName); 5001 5002 /** 5003 * Get the default Browser package name for a specific user. 5004 * 5005 * @param userId The user id. 5006 * 5007 * @return the package name of the default Browser for the specified user. If the user id passed 5008 * is -1 (all users) it will return a null value. 5009 * 5010 * @hide 5011 */ 5012 @TestApi 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 public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName, 5028 @UserIdInt int userId); 5029 5030 /** 5031 * Change the installer associated with a given package. There are limitations 5032 * on how the installer package can be changed; in particular: 5033 * <ul> 5034 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 5035 * is not signed with the same certificate as the calling application. 5036 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 5037 * has an installer package, and that installer package is not signed with 5038 * the same certificate as the calling application. 5039 * </ul> 5040 * 5041 * @param targetPackage The installed package whose installer will be changed. 5042 * @param installerPackageName The package name of the new installer. May be 5043 * null to clear the association. 5044 */ 5045 public abstract void setInstallerPackageName(String targetPackage, 5046 String installerPackageName); 5047 5048 /** 5049 * Attempts to delete a package. Since this may take a little while, the 5050 * result will be posted back to the given observer. A deletion will fail if 5051 * the calling context lacks the 5052 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 5053 * named package cannot be found, or if the named package is a system 5054 * package. 5055 * 5056 * @param packageName The name of the package to delete 5057 * @param observer An observer callback to get notified when the package 5058 * deletion is complete. 5059 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 5060 * will be called when that happens. observer may be null to 5061 * indicate that no callback is desired. 5062 * @hide 5063 */ 5064 public abstract void deletePackage(String packageName, IPackageDeleteObserver observer, 5065 @DeleteFlags int flags); 5066 5067 /** 5068 * Attempts to delete a package. Since this may take a little while, the 5069 * result will be posted back to the given observer. A deletion will fail if 5070 * the named package cannot be found, or if the named package is a system 5071 * package. 5072 * 5073 * @param packageName The name of the package to delete 5074 * @param observer An observer callback to get notified when the package 5075 * deletion is complete. 5076 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 5077 * will be called when that happens. observer may be null to 5078 * indicate that no callback is desired. 5079 * @param userId The user Id 5080 * @hide 5081 */ 5082 @RequiresPermission(anyOf = { 5083 Manifest.permission.DELETE_PACKAGES, 5084 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 5085 public abstract void deletePackageAsUser(String packageName, IPackageDeleteObserver observer, 5086 @DeleteFlags int flags, @UserIdInt int userId); 5087 5088 /** 5089 * Retrieve the package name of the application that installed a package. This identifies 5090 * which market the package came from. 5091 * 5092 * @param packageName The name of the package to query 5093 */ 5094 public abstract String getInstallerPackageName(String packageName); 5095 5096 /** 5097 * Attempts to clear the user data directory of an application. 5098 * Since this may take a little while, the result will 5099 * be posted back to the given observer. A deletion will fail if the 5100 * named package cannot be found, or if the named package is a "system package". 5101 * 5102 * @param packageName The name of the package 5103 * @param observer An observer callback to get notified when the operation is finished 5104 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5105 * will be called when that happens. observer may be null to indicate that 5106 * no callback is desired. 5107 * 5108 * @hide 5109 */ 5110 public abstract void clearApplicationUserData(String packageName, 5111 IPackageDataObserver observer); 5112 /** 5113 * Attempts to delete the cache files associated with an application. 5114 * Since this may take a little while, the result will 5115 * be posted back to the given observer. A deletion will fail if the calling context 5116 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 5117 * named package cannot be found, or if the named package is a "system package". 5118 * 5119 * @param packageName The name of the package to delete 5120 * @param observer An observer callback to get notified when the cache file deletion 5121 * is complete. 5122 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5123 * will be called when that happens. observer may be null to indicate that 5124 * no callback is desired. 5125 * 5126 * @hide 5127 */ 5128 public abstract void deleteApplicationCacheFiles(String packageName, 5129 IPackageDataObserver observer); 5130 5131 /** 5132 * Attempts to delete the cache files associated with an application for a given user. Since 5133 * this may take a little while, the result will be posted back to the given observer. A 5134 * deletion will fail if the calling context lacks the 5135 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package 5136 * cannot be found, or if the named package is a "system package". If {@code userId} does not 5137 * belong to the calling user, the caller must have 5138 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission. 5139 * 5140 * @param packageName The name of the package to delete 5141 * @param userId the user for which the cache files needs to be deleted 5142 * @param observer An observer callback to get notified when the cache file deletion is 5143 * complete. 5144 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5145 * will be called when that happens. observer may be null to indicate that no 5146 * callback is desired. 5147 * @hide 5148 */ 5149 public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId, 5150 IPackageDataObserver observer); 5151 5152 /** 5153 * Free storage by deleting LRU sorted list of cache files across 5154 * all applications. If the currently available free storage 5155 * on the device is greater than or equal to the requested 5156 * free storage, no cache files are cleared. If the currently 5157 * available storage on the device is less than the requested 5158 * free storage, some or all of the cache files across 5159 * all applications are deleted (based on last accessed time) 5160 * to increase the free storage space on the device to 5161 * the requested value. There is no guarantee that clearing all 5162 * the cache files from all applications will clear up 5163 * enough storage to achieve the desired value. 5164 * @param freeStorageSize The number of bytes of storage to be 5165 * freed by the system. Say if freeStorageSize is XX, 5166 * and the current free storage is YY, 5167 * if XX is less than YY, just return. if not free XX-YY number 5168 * of bytes if possible. 5169 * @param observer call back used to notify when 5170 * the operation is completed 5171 * 5172 * @hide 5173 */ 5174 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) { 5175 freeStorageAndNotify(null, freeStorageSize, observer); 5176 } 5177 5178 /** {@hide} */ 5179 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize, 5180 IPackageDataObserver observer); 5181 5182 /** 5183 * Free storage by deleting LRU sorted list of cache files across 5184 * all applications. If the currently available free storage 5185 * on the device is greater than or equal to the requested 5186 * free storage, no cache files are cleared. If the currently 5187 * available storage on the device is less than the requested 5188 * free storage, some or all of the cache files across 5189 * all applications are deleted (based on last accessed time) 5190 * to increase the free storage space on the device to 5191 * the requested value. There is no guarantee that clearing all 5192 * the cache files from all applications will clear up 5193 * enough storage to achieve the desired value. 5194 * @param freeStorageSize The number of bytes of storage to be 5195 * freed by the system. Say if freeStorageSize is XX, 5196 * and the current free storage is YY, 5197 * if XX is less than YY, just return. if not free XX-YY number 5198 * of bytes if possible. 5199 * @param pi IntentSender call back used to 5200 * notify when the operation is completed.May be null 5201 * to indicate that no call back is desired. 5202 * 5203 * @hide 5204 */ 5205 public void freeStorage(long freeStorageSize, IntentSender pi) { 5206 freeStorage(null, freeStorageSize, pi); 5207 } 5208 5209 /** {@hide} */ 5210 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi); 5211 5212 /** 5213 * Retrieve the size information for a package. 5214 * Since this may take a little while, the result will 5215 * be posted back to the given observer. The calling context 5216 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 5217 * 5218 * @param packageName The name of the package whose size information is to be retrieved 5219 * @param userId The user whose size information should be retrieved. 5220 * @param observer An observer callback to get notified when the operation 5221 * is complete. 5222 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 5223 * The observer's callback is invoked with a PackageStats object(containing the 5224 * code, data and cache sizes of the package) and a boolean value representing 5225 * the status of the operation. observer may be null to indicate that 5226 * no callback is desired. 5227 * 5228 * @hide 5229 */ 5230 public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId, 5231 IPackageStatsObserver observer); 5232 5233 /** 5234 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but 5235 * returns the size for the calling user. 5236 * 5237 * @hide 5238 */ 5239 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 5240 getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer); 5241 } 5242 5243 /** 5244 * @deprecated This function no longer does anything; it was an old 5245 * approach to managing preferred activities, which has been superseded 5246 * by (and conflicts with) the modern activity-based preferences. 5247 */ 5248 @Deprecated 5249 public abstract void addPackageToPreferred(String packageName); 5250 5251 /** 5252 * @deprecated This function no longer does anything; it was an old 5253 * approach to managing preferred activities, which has been superseded 5254 * by (and conflicts with) the modern activity-based preferences. 5255 */ 5256 @Deprecated 5257 public abstract void removePackageFromPreferred(String packageName); 5258 5259 /** 5260 * Retrieve the list of all currently configured preferred packages. The 5261 * first package on the list is the most preferred, the last is the 5262 * least preferred. 5263 * 5264 * @param flags Additional option flags. Use any combination of 5265 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 5266 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 5267 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 5268 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 5269 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 5270 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 5271 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 5272 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 5273 * {@link #MATCH_UNINSTALLED_PACKAGES} 5274 * to modify the data returned. 5275 * 5276 * @return A List of PackageInfo objects, one for each preferred application, 5277 * in order of preference. 5278 * 5279 * @see #GET_ACTIVITIES 5280 * @see #GET_CONFIGURATIONS 5281 * @see #GET_GIDS 5282 * @see #GET_INSTRUMENTATION 5283 * @see #GET_INTENT_FILTERS 5284 * @see #GET_META_DATA 5285 * @see #GET_PERMISSIONS 5286 * @see #GET_PROVIDERS 5287 * @see #GET_RECEIVERS 5288 * @see #GET_SERVICES 5289 * @see #GET_SHARED_LIBRARY_FILES 5290 * @see #GET_SIGNATURES 5291 * @see #GET_URI_PERMISSION_PATTERNS 5292 * @see #MATCH_DISABLED_COMPONENTS 5293 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 5294 * @see #MATCH_UNINSTALLED_PACKAGES 5295 */ 5296 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags); 5297 5298 /** 5299 * @deprecated This is a protected API that should not have been available 5300 * to third party applications. It is the platform's responsibility for 5301 * assigning preferred activities and this cannot be directly modified. 5302 * 5303 * Add a new preferred activity mapping to the system. This will be used 5304 * to automatically select the given activity component when 5305 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5306 * multiple matching activities and also matches the given filter. 5307 * 5308 * @param filter The set of intents under which this activity will be 5309 * made preferred. 5310 * @param match The IntentFilter match category that this preference 5311 * applies to. 5312 * @param set The set of activities that the user was picking from when 5313 * this preference was made. 5314 * @param activity The component name of the activity that is to be 5315 * preferred. 5316 */ 5317 @Deprecated 5318 public abstract void addPreferredActivity(IntentFilter filter, int match, 5319 ComponentName[] set, ComponentName activity); 5320 5321 /** 5322 * Same as {@link #addPreferredActivity(IntentFilter, int, 5323 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 5324 to. 5325 * @hide 5326 */ 5327 public void addPreferredActivityAsUser(IntentFilter filter, int match, 5328 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5329 throw new RuntimeException("Not implemented. Must override in a subclass."); 5330 } 5331 5332 /** 5333 * @deprecated This is a protected API that should not have been available 5334 * to third party applications. It is the platform's responsibility for 5335 * assigning preferred activities and this cannot be directly modified. 5336 * 5337 * Replaces an existing preferred activity mapping to the system, and if that were not present 5338 * adds a new preferred activity. This will be used 5339 * to automatically select the given activity component when 5340 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5341 * multiple matching activities and also matches the given filter. 5342 * 5343 * @param filter The set of intents under which this activity will be 5344 * made preferred. 5345 * @param match The IntentFilter match category that this preference 5346 * applies to. 5347 * @param set The set of activities that the user was picking from when 5348 * this preference was made. 5349 * @param activity The component name of the activity that is to be 5350 * preferred. 5351 * @hide 5352 */ 5353 @Deprecated 5354 public abstract void replacePreferredActivity(IntentFilter filter, int match, 5355 ComponentName[] set, ComponentName activity); 5356 5357 /** 5358 * @hide 5359 */ 5360 @Deprecated 5361 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 5362 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5363 throw new RuntimeException("Not implemented. Must override in a subclass."); 5364 } 5365 5366 /** 5367 * Remove all preferred activity mappings, previously added with 5368 * {@link #addPreferredActivity}, from the 5369 * system whose activities are implemented in the given package name. 5370 * An application can only clear its own package(s). 5371 * 5372 * @param packageName The name of the package whose preferred activity 5373 * mappings are to be removed. 5374 */ 5375 public abstract void clearPackagePreferredActivities(String packageName); 5376 5377 /** 5378 * Retrieve all preferred activities, previously added with 5379 * {@link #addPreferredActivity}, that are 5380 * currently registered with the system. 5381 * 5382 * @param outFilters A required list in which to place the filters of all of the 5383 * preferred activities. 5384 * @param outActivities A required list in which to place the component names of 5385 * all of the preferred activities. 5386 * @param packageName An optional package in which you would like to limit 5387 * the list. If null, all activities will be returned; if non-null, only 5388 * those activities in the given package are returned. 5389 * 5390 * @return Returns the total number of registered preferred activities 5391 * (the number of distinct IntentFilter records, not the number of unique 5392 * activity components) that were found. 5393 */ 5394 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 5395 @NonNull List<ComponentName> outActivities, String packageName); 5396 5397 /** 5398 * Ask for the set of available 'home' activities and the current explicit 5399 * default, if any. 5400 * @hide 5401 */ 5402 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 5403 5404 /** 5405 * Set the enabled setting for a package component (activity, receiver, service, provider). 5406 * This setting will override any enabled state which may have been set by the component in its 5407 * manifest. 5408 * 5409 * @param componentName The component to enable 5410 * @param newState The new enabled state for the component. The legal values for this state 5411 * are: 5412 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5413 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 5414 * and 5415 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 5416 * The last one removes the setting, thereby restoring the component's state to 5417 * whatever was set in it's manifest (or enabled, by default). 5418 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 5419 */ 5420 public abstract void setComponentEnabledSetting(ComponentName componentName, 5421 int newState, int flags); 5422 5423 /** 5424 * Return the enabled setting for a package component (activity, 5425 * receiver, service, provider). This returns the last value set by 5426 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 5427 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5428 * the value originally specified in the manifest has not been modified. 5429 * 5430 * @param componentName The component to retrieve. 5431 * @return Returns the current enabled state for the component. May 5432 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5433 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 5434 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 5435 * component's enabled state is based on the original information in 5436 * the manifest as found in {@link ComponentInfo}. 5437 */ 5438 public abstract int getComponentEnabledSetting(ComponentName componentName); 5439 5440 /** 5441 * Set the enabled setting for an application 5442 * This setting will override any enabled state which may have been set by the application in 5443 * its manifest. It also overrides the enabled state set in the manifest for any of the 5444 * application's components. It does not override any enabled state set by 5445 * {@link #setComponentEnabledSetting} for any of the application's components. 5446 * 5447 * @param packageName The package name of the application to enable 5448 * @param newState The new enabled state for the component. The legal values for this state 5449 * are: 5450 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5451 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 5452 * and 5453 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 5454 * The last one removes the setting, thereby restoring the applications's state to 5455 * whatever was set in its manifest (or enabled, by default). 5456 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 5457 */ 5458 public abstract void setApplicationEnabledSetting(String packageName, 5459 int newState, int flags); 5460 5461 /** 5462 * Return the enabled setting for an application. This returns 5463 * the last value set by 5464 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 5465 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5466 * the value originally specified in the manifest has not been modified. 5467 * 5468 * @param packageName The package name of the application to retrieve. 5469 * @return Returns the current enabled state for the application. May 5470 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5471 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 5472 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 5473 * application's enabled state is based on the original information in 5474 * the manifest as found in {@link ApplicationInfo}. 5475 * @throws IllegalArgumentException if the named package does not exist. 5476 */ 5477 public abstract int getApplicationEnabledSetting(String packageName); 5478 5479 /** 5480 * Flush the package restrictions for a given user to disk. This forces the package restrictions 5481 * like component and package enabled settings to be written to disk and avoids the delay that 5482 * is otherwise present when changing those settings. 5483 * 5484 * @param userId Ther userId of the user whose restrictions are to be flushed. 5485 * @hide 5486 */ 5487 public abstract void flushPackageRestrictionsAsUser(int userId); 5488 5489 /** 5490 * Puts the package in a hidden state, which is almost like an uninstalled state, 5491 * making the package unavailable, but it doesn't remove the data or the actual 5492 * package file. Application can be unhidden by either resetting the hidden state 5493 * or by installing it, such as with {@link #installExistingPackage(String)} 5494 * @hide 5495 */ 5496 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 5497 UserHandle userHandle); 5498 5499 /** 5500 * Returns the hidden state of a package. 5501 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 5502 * @hide 5503 */ 5504 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 5505 UserHandle userHandle); 5506 5507 /** 5508 * Return whether the device has been booted into safe mode. 5509 */ 5510 public abstract boolean isSafeMode(); 5511 5512 /** 5513 * Adds a listener for permission changes for installed packages. 5514 * 5515 * @param listener The listener to add. 5516 * 5517 * @hide 5518 */ 5519 @SystemApi 5520 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 5521 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5522 5523 /** 5524 * Remvoes a listener for permission changes for installed packages. 5525 * 5526 * @param listener The listener to remove. 5527 * 5528 * @hide 5529 */ 5530 @SystemApi 5531 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5532 5533 /** 5534 * Return the {@link KeySet} associated with the String alias for this 5535 * application. 5536 * 5537 * @param alias The alias for a given {@link KeySet} as defined in the 5538 * application's AndroidManifest.xml. 5539 * @hide 5540 */ 5541 public abstract KeySet getKeySetByAlias(String packageName, String alias); 5542 5543 /** Return the signing {@link KeySet} for this application. 5544 * @hide 5545 */ 5546 public abstract KeySet getSigningKeySet(String packageName); 5547 5548 /** 5549 * Return whether the package denoted by packageName has been signed by all 5550 * of the keys specified by the {@link KeySet} ks. This will return true if 5551 * the package has been signed by additional keys (a superset) as well. 5552 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 5553 * @hide 5554 */ 5555 public abstract boolean isSignedBy(String packageName, KeySet ks); 5556 5557 /** 5558 * Return whether the package denoted by packageName has been signed by all 5559 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 5560 * {@link #isSignedBy(String packageName, KeySet ks)}. 5561 * @hide 5562 */ 5563 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 5564 5565 /** 5566 * Puts the package in a suspended state, where attempts at starting activities are denied. 5567 * 5568 * <p>It doesn't remove the data or the actual package file. The application notifications 5569 * will be hidden, the application will not show up in recents, will not be able to show 5570 * toasts or dialogs or ring the device. 5571 * 5572 * <p>The package must already be installed. If the package is uninstalled while suspended 5573 * the package will no longer be suspended. 5574 * 5575 * @param packageNames The names of the packages to set the suspended status. 5576 * @param suspended If set to {@code true} than the packages will be suspended, if set to 5577 * {@code false} the packages will be unsuspended. 5578 * @param userId The user id. 5579 * 5580 * @return an array of package names for which the suspended status is not set as requested in 5581 * this method. 5582 * 5583 * @hide 5584 */ 5585 public abstract String[] setPackagesSuspendedAsUser( 5586 String[] packageNames, boolean suspended, @UserIdInt int userId); 5587 5588 /** 5589 * @see #setPackageSuspendedAsUser(String, boolean, int) 5590 * @param packageName The name of the package to get the suspended status of. 5591 * @param userId The user id. 5592 * @return {@code true} if the package is suspended or {@code false} if the package is not 5593 * suspended or could not be found. 5594 * @hide 5595 */ 5596 public abstract boolean isPackageSuspendedForUser(String packageName, int userId); 5597 5598 /** {@hide} */ 5599 public static boolean isMoveStatusFinished(int status) { 5600 return (status < 0 || status > 100); 5601 } 5602 5603 /** {@hide} */ 5604 public static abstract class MoveCallback { 5605 public void onCreated(int moveId, Bundle extras) {} 5606 public abstract void onStatusChanged(int moveId, int status, long estMillis); 5607 } 5608 5609 /** {@hide} */ 5610 public abstract int getMoveStatus(int moveId); 5611 5612 /** {@hide} */ 5613 public abstract void registerMoveCallback(MoveCallback callback, Handler handler); 5614 /** {@hide} */ 5615 public abstract void unregisterMoveCallback(MoveCallback callback); 5616 5617 /** {@hide} */ 5618 public abstract int movePackage(String packageName, VolumeInfo vol); 5619 /** {@hide} */ 5620 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app); 5621 /** {@hide} */ 5622 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app); 5623 5624 /** {@hide} */ 5625 public abstract int movePrimaryStorage(VolumeInfo vol); 5626 /** {@hide} */ 5627 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 5628 /** {@hide} */ 5629 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 5630 5631 /** 5632 * Returns the device identity that verifiers can use to associate their scheme to a particular 5633 * device. This should not be used by anything other than a package verifier. 5634 * 5635 * @return identity that uniquely identifies current device 5636 * @hide 5637 */ 5638 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 5639 5640 /** 5641 * Returns true if the device is upgrading, such as first boot after OTA. 5642 * 5643 * @hide 5644 */ 5645 public abstract boolean isUpgrade(); 5646 5647 /** 5648 * Return interface that offers the ability to install, upgrade, and remove 5649 * applications on the device. 5650 */ 5651 public abstract @NonNull PackageInstaller getPackageInstaller(); 5652 5653 /** 5654 * Adds a {@code CrossProfileIntentFilter}. After calling this method all 5655 * intents sent from the user with id sourceUserId can also be be resolved 5656 * by activities in the user with id targetUserId if they match the 5657 * specified intent filter. 5658 * 5659 * @param filter The {@link IntentFilter} the intent has to match 5660 * @param sourceUserId The source user id. 5661 * @param targetUserId The target user id. 5662 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 5663 * {@link #ONLY_IF_NO_MATCH_FOUND}. 5664 * @hide 5665 */ 5666 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 5667 int targetUserId, int flags); 5668 5669 /** 5670 * Clearing {@code CrossProfileIntentFilter}s which have the specified user 5671 * as their source, and have been set by the app calling this method. 5672 * 5673 * @param sourceUserId The source user id. 5674 * @hide 5675 */ 5676 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 5677 5678 /** 5679 * @hide 5680 */ 5681 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 5682 5683 /** 5684 * @hide 5685 */ 5686 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 5687 5688 /** {@hide} */ 5689 public abstract boolean isPackageAvailable(String packageName); 5690 5691 /** {@hide} */ 5692 public static String installStatusToString(int status, String msg) { 5693 final String str = installStatusToString(status); 5694 if (msg != null) { 5695 return str + ": " + msg; 5696 } else { 5697 return str; 5698 } 5699 } 5700 5701 /** {@hide} */ 5702 public static String installStatusToString(int status) { 5703 switch (status) { 5704 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 5705 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 5706 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 5707 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 5708 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 5709 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 5710 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 5711 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 5712 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 5713 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 5714 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 5715 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 5716 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 5717 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 5718 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 5719 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 5720 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 5721 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 5722 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 5723 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 5724 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 5725 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 5726 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 5727 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 5728 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 5729 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 5730 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 5731 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 5732 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 5733 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 5734 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 5735 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 5736 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 5737 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 5738 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 5739 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 5740 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 5741 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 5742 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 5743 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 5744 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 5745 default: return Integer.toString(status); 5746 } 5747 } 5748 5749 /** {@hide} */ 5750 public static int installStatusToPublicStatus(int status) { 5751 switch (status) { 5752 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5753 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5754 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5755 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 5756 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5757 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5758 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5759 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5760 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5761 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5762 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5763 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 5764 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5765 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5766 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5767 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 5768 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5769 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5770 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 5771 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 5772 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 5773 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 5774 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 5775 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5776 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 5777 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5778 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 5779 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 5780 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 5781 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 5782 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5783 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 5784 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 5785 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 5786 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 5787 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 5788 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 5789 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5790 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5791 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 5792 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 5793 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5794 default: return PackageInstaller.STATUS_FAILURE; 5795 } 5796 } 5797 5798 /** {@hide} */ 5799 public static String deleteStatusToString(int status, String msg) { 5800 final String str = deleteStatusToString(status); 5801 if (msg != null) { 5802 return str + ": " + msg; 5803 } else { 5804 return str; 5805 } 5806 } 5807 5808 /** {@hide} */ 5809 public static String deleteStatusToString(int status) { 5810 switch (status) { 5811 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 5812 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 5813 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 5814 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 5815 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 5816 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 5817 default: return Integer.toString(status); 5818 } 5819 } 5820 5821 /** {@hide} */ 5822 public static int deleteStatusToPublicStatus(int status) { 5823 switch (status) { 5824 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 5825 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 5826 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5827 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5828 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 5829 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 5830 default: return PackageInstaller.STATUS_FAILURE; 5831 } 5832 } 5833 5834 /** {@hide} */ 5835 public static String permissionFlagToString(int flag) { 5836 switch (flag) { 5837 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 5838 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 5839 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 5840 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 5841 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE"; 5842 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 5843 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 5844 default: return Integer.toString(flag); 5845 } 5846 } 5847 5848 /** {@hide} */ 5849 public static class LegacyPackageInstallObserver extends PackageInstallObserver { 5850 private final IPackageInstallObserver mLegacy; 5851 5852 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { 5853 mLegacy = legacy; 5854 } 5855 5856 @Override 5857 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 5858 Bundle extras) { 5859 if (mLegacy == null) return; 5860 try { 5861 mLegacy.packageInstalled(basePackageName, returnCode); 5862 } catch (RemoteException ignored) { 5863 } 5864 } 5865 } 5866 5867 /** {@hide} */ 5868 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 5869 private final IPackageDeleteObserver mLegacy; 5870 5871 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 5872 mLegacy = legacy; 5873 } 5874 5875 @Override 5876 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 5877 if (mLegacy == null) return; 5878 try { 5879 mLegacy.packageDeleted(basePackageName, returnCode); 5880 } catch (RemoteException ignored) { 5881 } 5882 } 5883 } 5884} 5885