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