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