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