PackageManager.java revision 2bd3c49eb44d9dad670daa8ac6950e46dcf16615
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 can perform backup and restore operations on installed applications. 2224 */ 2225 @SdkConstant(SdkConstantType.FEATURE) 2226 public static final String FEATURE_BACKUP = "android.software.backup"; 2227 2228 /** 2229 * Feature for {@link #getSystemAvailableFeatures} and 2230 * {@link #hasSystemFeature}: The device supports freeform window management. 2231 * Windows have title bars and can be moved and resized. 2232 */ 2233 // If this feature is present, you also need to set 2234 // com.android.internal.R.config_freeformWindowManagement to true in your configuration overlay. 2235 @SdkConstant(SdkConstantType.FEATURE) 2236 public static final String FEATURE_FREEFORM_WINDOW_MANAGEMENT 2237 = "android.software.freeform_window_management"; 2238 2239 /** 2240 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2241 * The device supports picture-in-picture multi-window mode. 2242 */ 2243 @SdkConstant(SdkConstantType.FEATURE) 2244 public static final String FEATURE_PICTURE_IN_PICTURE = "android.software.picture_in_picture"; 2245 2246 /** 2247 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2248 * The device supports creating secondary users and managed profiles via 2249 * {@link DevicePolicyManager}. 2250 */ 2251 @SdkConstant(SdkConstantType.FEATURE) 2252 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 2253 2254 /** 2255 * @hide 2256 * TODO: Remove after dependencies updated b/17392243 2257 */ 2258 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 2259 2260 /** 2261 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2262 * The device supports verified boot. 2263 */ 2264 @SdkConstant(SdkConstantType.FEATURE) 2265 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 2266 2267 /** 2268 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2269 * The device supports secure removal of users. When a user is deleted the data associated 2270 * with that user is securely deleted and no longer available. 2271 */ 2272 @SdkConstant(SdkConstantType.FEATURE) 2273 public static final String FEATURE_SECURELY_REMOVES_USERS 2274 = "android.software.securely_removes_users"; 2275 2276 /** {@hide} */ 2277 @SdkConstant(SdkConstantType.FEATURE) 2278 public static final String FEATURE_FILE_BASED_ENCRYPTION 2279 = "android.software.file_based_encryption"; 2280 2281 /** 2282 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2283 * The device has a full implementation of the android.webkit.* APIs. Devices 2284 * lacking this feature will not have a functioning WebView implementation. 2285 */ 2286 @SdkConstant(SdkConstantType.FEATURE) 2287 public static final String FEATURE_WEBVIEW = "android.software.webview"; 2288 2289 /** 2290 * Feature for {@link #getSystemAvailableFeatures} and 2291 * {@link #hasSystemFeature}: This device supports ethernet. 2292 */ 2293 @SdkConstant(SdkConstantType.FEATURE) 2294 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 2295 2296 /** 2297 * Feature for {@link #getSystemAvailableFeatures} and 2298 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 2299 * @hide 2300 */ 2301 @SdkConstant(SdkConstantType.FEATURE) 2302 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 2303 2304 /** 2305 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2306 * The device has all of the inputs necessary to be considered a compatible game controller, or 2307 * includes a compatible game controller in the box. 2308 */ 2309 @SdkConstant(SdkConstantType.FEATURE) 2310 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 2311 2312 /** 2313 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2314 * The device has a full implementation of the android.media.midi.* APIs. 2315 */ 2316 @SdkConstant(SdkConstantType.FEATURE) 2317 public static final String FEATURE_MIDI = "android.software.midi"; 2318 2319 /** 2320 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2321 * The device implements an optimized mode for virtual reality (VR) applications that handles 2322 * stereoscopic rendering of notifications, and disables most monocular system UI components 2323 * while a VR application has user focus. 2324 * Devices declaring this feature must include an application implementing a 2325 * {@link android.service.vr.VrListenerService} that can be targeted by VR applications via 2326 * {@link android.app.Activity#setVrModeEnabled}. 2327 */ 2328 @SdkConstant(SdkConstantType.FEATURE) 2329 public static final String FEATURE_VR_MODE = "android.software.vr.mode"; 2330 2331 /** 2332 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2333 * The device implements {@link #FEATURE_VR_MODE} but additionally meets extra CDD requirements 2334 * to provide a high-quality VR experience. In general, devices declaring this feature will 2335 * additionally: 2336 * <ul> 2337 * <li>Deliver consistent performance at a high framerate over an extended period of time 2338 * for typical VR application CPU/GPU workloads with a minimal number of frame drops for VR 2339 * applications that have called 2340 * {@link android.view.Window#setSustainedPerformanceMode}.</li> 2341 * <li>Implement {@link #FEATURE_HIFI_SENSORS} and have a low sensor latency.</li> 2342 * <li>Include optimizations to lower display persistence while running VR applications.</li> 2343 * <li>Implement an optimized render path to minimize latency to draw to the device's main 2344 * display.</li> 2345 * <li>Include the following EGL extensions: EGL_ANDROID_create_native_client_buffer, 2346 * EGL_ANDROID_front_buffer_auto_refresh, EGL_EXT_protected_content, 2347 * EGL_KHR_mutable_render_buffer, EGL_KHR_reusable_sync, and EGL_KHR_wait_sync.</li> 2348 * <li>Provide at least one CPU core that is reserved for use solely by the top, foreground 2349 * VR application process for critical render threads while such an application is 2350 * running.</li> 2351 * </ul> 2352 */ 2353 @SdkConstant(SdkConstantType.FEATURE) 2354 public static final String FEATURE_VR_MODE_HIGH_PERFORMANCE 2355 = "android.hardware.vr.high_performance"; 2356 2357 /** 2358 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 2359 * The device implements headtracking suitable for a VR device. 2360 */ 2361 @SdkConstant(SdkConstantType.FEATURE) 2362 public static final String FEATURE_VR_HEADTRACKING = "android.hardware.vr.headtracking"; 2363 2364 /** 2365 * Action to external storage service to clean out removed apps. 2366 * @hide 2367 */ 2368 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 2369 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 2370 2371 /** 2372 * Extra field name for the URI to a verification file. Passed to a package 2373 * verifier. 2374 * 2375 * @hide 2376 */ 2377 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 2378 2379 /** 2380 * Extra field name for the ID of a package pending verification. Passed to 2381 * a package verifier and is used to call back to 2382 * {@link PackageManager#verifyPendingInstall(int, int)} 2383 */ 2384 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 2385 2386 /** 2387 * Extra field name for the package identifier which is trying to install 2388 * the package. 2389 * 2390 * @hide 2391 */ 2392 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 2393 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 2394 2395 /** 2396 * Extra field name for the requested install flags for a package pending 2397 * verification. Passed to a package verifier. 2398 * 2399 * @hide 2400 */ 2401 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 2402 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 2403 2404 /** 2405 * Extra field name for the uid of who is requesting to install 2406 * the package. 2407 * 2408 * @hide 2409 */ 2410 public static final String EXTRA_VERIFICATION_INSTALLER_UID 2411 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 2412 2413 /** 2414 * Extra field name for the package name of a package pending verification. 2415 * 2416 * @hide 2417 */ 2418 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 2419 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 2420 /** 2421 * Extra field name for the result of a verification, either 2422 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 2423 * Passed to package verifiers after a package is verified. 2424 */ 2425 public static final String EXTRA_VERIFICATION_RESULT 2426 = "android.content.pm.extra.VERIFICATION_RESULT"; 2427 2428 /** 2429 * Extra field name for the version code of a package pending verification. 2430 * 2431 * @hide 2432 */ 2433 public static final String EXTRA_VERIFICATION_VERSION_CODE 2434 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 2435 2436 /** 2437 * Extra field name for the ID of a intent filter pending verification. 2438 * Passed to an intent filter verifier and is used to call back to 2439 * {@link #verifyIntentFilter} 2440 * 2441 * @hide 2442 */ 2443 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 2444 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 2445 2446 /** 2447 * Extra field name for the scheme used for an intent filter pending verification. Passed to 2448 * an intent filter verifier and is used to construct the URI to verify against. 2449 * 2450 * Usually this is "https" 2451 * 2452 * @hide 2453 */ 2454 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 2455 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 2456 2457 /** 2458 * Extra field name for the host names to be used for an intent filter pending verification. 2459 * Passed to an intent filter verifier and is used to construct the URI to verify the 2460 * intent filter. 2461 * 2462 * This is a space delimited list of hosts. 2463 * 2464 * @hide 2465 */ 2466 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 2467 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 2468 2469 /** 2470 * Extra field name for the package name to be used for an intent filter pending verification. 2471 * Passed to an intent filter verifier and is used to check the verification responses coming 2472 * from the hosts. Each host response will need to include the package name of APK containing 2473 * the intent filter. 2474 * 2475 * @hide 2476 */ 2477 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 2478 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 2479 2480 /** 2481 * The action used to request that the user approve a permission request 2482 * from the application. 2483 * 2484 * @hide 2485 */ 2486 @SystemApi 2487 public static final String ACTION_REQUEST_PERMISSIONS = 2488 "android.content.pm.action.REQUEST_PERMISSIONS"; 2489 2490 /** 2491 * The names of the requested permissions. 2492 * <p> 2493 * <strong>Type:</strong> String[] 2494 * </p> 2495 * 2496 * @hide 2497 */ 2498 @SystemApi 2499 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 2500 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 2501 2502 /** 2503 * The results from the permissions request. 2504 * <p> 2505 * <strong>Type:</strong> int[] of #PermissionResult 2506 * </p> 2507 * 2508 * @hide 2509 */ 2510 @SystemApi 2511 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 2512 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 2513 2514 /** 2515 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2516 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 2517 * the existing definition for the permission. 2518 * @hide 2519 */ 2520 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 2521 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 2522 2523 /** 2524 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 2525 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 2526 * being redundantly defined by the package being installed. 2527 * @hide 2528 */ 2529 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 2530 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 2531 2532 /** 2533 * Permission flag: The permission is set in its current state 2534 * by the user and apps can still request it at runtime. 2535 * 2536 * @hide 2537 */ 2538 @SystemApi 2539 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 2540 2541 /** 2542 * Permission flag: The permission is set in its current state 2543 * by the user and it is fixed, i.e. apps can no longer request 2544 * this permission. 2545 * 2546 * @hide 2547 */ 2548 @SystemApi 2549 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 2550 2551 /** 2552 * Permission flag: The permission is set in its current state 2553 * by device policy and neither apps nor the user can change 2554 * its state. 2555 * 2556 * @hide 2557 */ 2558 @SystemApi 2559 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 2560 2561 /** 2562 * Permission flag: The permission is set in a granted state but 2563 * access to resources it guards is restricted by other means to 2564 * enable revoking a permission on legacy apps that do not support 2565 * runtime permissions. If this permission is upgraded to runtime 2566 * because the app was updated to support runtime permissions, the 2567 * the permission will be revoked in the upgrade process. 2568 * 2569 * @hide 2570 */ 2571 @SystemApi 2572 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 2573 2574 /** 2575 * Permission flag: The permission is set in its current state 2576 * because the app is a component that is a part of the system. 2577 * 2578 * @hide 2579 */ 2580 @SystemApi 2581 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 2582 2583 /** 2584 * Permission flag: The permission is granted by default because it 2585 * enables app functionality that is expected to work out-of-the-box 2586 * for providing a smooth user experience. For example, the phone app 2587 * is expected to have the phone permission. 2588 * 2589 * @hide 2590 */ 2591 @SystemApi 2592 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 2593 2594 /** 2595 * Permission flag: The permission has to be reviewed before any of 2596 * the app components can run. 2597 * 2598 * @hide 2599 */ 2600 @SystemApi 2601 public static final int FLAG_PERMISSION_REVIEW_REQUIRED = 1 << 6; 2602 2603 /** 2604 * Mask for all permission flags. 2605 * 2606 * @hide 2607 */ 2608 @SystemApi 2609 public static final int MASK_PERMISSION_FLAGS = 0xFF; 2610 2611 /** 2612 * This is a library that contains components apps can invoke. For 2613 * example, a services for apps to bind to, or standard chooser UI, 2614 * etc. This library is versioned and backwards compatible. Clients 2615 * should check its version via {@link android.ext.services.Version 2616 * #getVersionCode()} and avoid calling APIs added in later versions. 2617 * 2618 * @hide 2619 */ 2620 public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services"; 2621 2622 /** 2623 * This is a library that contains components apps can dynamically 2624 * load. For example, new widgets, helper classes, etc. This library 2625 * is versioned and backwards compatible. Clients should check its 2626 * version via {@link android.ext.shared.Version#getVersionCode()} 2627 * and avoid calling APIs added in later versions. 2628 * 2629 * @hide 2630 */ 2631 public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared"; 2632 2633 /** 2634 * Used when starting a process for an Activity. 2635 * 2636 * @hide 2637 */ 2638 public static final int NOTIFY_PACKAGE_USE_ACTIVITY = 0; 2639 2640 /** 2641 * Used when starting a process for a Service. 2642 * 2643 * @hide 2644 */ 2645 public static final int NOTIFY_PACKAGE_USE_SERVICE = 1; 2646 2647 /** 2648 * Used when moving a Service to the foreground. 2649 * 2650 * @hide 2651 */ 2652 public static final int NOTIFY_PACKAGE_USE_FOREGROUND_SERVICE = 2; 2653 2654 /** 2655 * Used when starting a process for a BroadcastReceiver. 2656 * 2657 * @hide 2658 */ 2659 public static final int NOTIFY_PACKAGE_USE_BROADCAST_RECEIVER = 3; 2660 2661 /** 2662 * Used when starting a process for a ContentProvider. 2663 * 2664 * @hide 2665 */ 2666 public static final int NOTIFY_PACKAGE_USE_CONTENT_PROVIDER = 4; 2667 2668 /** 2669 * Used when starting a process for a BroadcastReceiver. 2670 * 2671 * @hide 2672 */ 2673 public static final int NOTIFY_PACKAGE_USE_BACKUP = 5; 2674 2675 /** 2676 * Used with Context.getClassLoader() across Android packages. 2677 * 2678 * @hide 2679 */ 2680 public static final int NOTIFY_PACKAGE_USE_CROSS_PACKAGE = 6; 2681 2682 /** 2683 * Used when starting a package within a process for Instrumentation. 2684 * 2685 * @hide 2686 */ 2687 public static final int NOTIFY_PACKAGE_USE_INSTRUMENTATION = 7; 2688 2689 /** 2690 * Total number of usage reasons. 2691 * 2692 * @hide 2693 */ 2694 public static final int NOTIFY_PACKAGE_USE_REASONS_COUNT = 8; 2695 2696 /** 2697 * Constant for specifying the highest installed package version code. 2698 */ 2699 public static final int VERSION_CODE_HIGHEST = -1; 2700 2701 /** 2702 * Retrieve overall information about an application package that is 2703 * installed on the system. 2704 * 2705 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2706 * desired package. 2707 * @param flags Additional option flags. Use any combination of 2708 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2709 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2710 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2711 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2712 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2713 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2714 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2715 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2716 * {@link #MATCH_UNINSTALLED_PACKAGES} 2717 * to modify the data returned. 2718 * 2719 * @return A PackageInfo object containing information about the 2720 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2721 * package is not found in the list of installed applications, the 2722 * package information is retrieved from the list of uninstalled 2723 * applications (which includes installed applications as well as 2724 * applications with data directory i.e. applications which had been 2725 * deleted with {@code DONT_DELETE_DATA} flag set). 2726 * @throws NameNotFoundException if a package with the given name cannot be 2727 * found on the system. 2728 * @see #GET_ACTIVITIES 2729 * @see #GET_CONFIGURATIONS 2730 * @see #GET_GIDS 2731 * @see #GET_INSTRUMENTATION 2732 * @see #GET_INTENT_FILTERS 2733 * @see #GET_META_DATA 2734 * @see #GET_PERMISSIONS 2735 * @see #GET_PROVIDERS 2736 * @see #GET_RECEIVERS 2737 * @see #GET_SERVICES 2738 * @see #GET_SHARED_LIBRARY_FILES 2739 * @see #GET_SIGNATURES 2740 * @see #GET_URI_PERMISSION_PATTERNS 2741 * @see #MATCH_DISABLED_COMPONENTS 2742 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2743 * @see #MATCH_UNINSTALLED_PACKAGES 2744 */ 2745 public abstract PackageInfo getPackageInfo(String packageName, @PackageInfoFlags int flags) 2746 throws NameNotFoundException; 2747 2748 /** 2749 * Retrieve overall information about an application package that is 2750 * installed on the system. This method can be used for retrieving 2751 * information about packages for which multiple versions can be 2752 * installed at the time. Currently only packages hosting static shared 2753 * libraries can have multiple installed versions. The method can also 2754 * be used to get info for a package that has a single version installed 2755 * by passing {@link #VERSION_CODE_HIGHEST} in the {@link VersionedPackage} 2756 * constructor. 2757 * 2758 * @param versionedPackage The versioned packages for which to query. 2759 * @param flags Additional option flags. Use any combination of 2760 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2761 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2762 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2763 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2764 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2765 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2766 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2767 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2768 * {@link #MATCH_UNINSTALLED_PACKAGES} 2769 * to modify the data returned. 2770 * 2771 * @return A PackageInfo object containing information about the 2772 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2773 * package is not found in the list of installed applications, the 2774 * package information is retrieved from the list of uninstalled 2775 * applications (which includes installed applications as well as 2776 * applications with data directory i.e. applications which had been 2777 * deleted with {@code DONT_DELETE_DATA} flag set). 2778 * @throws NameNotFoundException if a package with the given name cannot be 2779 * found on the system. 2780 * @see #GET_ACTIVITIES 2781 * @see #GET_CONFIGURATIONS 2782 * @see #GET_GIDS 2783 * @see #GET_INSTRUMENTATION 2784 * @see #GET_INTENT_FILTERS 2785 * @see #GET_META_DATA 2786 * @see #GET_PERMISSIONS 2787 * @see #GET_PROVIDERS 2788 * @see #GET_RECEIVERS 2789 * @see #GET_SERVICES 2790 * @see #GET_SHARED_LIBRARY_FILES 2791 * @see #GET_SIGNATURES 2792 * @see #GET_URI_PERMISSION_PATTERNS 2793 * @see #MATCH_DISABLED_COMPONENTS 2794 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2795 * @see #MATCH_UNINSTALLED_PACKAGES 2796 */ 2797 public abstract PackageInfo getPackageInfo(VersionedPackage versionedPackage, 2798 @PackageInfoFlags int flags) throws NameNotFoundException; 2799 2800 /** 2801 * Retrieve overall information about an application package that is 2802 * installed on the system. 2803 * 2804 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2805 * desired package. 2806 * @param flags Additional option flags. Use any combination of 2807 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 2808 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 2809 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 2810 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 2811 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 2812 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 2813 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 2814 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 2815 * {@link #MATCH_UNINSTALLED_PACKAGES} 2816 * to modify the data returned. 2817 * @param userId The user id. 2818 * 2819 * @return A PackageInfo object containing information about the 2820 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 2821 * package is not found in the list of installed applications, the 2822 * package information is retrieved from the list of uninstalled 2823 * applications (which includes installed applications as well as 2824 * applications with data directory i.e. applications which had been 2825 * deleted with {@code DONT_DELETE_DATA} flag set). 2826 * @throws NameNotFoundException if a package with the given name cannot be 2827 * found on the system. 2828 * @see #GET_ACTIVITIES 2829 * @see #GET_CONFIGURATIONS 2830 * @see #GET_GIDS 2831 * @see #GET_INSTRUMENTATION 2832 * @see #GET_INTENT_FILTERS 2833 * @see #GET_META_DATA 2834 * @see #GET_PERMISSIONS 2835 * @see #GET_PROVIDERS 2836 * @see #GET_RECEIVERS 2837 * @see #GET_SERVICES 2838 * @see #GET_SHARED_LIBRARY_FILES 2839 * @see #GET_SIGNATURES 2840 * @see #GET_URI_PERMISSION_PATTERNS 2841 * @see #MATCH_DISABLED_COMPONENTS 2842 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 2843 * @see #MATCH_UNINSTALLED_PACKAGES 2844 * 2845 * @hide 2846 */ 2847 @RequiresPermission(Manifest.permission.INTERACT_ACROSS_USERS) 2848 public abstract PackageInfo getPackageInfoAsUser(String packageName, 2849 @PackageInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 2850 2851 /** 2852 * Map from the current package names in use on the device to whatever 2853 * the current canonical name of that package is. 2854 * @param names Array of current names to be mapped. 2855 * @return Returns an array of the same size as the original, containing 2856 * the canonical name for each package. 2857 */ 2858 public abstract String[] currentToCanonicalPackageNames(String[] names); 2859 2860 /** 2861 * Map from a packages canonical name to the current name in use on the device. 2862 * @param names Array of new names to be mapped. 2863 * @return Returns an array of the same size as the original, containing 2864 * the current name for each package. 2865 */ 2866 public abstract String[] canonicalToCurrentPackageNames(String[] names); 2867 2868 /** 2869 * Returns a "good" intent to launch a front-door activity in a package. 2870 * This is used, for example, to implement an "open" button when browsing 2871 * through packages. The current implementation looks first for a main 2872 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 2873 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 2874 * <code>null</code> if neither are found. 2875 * 2876 * @param packageName The name of the package to inspect. 2877 * 2878 * @return A fully-qualified {@link Intent} that can be used to launch the 2879 * main activity in the package. Returns <code>null</code> if the package 2880 * does not contain such an activity, or if <em>packageName</em> is not 2881 * recognized. 2882 */ 2883 public abstract Intent getLaunchIntentForPackage(String packageName); 2884 2885 /** 2886 * Return a "good" intent to launch a front-door Leanback activity in a 2887 * package, for use for example to implement an "open" button when browsing 2888 * through packages. The current implementation will look for a main 2889 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 2890 * return null if no main leanback activities are found. 2891 * 2892 * @param packageName The name of the package to inspect. 2893 * @return Returns either a fully-qualified Intent that can be used to launch 2894 * the main Leanback activity in the package, or null if the package 2895 * does not contain such an activity. 2896 */ 2897 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName); 2898 2899 /** 2900 * Return an array of all of the POSIX secondary group IDs that have been 2901 * assigned to the given package. 2902 * <p> 2903 * Note that the same package may have different GIDs under different 2904 * {@link UserHandle} on the same device. 2905 * 2906 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2907 * desired package. 2908 * @return Returns an int array of the assigned GIDs, or null if there are 2909 * none. 2910 * @throws NameNotFoundException if a package with the given name cannot be 2911 * found on the system. 2912 */ 2913 public abstract int[] getPackageGids(String packageName) 2914 throws NameNotFoundException; 2915 2916 /** 2917 * Return an array of all of the POSIX secondary group IDs that have been 2918 * assigned to the given package. 2919 * <p> 2920 * Note that the same package may have different GIDs under different 2921 * {@link UserHandle} on the same device. 2922 * 2923 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2924 * desired package. 2925 * @return Returns an int array of the assigned gids, or null if there are 2926 * none. 2927 * @throws NameNotFoundException if a package with the given name cannot be 2928 * found on the system. 2929 */ 2930 public abstract int[] getPackageGids(String packageName, @PackageInfoFlags int flags) 2931 throws NameNotFoundException; 2932 2933 /** 2934 * Return the UID associated with the given package name. 2935 * <p> 2936 * Note that the same package will have different UIDs under different 2937 * {@link UserHandle} on the same device. 2938 * 2939 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2940 * desired package. 2941 * @return Returns an integer UID who owns the given package name. 2942 * @throws NameNotFoundException if a package with the given name can not be 2943 * found on the system. 2944 */ 2945 public abstract int getPackageUid(String packageName, @PackageInfoFlags int flags) 2946 throws NameNotFoundException; 2947 2948 /** 2949 * Return the UID associated with the given package name. 2950 * <p> 2951 * Note that the same package will have different UIDs under different 2952 * {@link UserHandle} on the same device. 2953 * 2954 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2955 * desired package. 2956 * @param userId The user handle identifier to look up the package under. 2957 * @return Returns an integer UID who owns the given package name. 2958 * @throws NameNotFoundException if a package with the given name can not be 2959 * found on the system. 2960 * @hide 2961 */ 2962 public abstract int getPackageUidAsUser(String packageName, @UserIdInt int userId) 2963 throws NameNotFoundException; 2964 2965 /** 2966 * Return the UID associated with the given package name. 2967 * <p> 2968 * Note that the same package will have different UIDs under different 2969 * {@link UserHandle} on the same device. 2970 * 2971 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2972 * desired package. 2973 * @param userId The user handle identifier to look up the package under. 2974 * @return Returns an integer UID who owns the given package name. 2975 * @throws NameNotFoundException if a package with the given name can not be 2976 * found on the system. 2977 * @hide 2978 */ 2979 public abstract int getPackageUidAsUser(String packageName, @PackageInfoFlags int flags, 2980 @UserIdInt int userId) throws NameNotFoundException; 2981 2982 /** 2983 * Retrieve all of the information we know about a particular permission. 2984 * 2985 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 2986 * of the permission you are interested in. 2987 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2988 * retrieve any meta-data associated with the permission. 2989 * 2990 * @return Returns a {@link PermissionInfo} containing information about the 2991 * permission. 2992 * @throws NameNotFoundException if a package with the given name cannot be 2993 * found on the system. 2994 * 2995 * @see #GET_META_DATA 2996 */ 2997 public abstract PermissionInfo getPermissionInfo(String name, @PermissionInfoFlags int flags) 2998 throws NameNotFoundException; 2999 3000 /** 3001 * Query for all of the permissions associated with a particular group. 3002 * 3003 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 3004 * of the permission group you are interested in. Use null to 3005 * find all of the permissions not associated with a group. 3006 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 3007 * retrieve any meta-data associated with the permissions. 3008 * 3009 * @return Returns a list of {@link PermissionInfo} containing information 3010 * about all of the permissions in the given group. 3011 * @throws NameNotFoundException if a package with the given name cannot be 3012 * found on the system. 3013 * 3014 * @see #GET_META_DATA 3015 */ 3016 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 3017 @PermissionInfoFlags int flags) throws NameNotFoundException; 3018 3019 /** 3020 * Returns true if Permission Review Mode is enabled, false otherwise. 3021 * 3022 * @hide 3023 */ 3024 @TestApi 3025 public abstract boolean isPermissionReviewModeEnabled(); 3026 3027 /** 3028 * Retrieve all of the information we know about a particular group of 3029 * permissions. 3030 * 3031 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 3032 * of the permission you are interested in. 3033 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 3034 * retrieve any meta-data associated with the permission group. 3035 * 3036 * @return Returns a {@link PermissionGroupInfo} containing information 3037 * about the permission. 3038 * @throws NameNotFoundException if a package with the given name cannot be 3039 * found on the system. 3040 * 3041 * @see #GET_META_DATA 3042 */ 3043 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 3044 @PermissionGroupInfoFlags int flags) throws NameNotFoundException; 3045 3046 /** 3047 * Retrieve all of the known permission groups in the system. 3048 * 3049 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 3050 * retrieve any meta-data associated with the permission group. 3051 * 3052 * @return Returns a list of {@link PermissionGroupInfo} containing 3053 * information about all of the known permission groups. 3054 * 3055 * @see #GET_META_DATA 3056 */ 3057 public abstract List<PermissionGroupInfo> getAllPermissionGroups( 3058 @PermissionGroupInfoFlags int flags); 3059 3060 /** 3061 * Retrieve all of the information we know about a particular 3062 * package/application. 3063 * 3064 * @param packageName The full name (i.e. com.google.apps.contacts) of an 3065 * application. 3066 * @param flags Additional option flags. Use any combination of 3067 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3068 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3069 * to modify the data returned. 3070 * 3071 * @return An {@link ApplicationInfo} containing information about the 3072 * package. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set and if the 3073 * package is not found in the list of installed applications, the 3074 * application information is retrieved from the list of uninstalled 3075 * applications (which includes installed applications as well as 3076 * applications with data directory i.e. applications which had been 3077 * deleted with {@code DONT_DELETE_DATA} flag set). 3078 * @throws NameNotFoundException if a package with the given name cannot be 3079 * found on the system. 3080 * 3081 * @see #GET_META_DATA 3082 * @see #GET_SHARED_LIBRARY_FILES 3083 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3084 * @see #MATCH_SYSTEM_ONLY 3085 * @see #MATCH_UNINSTALLED_PACKAGES 3086 */ 3087 public abstract ApplicationInfo getApplicationInfo(String packageName, 3088 @ApplicationInfoFlags int flags) throws NameNotFoundException; 3089 3090 /** {@hide} */ 3091 public abstract ApplicationInfo getApplicationInfoAsUser(String packageName, 3092 @ApplicationInfoFlags int flags, @UserIdInt int userId) throws NameNotFoundException; 3093 3094 /** 3095 * Retrieve all of the information we know about a particular activity 3096 * class. 3097 * 3098 * @param component The full component name (i.e. 3099 * com.google.apps.contacts/com.google.apps.contacts. 3100 * ContactsList) of an Activity class. 3101 * @param flags Additional option flags. Use any combination of 3102 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3103 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3104 * {@link #MATCH_DISABLED_COMPONENTS}, 3105 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3106 * {@link #MATCH_DIRECT_BOOT_AWARE}, 3107 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3108 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3109 * returned. 3110 * @return An {@link ActivityInfo} containing information about the 3111 * activity. 3112 * @throws NameNotFoundException if a package with the given name cannot be 3113 * found on the system. 3114 * @see #GET_META_DATA 3115 * @see #GET_SHARED_LIBRARY_FILES 3116 * @see #MATCH_ALL 3117 * @see #MATCH_DEBUG_TRIAGED_MISSING 3118 * @see #MATCH_DEFAULT_ONLY 3119 * @see #MATCH_DISABLED_COMPONENTS 3120 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3121 * @see #MATCH_DIRECT_BOOT_AWARE 3122 * @see #MATCH_DIRECT_BOOT_UNAWARE 3123 * @see #MATCH_SYSTEM_ONLY 3124 * @see #MATCH_UNINSTALLED_PACKAGES 3125 */ 3126 public abstract ActivityInfo getActivityInfo(ComponentName component, 3127 @ComponentInfoFlags int flags) throws NameNotFoundException; 3128 3129 /** 3130 * Retrieve all of the information we know about a particular receiver 3131 * class. 3132 * 3133 * @param component The full component name (i.e. 3134 * com.google.apps.calendar/com.google.apps.calendar. 3135 * CalendarAlarm) of a Receiver class. 3136 * @param flags Additional option flags. Use any combination of 3137 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3138 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3139 * {@link #MATCH_DISABLED_COMPONENTS}, 3140 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3141 * {@link #MATCH_DIRECT_BOOT_AWARE}, 3142 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3143 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3144 * returned. 3145 * @return An {@link ActivityInfo} containing information about the 3146 * receiver. 3147 * @throws NameNotFoundException if a package with the given name cannot be 3148 * found on the system. 3149 * @see #GET_META_DATA 3150 * @see #GET_SHARED_LIBRARY_FILES 3151 * @see #MATCH_ALL 3152 * @see #MATCH_DEBUG_TRIAGED_MISSING 3153 * @see #MATCH_DEFAULT_ONLY 3154 * @see #MATCH_DISABLED_COMPONENTS 3155 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3156 * @see #MATCH_DIRECT_BOOT_AWARE 3157 * @see #MATCH_DIRECT_BOOT_UNAWARE 3158 * @see #MATCH_SYSTEM_ONLY 3159 * @see #MATCH_UNINSTALLED_PACKAGES 3160 */ 3161 public abstract ActivityInfo getReceiverInfo(ComponentName component, 3162 @ComponentInfoFlags int flags) throws NameNotFoundException; 3163 3164 /** 3165 * Retrieve all of the information we know about a particular service class. 3166 * 3167 * @param component The full component name (i.e. 3168 * com.google.apps.media/com.google.apps.media. 3169 * BackgroundPlayback) of a Service class. 3170 * @param flags Additional option flags. Use any combination of 3171 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3172 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3173 * {@link #MATCH_DISABLED_COMPONENTS}, 3174 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3175 * {@link #MATCH_DIRECT_BOOT_AWARE}, 3176 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3177 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3178 * returned. 3179 * @return A {@link ServiceInfo} object containing information about the 3180 * service. 3181 * @throws NameNotFoundException if a package with the given name cannot be 3182 * found on the system. 3183 * @see #GET_META_DATA 3184 * @see #GET_SHARED_LIBRARY_FILES 3185 * @see #MATCH_ALL 3186 * @see #MATCH_DEBUG_TRIAGED_MISSING 3187 * @see #MATCH_DEFAULT_ONLY 3188 * @see #MATCH_DISABLED_COMPONENTS 3189 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3190 * @see #MATCH_DIRECT_BOOT_AWARE 3191 * @see #MATCH_DIRECT_BOOT_UNAWARE 3192 * @see #MATCH_SYSTEM_ONLY 3193 * @see #MATCH_UNINSTALLED_PACKAGES 3194 */ 3195 public abstract ServiceInfo getServiceInfo(ComponentName component, 3196 @ComponentInfoFlags int flags) throws NameNotFoundException; 3197 3198 /** 3199 * Retrieve all of the information we know about a particular content 3200 * provider class. 3201 * 3202 * @param component The full component name (i.e. 3203 * com.google.providers.media/com.google.providers.media. 3204 * MediaProvider) of a ContentProvider class. 3205 * @param flags Additional option flags. Use any combination of 3206 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3207 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 3208 * {@link #MATCH_DISABLED_COMPONENTS}, 3209 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3210 * {@link #MATCH_DIRECT_BOOT_AWARE}, 3211 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3212 * {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3213 * returned. 3214 * @return A {@link ProviderInfo} object containing information about the 3215 * provider. 3216 * @throws NameNotFoundException if a package with the given name cannot be 3217 * found on the system. 3218 * @see #GET_META_DATA 3219 * @see #GET_SHARED_LIBRARY_FILES 3220 * @see #MATCH_ALL 3221 * @see #MATCH_DEBUG_TRIAGED_MISSING 3222 * @see #MATCH_DEFAULT_ONLY 3223 * @see #MATCH_DISABLED_COMPONENTS 3224 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3225 * @see #MATCH_DIRECT_BOOT_AWARE 3226 * @see #MATCH_DIRECT_BOOT_UNAWARE 3227 * @see #MATCH_SYSTEM_ONLY 3228 * @see #MATCH_UNINSTALLED_PACKAGES 3229 */ 3230 public abstract ProviderInfo getProviderInfo(ComponentName component, 3231 @ComponentInfoFlags int flags) throws NameNotFoundException; 3232 3233 /** 3234 * Return a List of all packages that are installed 3235 * on the device. 3236 * 3237 * @param flags Additional option flags. Use any combination of 3238 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 3239 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 3240 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 3241 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 3242 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 3243 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 3244 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 3245 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3246 * {@link #MATCH_UNINSTALLED_PACKAGES} 3247 * to modify the data returned. 3248 * 3249 * @return A List of PackageInfo objects, one for each installed package, 3250 * containing information about the package. In the unlikely case 3251 * there are no installed packages, an empty list is returned. If 3252 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3253 * information is retrieved from the list of uninstalled 3254 * applications (which includes installed applications as well as 3255 * applications with data directory i.e. applications which had been 3256 * deleted with {@code DONT_DELETE_DATA} flag set). 3257 * 3258 * @see #GET_ACTIVITIES 3259 * @see #GET_CONFIGURATIONS 3260 * @see #GET_GIDS 3261 * @see #GET_INSTRUMENTATION 3262 * @see #GET_INTENT_FILTERS 3263 * @see #GET_META_DATA 3264 * @see #GET_PERMISSIONS 3265 * @see #GET_PROVIDERS 3266 * @see #GET_RECEIVERS 3267 * @see #GET_SERVICES 3268 * @see #GET_SHARED_LIBRARY_FILES 3269 * @see #GET_SIGNATURES 3270 * @see #GET_URI_PERMISSION_PATTERNS 3271 * @see #MATCH_DISABLED_COMPONENTS 3272 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3273 * @see #MATCH_UNINSTALLED_PACKAGES 3274 */ 3275 public abstract List<PackageInfo> getInstalledPackages(@PackageInfoFlags int flags); 3276 3277 /** 3278 * Return a List of all installed packages that are currently 3279 * holding any of the given permissions. 3280 * 3281 * @param flags Additional option flags. Use any combination of 3282 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 3283 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 3284 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 3285 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 3286 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 3287 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 3288 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 3289 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3290 * {@link #MATCH_UNINSTALLED_PACKAGES} 3291 * to modify the data returned. 3292 * 3293 * @return A List of PackageInfo objects, one for each installed package 3294 * that holds any of the permissions that were provided, containing 3295 * information about the package. If no installed packages hold any 3296 * of the permissions, an empty list is returned. If flag 3297 * {@code MATCH_UNINSTALLED_PACKAGES} is set, the package information 3298 * is retrieved from the list of uninstalled applications (which 3299 * includes installed applications as well as applications with data 3300 * directory i.e. applications which had been deleted with 3301 * {@code DONT_DELETE_DATA} flag set). 3302 * 3303 * @see #GET_ACTIVITIES 3304 * @see #GET_CONFIGURATIONS 3305 * @see #GET_GIDS 3306 * @see #GET_INSTRUMENTATION 3307 * @see #GET_INTENT_FILTERS 3308 * @see #GET_META_DATA 3309 * @see #GET_PERMISSIONS 3310 * @see #GET_PROVIDERS 3311 * @see #GET_RECEIVERS 3312 * @see #GET_SERVICES 3313 * @see #GET_SHARED_LIBRARY_FILES 3314 * @see #GET_SIGNATURES 3315 * @see #GET_URI_PERMISSION_PATTERNS 3316 * @see #MATCH_DISABLED_COMPONENTS 3317 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3318 * @see #MATCH_UNINSTALLED_PACKAGES 3319 */ 3320 public abstract List<PackageInfo> getPackagesHoldingPermissions( 3321 String[] permissions, @PackageInfoFlags int flags); 3322 3323 /** 3324 * Return a List of all packages that are installed on the device, for a specific user. 3325 * Requesting a list of installed packages for another user 3326 * will require the permission INTERACT_ACROSS_USERS_FULL. 3327 * 3328 * @param flags Additional option flags. Use any combination of 3329 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 3330 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 3331 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 3332 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 3333 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 3334 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 3335 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 3336 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3337 * {@link #MATCH_UNINSTALLED_PACKAGES} 3338 * to modify the data returned. 3339 * @param userId The user for whom the installed packages are to be listed 3340 * 3341 * @return A List of PackageInfo objects, one for each installed package, 3342 * containing information about the package. In the unlikely case 3343 * there are no installed packages, an empty list is returned. If 3344 * flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the package 3345 * information is retrieved from the list of uninstalled 3346 * applications (which includes installed applications as well as 3347 * applications with data directory i.e. applications which had been 3348 * deleted with {@code DONT_DELETE_DATA} flag set). 3349 * 3350 * @see #GET_ACTIVITIES 3351 * @see #GET_CONFIGURATIONS 3352 * @see #GET_GIDS 3353 * @see #GET_INSTRUMENTATION 3354 * @see #GET_INTENT_FILTERS 3355 * @see #GET_META_DATA 3356 * @see #GET_PERMISSIONS 3357 * @see #GET_PROVIDERS 3358 * @see #GET_RECEIVERS 3359 * @see #GET_SERVICES 3360 * @see #GET_SHARED_LIBRARY_FILES 3361 * @see #GET_SIGNATURES 3362 * @see #GET_URI_PERMISSION_PATTERNS 3363 * @see #MATCH_DISABLED_COMPONENTS 3364 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3365 * @see #MATCH_UNINSTALLED_PACKAGES 3366 * 3367 * @hide 3368 */ 3369 @SystemApi 3370 public abstract List<PackageInfo> getInstalledPackagesAsUser(@PackageInfoFlags int flags, 3371 @UserIdInt int userId); 3372 3373 /** 3374 * Check whether a particular package has been granted a particular 3375 * permission. 3376 * 3377 * @param permName The name of the permission you are checking for. 3378 * @param pkgName The name of the package you are checking against. 3379 * 3380 * @return If the package has the permission, PERMISSION_GRANTED is 3381 * returned. If it does not have the permission, PERMISSION_DENIED 3382 * is returned. 3383 * 3384 * @see #PERMISSION_GRANTED 3385 * @see #PERMISSION_DENIED 3386 */ 3387 @CheckResult 3388 public abstract int checkPermission(String permName, String pkgName); 3389 3390 /** 3391 * Checks whether a particular permissions has been revoked for a 3392 * package by policy. Typically the device owner or the profile owner 3393 * may apply such a policy. The user cannot grant policy revoked 3394 * permissions, hence the only way for an app to get such a permission 3395 * is by a policy change. 3396 * 3397 * @param permName The name of the permission you are checking for. 3398 * @param pkgName The name of the package you are checking against. 3399 * 3400 * @return Whether the permission is restricted by policy. 3401 */ 3402 @CheckResult 3403 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 3404 @NonNull String pkgName); 3405 3406 /** 3407 * Gets the package name of the component controlling runtime permissions. 3408 * 3409 * @return The package name. 3410 * 3411 * @hide 3412 */ 3413 public abstract String getPermissionControllerPackageName(); 3414 3415 /** 3416 * Add a new dynamic permission to the system. For this to work, your 3417 * package must have defined a permission tree through the 3418 * {@link android.R.styleable#AndroidManifestPermissionTree 3419 * <permission-tree>} tag in its manifest. A package can only add 3420 * permissions to trees that were defined by either its own package or 3421 * another with the same user id; a permission is in a tree if it 3422 * matches the name of the permission tree + ".": for example, 3423 * "com.foo.bar" is a member of the permission tree "com.foo". 3424 * 3425 * <p>It is good to make your permission tree name descriptive, because you 3426 * are taking possession of that entire set of permission names. Thus, it 3427 * must be under a domain you control, with a suffix that will not match 3428 * any normal permissions that may be declared in any applications that 3429 * are part of that domain. 3430 * 3431 * <p>New permissions must be added before 3432 * any .apks are installed that use those permissions. Permissions you 3433 * add through this method are remembered across reboots of the device. 3434 * If the given permission already exists, the info you supply here 3435 * will be used to update it. 3436 * 3437 * @param info Description of the permission to be added. 3438 * 3439 * @return Returns true if a new permission was created, false if an 3440 * existing one was updated. 3441 * 3442 * @throws SecurityException if you are not allowed to add the 3443 * given permission name. 3444 * 3445 * @see #removePermission(String) 3446 */ 3447 public abstract boolean addPermission(PermissionInfo info); 3448 3449 /** 3450 * Like {@link #addPermission(PermissionInfo)} but asynchronously 3451 * persists the package manager state after returning from the call, 3452 * allowing it to return quicker and batch a series of adds at the 3453 * expense of no guarantee the added permission will be retained if 3454 * the device is rebooted before it is written. 3455 */ 3456 public abstract boolean addPermissionAsync(PermissionInfo info); 3457 3458 /** 3459 * Removes a permission that was previously added with 3460 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 3461 * -- you are only allowed to remove permissions that you are allowed 3462 * to add. 3463 * 3464 * @param name The name of the permission to remove. 3465 * 3466 * @throws SecurityException if you are not allowed to remove the 3467 * given permission name. 3468 * 3469 * @see #addPermission(PermissionInfo) 3470 */ 3471 public abstract void removePermission(String name); 3472 3473 /** 3474 * Permission flags set when granting or revoking a permission. 3475 * 3476 * @hide 3477 */ 3478 @SystemApi 3479 @IntDef({FLAG_PERMISSION_USER_SET, 3480 FLAG_PERMISSION_USER_FIXED, 3481 FLAG_PERMISSION_POLICY_FIXED, 3482 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 3483 FLAG_PERMISSION_SYSTEM_FIXED, 3484 FLAG_PERMISSION_GRANTED_BY_DEFAULT}) 3485 @Retention(RetentionPolicy.SOURCE) 3486 public @interface PermissionFlags {} 3487 3488 /** 3489 * Grant a runtime permission to an application which the application does not 3490 * already have. The permission must have been requested by the application. 3491 * If the application is not allowed to hold the permission, a {@link 3492 * java.lang.SecurityException} is thrown. If the package or permission is 3493 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 3494 * <p> 3495 * <strong>Note: </strong>Using this API requires holding 3496 * android.permission.GRANT_RUNTIME_PERMISSIONS and if the user id is 3497 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3498 * </p> 3499 * 3500 * @param packageName The package to which to grant the permission. 3501 * @param permissionName The permission name to grant. 3502 * @param user The user for which to grant the permission. 3503 * 3504 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 3505 * 3506 * @hide 3507 */ 3508 @SystemApi 3509 public abstract void grantRuntimePermission(@NonNull String packageName, 3510 @NonNull String permissionName, @NonNull UserHandle user); 3511 3512 /** 3513 * Revoke a runtime permission that was previously granted by {@link 3514 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 3515 * permission must have been requested by and granted to the application. 3516 * If the application is not allowed to hold the permission, a {@link 3517 * java.lang.SecurityException} is thrown. If the package or permission is 3518 * invalid, a {@link java.lang.IllegalArgumentException} is thrown. 3519 * <p> 3520 * <strong>Note: </strong>Using this API requires holding 3521 * android.permission.REVOKE_RUNTIME_PERMISSIONS and if the user id is 3522 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 3523 * </p> 3524 * 3525 * @param packageName The package from which to revoke the permission. 3526 * @param permissionName The permission name to revoke. 3527 * @param user The user for which to revoke the permission. 3528 * 3529 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 3530 * 3531 * @hide 3532 */ 3533 @SystemApi 3534 public abstract void revokeRuntimePermission(@NonNull String packageName, 3535 @NonNull String permissionName, @NonNull UserHandle user); 3536 3537 /** 3538 * Gets the state flags associated with a permission. 3539 * 3540 * @param permissionName The permission for which to get the flags. 3541 * @param packageName The package name for which to get the flags. 3542 * @param user The user for which to get permission flags. 3543 * @return The permission flags. 3544 * 3545 * @hide 3546 */ 3547 @SystemApi 3548 public abstract @PermissionFlags int getPermissionFlags(String permissionName, 3549 String packageName, @NonNull UserHandle user); 3550 3551 /** 3552 * Updates the flags associated with a permission by replacing the flags in 3553 * the specified mask with the provided flag values. 3554 * 3555 * @param permissionName The permission for which to update the flags. 3556 * @param packageName The package name for which to update the flags. 3557 * @param flagMask The flags which to replace. 3558 * @param flagValues The flags with which to replace. 3559 * @param user The user for which to update the permission flags. 3560 * 3561 * @hide 3562 */ 3563 @SystemApi 3564 public abstract void updatePermissionFlags(String permissionName, 3565 String packageName, @PermissionFlags int flagMask, int flagValues, 3566 @NonNull UserHandle user); 3567 3568 /** 3569 * Gets whether you should show UI with rationale for requesting a permission. 3570 * You should do this only if you do not have the permission and the context in 3571 * which the permission is requested does not clearly communicate to the user 3572 * what would be the benefit from grating this permission. 3573 * 3574 * @param permission A permission your app wants to request. 3575 * @return Whether you can show permission rationale UI. 3576 * 3577 * @hide 3578 */ 3579 public abstract boolean shouldShowRequestPermissionRationale(String permission); 3580 3581 /** 3582 * Returns an {@link android.content.Intent} suitable for passing to 3583 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 3584 * which prompts the user to grant permissions to this application. 3585 * 3586 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 3587 * 3588 * @hide 3589 */ 3590 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 3591 if (ArrayUtils.isEmpty(permissions)) { 3592 throw new IllegalArgumentException("permission cannot be null or empty"); 3593 } 3594 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 3595 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 3596 intent.setPackage(getPermissionControllerPackageName()); 3597 return intent; 3598 } 3599 3600 /** 3601 * Compare the signatures of two packages to determine if the same 3602 * signature appears in both of them. If they do contain the same 3603 * signature, then they are allowed special privileges when working 3604 * with each other: they can share the same user-id, run instrumentation 3605 * against each other, etc. 3606 * 3607 * @param pkg1 First package name whose signature will be compared. 3608 * @param pkg2 Second package name whose signature will be compared. 3609 * 3610 * @return Returns an integer indicating whether all signatures on the 3611 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3612 * all signatures match or < 0 if there is not a match ({@link 3613 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3614 * 3615 * @see #checkSignatures(int, int) 3616 * @see #SIGNATURE_MATCH 3617 * @see #SIGNATURE_NO_MATCH 3618 * @see #SIGNATURE_UNKNOWN_PACKAGE 3619 */ 3620 @CheckResult 3621 public abstract int checkSignatures(String pkg1, String pkg2); 3622 3623 /** 3624 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 3625 * the two packages to be checked. This can be useful, for example, 3626 * when doing the check in an IPC, where the UID is the only identity 3627 * available. It is functionally identical to determining the package 3628 * associated with the UIDs and checking their signatures. 3629 * 3630 * @param uid1 First UID whose signature will be compared. 3631 * @param uid2 Second UID whose signature will be compared. 3632 * 3633 * @return Returns an integer indicating whether all signatures on the 3634 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 3635 * all signatures match or < 0 if there is not a match ({@link 3636 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 3637 * 3638 * @see #checkSignatures(String, String) 3639 * @see #SIGNATURE_MATCH 3640 * @see #SIGNATURE_NO_MATCH 3641 * @see #SIGNATURE_UNKNOWN_PACKAGE 3642 */ 3643 @CheckResult 3644 public abstract int checkSignatures(int uid1, int uid2); 3645 3646 /** 3647 * Retrieve the names of all packages that are associated with a particular 3648 * user id. In most cases, this will be a single package name, the package 3649 * that has been assigned that user id. Where there are multiple packages 3650 * sharing the same user id through the "sharedUserId" mechanism, all 3651 * packages with that id will be returned. 3652 * 3653 * @param uid The user id for which you would like to retrieve the 3654 * associated packages. 3655 * 3656 * @return Returns an array of one or more packages assigned to the user 3657 * id, or null if there are no known packages with the given id. 3658 */ 3659 public abstract @Nullable String[] getPackagesForUid(int uid); 3660 3661 /** 3662 * Retrieve the official name associated with a uid. This name is 3663 * guaranteed to never change, though it is possible for the underlying 3664 * uid to be changed. That is, if you are storing information about 3665 * uids in persistent storage, you should use the string returned 3666 * by this function instead of the raw uid. 3667 * 3668 * @param uid The uid for which you would like to retrieve a name. 3669 * @return Returns a unique name for the given uid, or null if the 3670 * uid is not currently assigned. 3671 */ 3672 public abstract @Nullable String getNameForUid(int uid); 3673 3674 /** 3675 * Return the user id associated with a shared user name. Multiple 3676 * applications can specify a shared user name in their manifest and thus 3677 * end up using a common uid. This might be used for new applications 3678 * that use an existing shared user name and need to know the uid of the 3679 * shared user. 3680 * 3681 * @param sharedUserName The shared user name whose uid is to be retrieved. 3682 * @return Returns the UID associated with the shared user. 3683 * @throws NameNotFoundException if a package with the given name cannot be 3684 * found on the system. 3685 * @hide 3686 */ 3687 public abstract int getUidForSharedUser(String sharedUserName) 3688 throws NameNotFoundException; 3689 3690 /** 3691 * Return a List of all application packages that are installed on the 3692 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 3693 * applications including those deleted with {@code DONT_DELETE_DATA} (partially 3694 * installed apps with data directory) will be returned. 3695 * 3696 * @param flags Additional option flags. Use any combination of 3697 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3698 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3699 * to modify the data returned. 3700 * 3701 * @return A List of ApplicationInfo objects, one for each installed application. 3702 * In the unlikely case there are no installed packages, an empty list 3703 * is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the 3704 * application information is retrieved from the list of uninstalled 3705 * applications (which includes installed applications as well as 3706 * applications with data directory i.e. applications which had been 3707 * deleted with {@code DONT_DELETE_DATA} flag set). 3708 * 3709 * @see #GET_META_DATA 3710 * @see #GET_SHARED_LIBRARY_FILES 3711 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3712 * @see #MATCH_SYSTEM_ONLY 3713 * @see #MATCH_UNINSTALLED_PACKAGES 3714 */ 3715 public abstract List<ApplicationInfo> getInstalledApplications(@ApplicationInfoFlags int flags); 3716 3717 /** 3718 * Return a List of all application packages that are installed on the device, for a specific 3719 * user. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all applications including 3720 * those deleted with {@code DONT_DELETE_DATA} (partially installed apps with data directory) 3721 * will be returned. 3722 * 3723 * @param flags Additional option flags. Use any combination of 3724 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 3725 * {@link #MATCH_SYSTEM_ONLY}, {@link #MATCH_UNINSTALLED_PACKAGES} 3726 * to modify the data returned. 3727 * @param userId The user for whom the installed applications are to be listed 3728 * 3729 * @return A List of ApplicationInfo objects, one for each installed application. 3730 * In the unlikely case there are no installed packages, an empty list 3731 * is returned. If flag {@code MATCH_UNINSTALLED_PACKAGES} is set, the 3732 * application information is retrieved from the list of uninstalled 3733 * applications (which includes installed applications as well as 3734 * applications with data directory i.e. applications which had been 3735 * deleted with {@code DONT_DELETE_DATA} flag set). 3736 * @hide 3737 * 3738 * @see #GET_META_DATA 3739 * @see #GET_SHARED_LIBRARY_FILES 3740 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3741 * @see #MATCH_SYSTEM_ONLY 3742 * @see #MATCH_UNINSTALLED_PACKAGES 3743 */ 3744 public abstract List<ApplicationInfo> getInstalledApplicationsAsUser( 3745 @ApplicationInfoFlags int flags, @UserIdInt int userId); 3746 3747 /** 3748 * Gets the instant applications the user recently used. Requires 3749 * holding "android.permission.ACCESS_INSTANT_APPS". 3750 * 3751 * @return The instant app list. 3752 * 3753 * @hide 3754 */ 3755 @SystemApi 3756 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) 3757 public abstract @NonNull List<InstantAppInfo> getInstantApps(); 3758 3759 /** 3760 * Gets the icon for an instant application. 3761 * 3762 * @param packageName The app package name. 3763 * 3764 * @hide 3765 */ 3766 @SystemApi 3767 @RequiresPermission(Manifest.permission.ACCESS_INSTANT_APPS) 3768 public abstract @Nullable Drawable getInstantAppIcon(String packageName); 3769 3770 /** 3771 * Gets whether this application is an instant app. 3772 * 3773 * @return Whether caller is an instant app. 3774 * 3775 * @see #isInstantApp(String) 3776 * @see #setInstantAppCookie(byte[]) 3777 * @see #getInstantAppCookie() 3778 * @see #getInstantAppCookieMaxSize() 3779 */ 3780 public abstract boolean isInstantApp(); 3781 3782 /** 3783 * Gets whether the given package is an instant app. 3784 * 3785 * @param packageName The package to check 3786 * @return Whether the given package is an instant app. 3787 * 3788 * @see #isInstantApp() 3789 * @see #setInstantAppCookie(byte[]) 3790 * @see #getInstantAppCookie() 3791 * @see #getInstantAppCookieMaxSize() 3792 */ 3793 public abstract boolean isInstantApp(String packageName); 3794 3795 /** 3796 * Gets the maximum size in bytes of the cookie data an instant app 3797 * can store on the device. 3798 * 3799 * @return The max cookie size in bytes. 3800 * 3801 * @see #isInstantApp() 3802 * @see #isInstantApp(String) 3803 * @see #setInstantAppCookie(byte[]) 3804 * @see #getInstantAppCookie() 3805 */ 3806 public abstract int getInstantAppCookieMaxSize(); 3807 3808 /** 3809 * Gets the instant application cookie for this app. Non 3810 * instant apps and apps that were instant but were upgraded 3811 * to normal apps can still access this API. For instant apps 3812 * this cooke is cached for some time after uninstall while for 3813 * normal apps the cookie is deleted after the app is uninstalled. 3814 * The cookie is always present while the app is installed. 3815 * 3816 * @return The cookie. 3817 * 3818 * @see #isInstantApp() 3819 * @see #isInstantApp(String) 3820 * @see #setInstantAppCookie(byte[]) 3821 * @see #getInstantAppCookieMaxSize() 3822 */ 3823 public abstract @NonNull byte[] getInstantAppCookie(); 3824 3825 /** 3826 * Sets the instant application cookie for the calling app. Non 3827 * instant apps and apps that were instant but were upgraded 3828 * to normal apps can still access this API. For instant apps 3829 * this cooke is cached for some time after uninstall while for 3830 * normal apps the cookie is deleted after the app is uninstalled. 3831 * The cookie is always present while the app is installed. The 3832 * cookie size is limited by {@link #getInstantAppCookieMaxSize()}. 3833 * If the provided cookie size is over the limit this method 3834 * returns <code>false</code>. Passing <code>null</code> or an empty 3835 * array clears the cookie. 3836 * </p> 3837 * 3838 * @param cookie The cookie data. 3839 * @return Whether the cookie was set. 3840 * 3841 * @see #isInstantApp() 3842 * @see #isInstantApp(String) 3843 * @see #getInstantAppCookieMaxSize() 3844 * @see #getInstantAppCookie() 3845 */ 3846 public abstract boolean setInstantAppCookie(@Nullable byte[] cookie); 3847 3848 /** 3849 * Get a list of shared libraries that are available on the 3850 * system. 3851 * 3852 * @return An array of shared library names that are 3853 * available on the system, or null if none are installed. 3854 * 3855 */ 3856 public abstract String[] getSystemSharedLibraryNames(); 3857 3858 /** 3859 * Get a list of shared libraries on the device. 3860 * 3861 * @param flags To filter the libraries to return. 3862 * @return The shared library list. 3863 * 3864 * @see #MATCH_FACTORY_ONLY 3865 * @see #MATCH_KNOWN_PACKAGES 3866 * @see #MATCH_ANY_USER 3867 * @see #MATCH_UNINSTALLED_PACKAGES 3868 */ 3869 public abstract @NonNull List<SharedLibraryInfo> getSharedLibraries( 3870 @InstallFlags int flags); 3871 3872 /** 3873 * Get a list of shared libraries on the device. 3874 * 3875 * @param flags To filter the libraries to return. 3876 * @param userId The user to query for. 3877 * @return The shared library list. 3878 * 3879 * @see #MATCH_FACTORY_ONLY 3880 * @see #MATCH_KNOWN_PACKAGES 3881 * @see #MATCH_ANY_USER 3882 * @see #MATCH_UNINSTALLED_PACKAGES 3883 * 3884 * @hide 3885 */ 3886 public abstract @NonNull List<SharedLibraryInfo> getSharedLibrariesAsUser( 3887 @InstallFlags int flags, @UserIdInt int userId); 3888 3889 /** 3890 * Get the name of the package hosting the services shared library. 3891 * 3892 * @return The library host package. 3893 * 3894 * @hide 3895 */ 3896 public abstract @NonNull String getServicesSystemSharedLibraryPackageName(); 3897 3898 /** 3899 * Get the name of the package hosting the shared components shared library. 3900 * 3901 * @return The library host package. 3902 * 3903 * @hide 3904 */ 3905 public abstract @NonNull String getSharedSystemSharedLibraryPackageName(); 3906 3907 /** 3908 * Returns the names of the packages that have been changed 3909 * [eg. added, removed or updated] since the given sequence 3910 * number. 3911 * <p>If no packages have been changed, returns <code>null</code>. 3912 * <p>The sequence number starts at <code>0</code> and is 3913 * reset every boot. 3914 */ 3915 public abstract @Nullable ChangedPackages getChangedPackages( 3916 @IntRange(from=0) int sequenceNumber); 3917 3918 /** 3919 * Get a list of features that are available on the 3920 * system. 3921 * 3922 * @return An array of FeatureInfo classes describing the features 3923 * that are available on the system, or null if there are none(!!). 3924 */ 3925 public abstract FeatureInfo[] getSystemAvailableFeatures(); 3926 3927 /** 3928 * Check whether the given feature name is one of the available features as 3929 * returned by {@link #getSystemAvailableFeatures()}. This tests for the 3930 * presence of <em>any</em> version of the given feature name; use 3931 * {@link #hasSystemFeature(String, int)} to check for a minimum version. 3932 * 3933 * @return Returns true if the devices supports the feature, else false. 3934 */ 3935 public abstract boolean hasSystemFeature(String name); 3936 3937 /** 3938 * Check whether the given feature name and version is one of the available 3939 * features as returned by {@link #getSystemAvailableFeatures()}. Since 3940 * features are defined to always be backwards compatible, this returns true 3941 * if the available feature version is greater than or equal to the 3942 * requested version. 3943 * 3944 * @return Returns true if the devices supports the feature, else false. 3945 */ 3946 public abstract boolean hasSystemFeature(String name, int version); 3947 3948 /** 3949 * Determine the best action to perform for a given Intent. This is how 3950 * {@link Intent#resolveActivity} finds an activity if a class has not been 3951 * explicitly specified. 3952 * <p> 3953 * <em>Note:</em> if using an implicit Intent (without an explicit 3954 * ComponentName specified), be sure to consider whether to set the 3955 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 3956 * activity in the same way that 3957 * {@link android.content.Context#startActivity(Intent)} and 3958 * {@link android.content.Intent#resolveActivity(PackageManager) 3959 * Intent.resolveActivity(PackageManager)} do. 3960 * </p> 3961 * 3962 * @param intent An intent containing all of the desired specification 3963 * (action, data, type, category, and/or component). 3964 * @param flags Additional option flags. Use any combination of 3965 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 3966 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 3967 * {@link #MATCH_DISABLED_COMPONENTS}, 3968 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 3969 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 3970 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 3971 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 3972 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 3973 * to limit the resolution to only those activities that support 3974 * the {@link android.content.Intent#CATEGORY_DEFAULT}. 3975 * @return Returns a ResolveInfo object containing the final activity intent 3976 * that was determined to be the best action. Returns null if no 3977 * matching activity was found. If multiple matching activities are 3978 * found and there is no default set, returns a ResolveInfo object 3979 * containing something else, such as the activity resolver. 3980 * @see #GET_META_DATA 3981 * @see #GET_RESOLVED_FILTER 3982 * @see #GET_SHARED_LIBRARY_FILES 3983 * @see #MATCH_ALL 3984 * @see #MATCH_DISABLED_COMPONENTS 3985 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 3986 * @see #MATCH_DEFAULT_ONLY 3987 * @see #MATCH_DIRECT_BOOT_AWARE 3988 * @see #MATCH_DIRECT_BOOT_UNAWARE 3989 * @see #MATCH_SYSTEM_ONLY 3990 * @see #MATCH_UNINSTALLED_PACKAGES 3991 */ 3992 public abstract ResolveInfo resolveActivity(Intent intent, @ResolveInfoFlags int flags); 3993 3994 /** 3995 * Determine the best action to perform for a given Intent for a given user. 3996 * This is how {@link Intent#resolveActivity} finds an activity if a class 3997 * has not been explicitly specified. 3998 * <p> 3999 * <em>Note:</em> if using an implicit Intent (without an explicit 4000 * ComponentName specified), be sure to consider whether to set the 4001 * {@link #MATCH_DEFAULT_ONLY} only flag. You need to do so to resolve the 4002 * activity in the same way that 4003 * {@link android.content.Context#startActivity(Intent)} and 4004 * {@link android.content.Intent#resolveActivity(PackageManager) 4005 * Intent.resolveActivity(PackageManager)} do. 4006 * </p> 4007 * 4008 * @param intent An intent containing all of the desired specification 4009 * (action, data, type, category, and/or component). 4010 * @param flags Additional option flags. Use any combination of 4011 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4012 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4013 * {@link #MATCH_DISABLED_COMPONENTS}, 4014 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4015 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4016 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4017 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4018 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 4019 * to limit the resolution to only those activities that support 4020 * the {@link android.content.Intent#CATEGORY_DEFAULT}. 4021 * @param userId The user id. 4022 * @return Returns a ResolveInfo object containing the final activity intent 4023 * that was determined to be the best action. Returns null if no 4024 * matching activity was found. If multiple matching activities are 4025 * found and there is no default set, returns a ResolveInfo object 4026 * containing something else, such as the activity resolver. 4027 * @see #GET_META_DATA 4028 * @see #GET_RESOLVED_FILTER 4029 * @see #GET_SHARED_LIBRARY_FILES 4030 * @see #MATCH_ALL 4031 * @see #MATCH_DISABLED_COMPONENTS 4032 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4033 * @see #MATCH_DEFAULT_ONLY 4034 * @see #MATCH_DIRECT_BOOT_AWARE 4035 * @see #MATCH_DIRECT_BOOT_UNAWARE 4036 * @see #MATCH_SYSTEM_ONLY 4037 * @see #MATCH_UNINSTALLED_PACKAGES 4038 * @hide 4039 */ 4040 public abstract ResolveInfo resolveActivityAsUser(Intent intent, @ResolveInfoFlags int flags, 4041 @UserIdInt int userId); 4042 4043 /** 4044 * Retrieve all activities that can be performed for the given intent. 4045 * 4046 * @param intent The desired intent as per resolveActivity(). 4047 * @param flags Additional option flags. Use any combination of 4048 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4049 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4050 * {@link #MATCH_DISABLED_COMPONENTS}, 4051 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4052 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4053 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4054 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4055 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 4056 * to limit the resolution to only those activities that support 4057 * the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 4058 * {@link #MATCH_ALL} to prevent any filtering of the results. 4059 * @return Returns a List of ResolveInfo objects containing one entry for 4060 * each matching activity, ordered from best to worst. In other 4061 * words, the first item is what would be returned by 4062 * {@link #resolveActivity}. If there are no matching activities, an 4063 * empty list is returned. 4064 * @see #GET_META_DATA 4065 * @see #GET_RESOLVED_FILTER 4066 * @see #GET_SHARED_LIBRARY_FILES 4067 * @see #MATCH_ALL 4068 * @see #MATCH_DISABLED_COMPONENTS 4069 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4070 * @see #MATCH_DEFAULT_ONLY 4071 * @see #MATCH_DIRECT_BOOT_AWARE 4072 * @see #MATCH_DIRECT_BOOT_UNAWARE 4073 * @see #MATCH_SYSTEM_ONLY 4074 * @see #MATCH_UNINSTALLED_PACKAGES 4075 */ 4076 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 4077 @ResolveInfoFlags int flags); 4078 4079 /** 4080 * Retrieve all activities that can be performed for the given intent, for a 4081 * specific user. 4082 * 4083 * @param intent The desired intent as per resolveActivity(). 4084 * @param flags Additional option flags. Use any combination of 4085 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4086 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4087 * {@link #MATCH_DISABLED_COMPONENTS}, 4088 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4089 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4090 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4091 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4092 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 4093 * to limit the resolution to only those activities that support 4094 * the {@link android.content.Intent#CATEGORY_DEFAULT}. Or, set 4095 * {@link #MATCH_ALL} to prevent any filtering of the results. 4096 * @return Returns a List of ResolveInfo objects containing one entry for 4097 * each matching activity, ordered from best to worst. In other 4098 * words, the first item is what would be returned by 4099 * {@link #resolveActivity}. If there are no matching activities, an 4100 * empty list is returned. 4101 * @see #GET_META_DATA 4102 * @see #GET_RESOLVED_FILTER 4103 * @see #GET_SHARED_LIBRARY_FILES 4104 * @see #MATCH_ALL 4105 * @see #MATCH_DISABLED_COMPONENTS 4106 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4107 * @see #MATCH_DEFAULT_ONLY 4108 * @see #MATCH_DIRECT_BOOT_AWARE 4109 * @see #MATCH_DIRECT_BOOT_UNAWARE 4110 * @see #MATCH_SYSTEM_ONLY 4111 * @see #MATCH_UNINSTALLED_PACKAGES 4112 * @hide 4113 */ 4114 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 4115 @ResolveInfoFlags int flags, @UserIdInt int userId); 4116 4117 /** 4118 * Retrieve a set of activities that should be presented to the user as 4119 * similar options. This is like {@link #queryIntentActivities}, except it 4120 * also allows you to supply a list of more explicit Intents that you would 4121 * like to resolve to particular options, and takes care of returning the 4122 * final ResolveInfo list in a reasonable order, with no duplicates, based 4123 * on those inputs. 4124 * 4125 * @param caller The class name of the activity that is making the request. 4126 * This activity will never appear in the output list. Can be 4127 * null. 4128 * @param specifics An array of Intents that should be resolved to the first 4129 * specific results. Can be null. 4130 * @param intent The desired intent as per resolveActivity(). 4131 * @param flags Additional option flags. Use any combination of 4132 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4133 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4134 * {@link #MATCH_DISABLED_COMPONENTS}, 4135 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4136 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4137 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4138 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4139 * returned. The most important is {@link #MATCH_DEFAULT_ONLY}, 4140 * to limit the resolution to only those activities that support 4141 * the {@link android.content.Intent#CATEGORY_DEFAULT}. 4142 * @return Returns a List of ResolveInfo objects containing one entry for 4143 * each matching activity. The list is ordered first by all of the 4144 * intents resolved in <var>specifics</var> and then any additional 4145 * activities that can handle <var>intent</var> but did not get 4146 * included by one of the <var>specifics</var> intents. If there are 4147 * no matching activities, an empty list is returned. 4148 * @see #GET_META_DATA 4149 * @see #GET_RESOLVED_FILTER 4150 * @see #GET_SHARED_LIBRARY_FILES 4151 * @see #MATCH_ALL 4152 * @see #MATCH_DISABLED_COMPONENTS 4153 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4154 * @see #MATCH_DEFAULT_ONLY 4155 * @see #MATCH_DIRECT_BOOT_AWARE 4156 * @see #MATCH_DIRECT_BOOT_UNAWARE 4157 * @see #MATCH_SYSTEM_ONLY 4158 * @see #MATCH_UNINSTALLED_PACKAGES 4159 */ 4160 public abstract List<ResolveInfo> queryIntentActivityOptions( 4161 ComponentName caller, Intent[] specifics, Intent intent, @ResolveInfoFlags int flags); 4162 4163 /** 4164 * Retrieve all receivers that can handle a broadcast of the given intent. 4165 * 4166 * @param intent The desired intent as per resolveActivity(). 4167 * @param flags Additional option flags. Use any combination of 4168 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4169 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4170 * {@link #MATCH_DISABLED_COMPONENTS}, 4171 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4172 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4173 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4174 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4175 * returned. 4176 * @return Returns a List of ResolveInfo objects containing one entry for 4177 * each matching receiver, ordered from best to worst. If there are 4178 * no matching receivers, an empty list or null is returned. 4179 * @see #GET_META_DATA 4180 * @see #GET_RESOLVED_FILTER 4181 * @see #GET_SHARED_LIBRARY_FILES 4182 * @see #MATCH_ALL 4183 * @see #MATCH_DISABLED_COMPONENTS 4184 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4185 * @see #MATCH_DEFAULT_ONLY 4186 * @see #MATCH_DIRECT_BOOT_AWARE 4187 * @see #MATCH_DIRECT_BOOT_UNAWARE 4188 * @see #MATCH_SYSTEM_ONLY 4189 * @see #MATCH_UNINSTALLED_PACKAGES 4190 */ 4191 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 4192 @ResolveInfoFlags int flags); 4193 4194 /** 4195 * Retrieve all receivers that can handle a broadcast of the given intent, 4196 * for a specific user. 4197 * 4198 * @param intent The desired intent as per resolveActivity(). 4199 * @param flags Additional option flags. Use any combination of 4200 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4201 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4202 * {@link #MATCH_DISABLED_COMPONENTS}, 4203 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4204 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4205 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4206 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4207 * returned. 4208 * @param userHandle UserHandle of the user being queried. 4209 * @return Returns a List of ResolveInfo objects containing one entry for 4210 * each matching receiver, ordered from best to worst. If there are 4211 * no matching receivers, an empty list or null is returned. 4212 * @see #GET_META_DATA 4213 * @see #GET_RESOLVED_FILTER 4214 * @see #GET_SHARED_LIBRARY_FILES 4215 * @see #MATCH_ALL 4216 * @see #MATCH_DISABLED_COMPONENTS 4217 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4218 * @see #MATCH_DEFAULT_ONLY 4219 * @see #MATCH_DIRECT_BOOT_AWARE 4220 * @see #MATCH_DIRECT_BOOT_UNAWARE 4221 * @see #MATCH_SYSTEM_ONLY 4222 * @see #MATCH_UNINSTALLED_PACKAGES 4223 * @hide 4224 */ 4225 @SystemApi 4226 public List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 4227 @ResolveInfoFlags int flags, UserHandle userHandle) { 4228 return queryBroadcastReceiversAsUser(intent, flags, userHandle.getIdentifier()); 4229 } 4230 4231 /** 4232 * @hide 4233 */ 4234 public abstract List<ResolveInfo> queryBroadcastReceiversAsUser(Intent intent, 4235 @ResolveInfoFlags int flags, @UserIdInt int userId); 4236 4237 4238 /** {@hide} */ 4239 @Deprecated 4240 public List<ResolveInfo> queryBroadcastReceivers(Intent intent, 4241 @ResolveInfoFlags int flags, @UserIdInt int userId) { 4242 Log.w(TAG, "STAHP USING HIDDEN APIS KTHX"); 4243 return queryBroadcastReceiversAsUser(intent, flags, userId); 4244 } 4245 4246 /** 4247 * Determine the best service to handle for a given Intent. 4248 * 4249 * @param intent An intent containing all of the desired specification 4250 * (action, data, type, category, and/or component). 4251 * @param flags Additional option flags. Use any combination of 4252 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4253 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4254 * {@link #MATCH_DISABLED_COMPONENTS}, 4255 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4256 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4257 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4258 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4259 * returned. 4260 * @return Returns a ResolveInfo object containing the final service intent 4261 * that was determined to be the best action. Returns null if no 4262 * matching service was found. 4263 * @see #GET_META_DATA 4264 * @see #GET_RESOLVED_FILTER 4265 * @see #GET_SHARED_LIBRARY_FILES 4266 * @see #MATCH_ALL 4267 * @see #MATCH_DISABLED_COMPONENTS 4268 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4269 * @see #MATCH_DEFAULT_ONLY 4270 * @see #MATCH_DIRECT_BOOT_AWARE 4271 * @see #MATCH_DIRECT_BOOT_UNAWARE 4272 * @see #MATCH_SYSTEM_ONLY 4273 * @see #MATCH_UNINSTALLED_PACKAGES 4274 */ 4275 public abstract ResolveInfo resolveService(Intent intent, @ResolveInfoFlags int flags); 4276 4277 /** 4278 * Retrieve all services that can match the given intent. 4279 * 4280 * @param intent The desired intent as per resolveService(). 4281 * @param flags Additional option flags. Use any combination of 4282 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4283 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4284 * {@link #MATCH_DISABLED_COMPONENTS}, 4285 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4286 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4287 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4288 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4289 * returned. 4290 * @return Returns a List of ResolveInfo objects containing one entry for 4291 * each matching service, ordered from best to worst. In other 4292 * words, the first item is what would be returned by 4293 * {@link #resolveService}. If there are no matching services, an 4294 * empty list or null is returned. 4295 * @see #GET_META_DATA 4296 * @see #GET_RESOLVED_FILTER 4297 * @see #GET_SHARED_LIBRARY_FILES 4298 * @see #MATCH_ALL 4299 * @see #MATCH_DISABLED_COMPONENTS 4300 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4301 * @see #MATCH_DEFAULT_ONLY 4302 * @see #MATCH_DIRECT_BOOT_AWARE 4303 * @see #MATCH_DIRECT_BOOT_UNAWARE 4304 * @see #MATCH_SYSTEM_ONLY 4305 * @see #MATCH_UNINSTALLED_PACKAGES 4306 */ 4307 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 4308 @ResolveInfoFlags int flags); 4309 4310 /** 4311 * Retrieve all services that can match the given intent for a given user. 4312 * 4313 * @param intent The desired intent as per resolveService(). 4314 * @param flags Additional option flags. Use any combination of 4315 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4316 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4317 * {@link #MATCH_DISABLED_COMPONENTS}, 4318 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4319 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4320 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4321 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4322 * returned. 4323 * @param userId The user id. 4324 * @return Returns a List of ResolveInfo objects containing one entry for 4325 * each matching service, ordered from best to worst. In other 4326 * words, the first item is what would be returned by 4327 * {@link #resolveService}. If there are no matching services, an 4328 * empty list or null is returned. 4329 * @see #GET_META_DATA 4330 * @see #GET_RESOLVED_FILTER 4331 * @see #GET_SHARED_LIBRARY_FILES 4332 * @see #MATCH_ALL 4333 * @see #MATCH_DISABLED_COMPONENTS 4334 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4335 * @see #MATCH_DEFAULT_ONLY 4336 * @see #MATCH_DIRECT_BOOT_AWARE 4337 * @see #MATCH_DIRECT_BOOT_UNAWARE 4338 * @see #MATCH_SYSTEM_ONLY 4339 * @see #MATCH_UNINSTALLED_PACKAGES 4340 * @hide 4341 */ 4342 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 4343 @ResolveInfoFlags int flags, @UserIdInt int userId); 4344 4345 /** 4346 * Retrieve all providers that can match the given intent. 4347 * 4348 * @param intent An intent containing all of the desired specification 4349 * (action, data, type, category, and/or component). 4350 * @param flags Additional option flags. Use any combination of 4351 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4352 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4353 * {@link #MATCH_DISABLED_COMPONENTS}, 4354 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4355 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4356 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4357 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4358 * returned. 4359 * @param userId The user id. 4360 * @return Returns a List of ResolveInfo objects containing one entry for 4361 * each matching provider, ordered from best to worst. If there are 4362 * no matching services, an empty list or null is returned. 4363 * @see #GET_META_DATA 4364 * @see #GET_RESOLVED_FILTER 4365 * @see #GET_SHARED_LIBRARY_FILES 4366 * @see #MATCH_ALL 4367 * @see #MATCH_DISABLED_COMPONENTS 4368 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4369 * @see #MATCH_DEFAULT_ONLY 4370 * @see #MATCH_DIRECT_BOOT_AWARE 4371 * @see #MATCH_DIRECT_BOOT_UNAWARE 4372 * @see #MATCH_SYSTEM_ONLY 4373 * @see #MATCH_UNINSTALLED_PACKAGES 4374 * @hide 4375 */ 4376 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 4377 Intent intent, @ResolveInfoFlags int flags, @UserIdInt int userId); 4378 4379 /** 4380 * Retrieve all providers that can match the given intent. 4381 * 4382 * @param intent An intent containing all of the desired specification 4383 * (action, data, type, category, and/or component). 4384 * @param flags Additional option flags. Use any combination of 4385 * {@link #GET_META_DATA}, {@link #GET_RESOLVED_FILTER}, 4386 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #MATCH_ALL}, 4387 * {@link #MATCH_DISABLED_COMPONENTS}, 4388 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4389 * {@link #MATCH_DEFAULT_ONLY}, {@link #MATCH_DIRECT_BOOT_AWARE}, 4390 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4391 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4392 * returned. 4393 * @return Returns a List of ResolveInfo objects containing one entry for 4394 * each matching provider, ordered from best to worst. If there are 4395 * no matching services, an empty list or null is returned. 4396 * @see #GET_META_DATA 4397 * @see #GET_RESOLVED_FILTER 4398 * @see #GET_SHARED_LIBRARY_FILES 4399 * @see #MATCH_ALL 4400 * @see #MATCH_DISABLED_COMPONENTS 4401 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4402 * @see #MATCH_DEFAULT_ONLY 4403 * @see #MATCH_DIRECT_BOOT_AWARE 4404 * @see #MATCH_DIRECT_BOOT_UNAWARE 4405 * @see #MATCH_SYSTEM_ONLY 4406 * @see #MATCH_UNINSTALLED_PACKAGES 4407 */ 4408 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, 4409 @ResolveInfoFlags int flags); 4410 4411 /** 4412 * Find a single content provider by its base path name. 4413 * 4414 * @param name The name of the provider to find. 4415 * @param flags Additional option flags. Use any combination of 4416 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 4417 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 4418 * {@link #MATCH_DISABLED_COMPONENTS}, 4419 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4420 * {@link #MATCH_DIRECT_BOOT_AWARE}, 4421 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4422 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4423 * returned. 4424 * @return A {@link ProviderInfo} object containing information about the 4425 * provider. If a provider was not found, returns null. 4426 * @see #GET_META_DATA 4427 * @see #GET_SHARED_LIBRARY_FILES 4428 * @see #MATCH_ALL 4429 * @see #MATCH_DEBUG_TRIAGED_MISSING 4430 * @see #MATCH_DEFAULT_ONLY 4431 * @see #MATCH_DISABLED_COMPONENTS 4432 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4433 * @see #MATCH_DIRECT_BOOT_AWARE 4434 * @see #MATCH_DIRECT_BOOT_UNAWARE 4435 * @see #MATCH_SYSTEM_ONLY 4436 * @see #MATCH_UNINSTALLED_PACKAGES 4437 */ 4438 public abstract ProviderInfo resolveContentProvider(String name, 4439 @ComponentInfoFlags int flags); 4440 4441 /** 4442 * Find a single content provider by its base path name. 4443 * 4444 * @param name The name of the provider to find. 4445 * @param flags Additional option flags. Use any combination of 4446 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 4447 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 4448 * {@link #MATCH_DISABLED_COMPONENTS}, 4449 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4450 * {@link #MATCH_DIRECT_BOOT_AWARE}, 4451 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4452 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4453 * returned. 4454 * @param userId The user id. 4455 * @return A {@link ProviderInfo} object containing information about the 4456 * provider. If a provider was not found, returns null. 4457 * @see #GET_META_DATA 4458 * @see #GET_SHARED_LIBRARY_FILES 4459 * @see #MATCH_ALL 4460 * @see #MATCH_DEBUG_TRIAGED_MISSING 4461 * @see #MATCH_DEFAULT_ONLY 4462 * @see #MATCH_DISABLED_COMPONENTS 4463 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4464 * @see #MATCH_DIRECT_BOOT_AWARE 4465 * @see #MATCH_DIRECT_BOOT_UNAWARE 4466 * @see #MATCH_SYSTEM_ONLY 4467 * @see #MATCH_UNINSTALLED_PACKAGES 4468 * @hide 4469 */ 4470 public abstract ProviderInfo resolveContentProviderAsUser(String name, 4471 @ComponentInfoFlags int flags, @UserIdInt int userId); 4472 4473 /** 4474 * Retrieve content provider information. 4475 * <p> 4476 * <em>Note: unlike most other methods, an empty result set is indicated 4477 * by a null return instead of an empty list.</em> 4478 * 4479 * @param processName If non-null, limits the returned providers to only 4480 * those that are hosted by the given process. If null, all 4481 * content providers are returned. 4482 * @param uid If <var>processName</var> is non-null, this is the required 4483 * uid owning the requested content providers. 4484 * @param flags Additional option flags. Use any combination of 4485 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 4486 * {@link #MATCH_ALL}, {@link #MATCH_DEFAULT_ONLY}, 4487 * {@link #MATCH_DISABLED_COMPONENTS}, 4488 * {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 4489 * {@link #MATCH_DIRECT_BOOT_AWARE}, 4490 * {@link #MATCH_DIRECT_BOOT_UNAWARE}, {@link #MATCH_SYSTEM_ONLY} 4491 * or {@link #MATCH_UNINSTALLED_PACKAGES} to modify the data 4492 * returned. 4493 * @return A list of {@link ProviderInfo} objects containing one entry for 4494 * each provider either matching <var>processName</var> or, if 4495 * <var>processName</var> is null, all known content providers. 4496 * <em>If there are no matching providers, null is returned.</em> 4497 * @see #GET_META_DATA 4498 * @see #GET_SHARED_LIBRARY_FILES 4499 * @see #MATCH_ALL 4500 * @see #MATCH_DEBUG_TRIAGED_MISSING 4501 * @see #MATCH_DEFAULT_ONLY 4502 * @see #MATCH_DISABLED_COMPONENTS 4503 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 4504 * @see #MATCH_DIRECT_BOOT_AWARE 4505 * @see #MATCH_DIRECT_BOOT_UNAWARE 4506 * @see #MATCH_SYSTEM_ONLY 4507 * @see #MATCH_UNINSTALLED_PACKAGES 4508 */ 4509 public abstract List<ProviderInfo> queryContentProviders( 4510 String processName, int uid, @ComponentInfoFlags int flags); 4511 4512 /** 4513 * Same as {@link #queryContentProviders}, except when {@code metaDataKey} is not null, 4514 * it only returns providers which have metadata with the {@code metaDataKey} key. 4515 * 4516 * <p>DO NOT USE the {@code metaDataKey} parameter, unless you're the contacts provider. 4517 * You really shouldn't need it. Other apps should use {@link #queryIntentContentProviders} 4518 * instead. 4519 * 4520 * <p>The {@code metaDataKey} parameter was added to allow the contacts provider to quickly 4521 * scan the GAL providers on the device. Unfortunately the discovery protocol used metadata 4522 * to mark GAL providers, rather than intent filters, so we can't use 4523 * {@link #queryIntentContentProviders} for that. 4524 * 4525 * @hide 4526 */ 4527 public List<ProviderInfo> queryContentProviders( 4528 String processName, int uid, @ComponentInfoFlags int flags, String metaDataKey) { 4529 // Provide the default implementation for mocks. 4530 return queryContentProviders(processName, uid, flags); 4531 } 4532 4533 /** 4534 * Retrieve all of the information we know about a particular 4535 * instrumentation class. 4536 * 4537 * @param className The full name (i.e. 4538 * com.google.apps.contacts.InstrumentList) of an 4539 * Instrumentation class. 4540 * @param flags Additional option flags. Use any combination of 4541 * {@link #GET_META_DATA} 4542 * to modify the data returned. 4543 * 4544 * @return An {@link InstrumentationInfo} object containing information about the 4545 * instrumentation. 4546 * @throws NameNotFoundException if a package with the given name cannot be 4547 * found on the system. 4548 * 4549 * @see #GET_META_DATA 4550 */ 4551 public abstract InstrumentationInfo getInstrumentationInfo(ComponentName className, 4552 @InstrumentationInfoFlags int flags) throws NameNotFoundException; 4553 4554 /** 4555 * Retrieve information about available instrumentation code. May be used 4556 * to retrieve either all instrumentation code, or only the code targeting 4557 * a particular package. 4558 * 4559 * @param targetPackage If null, all instrumentation is returned; only the 4560 * instrumentation targeting this package name is 4561 * returned. 4562 * @param flags Additional option flags. Use any combination of 4563 * {@link #GET_META_DATA} 4564 * to modify the data returned. 4565 * 4566 * @return A list of {@link InstrumentationInfo} objects containing one 4567 * entry for each matching instrumentation. If there are no 4568 * instrumentation available, returns an empty list. 4569 * 4570 * @see #GET_META_DATA 4571 */ 4572 public abstract List<InstrumentationInfo> queryInstrumentation(String targetPackage, 4573 @InstrumentationInfoFlags int flags); 4574 4575 /** 4576 * Retrieve an image from a package. This is a low-level API used by 4577 * the various package manager info structures (such as 4578 * {@link ComponentInfo} to implement retrieval of their associated 4579 * icon. 4580 * 4581 * @param packageName The name of the package that this icon is coming from. 4582 * Cannot be null. 4583 * @param resid The resource identifier of the desired image. Cannot be 0. 4584 * @param appInfo Overall information about <var>packageName</var>. This 4585 * may be null, in which case the application information will be retrieved 4586 * for you if needed; if you already have this information around, it can 4587 * be much more efficient to supply it here. 4588 * 4589 * @return Returns a Drawable holding the requested image. Returns null if 4590 * an image could not be found for any reason. 4591 */ 4592 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid, 4593 ApplicationInfo appInfo); 4594 4595 /** 4596 * Retrieve the icon associated with an activity. Given the full name of 4597 * an activity, retrieves the information about it and calls 4598 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 4599 * If the activity cannot be found, NameNotFoundException is thrown. 4600 * 4601 * @param activityName Name of the activity whose icon is to be retrieved. 4602 * 4603 * @return Returns the image of the icon, or the default activity icon if 4604 * it could not be found. Does not return null. 4605 * @throws NameNotFoundException Thrown if the resources for the given 4606 * activity could not be loaded. 4607 * 4608 * @see #getActivityIcon(Intent) 4609 */ 4610 public abstract Drawable getActivityIcon(ComponentName activityName) 4611 throws NameNotFoundException; 4612 4613 /** 4614 * Retrieve the icon associated with an Intent. If intent.getClassName() is 4615 * set, this simply returns the result of 4616 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 4617 * component and returns the icon associated with the resolved component. 4618 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4619 * to a component, NameNotFoundException is thrown. 4620 * 4621 * @param intent The intent for which you would like to retrieve an icon. 4622 * 4623 * @return Returns the image of the icon, or the default activity icon if 4624 * it could not be found. Does not return null. 4625 * @throws NameNotFoundException Thrown if the resources for application 4626 * matching the given intent could not be loaded. 4627 * 4628 * @see #getActivityIcon(ComponentName) 4629 */ 4630 public abstract Drawable getActivityIcon(Intent intent) 4631 throws NameNotFoundException; 4632 4633 /** 4634 * Retrieve the banner associated with an activity. Given the full name of 4635 * an activity, retrieves the information about it and calls 4636 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 4637 * banner. If the activity cannot be found, NameNotFoundException is thrown. 4638 * 4639 * @param activityName Name of the activity whose banner is to be retrieved. 4640 * @return Returns the image of the banner, or null if the activity has no 4641 * banner specified. 4642 * @throws NameNotFoundException Thrown if the resources for the given 4643 * activity could not be loaded. 4644 * @see #getActivityBanner(Intent) 4645 */ 4646 public abstract Drawable getActivityBanner(ComponentName activityName) 4647 throws NameNotFoundException; 4648 4649 /** 4650 * Retrieve the banner associated with an Intent. If intent.getClassName() 4651 * is set, this simply returns the result of 4652 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 4653 * intent's component and returns the banner associated with the resolved 4654 * component. If intent.getClassName() cannot be found or the Intent cannot 4655 * be resolved to a component, NameNotFoundException is thrown. 4656 * 4657 * @param intent The intent for which you would like to retrieve a banner. 4658 * @return Returns the image of the banner, or null if the activity has no 4659 * banner specified. 4660 * @throws NameNotFoundException Thrown if the resources for application 4661 * matching the given intent could not be loaded. 4662 * @see #getActivityBanner(ComponentName) 4663 */ 4664 public abstract Drawable getActivityBanner(Intent intent) 4665 throws NameNotFoundException; 4666 4667 /** 4668 * Return the generic icon for an activity that is used when no specific 4669 * icon is defined. 4670 * 4671 * @return Drawable Image of the icon. 4672 */ 4673 public abstract Drawable getDefaultActivityIcon(); 4674 4675 /** 4676 * Retrieve the icon associated with an application. If it has not defined 4677 * an icon, the default app icon is returned. Does not return null. 4678 * 4679 * @param info Information about application being queried. 4680 * 4681 * @return Returns the image of the icon, or the default application icon 4682 * if it could not be found. 4683 * 4684 * @see #getApplicationIcon(String) 4685 */ 4686 public abstract Drawable getApplicationIcon(ApplicationInfo info); 4687 4688 /** 4689 * Retrieve the icon associated with an application. Given the name of the 4690 * application's package, retrieves the information about it and calls 4691 * getApplicationIcon() to return its icon. If the application cannot be 4692 * found, NameNotFoundException is thrown. 4693 * 4694 * @param packageName Name of the package whose application icon is to be 4695 * retrieved. 4696 * 4697 * @return Returns the image of the icon, or the default application icon 4698 * if it could not be found. Does not return null. 4699 * @throws NameNotFoundException Thrown if the resources for the given 4700 * application could not be loaded. 4701 * 4702 * @see #getApplicationIcon(ApplicationInfo) 4703 */ 4704 public abstract Drawable getApplicationIcon(String packageName) 4705 throws NameNotFoundException; 4706 4707 /** 4708 * Retrieve the banner associated with an application. 4709 * 4710 * @param info Information about application being queried. 4711 * @return Returns the image of the banner or null if the application has no 4712 * banner specified. 4713 * @see #getApplicationBanner(String) 4714 */ 4715 public abstract Drawable getApplicationBanner(ApplicationInfo info); 4716 4717 /** 4718 * Retrieve the banner associated with an application. Given the name of the 4719 * application's package, retrieves the information about it and calls 4720 * getApplicationIcon() to return its banner. If the application cannot be 4721 * found, NameNotFoundException is thrown. 4722 * 4723 * @param packageName Name of the package whose application banner is to be 4724 * retrieved. 4725 * @return Returns the image of the banner or null if the application has no 4726 * banner specified. 4727 * @throws NameNotFoundException Thrown if the resources for the given 4728 * application could not be loaded. 4729 * @see #getApplicationBanner(ApplicationInfo) 4730 */ 4731 public abstract Drawable getApplicationBanner(String packageName) 4732 throws NameNotFoundException; 4733 4734 /** 4735 * Retrieve the logo associated with an activity. Given the full name of an 4736 * activity, retrieves the information about it and calls 4737 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 4738 * logo. If the activity cannot be found, NameNotFoundException is thrown. 4739 * 4740 * @param activityName Name of the activity whose logo is to be retrieved. 4741 * @return Returns the image of the logo or null if the activity has no logo 4742 * specified. 4743 * @throws NameNotFoundException Thrown if the resources for the given 4744 * activity could not be loaded. 4745 * @see #getActivityLogo(Intent) 4746 */ 4747 public abstract Drawable getActivityLogo(ComponentName activityName) 4748 throws NameNotFoundException; 4749 4750 /** 4751 * Retrieve the logo associated with an Intent. If intent.getClassName() is 4752 * set, this simply returns the result of 4753 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 4754 * component and returns the logo associated with the resolved component. 4755 * If intent.getClassName() cannot be found or the Intent cannot be resolved 4756 * to a component, NameNotFoundException is thrown. 4757 * 4758 * @param intent The intent for which you would like to retrieve a logo. 4759 * 4760 * @return Returns the image of the logo, or null if the activity has no 4761 * logo specified. 4762 * 4763 * @throws NameNotFoundException Thrown if the resources for application 4764 * matching the given intent could not be loaded. 4765 * 4766 * @see #getActivityLogo(ComponentName) 4767 */ 4768 public abstract Drawable getActivityLogo(Intent intent) 4769 throws NameNotFoundException; 4770 4771 /** 4772 * Retrieve the logo associated with an application. If it has not specified 4773 * a logo, this method returns null. 4774 * 4775 * @param info Information about application being queried. 4776 * 4777 * @return Returns the image of the logo, or null if no logo is specified 4778 * by the application. 4779 * 4780 * @see #getApplicationLogo(String) 4781 */ 4782 public abstract Drawable getApplicationLogo(ApplicationInfo info); 4783 4784 /** 4785 * Retrieve the logo associated with an application. Given the name of the 4786 * application's package, retrieves the information about it and calls 4787 * getApplicationLogo() to return its logo. If the application cannot be 4788 * found, NameNotFoundException is thrown. 4789 * 4790 * @param packageName Name of the package whose application logo is to be 4791 * retrieved. 4792 * 4793 * @return Returns the image of the logo, or null if no application logo 4794 * has been specified. 4795 * 4796 * @throws NameNotFoundException Thrown if the resources for the given 4797 * application could not be loaded. 4798 * 4799 * @see #getApplicationLogo(ApplicationInfo) 4800 */ 4801 public abstract Drawable getApplicationLogo(String packageName) 4802 throws NameNotFoundException; 4803 4804 /** 4805 * If the target user is a managed profile, then this returns a badged copy of the given icon 4806 * to be able to distinguish it from the original icon. For badging an arbitrary drawable use 4807 * {@link #getUserBadgedDrawableForDensity( 4808 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 4809 * <p> 4810 * If the original drawable is a BitmapDrawable and the backing bitmap is 4811 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 4812 * is performed in place and the original drawable is returned. 4813 * </p> 4814 * 4815 * @param icon The icon to badge. 4816 * @param user The target user. 4817 * @return A drawable that combines the original icon and a badge as 4818 * determined by the system. 4819 */ 4820 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 4821 4822 /** 4823 * If the target user is a managed profile of the calling user or the caller 4824 * is itself a managed profile, then this returns a badged copy of the given 4825 * drawable allowing the user to distinguish it from the original drawable. 4826 * The caller can specify the location in the bounds of the drawable to be 4827 * badged where the badge should be applied as well as the density of the 4828 * badge to be used. 4829 * <p> 4830 * If the original drawable is a BitmapDrawable and the backing bitmap is 4831 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 4832 * is performed in place and the original drawable is returned. 4833 * </p> 4834 * 4835 * @param drawable The drawable to badge. 4836 * @param user The target user. 4837 * @param badgeLocation Where in the bounds of the badged drawable to place 4838 * the badge. If it's {@code null}, the badge is applied on top of the entire 4839 * drawable being badged. 4840 * @param badgeDensity The optional desired density for the badge as per 4841 * {@link android.util.DisplayMetrics#densityDpi}. If it's not positive, 4842 * the density of the display is used. 4843 * @return A drawable that combines the original drawable and a badge as 4844 * determined by the system. 4845 */ 4846 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 4847 UserHandle user, Rect badgeLocation, int badgeDensity); 4848 4849 /** 4850 * If the target user is a managed profile of the calling user or the caller 4851 * is itself a managed profile, then this returns a drawable to use as a small 4852 * icon to include in a view to distinguish it from the original icon. 4853 * 4854 * @param user The target user. 4855 * @param density The optional desired density for the badge as per 4856 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4857 * the density of the current display is used. 4858 * @return the drawable or null if no drawable is required. 4859 * @hide 4860 */ 4861 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 4862 4863 /** 4864 * If the target user is a managed profile of the calling user or the caller 4865 * is itself a managed profile, then this returns a drawable to use as a small 4866 * icon to include in a view to distinguish it from the original icon. This version 4867 * doesn't have background protection and should be used over a light background instead of 4868 * a badge. 4869 * 4870 * @param user The target user. 4871 * @param density The optional desired density for the badge as per 4872 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 4873 * the density of the current display is used. 4874 * @return the drawable or null if no drawable is required. 4875 * @hide 4876 */ 4877 public abstract Drawable getUserBadgeForDensityNoBackground(UserHandle user, int density); 4878 4879 /** 4880 * If the target user is a managed profile of the calling user or the caller 4881 * is itself a managed profile, then this returns a copy of the label with 4882 * badging for accessibility services like talkback. E.g. passing in "Email" 4883 * and it might return "Work Email" for Email in the work profile. 4884 * 4885 * @param label The label to change. 4886 * @param user The target user. 4887 * @return A label that combines the original label and a badge as 4888 * determined by the system. 4889 */ 4890 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 4891 4892 /** 4893 * Retrieve text from a package. This is a low-level API used by 4894 * the various package manager info structures (such as 4895 * {@link ComponentInfo} to implement retrieval of their associated 4896 * labels and other text. 4897 * 4898 * @param packageName The name of the package that this text is coming from. 4899 * Cannot be null. 4900 * @param resid The resource identifier of the desired text. Cannot be 0. 4901 * @param appInfo Overall information about <var>packageName</var>. This 4902 * may be null, in which case the application information will be retrieved 4903 * for you if needed; if you already have this information around, it can 4904 * be much more efficient to supply it here. 4905 * 4906 * @return Returns a CharSequence holding the requested text. Returns null 4907 * if the text could not be found for any reason. 4908 */ 4909 public abstract CharSequence getText(String packageName, @StringRes int resid, 4910 ApplicationInfo appInfo); 4911 4912 /** 4913 * Retrieve an XML file from a package. This is a low-level API used to 4914 * retrieve XML meta data. 4915 * 4916 * @param packageName The name of the package that this xml is coming from. 4917 * Cannot be null. 4918 * @param resid The resource identifier of the desired xml. Cannot be 0. 4919 * @param appInfo Overall information about <var>packageName</var>. This 4920 * may be null, in which case the application information will be retrieved 4921 * for you if needed; if you already have this information around, it can 4922 * be much more efficient to supply it here. 4923 * 4924 * @return Returns an XmlPullParser allowing you to parse out the XML 4925 * data. Returns null if the xml resource could not be found for any 4926 * reason. 4927 */ 4928 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid, 4929 ApplicationInfo appInfo); 4930 4931 /** 4932 * Return the label to use for this application. 4933 * 4934 * @return Returns the label associated with this application, or null if 4935 * it could not be found for any reason. 4936 * @param info The application to get the label of. 4937 */ 4938 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 4939 4940 /** 4941 * Retrieve the resources associated with an activity. Given the full 4942 * name of an activity, retrieves the information about it and calls 4943 * getResources() to return its application's resources. If the activity 4944 * cannot be found, NameNotFoundException is thrown. 4945 * 4946 * @param activityName Name of the activity whose resources are to be 4947 * retrieved. 4948 * 4949 * @return Returns the application's Resources. 4950 * @throws NameNotFoundException Thrown if the resources for the given 4951 * application could not be loaded. 4952 * 4953 * @see #getResourcesForApplication(ApplicationInfo) 4954 */ 4955 public abstract Resources getResourcesForActivity(ComponentName activityName) 4956 throws NameNotFoundException; 4957 4958 /** 4959 * Retrieve the resources for an application. Throws NameNotFoundException 4960 * if the package is no longer installed. 4961 * 4962 * @param app Information about the desired application. 4963 * 4964 * @return Returns the application's Resources. 4965 * @throws NameNotFoundException Thrown if the resources for the given 4966 * application could not be loaded (most likely because it was uninstalled). 4967 */ 4968 public abstract Resources getResourcesForApplication(ApplicationInfo app) 4969 throws NameNotFoundException; 4970 4971 /** 4972 * Retrieve the resources associated with an application. Given the full 4973 * package name of an application, retrieves the information about it and 4974 * calls getResources() to return its application's resources. If the 4975 * appPackageName cannot be found, NameNotFoundException is thrown. 4976 * 4977 * @param appPackageName Package name of the application whose resources 4978 * are to be retrieved. 4979 * 4980 * @return Returns the application's Resources. 4981 * @throws NameNotFoundException Thrown if the resources for the given 4982 * application could not be loaded. 4983 * 4984 * @see #getResourcesForApplication(ApplicationInfo) 4985 */ 4986 public abstract Resources getResourcesForApplication(String appPackageName) 4987 throws NameNotFoundException; 4988 4989 /** @hide */ 4990 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, 4991 @UserIdInt int userId) throws NameNotFoundException; 4992 4993 /** 4994 * Retrieve overall information about an application package defined 4995 * in a package archive file 4996 * 4997 * @param archiveFilePath The path to the archive file 4998 * @param flags Additional option flags. Use any combination of 4999 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 5000 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 5001 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 5002 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 5003 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 5004 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 5005 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 5006 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 5007 * {@link #MATCH_UNINSTALLED_PACKAGES} 5008 * to modify the data returned. 5009 * 5010 * @return A PackageInfo object containing information about the 5011 * package archive. If the package could not be parsed, 5012 * returns null. 5013 * 5014 * @see #GET_ACTIVITIES 5015 * @see #GET_CONFIGURATIONS 5016 * @see #GET_GIDS 5017 * @see #GET_INSTRUMENTATION 5018 * @see #GET_INTENT_FILTERS 5019 * @see #GET_META_DATA 5020 * @see #GET_PERMISSIONS 5021 * @see #GET_PROVIDERS 5022 * @see #GET_RECEIVERS 5023 * @see #GET_SERVICES 5024 * @see #GET_SHARED_LIBRARY_FILES 5025 * @see #GET_SIGNATURES 5026 * @see #GET_URI_PERMISSION_PATTERNS 5027 * @see #MATCH_DISABLED_COMPONENTS 5028 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 5029 * @see #MATCH_UNINSTALLED_PACKAGES 5030 * 5031 */ 5032 public PackageInfo getPackageArchiveInfo(String archiveFilePath, @PackageInfoFlags int flags) { 5033 final PackageParser parser = new PackageParser(); 5034 parser.setCallback(new PackageParser.CallbackImpl(this)); 5035 final File apkFile = new File(archiveFilePath); 5036 try { 5037 if ((flags & (MATCH_DIRECT_BOOT_UNAWARE | MATCH_DIRECT_BOOT_AWARE)) != 0) { 5038 // Caller expressed an explicit opinion about what encryption 5039 // aware/unaware components they want to see, so fall through and 5040 // give them what they want 5041 } else { 5042 // Caller expressed no opinion, so match everything 5043 flags |= MATCH_DIRECT_BOOT_AWARE | MATCH_DIRECT_BOOT_UNAWARE; 5044 } 5045 5046 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 5047 if ((flags & GET_SIGNATURES) != 0) { 5048 PackageParser.collectCertificates(pkg, 0); 5049 } 5050 PackageUserState state = new PackageUserState(); 5051 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 5052 } catch (PackageParserException e) { 5053 return null; 5054 } 5055 } 5056 5057 /** 5058 * @deprecated replaced by {@link PackageInstaller} 5059 * @hide 5060 */ 5061 @Deprecated 5062 public abstract void installPackage( 5063 Uri packageURI, 5064 IPackageInstallObserver observer, 5065 @InstallFlags int flags, 5066 String installerPackageName); 5067 /** 5068 * @deprecated replaced by {@link PackageInstaller} 5069 * @hide 5070 */ 5071 @Deprecated 5072 public abstract void installPackage( 5073 Uri packageURI, 5074 PackageInstallObserver observer, 5075 @InstallFlags int flags, 5076 String installerPackageName); 5077 5078 /** 5079 * If there is already an application with the given package name installed 5080 * on the system for other users, also install it for the calling user. 5081 * @hide 5082 */ 5083 public abstract int installExistingPackage(String packageName) throws NameNotFoundException; 5084 5085 /** 5086 * If there is already an application with the given package name installed 5087 * on the system for other users, also install it for the specified user. 5088 * @hide 5089 */ 5090 @RequiresPermission(anyOf = { 5091 Manifest.permission.INSTALL_PACKAGES, 5092 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 5093 public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId) 5094 throws NameNotFoundException; 5095 5096 /** 5097 * Allows a package listening to the 5098 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 5099 * broadcast} to respond to the package manager. The response must include 5100 * the {@code verificationCode} which is one of 5101 * {@link PackageManager#VERIFICATION_ALLOW} or 5102 * {@link PackageManager#VERIFICATION_REJECT}. 5103 * 5104 * @param id pending package identifier as passed via the 5105 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 5106 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 5107 * or {@link PackageManager#VERIFICATION_REJECT}. 5108 * @throws SecurityException if the caller does not have the 5109 * PACKAGE_VERIFICATION_AGENT permission. 5110 */ 5111 public abstract void verifyPendingInstall(int id, int verificationCode); 5112 5113 /** 5114 * Allows a package listening to the 5115 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 5116 * broadcast} to extend the default timeout for a response and declare what 5117 * action to perform after the timeout occurs. The response must include 5118 * the {@code verificationCodeAtTimeout} which is one of 5119 * {@link PackageManager#VERIFICATION_ALLOW} or 5120 * {@link PackageManager#VERIFICATION_REJECT}. 5121 * 5122 * This method may only be called once per package id. Additional calls 5123 * will have no effect. 5124 * 5125 * @param id pending package identifier as passed via the 5126 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 5127 * @param verificationCodeAtTimeout either 5128 * {@link PackageManager#VERIFICATION_ALLOW} or 5129 * {@link PackageManager#VERIFICATION_REJECT}. If 5130 * {@code verificationCodeAtTimeout} is neither 5131 * {@link PackageManager#VERIFICATION_ALLOW} or 5132 * {@link PackageManager#VERIFICATION_REJECT}, then 5133 * {@code verificationCodeAtTimeout} will default to 5134 * {@link PackageManager#VERIFICATION_REJECT}. 5135 * @param millisecondsToDelay the amount of time requested for the timeout. 5136 * Must be positive and less than 5137 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 5138 * {@code millisecondsToDelay} is out of bounds, 5139 * {@code millisecondsToDelay} will be set to the closest in 5140 * bounds value; namely, 0 or 5141 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 5142 * @throws SecurityException if the caller does not have the 5143 * PACKAGE_VERIFICATION_AGENT permission. 5144 */ 5145 public abstract void extendVerificationTimeout(int id, 5146 int verificationCodeAtTimeout, long millisecondsToDelay); 5147 5148 /** 5149 * Allows a package listening to the 5150 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION} intent filter verification 5151 * broadcast to respond to the package manager. The response must include 5152 * the {@code verificationCode} which is one of 5153 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 5154 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 5155 * 5156 * @param verificationId pending package identifier as passed via the 5157 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 5158 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 5159 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 5160 * @param failedDomains a list of failed domains if the verificationCode is 5161 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 5162 * @throws SecurityException if the caller does not have the 5163 * INTENT_FILTER_VERIFICATION_AGENT permission. 5164 * 5165 * @hide 5166 */ 5167 @SystemApi 5168 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 5169 List<String> failedDomains); 5170 5171 /** 5172 * Get the status of a Domain Verification Result for an IntentFilter. This is 5173 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 5174 * {@link android.content.IntentFilter#getAutoVerify()} 5175 * 5176 * This is used by the ResolverActivity to change the status depending on what the User select 5177 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 5178 * for a domain. 5179 * 5180 * @param packageName The package name of the Activity associated with the IntentFilter. 5181 * @param userId The user id. 5182 * 5183 * @return The status to set to. This can be 5184 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 5185 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 5186 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 5187 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 5188 * 5189 * @hide 5190 */ 5191 @SystemApi 5192 public abstract int getIntentVerificationStatusAsUser(String packageName, @UserIdInt int userId); 5193 5194 /** 5195 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 5196 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 5197 * {@link android.content.IntentFilter#getAutoVerify()} 5198 * 5199 * This is used by the ResolverActivity to change the status depending on what the User select 5200 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 5201 * for a domain. 5202 * 5203 * @param packageName The package name of the Activity associated with the IntentFilter. 5204 * @param status The status to set to. This can be 5205 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 5206 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 5207 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 5208 * @param userId The user id. 5209 * 5210 * @return true if the status has been set. False otherwise. 5211 * 5212 * @hide 5213 */ 5214 @SystemApi 5215 public abstract boolean updateIntentVerificationStatusAsUser(String packageName, int status, 5216 @UserIdInt int userId); 5217 5218 /** 5219 * Get the list of IntentFilterVerificationInfo for a specific package and User. 5220 * 5221 * @param packageName the package name. When this parameter is set to a non null value, 5222 * the results will be filtered by the package name provided. 5223 * Otherwise, there will be no filtering and it will return a list 5224 * corresponding for all packages 5225 * 5226 * @return a list of IntentFilterVerificationInfo for a specific package. 5227 * 5228 * @hide 5229 */ 5230 @SystemApi 5231 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 5232 String packageName); 5233 5234 /** 5235 * Get the list of IntentFilter for a specific package. 5236 * 5237 * @param packageName the package name. This parameter is set to a non null value, 5238 * the list will contain all the IntentFilter for that package. 5239 * Otherwise, the list will be empty. 5240 * 5241 * @return a list of IntentFilter for a specific package. 5242 * 5243 * @hide 5244 */ 5245 @SystemApi 5246 public abstract List<IntentFilter> getAllIntentFilters(String packageName); 5247 5248 /** 5249 * Get the default Browser package name for a specific user. 5250 * 5251 * @param userId The user id. 5252 * 5253 * @return the package name of the default Browser for the specified user. If the user id passed 5254 * is -1 (all users) it will return a null value. 5255 * 5256 * @hide 5257 */ 5258 @TestApi 5259 @SystemApi 5260 public abstract String getDefaultBrowserPackageNameAsUser(@UserIdInt int userId); 5261 5262 /** 5263 * Set the default Browser package name for a specific user. 5264 * 5265 * @param packageName The package name of the default Browser. 5266 * @param userId The user id. 5267 * 5268 * @return true if the default Browser for the specified user has been set, 5269 * otherwise return false. If the user id passed is -1 (all users) this call will not 5270 * do anything and just return false. 5271 * 5272 * @hide 5273 */ 5274 @SystemApi 5275 public abstract boolean setDefaultBrowserPackageNameAsUser(String packageName, 5276 @UserIdInt int userId); 5277 5278 /** 5279 * Change the installer associated with a given package. There are limitations 5280 * on how the installer package can be changed; in particular: 5281 * <ul> 5282 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 5283 * is not signed with the same certificate as the calling application. 5284 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 5285 * has an installer package, and that installer package is not signed with 5286 * the same certificate as the calling application. 5287 * </ul> 5288 * 5289 * @param targetPackage The installed package whose installer will be changed. 5290 * @param installerPackageName The package name of the new installer. May be 5291 * null to clear the association. 5292 */ 5293 public abstract void setInstallerPackageName(String targetPackage, 5294 String installerPackageName); 5295 5296 /** @hide */ 5297 @SystemApi 5298 @RequiresPermission(Manifest.permission.INSTALL_PACKAGES) 5299 public abstract void setUpdateAvailable(String packageName, boolean updateAvaialble); 5300 5301 /** 5302 * Attempts to delete a package. Since this may take a little while, the 5303 * result will be posted back to the given observer. A deletion will fail if 5304 * the calling context lacks the 5305 * {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 5306 * named package cannot be found, or if the named package is a system 5307 * package. 5308 * 5309 * @param packageName The name of the package to delete 5310 * @param observer An observer callback to get notified when the package 5311 * deletion is complete. 5312 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 5313 * will be called when that happens. observer may be null to 5314 * indicate that no callback is desired. 5315 * @hide 5316 */ 5317 @RequiresPermission(Manifest.permission.DELETE_PACKAGES) 5318 public abstract void deletePackage(String packageName, IPackageDeleteObserver observer, 5319 @DeleteFlags int flags); 5320 5321 /** 5322 * Attempts to delete a package. Since this may take a little while, the 5323 * result will be posted back to the given observer. A deletion will fail if 5324 * the named package cannot be found, or if the named package is a system 5325 * package. 5326 * 5327 * @param packageName The name of the package to delete 5328 * @param observer An observer callback to get notified when the package 5329 * deletion is complete. 5330 * {@link android.content.pm.IPackageDeleteObserver#packageDeleted} 5331 * will be called when that happens. observer may be null to 5332 * indicate that no callback is desired. 5333 * @param userId The user Id 5334 * @hide 5335 */ 5336 @RequiresPermission(anyOf = { 5337 Manifest.permission.DELETE_PACKAGES, 5338 Manifest.permission.INTERACT_ACROSS_USERS_FULL}) 5339 public abstract void deletePackageAsUser(@NonNull String packageName, 5340 IPackageDeleteObserver observer, @DeleteFlags int flags, @UserIdInt int userId); 5341 5342 /** 5343 * Retrieve the package name of the application that installed a package. This identifies 5344 * which market the package came from. 5345 * 5346 * @param packageName The name of the package to query 5347 */ 5348 public abstract String getInstallerPackageName(String packageName); 5349 5350 /** 5351 * Attempts to clear the user data directory of an application. 5352 * Since this may take a little while, the result will 5353 * be posted back to the given observer. A deletion will fail if the 5354 * named package cannot be found, or if the named package is a "system package". 5355 * 5356 * @param packageName The name of the package 5357 * @param observer An observer callback to get notified when the operation is finished 5358 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5359 * will be called when that happens. observer may be null to indicate that 5360 * no callback is desired. 5361 * 5362 * @hide 5363 */ 5364 public abstract void clearApplicationUserData(String packageName, 5365 IPackageDataObserver observer); 5366 /** 5367 * Attempts to delete the cache files associated with an application. 5368 * Since this may take a little while, the result will 5369 * be posted back to the given observer. A deletion will fail if the calling context 5370 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 5371 * named package cannot be found, or if the named package is a "system package". 5372 * 5373 * @param packageName The name of the package to delete 5374 * @param observer An observer callback to get notified when the cache file deletion 5375 * is complete. 5376 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5377 * will be called when that happens. observer may be null to indicate that 5378 * no callback is desired. 5379 * 5380 * @hide 5381 */ 5382 public abstract void deleteApplicationCacheFiles(String packageName, 5383 IPackageDataObserver observer); 5384 5385 /** 5386 * Attempts to delete the cache files associated with an application for a given user. Since 5387 * this may take a little while, the result will be posted back to the given observer. A 5388 * deletion will fail if the calling context lacks the 5389 * {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the named package 5390 * cannot be found, or if the named package is a "system package". If {@code userId} does not 5391 * belong to the calling user, the caller must have 5392 * {@link android.Manifest.permission#INTERACT_ACROSS_USERS} permission. 5393 * 5394 * @param packageName The name of the package to delete 5395 * @param userId the user for which the cache files needs to be deleted 5396 * @param observer An observer callback to get notified when the cache file deletion is 5397 * complete. 5398 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 5399 * will be called when that happens. observer may be null to indicate that no 5400 * callback is desired. 5401 * @hide 5402 */ 5403 public abstract void deleteApplicationCacheFilesAsUser(String packageName, int userId, 5404 IPackageDataObserver observer); 5405 5406 /** 5407 * Free storage by deleting LRU sorted list of cache files across 5408 * all applications. If the currently available free storage 5409 * on the device is greater than or equal to the requested 5410 * free storage, no cache files are cleared. If the currently 5411 * available storage on the device is less than the requested 5412 * free storage, some or all of the cache files across 5413 * all applications are deleted (based on last accessed time) 5414 * to increase the free storage space on the device to 5415 * the requested value. There is no guarantee that clearing all 5416 * the cache files from all applications will clear up 5417 * enough storage to achieve the desired value. 5418 * @param freeStorageSize The number of bytes of storage to be 5419 * freed by the system. Say if freeStorageSize is XX, 5420 * and the current free storage is YY, 5421 * if XX is less than YY, just return. if not free XX-YY number 5422 * of bytes if possible. 5423 * @param observer call back used to notify when 5424 * the operation is completed 5425 * 5426 * @hide 5427 */ 5428 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) { 5429 freeStorageAndNotify(null, freeStorageSize, observer); 5430 } 5431 5432 /** {@hide} */ 5433 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize, 5434 IPackageDataObserver observer); 5435 5436 /** 5437 * Free storage by deleting LRU sorted list of cache files across 5438 * all applications. If the currently available free storage 5439 * on the device is greater than or equal to the requested 5440 * free storage, no cache files are cleared. If the currently 5441 * available storage on the device is less than the requested 5442 * free storage, some or all of the cache files across 5443 * all applications are deleted (based on last accessed time) 5444 * to increase the free storage space on the device to 5445 * the requested value. There is no guarantee that clearing all 5446 * the cache files from all applications will clear up 5447 * enough storage to achieve the desired value. 5448 * @param freeStorageSize The number of bytes of storage to be 5449 * freed by the system. Say if freeStorageSize is XX, 5450 * and the current free storage is YY, 5451 * if XX is less than YY, just return. if not free XX-YY number 5452 * of bytes if possible. 5453 * @param pi IntentSender call back used to 5454 * notify when the operation is completed.May be null 5455 * to indicate that no call back is desired. 5456 * 5457 * @hide 5458 */ 5459 public void freeStorage(long freeStorageSize, IntentSender pi) { 5460 freeStorage(null, freeStorageSize, pi); 5461 } 5462 5463 /** {@hide} */ 5464 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi); 5465 5466 /** 5467 * Retrieve the size information for a package. 5468 * Since this may take a little while, the result will 5469 * be posted back to the given observer. The calling context 5470 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 5471 * 5472 * @param packageName The name of the package whose size information is to be retrieved 5473 * @param userId The user whose size information should be retrieved. 5474 * @param observer An observer callback to get notified when the operation 5475 * is complete. 5476 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 5477 * The observer's callback is invoked with a PackageStats object(containing the 5478 * code, data and cache sizes of the package) and a boolean value representing 5479 * the status of the operation. observer may be null to indicate that 5480 * no callback is desired. 5481 * 5482 * @deprecated use {@link StorageStatsManager} instead. 5483 * @hide 5484 */ 5485 @Deprecated 5486 public abstract void getPackageSizeInfoAsUser(String packageName, @UserIdInt int userId, 5487 IPackageStatsObserver observer); 5488 5489 /** 5490 * Like {@link #getPackageSizeInfoAsUser(String, int, IPackageStatsObserver)}, but 5491 * returns the size for the calling user. 5492 * 5493 * @deprecated use {@link StorageStatsManager} instead. 5494 * @hide 5495 */ 5496 @Deprecated 5497 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 5498 getPackageSizeInfoAsUser(packageName, UserHandle.myUserId(), observer); 5499 } 5500 5501 /** 5502 * @deprecated This function no longer does anything; it was an old 5503 * approach to managing preferred activities, which has been superseded 5504 * by (and conflicts with) the modern activity-based preferences. 5505 */ 5506 @Deprecated 5507 public abstract void addPackageToPreferred(String packageName); 5508 5509 /** 5510 * @deprecated This function no longer does anything; it was an old 5511 * approach to managing preferred activities, which has been superseded 5512 * by (and conflicts with) the modern activity-based preferences. 5513 */ 5514 @Deprecated 5515 public abstract void removePackageFromPreferred(String packageName); 5516 5517 /** 5518 * Retrieve the list of all currently configured preferred packages. The 5519 * first package on the list is the most preferred, the last is the 5520 * least preferred. 5521 * 5522 * @param flags Additional option flags. Use any combination of 5523 * {@link #GET_ACTIVITIES}, {@link #GET_CONFIGURATIONS}, 5524 * {@link #GET_GIDS}, {@link #GET_INSTRUMENTATION}, 5525 * {@link #GET_INTENT_FILTERS}, {@link #GET_META_DATA}, 5526 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 5527 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 5528 * {@link #GET_SHARED_LIBRARY_FILES}, {@link #GET_SIGNATURES}, 5529 * {@link #GET_URI_PERMISSION_PATTERNS}, {@link #GET_UNINSTALLED_PACKAGES}, 5530 * {@link #MATCH_DISABLED_COMPONENTS}, {@link #MATCH_DISABLED_UNTIL_USED_COMPONENTS}, 5531 * {@link #MATCH_UNINSTALLED_PACKAGES} 5532 * to modify the data returned. 5533 * 5534 * @return A List of PackageInfo objects, one for each preferred application, 5535 * in order of preference. 5536 * 5537 * @see #GET_ACTIVITIES 5538 * @see #GET_CONFIGURATIONS 5539 * @see #GET_GIDS 5540 * @see #GET_INSTRUMENTATION 5541 * @see #GET_INTENT_FILTERS 5542 * @see #GET_META_DATA 5543 * @see #GET_PERMISSIONS 5544 * @see #GET_PROVIDERS 5545 * @see #GET_RECEIVERS 5546 * @see #GET_SERVICES 5547 * @see #GET_SHARED_LIBRARY_FILES 5548 * @see #GET_SIGNATURES 5549 * @see #GET_URI_PERMISSION_PATTERNS 5550 * @see #MATCH_DISABLED_COMPONENTS 5551 * @see #MATCH_DISABLED_UNTIL_USED_COMPONENTS 5552 * @see #MATCH_UNINSTALLED_PACKAGES 5553 */ 5554 public abstract List<PackageInfo> getPreferredPackages(@PackageInfoFlags int flags); 5555 5556 /** 5557 * @deprecated This is a protected API that should not have been available 5558 * to third party applications. It is the platform's responsibility for 5559 * assigning preferred activities and this cannot be directly modified. 5560 * 5561 * Add a new preferred activity mapping to the system. This will be used 5562 * to automatically select the given activity component when 5563 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5564 * multiple matching activities and also matches the given filter. 5565 * 5566 * @param filter The set of intents under which this activity will be 5567 * made preferred. 5568 * @param match The IntentFilter match category that this preference 5569 * applies to. 5570 * @param set The set of activities that the user was picking from when 5571 * this preference was made. 5572 * @param activity The component name of the activity that is to be 5573 * preferred. 5574 */ 5575 @Deprecated 5576 public abstract void addPreferredActivity(IntentFilter filter, int match, 5577 ComponentName[] set, ComponentName activity); 5578 5579 /** 5580 * Same as {@link #addPreferredActivity(IntentFilter, int, 5581 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 5582 to. 5583 * @hide 5584 */ 5585 public void addPreferredActivityAsUser(IntentFilter filter, int match, 5586 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5587 throw new RuntimeException("Not implemented. Must override in a subclass."); 5588 } 5589 5590 /** 5591 * @deprecated This is a protected API that should not have been available 5592 * to third party applications. It is the platform's responsibility for 5593 * assigning preferred activities and this cannot be directly modified. 5594 * 5595 * Replaces an existing preferred activity mapping to the system, and if that were not present 5596 * adds a new preferred activity. This will be used 5597 * to automatically select the given activity component when 5598 * {@link Context#startActivity(Intent) Context.startActivity()} finds 5599 * multiple matching activities and also matches the given filter. 5600 * 5601 * @param filter The set of intents under which this activity will be 5602 * made preferred. 5603 * @param match The IntentFilter match category that this preference 5604 * applies to. 5605 * @param set The set of activities that the user was picking from when 5606 * this preference was made. 5607 * @param activity The component name of the activity that is to be 5608 * preferred. 5609 * @hide 5610 */ 5611 @Deprecated 5612 public abstract void replacePreferredActivity(IntentFilter filter, int match, 5613 ComponentName[] set, ComponentName activity); 5614 5615 /** 5616 * @hide 5617 */ 5618 @Deprecated 5619 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 5620 ComponentName[] set, ComponentName activity, @UserIdInt int userId) { 5621 throw new RuntimeException("Not implemented. Must override in a subclass."); 5622 } 5623 5624 /** 5625 * Remove all preferred activity mappings, previously added with 5626 * {@link #addPreferredActivity}, from the 5627 * system whose activities are implemented in the given package name. 5628 * An application can only clear its own package(s). 5629 * 5630 * @param packageName The name of the package whose preferred activity 5631 * mappings are to be removed. 5632 */ 5633 public abstract void clearPackagePreferredActivities(String packageName); 5634 5635 /** 5636 * Retrieve all preferred activities, previously added with 5637 * {@link #addPreferredActivity}, that are 5638 * currently registered with the system. 5639 * 5640 * @param outFilters A required list in which to place the filters of all of the 5641 * preferred activities. 5642 * @param outActivities A required list in which to place the component names of 5643 * all of the preferred activities. 5644 * @param packageName An optional package in which you would like to limit 5645 * the list. If null, all activities will be returned; if non-null, only 5646 * those activities in the given package are returned. 5647 * 5648 * @return Returns the total number of registered preferred activities 5649 * (the number of distinct IntentFilter records, not the number of unique 5650 * activity components) that were found. 5651 */ 5652 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 5653 @NonNull List<ComponentName> outActivities, String packageName); 5654 5655 /** 5656 * Ask for the set of available 'home' activities and the current explicit 5657 * default, if any. 5658 * @hide 5659 */ 5660 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 5661 5662 /** 5663 * Set the enabled setting for a package component (activity, receiver, service, provider). 5664 * This setting will override any enabled state which may have been set by the component in its 5665 * manifest. 5666 * 5667 * @param componentName The component to enable 5668 * @param newState The new enabled state for the component. The legal values for this state 5669 * are: 5670 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5671 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 5672 * and 5673 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 5674 * The last one removes the setting, thereby restoring the component's state to 5675 * whatever was set in it's manifest (or enabled, by default). 5676 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 5677 */ 5678 public abstract void setComponentEnabledSetting(ComponentName componentName, 5679 int newState, int flags); 5680 5681 /** 5682 * Return the enabled setting for a package component (activity, 5683 * receiver, service, provider). This returns the last value set by 5684 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 5685 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5686 * the value originally specified in the manifest has not been modified. 5687 * 5688 * @param componentName The component to retrieve. 5689 * @return Returns the current enabled state for the component. May 5690 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5691 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 5692 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 5693 * component's enabled state is based on the original information in 5694 * the manifest as found in {@link ComponentInfo}. 5695 */ 5696 public abstract int getComponentEnabledSetting(ComponentName componentName); 5697 5698 /** 5699 * Set the enabled setting for an application 5700 * This setting will override any enabled state which may have been set by the application in 5701 * its manifest. It also overrides the enabled state set in the manifest for any of the 5702 * application's components. It does not override any enabled state set by 5703 * {@link #setComponentEnabledSetting} for any of the application's components. 5704 * 5705 * @param packageName The package name of the application to enable 5706 * @param newState The new enabled state for the component. The legal values for this state 5707 * are: 5708 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5709 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 5710 * and 5711 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 5712 * The last one removes the setting, thereby restoring the applications's state to 5713 * whatever was set in its manifest (or enabled, by default). 5714 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 5715 */ 5716 public abstract void setApplicationEnabledSetting(String packageName, 5717 int newState, int flags); 5718 5719 /** 5720 * Return the enabled setting for an application. This returns 5721 * the last value set by 5722 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 5723 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 5724 * the value originally specified in the manifest has not been modified. 5725 * 5726 * @param packageName The package name of the application to retrieve. 5727 * @return Returns the current enabled state for the application. May 5728 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 5729 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 5730 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 5731 * application's enabled state is based on the original information in 5732 * the manifest as found in {@link ApplicationInfo}. 5733 * @throws IllegalArgumentException if the named package does not exist. 5734 */ 5735 public abstract int getApplicationEnabledSetting(String packageName); 5736 5737 /** 5738 * Flush the package restrictions for a given user to disk. This forces the package restrictions 5739 * like component and package enabled settings to be written to disk and avoids the delay that 5740 * is otherwise present when changing those settings. 5741 * 5742 * @param userId Ther userId of the user whose restrictions are to be flushed. 5743 * @hide 5744 */ 5745 public abstract void flushPackageRestrictionsAsUser(int userId); 5746 5747 /** 5748 * Puts the package in a hidden state, which is almost like an uninstalled state, 5749 * making the package unavailable, but it doesn't remove the data or the actual 5750 * package file. Application can be unhidden by either resetting the hidden state 5751 * or by installing it, such as with {@link #installExistingPackage(String)} 5752 * @hide 5753 */ 5754 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 5755 UserHandle userHandle); 5756 5757 /** 5758 * Returns the hidden state of a package. 5759 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 5760 * @hide 5761 */ 5762 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 5763 UserHandle userHandle); 5764 5765 /** 5766 * Return whether the device has been booted into safe mode. 5767 */ 5768 public abstract boolean isSafeMode(); 5769 5770 /** 5771 * Adds a listener for permission changes for installed packages. 5772 * 5773 * @param listener The listener to add. 5774 * 5775 * @hide 5776 */ 5777 @SystemApi 5778 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 5779 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5780 5781 /** 5782 * Remvoes a listener for permission changes for installed packages. 5783 * 5784 * @param listener The listener to remove. 5785 * 5786 * @hide 5787 */ 5788 @SystemApi 5789 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener); 5790 5791 /** 5792 * Return the {@link KeySet} associated with the String alias for this 5793 * application. 5794 * 5795 * @param alias The alias for a given {@link KeySet} as defined in the 5796 * application's AndroidManifest.xml. 5797 * @hide 5798 */ 5799 public abstract KeySet getKeySetByAlias(String packageName, String alias); 5800 5801 /** Return the signing {@link KeySet} for this application. 5802 * @hide 5803 */ 5804 public abstract KeySet getSigningKeySet(String packageName); 5805 5806 /** 5807 * Return whether the package denoted by packageName has been signed by all 5808 * of the keys specified by the {@link KeySet} ks. This will return true if 5809 * the package has been signed by additional keys (a superset) as well. 5810 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 5811 * @hide 5812 */ 5813 public abstract boolean isSignedBy(String packageName, KeySet ks); 5814 5815 /** 5816 * Return whether the package denoted by packageName has been signed by all 5817 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 5818 * {@link #isSignedBy(String packageName, KeySet ks)}. 5819 * @hide 5820 */ 5821 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 5822 5823 /** 5824 * Puts the package in a suspended state, where attempts at starting activities are denied. 5825 * 5826 * <p>It doesn't remove the data or the actual package file. The application notifications 5827 * will be hidden, the application will not show up in recents, will not be able to show 5828 * toasts or dialogs or ring the device. 5829 * 5830 * <p>The package must already be installed. If the package is uninstalled while suspended 5831 * the package will no longer be suspended. 5832 * 5833 * @param packageNames The names of the packages to set the suspended status. 5834 * @param suspended If set to {@code true} than the packages will be suspended, if set to 5835 * {@code false} the packages will be unsuspended. 5836 * @param userId The user id. 5837 * 5838 * @return an array of package names for which the suspended status is not set as requested in 5839 * this method. 5840 * 5841 * @hide 5842 */ 5843 public abstract String[] setPackagesSuspendedAsUser( 5844 String[] packageNames, boolean suspended, @UserIdInt int userId); 5845 5846 /** 5847 * @see #setPackageSuspendedAsUser(String, boolean, int) 5848 * @param packageName The name of the package to get the suspended status of. 5849 * @param userId The user id. 5850 * @return {@code true} if the package is suspended or {@code false} if the package is not 5851 * suspended or could not be found. 5852 * @hide 5853 */ 5854 public abstract boolean isPackageSuspendedForUser(String packageName, int userId); 5855 5856 /** 5857 * Provide a hint of what the {@link ApplicationInfo#category} value should 5858 * be for the given package. 5859 * <p> 5860 * This hint can only be set by the app which installed this package, as 5861 * determined by {@link #getInstallerPackageName(String)}. 5862 */ 5863 public abstract void setApplicationCategoryHint(String packageName, 5864 @ApplicationInfo.Category int categoryHint); 5865 5866 /** {@hide} */ 5867 public static boolean isMoveStatusFinished(int status) { 5868 return (status < 0 || status > 100); 5869 } 5870 5871 /** {@hide} */ 5872 public static abstract class MoveCallback { 5873 public void onCreated(int moveId, Bundle extras) {} 5874 public abstract void onStatusChanged(int moveId, int status, long estMillis); 5875 } 5876 5877 /** {@hide} */ 5878 public abstract int getMoveStatus(int moveId); 5879 5880 /** {@hide} */ 5881 public abstract void registerMoveCallback(MoveCallback callback, Handler handler); 5882 /** {@hide} */ 5883 public abstract void unregisterMoveCallback(MoveCallback callback); 5884 5885 /** {@hide} */ 5886 public abstract int movePackage(String packageName, VolumeInfo vol); 5887 /** {@hide} */ 5888 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app); 5889 /** {@hide} */ 5890 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app); 5891 5892 /** {@hide} */ 5893 public abstract int movePrimaryStorage(VolumeInfo vol); 5894 /** {@hide} */ 5895 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 5896 /** {@hide} */ 5897 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 5898 5899 /** 5900 * Returns the device identity that verifiers can use to associate their scheme to a particular 5901 * device. This should not be used by anything other than a package verifier. 5902 * 5903 * @return identity that uniquely identifies current device 5904 * @hide 5905 */ 5906 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 5907 5908 /** 5909 * Returns true if the device is upgrading, such as first boot after OTA. 5910 * 5911 * @hide 5912 */ 5913 public abstract boolean isUpgrade(); 5914 5915 /** 5916 * Return interface that offers the ability to install, upgrade, and remove 5917 * applications on the device. 5918 */ 5919 public abstract @NonNull PackageInstaller getPackageInstaller(); 5920 5921 /** 5922 * Adds a {@code CrossProfileIntentFilter}. After calling this method all 5923 * intents sent from the user with id sourceUserId can also be be resolved 5924 * by activities in the user with id targetUserId if they match the 5925 * specified intent filter. 5926 * 5927 * @param filter The {@link IntentFilter} the intent has to match 5928 * @param sourceUserId The source user id. 5929 * @param targetUserId The target user id. 5930 * @param flags The possible values are {@link #SKIP_CURRENT_PROFILE} and 5931 * {@link #ONLY_IF_NO_MATCH_FOUND}. 5932 * @hide 5933 */ 5934 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 5935 int targetUserId, int flags); 5936 5937 /** 5938 * Clearing {@code CrossProfileIntentFilter}s which have the specified user 5939 * as their source, and have been set by the app calling this method. 5940 * 5941 * @param sourceUserId The source user id. 5942 * @hide 5943 */ 5944 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 5945 5946 /** 5947 * @hide 5948 */ 5949 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 5950 5951 /** 5952 * @hide 5953 */ 5954 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 5955 5956 /** {@hide} */ 5957 public abstract boolean isPackageAvailable(String packageName); 5958 5959 /** {@hide} */ 5960 public static String installStatusToString(int status, String msg) { 5961 final String str = installStatusToString(status); 5962 if (msg != null) { 5963 return str + ": " + msg; 5964 } else { 5965 return str; 5966 } 5967 } 5968 5969 /** {@hide} */ 5970 public static String installStatusToString(int status) { 5971 switch (status) { 5972 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 5973 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 5974 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 5975 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 5976 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 5977 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 5978 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 5979 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 5980 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 5981 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 5982 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 5983 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 5984 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 5985 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 5986 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 5987 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 5988 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 5989 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 5990 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 5991 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 5992 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 5993 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 5994 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 5995 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 5996 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 5997 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 5998 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 5999 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 6000 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 6001 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 6002 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 6003 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 6004 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 6005 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 6006 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 6007 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 6008 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 6009 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 6010 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 6011 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 6012 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 6013 default: return Integer.toString(status); 6014 } 6015 } 6016 6017 /** {@hide} */ 6018 public static int installStatusToPublicStatus(int status) { 6019 switch (status) { 6020 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 6021 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6022 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 6023 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 6024 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 6025 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6026 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6027 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6028 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6029 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6030 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6031 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 6032 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6033 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6034 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6035 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 6036 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6037 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6038 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 6039 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 6040 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 6041 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 6042 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 6043 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 6044 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 6045 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 6046 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 6047 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 6048 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 6049 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 6050 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 6051 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 6052 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 6053 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 6054 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 6055 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 6056 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 6057 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 6058 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6059 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6060 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 6061 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 6062 default: return PackageInstaller.STATUS_FAILURE; 6063 } 6064 } 6065 6066 /** {@hide} */ 6067 public static String deleteStatusToString(int status, String msg) { 6068 final String str = deleteStatusToString(status); 6069 if (msg != null) { 6070 return str + ": " + msg; 6071 } else { 6072 return str; 6073 } 6074 } 6075 6076 /** {@hide} */ 6077 public static String deleteStatusToString(int status) { 6078 switch (status) { 6079 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 6080 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 6081 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 6082 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 6083 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 6084 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 6085 case DELETE_FAILED_USED_SHARED_LIBRARY: return "DELETE_FAILED_USED_SHARED_LIBRARY"; 6086 default: return Integer.toString(status); 6087 } 6088 } 6089 6090 /** {@hide} */ 6091 public static int deleteStatusToPublicStatus(int status) { 6092 switch (status) { 6093 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 6094 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 6095 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 6096 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 6097 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 6098 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 6099 case DELETE_FAILED_USED_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_CONFLICT; 6100 default: return PackageInstaller.STATUS_FAILURE; 6101 } 6102 } 6103 6104 /** {@hide} */ 6105 public static String permissionFlagToString(int flag) { 6106 switch (flag) { 6107 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 6108 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 6109 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 6110 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 6111 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE"; 6112 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 6113 case FLAG_PERMISSION_REVIEW_REQUIRED: return "REVIEW_REQUIRED"; 6114 default: return Integer.toString(flag); 6115 } 6116 } 6117 6118 /** {@hide} */ 6119 public static class LegacyPackageInstallObserver extends PackageInstallObserver { 6120 private final IPackageInstallObserver mLegacy; 6121 6122 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { 6123 mLegacy = legacy; 6124 } 6125 6126 @Override 6127 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 6128 Bundle extras) { 6129 if (mLegacy == null) return; 6130 try { 6131 mLegacy.packageInstalled(basePackageName, returnCode); 6132 } catch (RemoteException ignored) { 6133 } 6134 } 6135 } 6136 6137 /** {@hide} */ 6138 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 6139 private final IPackageDeleteObserver mLegacy; 6140 6141 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 6142 mLegacy = legacy; 6143 } 6144 6145 @Override 6146 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 6147 if (mLegacy == null) return; 6148 try { 6149 mLegacy.packageDeleted(basePackageName, returnCode); 6150 } catch (RemoteException ignored) { 6151 } 6152 } 6153 } 6154 6155 /** 6156 * Return the install reason that was recorded when a package was first installed for a specific 6157 * user. Requesting the install reason for another user will require the permission 6158 * INTERACT_ACROSS_USERS_FULL. 6159 * 6160 * @param packageName The package for which to retrieve the install reason 6161 * @param user The user for whom to retrieve the install reason 6162 * 6163 * @return The install reason, currently one of {@code INSTALL_REASON_UNKNOWN} and 6164 * {@code INSTALL_REASON_POLICY}. If the package is not installed for the given user, 6165 * {@code INSTALL_REASON_UNKNOWN} is returned. 6166 * 6167 * @see #INSTALL_REASON_UNKNOWN 6168 * @see #INSTALL_REASON_POLICY 6169 * @see #INSTALL_REASON_DEVICE_RESTORE 6170 * @see #INSTALL_REASON_DEVICE_SETUP 6171 * @see #INSTALL_REASON_USER 6172 * 6173 * @hide 6174 */ 6175 @TestApi 6176 public abstract @InstallReason int getInstallReason(String packageName, 6177 @NonNull UserHandle user); 6178 6179 /** 6180 * Checks whether the calling package is allowed to request package installs through package 6181 * installer. Apps are encouraged to call this api before launching the package installer via 6182 * intent {@link android.content.Intent#ACTION_INSTALL_PACKAGE}. Starting from Android O, the 6183 * user can explicitly choose what external sources they trust to install apps on the device. 6184 * If this api returns false, the install request will be blocked by the package installer and 6185 * a dialog will be shown to the user with an option to launch settings to change their 6186 * preference. An application must target Android O or higher and declare permission 6187 * {@link android.Manifest.permission#REQUEST_INSTALL_PACKAGES} in order to use this api. 6188 * 6189 * @return true if the calling package is trusted by the user to request install packages on 6190 * the device, false otherwise. 6191 * @see {@link android.content.Intent#ACTION_INSTALL_PACKAGE} 6192 * @see {@link android.provider.Settings#ACTION_MANAGE_EXTERNAL_SOURCES} 6193 */ 6194 public abstract boolean canRequestPackageInstalls(); 6195} 6196