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