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