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