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