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