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