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