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