PackageManager.java revision f1b7f20bb839c96e8254ccb65398135f10fd45d9
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 has biometric hardware to detect a fingerprint. 1518 */ 1519 @SdkConstant(SdkConstantType.FEATURE) 1520 public static final String FEATURE_FINGERPRINT = "android.hardware.fingerprint"; 1521 1522 /** 1523 * Feature for {@link #getSystemAvailableFeatures} and 1524 * {@link #hasSystemFeature}: The device supports portrait orientation 1525 * screens. For backwards compatibility, you can assume that if neither 1526 * this nor {@link #FEATURE_SCREEN_LANDSCAPE} is set then the device supports 1527 * both portrait and landscape. 1528 */ 1529 @SdkConstant(SdkConstantType.FEATURE) 1530 public static final String FEATURE_SCREEN_PORTRAIT = "android.hardware.screen.portrait"; 1531 1532 /** 1533 * Feature for {@link #getSystemAvailableFeatures} and 1534 * {@link #hasSystemFeature}: The device supports landscape orientation 1535 * screens. For backwards compatibility, you can assume that if neither 1536 * this nor {@link #FEATURE_SCREEN_PORTRAIT} is set then the device supports 1537 * both portrait and landscape. 1538 */ 1539 @SdkConstant(SdkConstantType.FEATURE) 1540 public static final String FEATURE_SCREEN_LANDSCAPE = "android.hardware.screen.landscape"; 1541 1542 /** 1543 * Feature for {@link #getSystemAvailableFeatures} and 1544 * {@link #hasSystemFeature}: The device supports live wallpapers. 1545 */ 1546 @SdkConstant(SdkConstantType.FEATURE) 1547 public static final String FEATURE_LIVE_WALLPAPER = "android.software.live_wallpaper"; 1548 /** 1549 * Feature for {@link #getSystemAvailableFeatures} and 1550 * {@link #hasSystemFeature}: The device supports app widgets. 1551 */ 1552 @SdkConstant(SdkConstantType.FEATURE) 1553 public static final String FEATURE_APP_WIDGETS = "android.software.app_widgets"; 1554 1555 /** 1556 * @hide 1557 * Feature for {@link #getSystemAvailableFeatures} and 1558 * {@link #hasSystemFeature}: The device supports 1559 * {@link android.service.voice.VoiceInteractionService} and 1560 * {@link android.app.VoiceInteractor}. 1561 */ 1562 @SdkConstant(SdkConstantType.FEATURE) 1563 public static final String FEATURE_VOICE_RECOGNIZERS = "android.software.voice_recognizers"; 1564 1565 1566 /** 1567 * Feature for {@link #getSystemAvailableFeatures} and 1568 * {@link #hasSystemFeature}: The device supports a home screen that is replaceable 1569 * by third party applications. 1570 */ 1571 @SdkConstant(SdkConstantType.FEATURE) 1572 public static final String FEATURE_HOME_SCREEN = "android.software.home_screen"; 1573 1574 /** 1575 * Feature for {@link #getSystemAvailableFeatures} and 1576 * {@link #hasSystemFeature}: The device supports adding new input methods implemented 1577 * with the {@link android.inputmethodservice.InputMethodService} API. 1578 */ 1579 @SdkConstant(SdkConstantType.FEATURE) 1580 public static final String FEATURE_INPUT_METHODS = "android.software.input_methods"; 1581 1582 /** 1583 * Feature for {@link #getSystemAvailableFeatures} and 1584 * {@link #hasSystemFeature}: The device supports device policy enforcement via device admins. 1585 */ 1586 @SdkConstant(SdkConstantType.FEATURE) 1587 public static final String FEATURE_DEVICE_ADMIN = "android.software.device_admin"; 1588 1589 /** 1590 * Feature for {@link #getSystemAvailableFeatures} and 1591 * {@link #hasSystemFeature}: The device supports leanback UI. This is 1592 * typically used in a living room television experience, but is a software 1593 * feature unlike {@link #FEATURE_TELEVISION}. Devices running with this 1594 * feature will use resources associated with the "television" UI mode. 1595 */ 1596 @SdkConstant(SdkConstantType.FEATURE) 1597 public static final String FEATURE_LEANBACK = "android.software.leanback"; 1598 1599 /** 1600 * Feature for {@link #getSystemAvailableFeatures} and 1601 * {@link #hasSystemFeature}: The device supports only leanback UI. Only 1602 * applications designed for this experience should be run, though this is 1603 * not enforced by the system. 1604 * @hide 1605 */ 1606 @SdkConstant(SdkConstantType.FEATURE) 1607 public static final String FEATURE_LEANBACK_ONLY = "android.software.leanback_only"; 1608 1609 /** 1610 * Feature for {@link #getSystemAvailableFeatures} and 1611 * {@link #hasSystemFeature}: The device supports live TV and can display 1612 * contents from TV inputs implemented with the 1613 * {@link android.media.tv.TvInputService} API. 1614 */ 1615 @SdkConstant(SdkConstantType.FEATURE) 1616 public static final String FEATURE_LIVE_TV = "android.software.live_tv"; 1617 1618 /** 1619 * Feature for {@link #getSystemAvailableFeatures} and 1620 * {@link #hasSystemFeature}: The device supports WiFi (802.11) networking. 1621 */ 1622 @SdkConstant(SdkConstantType.FEATURE) 1623 public static final String FEATURE_WIFI = "android.hardware.wifi"; 1624 1625 /** 1626 * Feature for {@link #getSystemAvailableFeatures} and 1627 * {@link #hasSystemFeature}: The device supports Wi-Fi Direct networking. 1628 */ 1629 @SdkConstant(SdkConstantType.FEATURE) 1630 public static final String FEATURE_WIFI_DIRECT = "android.hardware.wifi.direct"; 1631 1632 /** 1633 * Feature for {@link #getSystemAvailableFeatures} and 1634 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1635 * on a vehicle headunit. A headunit here is defined to be inside a 1636 * vehicle that may or may not be moving. A headunit uses either a 1637 * primary display in the center console and/or additional displays in 1638 * the instrument cluster or elsewhere in the vehicle. Headunit display(s) 1639 * have limited size and resolution. The user will likely be focused on 1640 * driving so limiting driver distraction is a primary concern. User input 1641 * can be a variety of hard buttons, touch, rotary controllers and even mouse- 1642 * like interfaces. 1643 */ 1644 @SdkConstant(SdkConstantType.FEATURE) 1645 public static final String FEATURE_AUTOMOTIVE = "android.hardware.type.automotive"; 1646 1647 /** 1648 * Feature for {@link #getSystemAvailableFeatures} and 1649 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1650 * on a television. Television here is defined to be a typical living 1651 * room television experience: displayed on a big screen, where the user 1652 * is sitting far away from it, and the dominant form of input will be 1653 * something like a DPAD, not through touch or mouse. 1654 * @deprecated use {@link #FEATURE_LEANBACK} instead. 1655 */ 1656 @Deprecated 1657 @SdkConstant(SdkConstantType.FEATURE) 1658 public static final String FEATURE_TELEVISION = "android.hardware.type.television"; 1659 1660 /** 1661 * Feature for {@link #getSystemAvailableFeatures} and 1662 * {@link #hasSystemFeature}: This is a device dedicated to showing UI 1663 * on a watch. A watch here is defined to be a device worn on the body, perhaps on 1664 * the wrist. The user is very close when interacting with the device. 1665 */ 1666 @SdkConstant(SdkConstantType.FEATURE) 1667 public static final String FEATURE_WATCH = "android.hardware.type.watch"; 1668 1669 /** 1670 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1671 * The device supports printing. 1672 */ 1673 @SdkConstant(SdkConstantType.FEATURE) 1674 public static final String FEATURE_PRINTING = "android.software.print"; 1675 1676 /** 1677 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1678 * The device can perform backup and restore operations on installed applications. 1679 */ 1680 @SdkConstant(SdkConstantType.FEATURE) 1681 public static final String FEATURE_BACKUP = "android.software.backup"; 1682 1683 /** 1684 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1685 * The device supports creating secondary users and managed profiles via 1686 * {@link DevicePolicyManager}. 1687 */ 1688 @SdkConstant(SdkConstantType.FEATURE) 1689 public static final String FEATURE_MANAGED_USERS = "android.software.managed_users"; 1690 1691 /** 1692 * @hide 1693 * TODO: Remove after dependencies updated b/17392243 1694 */ 1695 public static final String FEATURE_MANAGED_PROFILES = "android.software.managed_users"; 1696 1697 /** 1698 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1699 * The device supports verified boot. 1700 */ 1701 @SdkConstant(SdkConstantType.FEATURE) 1702 public static final String FEATURE_VERIFIED_BOOT = "android.software.verified_boot"; 1703 1704 /** 1705 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1706 * The device supports secure removal of users. When a user is deleted the data associated 1707 * with that user is securely deleted and no longer available. 1708 */ 1709 @SdkConstant(SdkConstantType.FEATURE) 1710 public static final String FEATURE_SECURELY_REMOVES_USERS 1711 = "android.software.securely_removes_users"; 1712 1713 /** 1714 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1715 * The device has a full implementation of the android.webkit.* APIs. Devices 1716 * lacking this feature will not have a functioning WebView implementation. 1717 */ 1718 @SdkConstant(SdkConstantType.FEATURE) 1719 public static final String FEATURE_WEBVIEW = "android.software.webview"; 1720 1721 /** 1722 * Feature for {@link #getSystemAvailableFeatures} and 1723 * {@link #hasSystemFeature}: This device supports ethernet. 1724 * @hide 1725 */ 1726 @SdkConstant(SdkConstantType.FEATURE) 1727 public static final String FEATURE_ETHERNET = "android.hardware.ethernet"; 1728 1729 /** 1730 * Feature for {@link #getSystemAvailableFeatures} and 1731 * {@link #hasSystemFeature}: This device supports HDMI-CEC. 1732 * @hide 1733 */ 1734 @SdkConstant(SdkConstantType.FEATURE) 1735 public static final String FEATURE_HDMI_CEC = "android.hardware.hdmi.cec"; 1736 1737 /** 1738 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1739 * The device has all of the inputs necessary to be considered a compatible game controller, or 1740 * includes a compatible game controller in the box. 1741 */ 1742 @SdkConstant(SdkConstantType.FEATURE) 1743 public static final String FEATURE_GAMEPAD = "android.hardware.gamepad"; 1744 1745 /** 1746 * Feature for {@link #getSystemAvailableFeatures} and {@link #hasSystemFeature}: 1747 * The device has a full implementation of the android.media.midi.* APIs. 1748 */ 1749 @SdkConstant(SdkConstantType.FEATURE) 1750 public static final String FEATURE_MIDI = "android.software.midi"; 1751 1752 /** 1753 * Action to external storage service to clean out removed apps. 1754 * @hide 1755 */ 1756 public static final String ACTION_CLEAN_EXTERNAL_STORAGE 1757 = "android.content.pm.CLEAN_EXTERNAL_STORAGE"; 1758 1759 /** 1760 * Extra field name for the URI to a verification file. Passed to a package 1761 * verifier. 1762 * 1763 * @hide 1764 */ 1765 public static final String EXTRA_VERIFICATION_URI = "android.content.pm.extra.VERIFICATION_URI"; 1766 1767 /** 1768 * Extra field name for the ID of a package pending verification. Passed to 1769 * a package verifier and is used to call back to 1770 * {@link PackageManager#verifyPendingInstall(int, int)} 1771 */ 1772 public static final String EXTRA_VERIFICATION_ID = "android.content.pm.extra.VERIFICATION_ID"; 1773 1774 /** 1775 * Extra field name for the package identifier which is trying to install 1776 * the package. 1777 * 1778 * @hide 1779 */ 1780 public static final String EXTRA_VERIFICATION_INSTALLER_PACKAGE 1781 = "android.content.pm.extra.VERIFICATION_INSTALLER_PACKAGE"; 1782 1783 /** 1784 * Extra field name for the requested install flags for a package pending 1785 * verification. Passed to a package verifier. 1786 * 1787 * @hide 1788 */ 1789 public static final String EXTRA_VERIFICATION_INSTALL_FLAGS 1790 = "android.content.pm.extra.VERIFICATION_INSTALL_FLAGS"; 1791 1792 /** 1793 * Extra field name for the uid of who is requesting to install 1794 * the package. 1795 * 1796 * @hide 1797 */ 1798 public static final String EXTRA_VERIFICATION_INSTALLER_UID 1799 = "android.content.pm.extra.VERIFICATION_INSTALLER_UID"; 1800 1801 /** 1802 * Extra field name for the package name of a package pending verification. 1803 * 1804 * @hide 1805 */ 1806 public static final String EXTRA_VERIFICATION_PACKAGE_NAME 1807 = "android.content.pm.extra.VERIFICATION_PACKAGE_NAME"; 1808 /** 1809 * Extra field name for the result of a verification, either 1810 * {@link #VERIFICATION_ALLOW}, or {@link #VERIFICATION_REJECT}. 1811 * Passed to package verifiers after a package is verified. 1812 */ 1813 public static final String EXTRA_VERIFICATION_RESULT 1814 = "android.content.pm.extra.VERIFICATION_RESULT"; 1815 1816 /** 1817 * Extra field name for the version code of a package pending verification. 1818 * 1819 * @hide 1820 */ 1821 public static final String EXTRA_VERIFICATION_VERSION_CODE 1822 = "android.content.pm.extra.VERIFICATION_VERSION_CODE"; 1823 1824 /** 1825 * Extra field name for the ID of a intent filter pending verification. Passed to 1826 * an intent filter verifier and is used to call back to 1827 * {@link PackageManager#verifyIntentFilter(int, int)} 1828 * 1829 * @hide 1830 */ 1831 public static final String EXTRA_INTENT_FILTER_VERIFICATION_ID 1832 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_ID"; 1833 1834 /** 1835 * Extra field name for the scheme used for an intent filter pending verification. Passed to 1836 * an intent filter verifier and is used to construct the URI to verify against. 1837 * 1838 * Usually this is "https" 1839 * 1840 * @hide 1841 */ 1842 public static final String EXTRA_INTENT_FILTER_VERIFICATION_URI_SCHEME 1843 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_URI_SCHEME"; 1844 1845 /** 1846 * Extra field name for the host names to be used for an intent filter pending verification. 1847 * Passed to an intent filter verifier and is used to construct the URI to verify the 1848 * intent filter. 1849 * 1850 * This is a space delimited list of hosts. 1851 * 1852 * @hide 1853 */ 1854 public static final String EXTRA_INTENT_FILTER_VERIFICATION_HOSTS 1855 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_HOSTS"; 1856 1857 /** 1858 * Extra field name for the package name to be used for an intent filter pending verification. 1859 * Passed to an intent filter verifier and is used to check the verification responses coming 1860 * from the hosts. Each host response will need to include the package name of APK containing 1861 * the intent filter. 1862 * 1863 * @hide 1864 */ 1865 public static final String EXTRA_INTENT_FILTER_VERIFICATION_PACKAGE_NAME 1866 = "android.content.pm.extra.INTENT_FILTER_VERIFICATION_PACKAGE_NAME"; 1867 1868 /** 1869 * The action used to request that the user approve a permission request 1870 * from the application. 1871 * 1872 * @hide 1873 */ 1874 @SystemApi 1875 public static final String ACTION_REQUEST_PERMISSIONS = 1876 "android.content.pm.action.REQUEST_PERMISSIONS"; 1877 1878 /** 1879 * The names of the requested permissions. 1880 * <p> 1881 * <strong>Type:</strong> String[] 1882 * </p> 1883 * 1884 * @hide 1885 */ 1886 @SystemApi 1887 public static final String EXTRA_REQUEST_PERMISSIONS_NAMES = 1888 "android.content.pm.extra.REQUEST_PERMISSIONS_NAMES"; 1889 1890 /** 1891 * The results from the permissions request. 1892 * <p> 1893 * <strong>Type:</strong> int[] of #PermissionResult 1894 * </p> 1895 * 1896 * @hide 1897 */ 1898 @SystemApi 1899 public static final String EXTRA_REQUEST_PERMISSIONS_RESULTS 1900 = "android.content.pm.extra.REQUEST_PERMISSIONS_RESULTS"; 1901 1902 /** 1903 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 1904 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the package which provides 1905 * the existing definition for the permission. 1906 * @hide 1907 */ 1908 public static final String EXTRA_FAILURE_EXISTING_PACKAGE 1909 = "android.content.pm.extra.FAILURE_EXISTING_PACKAGE"; 1910 1911 /** 1912 * String extra for {@link PackageInstallObserver} in the 'extras' Bundle in case of 1913 * {@link #INSTALL_FAILED_DUPLICATE_PERMISSION}. This extra names the permission that is 1914 * being redundantly defined by the package being installed. 1915 * @hide 1916 */ 1917 public static final String EXTRA_FAILURE_EXISTING_PERMISSION 1918 = "android.content.pm.extra.FAILURE_EXISTING_PERMISSION"; 1919 1920 /** 1921 * Permission flag: The permission is set in its current state 1922 * by the user and apps can still request it at runtime. 1923 * 1924 * @hide 1925 */ 1926 public static final int FLAG_PERMISSION_USER_SET = 1 << 0; 1927 1928 /** 1929 * Permission flag: The permission is set in its current state 1930 * by the user and it is fixed, i.e. apps can no longer request 1931 * this permission. 1932 * 1933 * @hide 1934 */ 1935 public static final int FLAG_PERMISSION_USER_FIXED = 1 << 1; 1936 1937 /** 1938 * Permission flag: The permission is set in its current state 1939 * by device policy and neither apps nor the user can change 1940 * its state. 1941 * 1942 * @hide 1943 */ 1944 public static final int FLAG_PERMISSION_POLICY_FIXED = 1 << 2; 1945 1946 /** 1947 * Permission flag: The permission is set in a granted state but 1948 * access to resources it guards is restricted by other means to 1949 * enable revoking a permission on legacy apps that do not support 1950 * runtime permissions. If this permission is upgraded to runtime 1951 * because the app was updated to support runtime permissions, the 1952 * the permission will be revoked in the upgrade process. 1953 * 1954 * @hide 1955 */ 1956 public static final int FLAG_PERMISSION_REVOKE_ON_UPGRADE = 1 << 3; 1957 1958 /** 1959 * Permission flag: The permission is set in its current state 1960 * because the app is a component that is a part of the system. 1961 * 1962 * @hide 1963 */ 1964 public static final int FLAG_PERMISSION_SYSTEM_FIXED = 1 << 4; 1965 1966 1967 /** 1968 * Permission flag: The permission is granted by default because it 1969 * enables app functionality that is expected to work out-of-the-box 1970 * for providing a smooth user experience. For example, the phone app 1971 * is expected to have the phone permission. 1972 * 1973 * @hide 1974 */ 1975 public static final int FLAG_PERMISSION_GRANTED_BY_DEFAULT = 1 << 5; 1976 1977 /** 1978 * Mask for all permission flags. 1979 * 1980 * @hide 1981 */ 1982 @SystemApi 1983 public static final int MASK_PERMISSION_FLAGS = 0xFF; 1984 1985 /** 1986 * Retrieve overall information about an application package that is 1987 * installed on the system. 1988 * <p> 1989 * Throws {@link NameNotFoundException} if a package with the given name can 1990 * not be found on the system. 1991 * 1992 * @param packageName The full name (i.e. com.google.apps.contacts) of the 1993 * desired package. 1994 * @param flags Additional option flags. Use any combination of 1995 * {@link #GET_ACTIVITIES}, {@link #GET_GIDS}, 1996 * {@link #GET_CONFIGURATIONS}, {@link #GET_INSTRUMENTATION}, 1997 * {@link #GET_PERMISSIONS}, {@link #GET_PROVIDERS}, 1998 * {@link #GET_RECEIVERS}, {@link #GET_SERVICES}, 1999 * {@link #GET_SIGNATURES}, {@link #GET_UNINSTALLED_PACKAGES} to 2000 * modify the data returned. 2001 * @return Returns a PackageInfo object containing information about the 2002 * package. If flag GET_UNINSTALLED_PACKAGES is set and if the 2003 * package is not found in the list of installed applications, the 2004 * package information is retrieved from the list of uninstalled 2005 * applications (which includes installed applications as well as 2006 * applications with data directory i.e. applications which had been 2007 * deleted with {@code DONT_DELETE_DATA} flag set). 2008 * @see #GET_ACTIVITIES 2009 * @see #GET_GIDS 2010 * @see #GET_CONFIGURATIONS 2011 * @see #GET_INSTRUMENTATION 2012 * @see #GET_PERMISSIONS 2013 * @see #GET_PROVIDERS 2014 * @see #GET_RECEIVERS 2015 * @see #GET_SERVICES 2016 * @see #GET_SIGNATURES 2017 * @see #GET_UNINSTALLED_PACKAGES 2018 */ 2019 public abstract PackageInfo getPackageInfo(String packageName, int flags) 2020 throws NameNotFoundException; 2021 2022 /** 2023 * Map from the current package names in use on the device to whatever 2024 * the current canonical name of that package is. 2025 * @param names Array of current names to be mapped. 2026 * @return Returns an array of the same size as the original, containing 2027 * the canonical name for each package. 2028 */ 2029 public abstract String[] currentToCanonicalPackageNames(String[] names); 2030 2031 /** 2032 * Map from a packages canonical name to the current name in use on the device. 2033 * @param names Array of new names to be mapped. 2034 * @return Returns an array of the same size as the original, containing 2035 * the current name for each package. 2036 */ 2037 public abstract String[] canonicalToCurrentPackageNames(String[] names); 2038 2039 /** 2040 * Returns a "good" intent to launch a front-door activity in a package. 2041 * This is used, for example, to implement an "open" button when browsing 2042 * through packages. The current implementation looks first for a main 2043 * activity in the category {@link Intent#CATEGORY_INFO}, and next for a 2044 * main activity in the category {@link Intent#CATEGORY_LAUNCHER}. Returns 2045 * <code>null</code> if neither are found. 2046 * 2047 * @param packageName The name of the package to inspect. 2048 * 2049 * @return A fully-qualified {@link Intent} that can be used to launch the 2050 * main activity in the package. Returns <code>null</code> if the package 2051 * does not contain such an activity, or if <em>packageName</em> is not 2052 * recognized. 2053 */ 2054 public abstract Intent getLaunchIntentForPackage(String packageName); 2055 2056 /** 2057 * Return a "good" intent to launch a front-door Leanback activity in a 2058 * package, for use for example to implement an "open" button when browsing 2059 * through packages. The current implementation will look for a main 2060 * activity in the category {@link Intent#CATEGORY_LEANBACK_LAUNCHER}, or 2061 * return null if no main leanback activities are found. 2062 * <p> 2063 * Throws {@link NameNotFoundException} if a package with the given name 2064 * cannot be found on the system. 2065 * 2066 * @param packageName The name of the package to inspect. 2067 * @return Returns either a fully-qualified Intent that can be used to launch 2068 * the main Leanback activity in the package, or null if the package 2069 * does not contain such an activity. 2070 */ 2071 public abstract Intent getLeanbackLaunchIntentForPackage(String packageName); 2072 2073 /** 2074 * Return an array of all of the secondary group-ids that have been assigned 2075 * to a package. 2076 * <p> 2077 * Throws {@link NameNotFoundException} if a package with the given name 2078 * cannot be found on the system. 2079 * 2080 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2081 * desired package. 2082 * @return Returns an int array of the assigned gids, or null if there are 2083 * none. 2084 */ 2085 public abstract int[] getPackageGids(String packageName) 2086 throws NameNotFoundException; 2087 2088 /** 2089 * @hide Return the uid associated with the given package name for the 2090 * given user. 2091 * 2092 * <p>Throws {@link NameNotFoundException} if a package with the given 2093 * name can not be found on the system. 2094 * 2095 * @param packageName The full name (i.e. com.google.apps.contacts) of the 2096 * desired package. 2097 * @param userHandle The user handle identifier to look up the package under. 2098 * 2099 * @return Returns an integer uid who owns the given package name. 2100 */ 2101 public abstract int getPackageUid(String packageName, int userHandle) 2102 throws NameNotFoundException; 2103 2104 /** 2105 * Retrieve all of the information we know about a particular permission. 2106 * 2107 * <p>Throws {@link NameNotFoundException} if a permission with the given 2108 * name cannot be found on the system. 2109 * 2110 * @param name The fully qualified name (i.e. com.google.permission.LOGIN) 2111 * of the permission you are interested in. 2112 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2113 * retrieve any meta-data associated with the permission. 2114 * 2115 * @return Returns a {@link PermissionInfo} containing information about the 2116 * permission. 2117 */ 2118 public abstract PermissionInfo getPermissionInfo(String name, int flags) 2119 throws NameNotFoundException; 2120 2121 /** 2122 * Query for all of the permissions associated with a particular group. 2123 * 2124 * <p>Throws {@link NameNotFoundException} if the given group does not 2125 * exist. 2126 * 2127 * @param group The fully qualified name (i.e. com.google.permission.LOGIN) 2128 * of the permission group you are interested in. Use null to 2129 * find all of the permissions not associated with a group. 2130 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2131 * retrieve any meta-data associated with the permissions. 2132 * 2133 * @return Returns a list of {@link PermissionInfo} containing information 2134 * about all of the permissions in the given group. 2135 */ 2136 public abstract List<PermissionInfo> queryPermissionsByGroup(String group, 2137 int flags) throws NameNotFoundException; 2138 2139 /** 2140 * Retrieve all of the information we know about a particular group of 2141 * permissions. 2142 * 2143 * <p>Throws {@link NameNotFoundException} if a permission group with the given 2144 * name cannot be found on the system. 2145 * 2146 * @param name The fully qualified name (i.e. com.google.permission_group.APPS) 2147 * of the permission you are interested in. 2148 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2149 * retrieve any meta-data associated with the permission group. 2150 * 2151 * @return Returns a {@link PermissionGroupInfo} containing information 2152 * about the permission. 2153 */ 2154 public abstract PermissionGroupInfo getPermissionGroupInfo(String name, 2155 int flags) throws NameNotFoundException; 2156 2157 /** 2158 * Retrieve all of the known permission groups in the system. 2159 * 2160 * @param flags Additional option flags. Use {@link #GET_META_DATA} to 2161 * retrieve any meta-data associated with the permission group. 2162 * 2163 * @return Returns a list of {@link PermissionGroupInfo} containing 2164 * information about all of the known permission groups. 2165 */ 2166 public abstract List<PermissionGroupInfo> getAllPermissionGroups(int flags); 2167 2168 /** 2169 * Retrieve all of the information we know about a particular 2170 * package/application. 2171 * 2172 * <p>Throws {@link NameNotFoundException} if an application with the given 2173 * package name cannot be found on the system. 2174 * 2175 * @param packageName The full name (i.e. com.google.apps.contacts) of an 2176 * application. 2177 * @param flags Additional option flags. Use any combination of 2178 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2179 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2180 * 2181 * @return {@link ApplicationInfo} Returns ApplicationInfo object containing 2182 * information about the package. 2183 * If flag GET_UNINSTALLED_PACKAGES is set and if the package is not 2184 * found in the list of installed applications, 2185 * the application information is retrieved from the 2186 * list of uninstalled applications(which includes 2187 * installed applications as well as applications 2188 * with data directory ie applications which had been 2189 * deleted with {@code DONT_DELETE_DATA} flag set). 2190 * 2191 * @see #GET_META_DATA 2192 * @see #GET_SHARED_LIBRARY_FILES 2193 * @see #GET_UNINSTALLED_PACKAGES 2194 */ 2195 public abstract ApplicationInfo getApplicationInfo(String packageName, 2196 int flags) throws NameNotFoundException; 2197 2198 /** 2199 * Retrieve all of the information we know about a particular activity 2200 * class. 2201 * 2202 * <p>Throws {@link NameNotFoundException} if an activity with the given 2203 * class name cannot be found on the system. 2204 * 2205 * @param component The full component name (i.e. 2206 * com.google.apps.contacts/com.google.apps.contacts.ContactsList) of an Activity 2207 * class. 2208 * @param flags Additional option flags. Use any combination of 2209 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2210 * to modify the data (in ApplicationInfo) returned. 2211 * 2212 * @return {@link ActivityInfo} containing information about the activity. 2213 * 2214 * @see #GET_INTENT_FILTERS 2215 * @see #GET_META_DATA 2216 * @see #GET_SHARED_LIBRARY_FILES 2217 */ 2218 public abstract ActivityInfo getActivityInfo(ComponentName component, 2219 int flags) throws NameNotFoundException; 2220 2221 /** 2222 * Retrieve all of the information we know about a particular receiver 2223 * class. 2224 * 2225 * <p>Throws {@link NameNotFoundException} if a receiver with the given 2226 * class name cannot be found on the system. 2227 * 2228 * @param component The full component name (i.e. 2229 * com.google.apps.calendar/com.google.apps.calendar.CalendarAlarm) of a Receiver 2230 * class. 2231 * @param flags Additional option flags. Use any combination of 2232 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2233 * to modify the data returned. 2234 * 2235 * @return {@link ActivityInfo} containing information about the receiver. 2236 * 2237 * @see #GET_INTENT_FILTERS 2238 * @see #GET_META_DATA 2239 * @see #GET_SHARED_LIBRARY_FILES 2240 */ 2241 public abstract ActivityInfo getReceiverInfo(ComponentName component, 2242 int flags) throws NameNotFoundException; 2243 2244 /** 2245 * Retrieve all of the information we know about a particular service 2246 * class. 2247 * 2248 * <p>Throws {@link NameNotFoundException} if a service with the given 2249 * class name cannot be found on the system. 2250 * 2251 * @param component The full component name (i.e. 2252 * com.google.apps.media/com.google.apps.media.BackgroundPlayback) of a Service 2253 * class. 2254 * @param flags Additional option flags. Use any combination of 2255 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2256 * to modify the data returned. 2257 * 2258 * @return ServiceInfo containing information about the service. 2259 * 2260 * @see #GET_META_DATA 2261 * @see #GET_SHARED_LIBRARY_FILES 2262 */ 2263 public abstract ServiceInfo getServiceInfo(ComponentName component, 2264 int flags) throws NameNotFoundException; 2265 2266 /** 2267 * Retrieve all of the information we know about a particular content 2268 * provider class. 2269 * 2270 * <p>Throws {@link NameNotFoundException} if a provider with the given 2271 * class name cannot be found on the system. 2272 * 2273 * @param component The full component name (i.e. 2274 * com.google.providers.media/com.google.providers.media.MediaProvider) of a 2275 * ContentProvider class. 2276 * @param flags Additional option flags. Use any combination of 2277 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2278 * to modify the data returned. 2279 * 2280 * @return ProviderInfo containing information about the service. 2281 * 2282 * @see #GET_META_DATA 2283 * @see #GET_SHARED_LIBRARY_FILES 2284 */ 2285 public abstract ProviderInfo getProviderInfo(ComponentName component, 2286 int flags) throws NameNotFoundException; 2287 2288 /** 2289 * Return a List of all packages that are installed 2290 * on the device. 2291 * 2292 * @param flags Additional option flags. Use any combination of 2293 * {@link #GET_ACTIVITIES}, 2294 * {@link #GET_GIDS}, 2295 * {@link #GET_CONFIGURATIONS}, 2296 * {@link #GET_INSTRUMENTATION}, 2297 * {@link #GET_PERMISSIONS}, 2298 * {@link #GET_PROVIDERS}, 2299 * {@link #GET_RECEIVERS}, 2300 * {@link #GET_SERVICES}, 2301 * {@link #GET_SIGNATURES}, 2302 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2303 * 2304 * @return A List of PackageInfo objects, one for each package that is 2305 * installed on the device. In the unlikely case of there being no 2306 * installed packages, an empty list is returned. 2307 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2308 * applications including those deleted with {@code DONT_DELETE_DATA} 2309 * (partially installed apps with data directory) will be returned. 2310 * 2311 * @see #GET_ACTIVITIES 2312 * @see #GET_GIDS 2313 * @see #GET_CONFIGURATIONS 2314 * @see #GET_INSTRUMENTATION 2315 * @see #GET_PERMISSIONS 2316 * @see #GET_PROVIDERS 2317 * @see #GET_RECEIVERS 2318 * @see #GET_SERVICES 2319 * @see #GET_SIGNATURES 2320 * @see #GET_UNINSTALLED_PACKAGES 2321 */ 2322 public abstract List<PackageInfo> getInstalledPackages(int flags); 2323 2324 /** 2325 * Return a List of all installed packages that are currently 2326 * holding any of the given permissions. 2327 * 2328 * @param flags Additional option flags. Use any combination of 2329 * {@link #GET_ACTIVITIES}, 2330 * {@link #GET_GIDS}, 2331 * {@link #GET_CONFIGURATIONS}, 2332 * {@link #GET_INSTRUMENTATION}, 2333 * {@link #GET_PERMISSIONS}, 2334 * {@link #GET_PROVIDERS}, 2335 * {@link #GET_RECEIVERS}, 2336 * {@link #GET_SERVICES}, 2337 * {@link #GET_SIGNATURES}, 2338 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2339 * 2340 * @return Returns a List of PackageInfo objects, one for each installed 2341 * application that is holding any of the permissions that were provided. 2342 * 2343 * @see #GET_ACTIVITIES 2344 * @see #GET_GIDS 2345 * @see #GET_CONFIGURATIONS 2346 * @see #GET_INSTRUMENTATION 2347 * @see #GET_PERMISSIONS 2348 * @see #GET_PROVIDERS 2349 * @see #GET_RECEIVERS 2350 * @see #GET_SERVICES 2351 * @see #GET_SIGNATURES 2352 * @see #GET_UNINSTALLED_PACKAGES 2353 */ 2354 public abstract List<PackageInfo> getPackagesHoldingPermissions( 2355 String[] permissions, int flags); 2356 2357 /** 2358 * Return a List of all packages that are installed on the device, for a specific user. 2359 * Requesting a list of installed packages for another user 2360 * will require the permission INTERACT_ACROSS_USERS_FULL. 2361 * @param flags Additional option flags. Use any combination of 2362 * {@link #GET_ACTIVITIES}, 2363 * {@link #GET_GIDS}, 2364 * {@link #GET_CONFIGURATIONS}, 2365 * {@link #GET_INSTRUMENTATION}, 2366 * {@link #GET_PERMISSIONS}, 2367 * {@link #GET_PROVIDERS}, 2368 * {@link #GET_RECEIVERS}, 2369 * {@link #GET_SERVICES}, 2370 * {@link #GET_SIGNATURES}, 2371 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2372 * @param userId The user for whom the installed packages are to be listed 2373 * 2374 * @return A List of PackageInfo objects, one for each package that is 2375 * installed on the device. In the unlikely case of there being no 2376 * installed packages, an empty list is returned. 2377 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2378 * applications including those deleted with {@code DONT_DELETE_DATA} 2379 * (partially installed apps with data directory) will be returned. 2380 * 2381 * @see #GET_ACTIVITIES 2382 * @see #GET_GIDS 2383 * @see #GET_CONFIGURATIONS 2384 * @see #GET_INSTRUMENTATION 2385 * @see #GET_PERMISSIONS 2386 * @see #GET_PROVIDERS 2387 * @see #GET_RECEIVERS 2388 * @see #GET_SERVICES 2389 * @see #GET_SIGNATURES 2390 * @see #GET_UNINSTALLED_PACKAGES 2391 * 2392 * @hide 2393 */ 2394 public abstract List<PackageInfo> getInstalledPackages(int flags, int userId); 2395 2396 /** 2397 * Check whether a particular package has been granted a particular 2398 * permission. 2399 * 2400 * @param permName The name of the permission you are checking for. 2401 * @param pkgName The name of the package you are checking against. 2402 * 2403 * @return If the package has the permission, PERMISSION_GRANTED is 2404 * returned. If it does not have the permission, PERMISSION_DENIED 2405 * is returned. 2406 * 2407 * @see #PERMISSION_GRANTED 2408 * @see #PERMISSION_DENIED 2409 */ 2410 @CheckResult 2411 public abstract int checkPermission(String permName, String pkgName); 2412 2413 /** 2414 * Checks whether a particular permissions has been revoked for a 2415 * package by policy. Typically the device owner or the profile owner 2416 * may apply such a policy. The user cannot grant policy revoked 2417 * permissions, hence the only way for an app to get such a permission 2418 * is by a policy change. 2419 * 2420 * @param permName The name of the permission you are checking for. 2421 * @param pkgName The name of the package you are checking against. 2422 * 2423 * @return Whether the permission is restricted by policy. 2424 */ 2425 @CheckResult 2426 public abstract boolean isPermissionRevokedByPolicy(@NonNull String permName, 2427 @NonNull String pkgName); 2428 2429 /** 2430 * Gets the package name of the component controlling runtime permissions. 2431 * 2432 * @return The package name. 2433 * 2434 * @hide 2435 */ 2436 public abstract String getPermissionControllerPackageName(); 2437 2438 /** 2439 * Add a new dynamic permission to the system. For this to work, your 2440 * package must have defined a permission tree through the 2441 * {@link android.R.styleable#AndroidManifestPermissionTree 2442 * <permission-tree>} tag in its manifest. A package can only add 2443 * permissions to trees that were defined by either its own package or 2444 * another with the same user id; a permission is in a tree if it 2445 * matches the name of the permission tree + ".": for example, 2446 * "com.foo.bar" is a member of the permission tree "com.foo". 2447 * 2448 * <p>It is good to make your permission tree name descriptive, because you 2449 * are taking possession of that entire set of permission names. Thus, it 2450 * must be under a domain you control, with a suffix that will not match 2451 * any normal permissions that may be declared in any applications that 2452 * are part of that domain. 2453 * 2454 * <p>New permissions must be added before 2455 * any .apks are installed that use those permissions. Permissions you 2456 * add through this method are remembered across reboots of the device. 2457 * If the given permission already exists, the info you supply here 2458 * will be used to update it. 2459 * 2460 * @param info Description of the permission to be added. 2461 * 2462 * @return Returns true if a new permission was created, false if an 2463 * existing one was updated. 2464 * 2465 * @throws SecurityException if you are not allowed to add the 2466 * given permission name. 2467 * 2468 * @see #removePermission(String) 2469 */ 2470 public abstract boolean addPermission(PermissionInfo info); 2471 2472 /** 2473 * Like {@link #addPermission(PermissionInfo)} but asynchronously 2474 * persists the package manager state after returning from the call, 2475 * allowing it to return quicker and batch a series of adds at the 2476 * expense of no guarantee the added permission will be retained if 2477 * the device is rebooted before it is written. 2478 */ 2479 public abstract boolean addPermissionAsync(PermissionInfo info); 2480 2481 /** 2482 * Removes a permission that was previously added with 2483 * {@link #addPermission(PermissionInfo)}. The same ownership rules apply 2484 * -- you are only allowed to remove permissions that you are allowed 2485 * to add. 2486 * 2487 * @param name The name of the permission to remove. 2488 * 2489 * @throws SecurityException if you are not allowed to remove the 2490 * given permission name. 2491 * 2492 * @see #addPermission(PermissionInfo) 2493 */ 2494 public abstract void removePermission(String name); 2495 2496 2497 /** 2498 * Permission flags set when granting or revoking a permission. 2499 * 2500 * @hide 2501 */ 2502 @SystemApi 2503 @IntDef({FLAG_PERMISSION_USER_SET, 2504 FLAG_PERMISSION_USER_FIXED, 2505 FLAG_PERMISSION_POLICY_FIXED, 2506 FLAG_PERMISSION_REVOKE_ON_UPGRADE, 2507 FLAG_PERMISSION_SYSTEM_FIXED, 2508 FLAG_PERMISSION_GRANTED_BY_DEFAULT}) 2509 @Retention(RetentionPolicy.SOURCE) 2510 public @interface PermissionFlags {} 2511 2512 /** 2513 * Grant a runtime permission to an application which the application does not 2514 * already have. The permission must have been requested by the application. 2515 * If the application is not allowed to hold the permission, a {@link 2516 * java.lang.SecurityException} is thrown. 2517 * <p> 2518 * <strong>Note: </strong>Using this API requires holding 2519 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is 2520 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 2521 * </p> 2522 * 2523 * @param packageName The package to which to grant the permission. 2524 * @param permissionName The permission name to grant. 2525 * @param user The user for which to grant the permission. 2526 * 2527 * @see #revokeRuntimePermission(String, String, android.os.UserHandle) 2528 * @see android.content.pm.PackageManager.PermissionFlags 2529 * 2530 * @hide 2531 */ 2532 @SystemApi 2533 public abstract void grantRuntimePermission(@NonNull String packageName, 2534 @NonNull String permissionName, @NonNull UserHandle user); 2535 2536 /** 2537 * Revoke a runtime permission that was previously granted by {@link 2538 * #grantRuntimePermission(String, String, android.os.UserHandle)}. The 2539 * permission must have been requested by and granted to the application. 2540 * If the application is not allowed to hold the permission, a {@link 2541 * java.lang.SecurityException} is thrown. 2542 * <p> 2543 * <strong>Note: </strong>Using this API requires holding 2544 * android.permission.GRANT_REVOKE_PERMISSIONS and if the user id is 2545 * not the current user android.permission.INTERACT_ACROSS_USERS_FULL. 2546 * </p> 2547 * 2548 * @param packageName The package from which to revoke the permission. 2549 * @param permissionName The permission name to revoke. 2550 * @param user The user for which to revoke the permission. 2551 * 2552 * @see #grantRuntimePermission(String, String, android.os.UserHandle) 2553 * @see android.content.pm.PackageManager.PermissionFlags 2554 * 2555 * @hide 2556 */ 2557 @SystemApi 2558 public abstract void revokeRuntimePermission(@NonNull String packageName, 2559 @NonNull String permissionName, @NonNull UserHandle user); 2560 2561 /** 2562 * Gets the state flags associated with a permission. 2563 * 2564 * @param permissionName The permission for which to get the flags. 2565 * @param packageName The package name for which to get the flags. 2566 * @param user The user for which to get permission flags. 2567 * @return The permission flags. 2568 * 2569 * @hide 2570 */ 2571 @SystemApi 2572 public abstract @PermissionFlags int getPermissionFlags(String permissionName, 2573 String packageName, @NonNull UserHandle user); 2574 2575 /** 2576 * Updates the flags associated with a permission by replacing the flags in 2577 * the specified mask with the provided flag values. 2578 * 2579 * @param permissionName The permission for which to update the flags. 2580 * @param packageName The package name for which to update the flags. 2581 * @param flagMask The flags which to replace. 2582 * @param flagValues The flags with which to replace. 2583 * @param user The user for which to update the permission flags. 2584 * 2585 * @hide 2586 */ 2587 @SystemApi 2588 public abstract void updatePermissionFlags(String permissionName, 2589 String packageName, @PermissionFlags int flagMask, int flagValues, 2590 @NonNull UserHandle user); 2591 2592 /** 2593 * Gets whether you should show UI with rationale for requesting a permission. 2594 * You should do this only if you do not have the permission and the context in 2595 * which the permission is requested does not clearly communicate to the user 2596 * what would be the benefit from grating this permission. 2597 * 2598 * @param permission A permission your app wants to request. 2599 * @return Whether you can show permission rationale UI. 2600 * 2601 * @hide 2602 */ 2603 public abstract boolean shouldShowRequestPermissionRationale(String permission); 2604 2605 /** 2606 * Returns an {@link android.content.Intent} suitable for passing to 2607 * {@link android.app.Activity#startActivityForResult(android.content.Intent, int)} 2608 * which prompts the user to grant permissions to this application. 2609 * 2610 * @throws NullPointerException if {@code permissions} is {@code null} or empty. 2611 * 2612 * @hide 2613 */ 2614 public Intent buildRequestPermissionsIntent(@NonNull String[] permissions) { 2615 if (ArrayUtils.isEmpty(permissions)) { 2616 throw new NullPointerException("permission cannot be null or empty"); 2617 } 2618 Intent intent = new Intent(ACTION_REQUEST_PERMISSIONS); 2619 intent.putExtra(EXTRA_REQUEST_PERMISSIONS_NAMES, permissions); 2620 intent.setPackage(getPermissionControllerPackageName()); 2621 return intent; 2622 } 2623 2624 /** 2625 * Compare the signatures of two packages to determine if the same 2626 * signature appears in both of them. If they do contain the same 2627 * signature, then they are allowed special privileges when working 2628 * with each other: they can share the same user-id, run instrumentation 2629 * against each other, etc. 2630 * 2631 * @param pkg1 First package name whose signature will be compared. 2632 * @param pkg2 Second package name whose signature will be compared. 2633 * 2634 * @return Returns an integer indicating whether all signatures on the 2635 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2636 * all signatures match or < 0 if there is not a match ({@link 2637 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2638 * 2639 * @see #checkSignatures(int, int) 2640 * @see #SIGNATURE_MATCH 2641 * @see #SIGNATURE_NO_MATCH 2642 * @see #SIGNATURE_UNKNOWN_PACKAGE 2643 */ 2644 @CheckResult 2645 public abstract int checkSignatures(String pkg1, String pkg2); 2646 2647 /** 2648 * Like {@link #checkSignatures(String, String)}, but takes UIDs of 2649 * the two packages to be checked. This can be useful, for example, 2650 * when doing the check in an IPC, where the UID is the only identity 2651 * available. It is functionally identical to determining the package 2652 * associated with the UIDs and checking their signatures. 2653 * 2654 * @param uid1 First UID whose signature will be compared. 2655 * @param uid2 Second UID whose signature will be compared. 2656 * 2657 * @return Returns an integer indicating whether all signatures on the 2658 * two packages match. The value is >= 0 ({@link #SIGNATURE_MATCH}) if 2659 * all signatures match or < 0 if there is not a match ({@link 2660 * #SIGNATURE_NO_MATCH} or {@link #SIGNATURE_UNKNOWN_PACKAGE}). 2661 * 2662 * @see #checkSignatures(String, String) 2663 * @see #SIGNATURE_MATCH 2664 * @see #SIGNATURE_NO_MATCH 2665 * @see #SIGNATURE_UNKNOWN_PACKAGE 2666 */ 2667 @CheckResult 2668 public abstract int checkSignatures(int uid1, int uid2); 2669 2670 /** 2671 * Retrieve the names of all packages that are associated with a particular 2672 * user id. In most cases, this will be a single package name, the package 2673 * that has been assigned that user id. Where there are multiple packages 2674 * sharing the same user id through the "sharedUserId" mechanism, all 2675 * packages with that id will be returned. 2676 * 2677 * @param uid The user id for which you would like to retrieve the 2678 * associated packages. 2679 * 2680 * @return Returns an array of one or more packages assigned to the user 2681 * id, or null if there are no known packages with the given id. 2682 */ 2683 public abstract String[] getPackagesForUid(int uid); 2684 2685 /** 2686 * Retrieve the official name associated with a user id. This name is 2687 * guaranteed to never change, though it is possible for the underlying 2688 * user id to be changed. That is, if you are storing information about 2689 * user ids in persistent storage, you should use the string returned 2690 * by this function instead of the raw user-id. 2691 * 2692 * @param uid The user id for which you would like to retrieve a name. 2693 * @return Returns a unique name for the given user id, or null if the 2694 * user id is not currently assigned. 2695 */ 2696 public abstract String getNameForUid(int uid); 2697 2698 /** 2699 * Return the user id associated with a shared user name. Multiple 2700 * applications can specify a shared user name in their manifest and thus 2701 * end up using a common uid. This might be used for new applications 2702 * that use an existing shared user name and need to know the uid of the 2703 * shared user. 2704 * 2705 * @param sharedUserName The shared user name whose uid is to be retrieved. 2706 * @return Returns the uid associated with the shared user, or NameNotFoundException 2707 * if the shared user name is not being used by any installed packages 2708 * @hide 2709 */ 2710 public abstract int getUidForSharedUser(String sharedUserName) 2711 throws NameNotFoundException; 2712 2713 /** 2714 * Return a List of all application packages that are installed on the 2715 * device. If flag GET_UNINSTALLED_PACKAGES has been set, a list of all 2716 * applications including those deleted with {@code DONT_DELETE_DATA} (partially 2717 * installed apps with data directory) will be returned. 2718 * 2719 * @param flags Additional option flags. Use any combination of 2720 * {@link #GET_META_DATA}, {@link #GET_SHARED_LIBRARY_FILES}, 2721 * {@link #GET_UNINSTALLED_PACKAGES} to modify the data returned. 2722 * 2723 * @return Returns a List of ApplicationInfo objects, one for each application that 2724 * is installed on the device. In the unlikely case of there being 2725 * no installed applications, an empty list is returned. 2726 * If flag GET_UNINSTALLED_PACKAGES is set, a list of all 2727 * applications including those deleted with {@code DONT_DELETE_DATA} 2728 * (partially installed apps with data directory) will be returned. 2729 * 2730 * @see #GET_META_DATA 2731 * @see #GET_SHARED_LIBRARY_FILES 2732 * @see #GET_UNINSTALLED_PACKAGES 2733 */ 2734 public abstract List<ApplicationInfo> getInstalledApplications(int flags); 2735 2736 /** 2737 * Get a list of shared libraries that are available on the 2738 * system. 2739 * 2740 * @return An array of shared library names that are 2741 * available on the system, or null if none are installed. 2742 * 2743 */ 2744 public abstract String[] getSystemSharedLibraryNames(); 2745 2746 /** 2747 * Get a list of features that are available on the 2748 * system. 2749 * 2750 * @return An array of FeatureInfo classes describing the features 2751 * that are available on the system, or null if there are none(!!). 2752 */ 2753 public abstract FeatureInfo[] getSystemAvailableFeatures(); 2754 2755 /** 2756 * Check whether the given feature name is one of the available 2757 * features as returned by {@link #getSystemAvailableFeatures()}. 2758 * 2759 * @return Returns true if the devices supports the feature, else 2760 * false. 2761 */ 2762 public abstract boolean hasSystemFeature(String name); 2763 2764 /** 2765 * Determine the best action to perform for a given Intent. This is how 2766 * {@link Intent#resolveActivity} finds an activity if a class has not 2767 * been explicitly specified. 2768 * 2769 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 2770 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 2771 * only flag. You need to do so to resolve the activity in the same way 2772 * that {@link android.content.Context#startActivity(Intent)} and 2773 * {@link android.content.Intent#resolveActivity(PackageManager) 2774 * Intent.resolveActivity(PackageManager)} do.</p> 2775 * 2776 * @param intent An intent containing all of the desired specification 2777 * (action, data, type, category, and/or component). 2778 * @param flags Additional option flags. The most important is 2779 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2780 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2781 * 2782 * @return Returns a ResolveInfo containing the final activity intent that 2783 * was determined to be the best action. Returns null if no 2784 * matching activity was found. If multiple matching activities are 2785 * found and there is no default set, returns a ResolveInfo 2786 * containing something else, such as the activity resolver. 2787 * 2788 * @see #MATCH_DEFAULT_ONLY 2789 * @see #GET_INTENT_FILTERS 2790 * @see #GET_RESOLVED_FILTER 2791 */ 2792 public abstract ResolveInfo resolveActivity(Intent intent, int flags); 2793 2794 /** 2795 * Determine the best action to perform for a given Intent for a given user. This 2796 * is how {@link Intent#resolveActivity} finds an activity if a class has not 2797 * been explicitly specified. 2798 * 2799 * <p><em>Note:</em> if using an implicit Intent (without an explicit ComponentName 2800 * specified), be sure to consider whether to set the {@link #MATCH_DEFAULT_ONLY} 2801 * only flag. You need to do so to resolve the activity in the same way 2802 * that {@link android.content.Context#startActivity(Intent)} and 2803 * {@link android.content.Intent#resolveActivity(PackageManager) 2804 * Intent.resolveActivity(PackageManager)} do.</p> 2805 * 2806 * @param intent An intent containing all of the desired specification 2807 * (action, data, type, category, and/or component). 2808 * @param flags Additional option flags. The most important is 2809 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2810 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2811 * @param userId The user id. 2812 * 2813 * @return Returns a ResolveInfo containing the final activity intent that 2814 * was determined to be the best action. Returns null if no 2815 * matching activity was found. If multiple matching activities are 2816 * found and there is no default set, returns a ResolveInfo 2817 * containing something else, such as the activity resolver. 2818 * 2819 * @see #MATCH_DEFAULT_ONLY 2820 * @see #GET_INTENT_FILTERS 2821 * @see #GET_RESOLVED_FILTER 2822 * 2823 * @hide 2824 */ 2825 public abstract ResolveInfo resolveActivityAsUser(Intent intent, int flags, int userId); 2826 2827 /** 2828 * Retrieve all activities that can be performed for the given intent. 2829 * 2830 * @param intent The desired intent as per resolveActivity(). 2831 * @param flags Additional option flags. The most important is 2832 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2833 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2834 * 2835 * You can also set {@link #MATCH_ALL} for preventing the filtering of the results. 2836 * 2837 * @return A List<ResolveInfo> containing one entry for each matching 2838 * Activity. These are ordered from best to worst match -- that 2839 * is, the first item in the list is what is returned by 2840 * {@link #resolveActivity}. If there are no matching activities, an empty 2841 * list is returned. 2842 * 2843 * @see #MATCH_DEFAULT_ONLY 2844 * @see #GET_INTENT_FILTERS 2845 * @see #GET_RESOLVED_FILTER 2846 */ 2847 public abstract List<ResolveInfo> queryIntentActivities(Intent intent, 2848 int flags); 2849 2850 /** 2851 * Retrieve all activities that can be performed for the given intent, for a specific user. 2852 * 2853 * @param intent The desired intent as per resolveActivity(). 2854 * @param flags Additional option flags. The most important is 2855 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2856 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2857 * 2858 * You can also set {@link #MATCH_ALL} for preventing the filtering of the results. 2859 * 2860 * @return A List<ResolveInfo> containing one entry for each matching 2861 * Activity. These are ordered from best to worst match -- that 2862 * is, the first item in the list is what is returned by 2863 * {@link #resolveActivity}. If there are no matching activities, an empty 2864 * list is returned. 2865 * 2866 * @see #MATCH_DEFAULT_ONLY 2867 * @see #GET_INTENT_FILTERS 2868 * @see #GET_RESOLVED_FILTER 2869 * @hide 2870 */ 2871 public abstract List<ResolveInfo> queryIntentActivitiesAsUser(Intent intent, 2872 int flags, int userId); 2873 2874 2875 /** 2876 * Retrieve a set of activities that should be presented to the user as 2877 * similar options. This is like {@link #queryIntentActivities}, except it 2878 * also allows you to supply a list of more explicit Intents that you would 2879 * like to resolve to particular options, and takes care of returning the 2880 * final ResolveInfo list in a reasonable order, with no duplicates, based 2881 * on those inputs. 2882 * 2883 * @param caller The class name of the activity that is making the 2884 * request. This activity will never appear in the output 2885 * list. Can be null. 2886 * @param specifics An array of Intents that should be resolved to the 2887 * first specific results. Can be null. 2888 * @param intent The desired intent as per resolveActivity(). 2889 * @param flags Additional option flags. The most important is 2890 * {@link #MATCH_DEFAULT_ONLY}, to limit the resolution to only 2891 * those activities that support the {@link android.content.Intent#CATEGORY_DEFAULT}. 2892 * 2893 * @return A List<ResolveInfo> containing one entry for each matching 2894 * Activity. These are ordered first by all of the intents resolved 2895 * in <var>specifics</var> and then any additional activities that 2896 * can handle <var>intent</var> but did not get included by one of 2897 * the <var>specifics</var> intents. If there are no matching 2898 * activities, an empty list is returned. 2899 * 2900 * @see #MATCH_DEFAULT_ONLY 2901 * @see #GET_INTENT_FILTERS 2902 * @see #GET_RESOLVED_FILTER 2903 */ 2904 public abstract List<ResolveInfo> queryIntentActivityOptions( 2905 ComponentName caller, Intent[] specifics, Intent intent, int flags); 2906 2907 /** 2908 * Retrieve all receivers that can handle a broadcast of the given intent. 2909 * 2910 * @param intent The desired intent as per resolveActivity(). 2911 * @param flags Additional option flags. 2912 * 2913 * @return A List<ResolveInfo> containing one entry for each matching 2914 * Receiver. These are ordered from first to last in priority. If 2915 * there are no matching receivers, an empty list is returned. 2916 * 2917 * @see #MATCH_DEFAULT_ONLY 2918 * @see #GET_INTENT_FILTERS 2919 * @see #GET_RESOLVED_FILTER 2920 */ 2921 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 2922 int flags); 2923 2924 /** 2925 * Retrieve all receivers that can handle a broadcast of the given intent, for a specific 2926 * user. 2927 * 2928 * @param intent The desired intent as per resolveActivity(). 2929 * @param flags Additional option flags. 2930 * @param userId The userId of the user being queried. 2931 * 2932 * @return A List<ResolveInfo> containing one entry for each matching 2933 * Receiver. These are ordered from first to last in priority. If 2934 * there are no matching receivers, an empty list or {@code null} is returned. 2935 * 2936 * @see #MATCH_DEFAULT_ONLY 2937 * @see #GET_INTENT_FILTERS 2938 * @see #GET_RESOLVED_FILTER 2939 * @hide 2940 */ 2941 public abstract List<ResolveInfo> queryBroadcastReceivers(Intent intent, 2942 int flags, int userId); 2943 2944 /** 2945 * Determine the best service to handle for a given Intent. 2946 * 2947 * @param intent An intent containing all of the desired specification 2948 * (action, data, type, category, and/or component). 2949 * @param flags Additional option flags. 2950 * 2951 * @return Returns a ResolveInfo containing the final service intent that 2952 * was determined to be the best action. Returns null if no 2953 * matching service was found. 2954 * 2955 * @see #GET_INTENT_FILTERS 2956 * @see #GET_RESOLVED_FILTER 2957 */ 2958 public abstract ResolveInfo resolveService(Intent intent, int flags); 2959 2960 /** 2961 * Retrieve all services that can match the given intent. 2962 * 2963 * @param intent The desired intent as per resolveService(). 2964 * @param flags Additional option flags. 2965 * 2966 * @return A List<ResolveInfo> containing one entry for each matching 2967 * ServiceInfo. These are ordered from best to worst match -- that 2968 * is, the first item in the list is what is returned by 2969 * resolveService(). If there are no matching services, an empty 2970 * list or {@code null} is returned. 2971 * 2972 * @see #GET_INTENT_FILTERS 2973 * @see #GET_RESOLVED_FILTER 2974 */ 2975 public abstract List<ResolveInfo> queryIntentServices(Intent intent, 2976 int flags); 2977 2978 /** 2979 * Retrieve all services that can match the given intent for a given user. 2980 * 2981 * @param intent The desired intent as per resolveService(). 2982 * @param flags Additional option flags. 2983 * @param userId The user id. 2984 * 2985 * @return A List<ResolveInfo> containing one entry for each matching 2986 * ServiceInfo. These are ordered from best to worst match -- that 2987 * is, the first item in the list is what is returned by 2988 * resolveService(). If there are no matching services, an empty 2989 * list or {@code null} is returned. 2990 * 2991 * @see #GET_INTENT_FILTERS 2992 * @see #GET_RESOLVED_FILTER 2993 * 2994 * @hide 2995 */ 2996 public abstract List<ResolveInfo> queryIntentServicesAsUser(Intent intent, 2997 int flags, int userId); 2998 2999 /** {@hide} */ 3000 public abstract List<ResolveInfo> queryIntentContentProvidersAsUser( 3001 Intent intent, int flags, int userId); 3002 3003 /** 3004 * Retrieve all providers that can match the given intent. 3005 * 3006 * @param intent An intent containing all of the desired specification 3007 * (action, data, type, category, and/or component). 3008 * @param flags Additional option flags. 3009 * @return A List<ResolveInfo> containing one entry for each matching 3010 * ProviderInfo. These are ordered from best to worst match. If 3011 * there are no matching providers, an empty list or {@code null} is returned. 3012 * @see #GET_INTENT_FILTERS 3013 * @see #GET_RESOLVED_FILTER 3014 */ 3015 public abstract List<ResolveInfo> queryIntentContentProviders(Intent intent, int flags); 3016 3017 /** 3018 * Find a single content provider by its base path name. 3019 * 3020 * @param name The name of the provider to find. 3021 * @param flags Additional option flags. Currently should always be 0. 3022 * 3023 * @return ContentProviderInfo Information about the provider, if found, 3024 * else null. 3025 */ 3026 public abstract ProviderInfo resolveContentProvider(String name, 3027 int flags); 3028 3029 /** 3030 * Find a single content provider by its base path name. 3031 * 3032 * @param name The name of the provider to find. 3033 * @param flags Additional option flags. Currently should always be 0. 3034 * @param userId The user id. 3035 * 3036 * @return ContentProviderInfo Information about the provider, if found, 3037 * else null. 3038 * @hide 3039 */ 3040 public abstract ProviderInfo resolveContentProviderAsUser(String name, int flags, int userId); 3041 3042 /** 3043 * Retrieve content provider information. 3044 * 3045 * <p><em>Note: unlike most other methods, an empty result set is indicated 3046 * by a null return instead of an empty list.</em> 3047 * 3048 * @param processName If non-null, limits the returned providers to only 3049 * those that are hosted by the given process. If null, 3050 * all content providers are returned. 3051 * @param uid If <var>processName</var> is non-null, this is the required 3052 * uid owning the requested content providers. 3053 * @param flags Additional option flags. Currently should always be 0. 3054 * 3055 * @return A List<ContentProviderInfo> containing one entry for each 3056 * content provider either patching <var>processName</var> or, if 3057 * <var>processName</var> is null, all known content providers. 3058 * <em>If there are no matching providers, null is returned.</em> 3059 */ 3060 public abstract List<ProviderInfo> queryContentProviders( 3061 String processName, int uid, int flags); 3062 3063 /** 3064 * Retrieve all of the information we know about a particular 3065 * instrumentation class. 3066 * 3067 * <p>Throws {@link NameNotFoundException} if instrumentation with the 3068 * given class name cannot be found on the system. 3069 * 3070 * @param className The full name (i.e. 3071 * com.google.apps.contacts.InstrumentList) of an 3072 * Instrumentation class. 3073 * @param flags Additional option flags. Currently should always be 0. 3074 * 3075 * @return InstrumentationInfo containing information about the 3076 * instrumentation. 3077 */ 3078 public abstract InstrumentationInfo getInstrumentationInfo( 3079 ComponentName className, int flags) throws NameNotFoundException; 3080 3081 /** 3082 * Retrieve information about available instrumentation code. May be used 3083 * to retrieve either all instrumentation code, or only the code targeting 3084 * a particular package. 3085 * 3086 * @param targetPackage If null, all instrumentation is returned; only the 3087 * instrumentation targeting this package name is 3088 * returned. 3089 * @param flags Additional option flags. Currently should always be 0. 3090 * 3091 * @return A List<InstrumentationInfo> containing one entry for each 3092 * matching available Instrumentation. Returns an empty list if 3093 * there is no instrumentation available for the given package. 3094 */ 3095 public abstract List<InstrumentationInfo> queryInstrumentation( 3096 String targetPackage, int flags); 3097 3098 /** 3099 * Retrieve an image from a package. This is a low-level API used by 3100 * the various package manager info structures (such as 3101 * {@link ComponentInfo} to implement retrieval of their associated 3102 * icon. 3103 * 3104 * @param packageName The name of the package that this icon is coming from. 3105 * Cannot be null. 3106 * @param resid The resource identifier of the desired image. Cannot be 0. 3107 * @param appInfo Overall information about <var>packageName</var>. This 3108 * may be null, in which case the application information will be retrieved 3109 * for you if needed; if you already have this information around, it can 3110 * be much more efficient to supply it here. 3111 * 3112 * @return Returns a Drawable holding the requested image. Returns null if 3113 * an image could not be found for any reason. 3114 */ 3115 public abstract Drawable getDrawable(String packageName, @DrawableRes int resid, 3116 ApplicationInfo appInfo); 3117 3118 /** 3119 * Retrieve the icon associated with an activity. Given the full name of 3120 * an activity, retrieves the information about it and calls 3121 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its icon. 3122 * If the activity cannot be found, NameNotFoundException is thrown. 3123 * 3124 * @param activityName Name of the activity whose icon is to be retrieved. 3125 * 3126 * @return Returns the image of the icon, or the default activity icon if 3127 * it could not be found. Does not return null. 3128 * @throws NameNotFoundException Thrown if the resources for the given 3129 * activity could not be loaded. 3130 * 3131 * @see #getActivityIcon(Intent) 3132 */ 3133 public abstract Drawable getActivityIcon(ComponentName activityName) 3134 throws NameNotFoundException; 3135 3136 /** 3137 * Retrieve the icon associated with an Intent. If intent.getClassName() is 3138 * set, this simply returns the result of 3139 * getActivityIcon(intent.getClassName()). Otherwise it resolves the intent's 3140 * component and returns the icon associated with the resolved component. 3141 * If intent.getClassName() cannot be found or the Intent cannot be resolved 3142 * to a component, NameNotFoundException is thrown. 3143 * 3144 * @param intent The intent for which you would like to retrieve an icon. 3145 * 3146 * @return Returns the image of the icon, or the default activity icon if 3147 * it could not be found. Does not return null. 3148 * @throws NameNotFoundException Thrown if the resources for application 3149 * matching the given intent could not be loaded. 3150 * 3151 * @see #getActivityIcon(ComponentName) 3152 */ 3153 public abstract Drawable getActivityIcon(Intent intent) 3154 throws NameNotFoundException; 3155 3156 /** 3157 * Retrieve the banner associated with an activity. Given the full name of 3158 * an activity, retrieves the information about it and calls 3159 * {@link ComponentInfo#loadIcon ComponentInfo.loadIcon()} to return its 3160 * banner. If the activity cannot be found, NameNotFoundException is thrown. 3161 * 3162 * @param activityName Name of the activity whose banner is to be retrieved. 3163 * @return Returns the image of the banner, or null if the activity has no 3164 * banner specified. 3165 * @throws NameNotFoundException Thrown if the resources for the given 3166 * activity could not be loaded. 3167 * @see #getActivityBanner(Intent) 3168 */ 3169 public abstract Drawable getActivityBanner(ComponentName activityName) 3170 throws NameNotFoundException; 3171 3172 /** 3173 * Retrieve the banner associated with an Intent. If intent.getClassName() 3174 * is set, this simply returns the result of 3175 * getActivityBanner(intent.getClassName()). Otherwise it resolves the 3176 * intent's component and returns the banner associated with the resolved 3177 * component. If intent.getClassName() cannot be found or the Intent cannot 3178 * be resolved to a component, NameNotFoundException is thrown. 3179 * 3180 * @param intent The intent for which you would like to retrieve a banner. 3181 * @return Returns the image of the banner, or null if the activity has no 3182 * banner specified. 3183 * @throws NameNotFoundException Thrown if the resources for application 3184 * matching the given intent could not be loaded. 3185 * @see #getActivityBanner(ComponentName) 3186 */ 3187 public abstract Drawable getActivityBanner(Intent intent) 3188 throws NameNotFoundException; 3189 3190 /** 3191 * Return the generic icon for an activity that is used when no specific 3192 * icon is defined. 3193 * 3194 * @return Drawable Image of the icon. 3195 */ 3196 public abstract Drawable getDefaultActivityIcon(); 3197 3198 /** 3199 * Retrieve the icon associated with an application. If it has not defined 3200 * an icon, the default app icon is returned. Does not return null. 3201 * 3202 * @param info Information about application being queried. 3203 * 3204 * @return Returns the image of the icon, or the default application icon 3205 * if it could not be found. 3206 * 3207 * @see #getApplicationIcon(String) 3208 */ 3209 public abstract Drawable getApplicationIcon(ApplicationInfo info); 3210 3211 /** 3212 * Retrieve the icon associated with an application. Given the name of the 3213 * application's package, retrieves the information about it and calls 3214 * getApplicationIcon() to return its icon. If the application cannot be 3215 * found, NameNotFoundException is thrown. 3216 * 3217 * @param packageName Name of the package whose application icon is to be 3218 * retrieved. 3219 * 3220 * @return Returns the image of the icon, or the default application icon 3221 * if it could not be found. Does not return null. 3222 * @throws NameNotFoundException Thrown if the resources for the given 3223 * application could not be loaded. 3224 * 3225 * @see #getApplicationIcon(ApplicationInfo) 3226 */ 3227 public abstract Drawable getApplicationIcon(String packageName) 3228 throws NameNotFoundException; 3229 3230 /** 3231 * Retrieve the banner associated with an application. 3232 * 3233 * @param info Information about application being queried. 3234 * @return Returns the image of the banner or null if the application has no 3235 * banner specified. 3236 * @see #getApplicationBanner(String) 3237 */ 3238 public abstract Drawable getApplicationBanner(ApplicationInfo info); 3239 3240 /** 3241 * Retrieve the banner associated with an application. Given the name of the 3242 * application's package, retrieves the information about it and calls 3243 * getApplicationIcon() to return its banner. If the application cannot be 3244 * found, NameNotFoundException is thrown. 3245 * 3246 * @param packageName Name of the package whose application banner is to be 3247 * retrieved. 3248 * @return Returns the image of the banner or null if the application has no 3249 * banner specified. 3250 * @throws NameNotFoundException Thrown if the resources for the given 3251 * application could not be loaded. 3252 * @see #getApplicationBanner(ApplicationInfo) 3253 */ 3254 public abstract Drawable getApplicationBanner(String packageName) 3255 throws NameNotFoundException; 3256 3257 /** 3258 * Retrieve the logo associated with an activity. Given the full name of an 3259 * activity, retrieves the information about it and calls 3260 * {@link ComponentInfo#loadLogo ComponentInfo.loadLogo()} to return its 3261 * logo. If the activity cannot be found, NameNotFoundException is thrown. 3262 * 3263 * @param activityName Name of the activity whose logo is to be retrieved. 3264 * @return Returns the image of the logo or null if the activity has no logo 3265 * specified. 3266 * @throws NameNotFoundException Thrown if the resources for the given 3267 * activity could not be loaded. 3268 * @see #getActivityLogo(Intent) 3269 */ 3270 public abstract Drawable getActivityLogo(ComponentName activityName) 3271 throws NameNotFoundException; 3272 3273 /** 3274 * Retrieve the logo associated with an Intent. If intent.getClassName() is 3275 * set, this simply returns the result of 3276 * getActivityLogo(intent.getClassName()). Otherwise it resolves the intent's 3277 * component and returns the logo associated with the resolved component. 3278 * If intent.getClassName() cannot be found or the Intent cannot be resolved 3279 * to a component, NameNotFoundException is thrown. 3280 * 3281 * @param intent The intent for which you would like to retrieve a logo. 3282 * 3283 * @return Returns the image of the logo, or null if the activity has no 3284 * logo specified. 3285 * 3286 * @throws NameNotFoundException Thrown if the resources for application 3287 * matching the given intent could not be loaded. 3288 * 3289 * @see #getActivityLogo(ComponentName) 3290 */ 3291 public abstract Drawable getActivityLogo(Intent intent) 3292 throws NameNotFoundException; 3293 3294 /** 3295 * Retrieve the logo associated with an application. If it has not specified 3296 * a logo, this method returns null. 3297 * 3298 * @param info Information about application being queried. 3299 * 3300 * @return Returns the image of the logo, or null if no logo is specified 3301 * by the application. 3302 * 3303 * @see #getApplicationLogo(String) 3304 */ 3305 public abstract Drawable getApplicationLogo(ApplicationInfo info); 3306 3307 /** 3308 * Retrieve the logo associated with an application. Given the name of the 3309 * application's package, retrieves the information about it and calls 3310 * getApplicationLogo() to return its logo. If the application cannot be 3311 * found, NameNotFoundException is thrown. 3312 * 3313 * @param packageName Name of the package whose application logo is to be 3314 * retrieved. 3315 * 3316 * @return Returns the image of the logo, or null if no application logo 3317 * has been specified. 3318 * 3319 * @throws NameNotFoundException Thrown if the resources for the given 3320 * application could not be loaded. 3321 * 3322 * @see #getApplicationLogo(ApplicationInfo) 3323 */ 3324 public abstract Drawable getApplicationLogo(String packageName) 3325 throws NameNotFoundException; 3326 3327 /** 3328 * If the target user is a managed profile of the calling user or if the 3329 * target user is the caller and is itself a managed profile, then this 3330 * returns a badged copy of the given icon to be able to distinguish it from 3331 * the original icon. For badging an arbitrary drawable use 3332 * {@link #getUserBadgedDrawableForDensity( 3333 * android.graphics.drawable.Drawable, UserHandle, android.graphics.Rect, int)}. 3334 * <p> 3335 * If the original drawable is a BitmapDrawable and the backing bitmap is 3336 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the badging 3337 * is performed in place and the original drawable is returned. 3338 * </p> 3339 * 3340 * @param icon The icon to badge. 3341 * @param user The target user. 3342 * @return A drawable that combines the original icon and a badge as 3343 * determined by the system. 3344 */ 3345 public abstract Drawable getUserBadgedIcon(Drawable icon, UserHandle user); 3346 3347 /** 3348 * If the target user is a managed profile of the calling user or the caller 3349 * is itself a managed profile, then this returns a badged copy of the given 3350 * drawable allowing the user to distinguish it from the original drawable. 3351 * The caller can specify the location in the bounds of the drawable to be 3352 * badged where the badge should be applied as well as the density of the 3353 * badge to be used. 3354 * <p> 3355 * If the original drawable is a BitmapDrawable and the backing bitmap is 3356 * mutable as per {@link android.graphics.Bitmap#isMutable()}, the bading 3357 * is performed in place and the original drawable is returned. 3358 * </p> 3359 * 3360 * @param drawable The drawable to badge. 3361 * @param user The target user. 3362 * @param badgeLocation Where in the bounds of the badged drawable to place 3363 * the badge. If not provided, the badge is applied on top of the entire 3364 * drawable being badged. 3365 * @param badgeDensity The optional desired density for the badge as per 3366 * {@link android.util.DisplayMetrics#densityDpi}. If not provided, 3367 * the density of the display is used. 3368 * @return A drawable that combines the original drawable and a badge as 3369 * determined by the system. 3370 */ 3371 public abstract Drawable getUserBadgedDrawableForDensity(Drawable drawable, 3372 UserHandle user, Rect badgeLocation, int badgeDensity); 3373 3374 /** 3375 * If the target user is a managed profile of the calling user or the caller 3376 * is itself a managed profile, then this returns a drawable to use as a small 3377 * icon to include in a view to distinguish it from the original icon. 3378 * 3379 * @param user The target user. 3380 * @param density The optional desired density for the badge as per 3381 * {@link android.util.DisplayMetrics#densityDpi}. If not provided 3382 * the density of the current display is used. 3383 * @return the drawable or null if no drawable is required. 3384 * @hide 3385 */ 3386 public abstract Drawable getUserBadgeForDensity(UserHandle user, int density); 3387 3388 /** 3389 * If the target user is a managed profile of the calling user or the caller 3390 * is itself a managed profile, then this returns a copy of the label with 3391 * badging for accessibility services like talkback. E.g. passing in "Email" 3392 * and it might return "Work Email" for Email in the work profile. 3393 * 3394 * @param label The label to change. 3395 * @param user The target user. 3396 * @return A label that combines the original label and a badge as 3397 * determined by the system. 3398 */ 3399 public abstract CharSequence getUserBadgedLabel(CharSequence label, UserHandle user); 3400 3401 /** 3402 * Retrieve text from a package. This is a low-level API used by 3403 * the various package manager info structures (such as 3404 * {@link ComponentInfo} to implement retrieval of their associated 3405 * labels and other text. 3406 * 3407 * @param packageName The name of the package that this text is coming from. 3408 * Cannot be null. 3409 * @param resid The resource identifier of the desired text. Cannot be 0. 3410 * @param appInfo Overall information about <var>packageName</var>. This 3411 * may be null, in which case the application information will be retrieved 3412 * for you if needed; if you already have this information around, it can 3413 * be much more efficient to supply it here. 3414 * 3415 * @return Returns a CharSequence holding the requested text. Returns null 3416 * if the text could not be found for any reason. 3417 */ 3418 public abstract CharSequence getText(String packageName, @StringRes int resid, 3419 ApplicationInfo appInfo); 3420 3421 /** 3422 * Retrieve an XML file from a package. This is a low-level API used to 3423 * retrieve XML meta data. 3424 * 3425 * @param packageName The name of the package that this xml is coming from. 3426 * Cannot be null. 3427 * @param resid The resource identifier of the desired xml. Cannot be 0. 3428 * @param appInfo Overall information about <var>packageName</var>. This 3429 * may be null, in which case the application information will be retrieved 3430 * for you if needed; if you already have this information around, it can 3431 * be much more efficient to supply it here. 3432 * 3433 * @return Returns an XmlPullParser allowing you to parse out the XML 3434 * data. Returns null if the xml resource could not be found for any 3435 * reason. 3436 */ 3437 public abstract XmlResourceParser getXml(String packageName, @XmlRes int resid, 3438 ApplicationInfo appInfo); 3439 3440 /** 3441 * Return the label to use for this application. 3442 * 3443 * @return Returns the label associated with this application, or null if 3444 * it could not be found for any reason. 3445 * @param info The application to get the label of. 3446 */ 3447 public abstract CharSequence getApplicationLabel(ApplicationInfo info); 3448 3449 /** 3450 * Retrieve the resources associated with an activity. Given the full 3451 * name of an activity, retrieves the information about it and calls 3452 * getResources() to return its application's resources. If the activity 3453 * cannot be found, NameNotFoundException is thrown. 3454 * 3455 * @param activityName Name of the activity whose resources are to be 3456 * retrieved. 3457 * 3458 * @return Returns the application's Resources. 3459 * @throws NameNotFoundException Thrown if the resources for the given 3460 * application could not be loaded. 3461 * 3462 * @see #getResourcesForApplication(ApplicationInfo) 3463 */ 3464 public abstract Resources getResourcesForActivity(ComponentName activityName) 3465 throws NameNotFoundException; 3466 3467 /** 3468 * Retrieve the resources for an application. Throws NameNotFoundException 3469 * if the package is no longer installed. 3470 * 3471 * @param app Information about the desired application. 3472 * 3473 * @return Returns the application's Resources. 3474 * @throws NameNotFoundException Thrown if the resources for the given 3475 * application could not be loaded (most likely because it was uninstalled). 3476 */ 3477 public abstract Resources getResourcesForApplication(ApplicationInfo app) 3478 throws NameNotFoundException; 3479 3480 /** 3481 * Retrieve the resources associated with an application. Given the full 3482 * package name of an application, retrieves the information about it and 3483 * calls getResources() to return its application's resources. If the 3484 * appPackageName cannot be found, NameNotFoundException is thrown. 3485 * 3486 * @param appPackageName Package name of the application whose resources 3487 * are to be retrieved. 3488 * 3489 * @return Returns the application's Resources. 3490 * @throws NameNotFoundException Thrown if the resources for the given 3491 * application could not be loaded. 3492 * 3493 * @see #getResourcesForApplication(ApplicationInfo) 3494 */ 3495 public abstract Resources getResourcesForApplication(String appPackageName) 3496 throws NameNotFoundException; 3497 3498 /** @hide */ 3499 public abstract Resources getResourcesForApplicationAsUser(String appPackageName, int userId) 3500 throws NameNotFoundException; 3501 3502 /** 3503 * Retrieve overall information about an application package defined 3504 * in a package archive file 3505 * 3506 * @param archiveFilePath The path to the archive file 3507 * @param flags Additional option flags. Use any combination of 3508 * {@link #GET_ACTIVITIES}, 3509 * {@link #GET_GIDS}, 3510 * {@link #GET_CONFIGURATIONS}, 3511 * {@link #GET_INSTRUMENTATION}, 3512 * {@link #GET_PERMISSIONS}, 3513 * {@link #GET_PROVIDERS}, 3514 * {@link #GET_RECEIVERS}, 3515 * {@link #GET_SERVICES}, 3516 * {@link #GET_SIGNATURES}, to modify the data returned. 3517 * 3518 * @return Returns the information about the package. Returns 3519 * null if the package could not be successfully parsed. 3520 * 3521 * @see #GET_ACTIVITIES 3522 * @see #GET_GIDS 3523 * @see #GET_CONFIGURATIONS 3524 * @see #GET_INSTRUMENTATION 3525 * @see #GET_PERMISSIONS 3526 * @see #GET_PROVIDERS 3527 * @see #GET_RECEIVERS 3528 * @see #GET_SERVICES 3529 * @see #GET_SIGNATURES 3530 * 3531 */ 3532 public PackageInfo getPackageArchiveInfo(String archiveFilePath, int flags) { 3533 final PackageParser parser = new PackageParser(); 3534 final File apkFile = new File(archiveFilePath); 3535 try { 3536 PackageParser.Package pkg = parser.parseMonolithicPackage(apkFile, 0); 3537 if ((flags & GET_SIGNATURES) != 0) { 3538 parser.collectCertificates(pkg, 0); 3539 parser.collectManifestDigest(pkg); 3540 } 3541 PackageUserState state = new PackageUserState(); 3542 return PackageParser.generatePackageInfo(pkg, null, flags, 0, 0, null, state); 3543 } catch (PackageParserException e) { 3544 return null; 3545 } 3546 } 3547 3548 /** 3549 * @hide Install a package. Since this may take a little while, the result 3550 * will be posted back to the given observer. An installation will 3551 * fail if the calling context lacks the 3552 * {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if 3553 * the package named in the package file's manifest is already 3554 * installed, or if there's no space available on the device. 3555 * @param packageURI The location of the package file to install. This can 3556 * be a 'file:' or a 'content:' URI. 3557 * @param observer An observer callback to get notified when the package 3558 * installation is complete. 3559 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3560 * will be called when that happens. This parameter must not be 3561 * null. 3562 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3563 * {@link #INSTALL_REPLACE_EXISTING}, 3564 * {@link #INSTALL_ALLOW_TEST}. 3565 * @param installerPackageName Optional package name of the application that 3566 * is performing the installation. This identifies which market 3567 * the package came from. 3568 * @deprecated Use {@link #installPackage(Uri, PackageInstallObserver, int, 3569 * String)} instead. This method will continue to be supported 3570 * but the older observer interface will not get additional 3571 * failure details. 3572 */ 3573 // @SystemApi 3574 public abstract void installPackage( 3575 Uri packageURI, IPackageInstallObserver observer, int flags, 3576 String installerPackageName); 3577 3578 /** 3579 * Similar to 3580 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3581 * with an extra verification file provided. 3582 * 3583 * @param packageURI The location of the package file to install. This can 3584 * be a 'file:' or a 'content:' URI. 3585 * @param observer An observer callback to get notified when the package 3586 * installation is complete. 3587 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3588 * will be called when that happens. This parameter must not be 3589 * null. 3590 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3591 * {@link #INSTALL_REPLACE_EXISTING}, 3592 * {@link #INSTALL_ALLOW_TEST}. 3593 * @param installerPackageName Optional package name of the application that 3594 * is performing the installation. This identifies which market 3595 * the package came from. 3596 * @param verificationURI The location of the supplementary verification 3597 * file. This can be a 'file:' or a 'content:' URI. May be 3598 * {@code null}. 3599 * @param manifestDigest an object that holds the digest of the package 3600 * which can be used to verify ownership. May be {@code null}. 3601 * @param encryptionParams if the package to be installed is encrypted, 3602 * these parameters describing the encryption and authentication 3603 * used. May be {@code null}. 3604 * @hide 3605 * @deprecated Use {@link #installPackageWithVerification(Uri, 3606 * PackageInstallObserver, int, String, Uri, ManifestDigest, 3607 * ContainerEncryptionParams)} instead. This method will 3608 * continue to be supported but the older observer interface 3609 * will not get additional failure details. 3610 */ 3611 // @SystemApi 3612 public abstract void installPackageWithVerification(Uri packageURI, 3613 IPackageInstallObserver observer, int flags, String installerPackageName, 3614 Uri verificationURI, ManifestDigest manifestDigest, 3615 ContainerEncryptionParams encryptionParams); 3616 3617 /** 3618 * Similar to 3619 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3620 * with an extra verification information provided. 3621 * 3622 * @param packageURI The location of the package file to install. This can 3623 * be a 'file:' or a 'content:' URI. 3624 * @param observer An observer callback to get notified when the package 3625 * installation is complete. 3626 * {@link IPackageInstallObserver#packageInstalled(String, int)} 3627 * will be called when that happens. This parameter must not be 3628 * null. 3629 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3630 * {@link #INSTALL_REPLACE_EXISTING}, 3631 * {@link #INSTALL_ALLOW_TEST}. 3632 * @param installerPackageName Optional package name of the application that 3633 * is performing the installation. This identifies which market 3634 * the package came from. 3635 * @param verificationParams an object that holds signal information to 3636 * assist verification. May be {@code null}. 3637 * @param encryptionParams if the package to be installed is encrypted, 3638 * these parameters describing the encryption and authentication 3639 * used. May be {@code null}. 3640 * @hide 3641 * @deprecated Use {@link #installPackageWithVerificationAndEncryption(Uri, 3642 * PackageInstallObserver, int, String, VerificationParams, 3643 * ContainerEncryptionParams)} instead. This method will 3644 * continue to be supported but the older observer interface 3645 * will not get additional failure details. 3646 */ 3647 @Deprecated 3648 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 3649 IPackageInstallObserver observer, int flags, String installerPackageName, 3650 VerificationParams verificationParams, 3651 ContainerEncryptionParams encryptionParams); 3652 3653 // Package-install variants that take the new, expanded form of observer interface. 3654 // Note that these *also* take the original observer type and will redundantly 3655 // report the same information to that observer if supplied; but it is not required. 3656 3657 /** 3658 * @hide 3659 * 3660 * Install a package. Since this may take a little while, the result will 3661 * be posted back to the given observer. An installation will fail if the calling context 3662 * lacks the {@link android.Manifest.permission#INSTALL_PACKAGES} permission, if the 3663 * package named in the package file's manifest is already installed, or if there's no space 3664 * available on the device. 3665 * 3666 * @param packageURI The location of the package file to install. This can be a 'file:' or a 3667 * 'content:' URI. 3668 * @param observer An observer callback to get notified when the package installation is 3669 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3670 * called when that happens. This parameter must not be null. 3671 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3672 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3673 * @param installerPackageName Optional package name of the application that is performing the 3674 * installation. This identifies which market the package came from. 3675 */ 3676 public abstract void installPackage( 3677 Uri packageURI, PackageInstallObserver observer, 3678 int flags, String installerPackageName); 3679 3680 /** 3681 * Similar to 3682 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3683 * with an extra verification file provided. 3684 * 3685 * @param packageURI The location of the package file to install. This can 3686 * be a 'file:' or a 'content:' URI. 3687 * @param observer An observer callback to get notified when the package installation is 3688 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3689 * called when that happens. This parameter must not be null. 3690 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3691 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3692 * @param installerPackageName Optional package name of the application that 3693 * is performing the installation. This identifies which market 3694 * the package came from. 3695 * @param verificationURI The location of the supplementary verification 3696 * file. This can be a 'file:' or a 'content:' URI. May be 3697 * {@code null}. 3698 * @param manifestDigest an object that holds the digest of the package 3699 * which can be used to verify ownership. May be {@code null}. 3700 * @param encryptionParams if the package to be installed is encrypted, 3701 * these parameters describing the encryption and authentication 3702 * used. May be {@code null}. 3703 * @hide 3704 */ 3705 public abstract void installPackageWithVerification(Uri packageURI, 3706 PackageInstallObserver observer, int flags, String installerPackageName, 3707 Uri verificationURI, ManifestDigest manifestDigest, 3708 ContainerEncryptionParams encryptionParams); 3709 3710 /** 3711 * Similar to 3712 * {@link #installPackage(Uri, IPackageInstallObserver, int, String)} but 3713 * with an extra verification information provided. 3714 * 3715 * @param packageURI The location of the package file to install. This can 3716 * be a 'file:' or a 'content:' URI. 3717 * @param observer An observer callback to get notified when the package installation is 3718 * complete. {@link PackageInstallObserver#packageInstalled(String, Bundle, int)} will be 3719 * called when that happens. This parameter must not be null. 3720 * @param flags - possible values: {@link #INSTALL_FORWARD_LOCK}, 3721 * {@link #INSTALL_REPLACE_EXISTING}, {@link #INSTALL_ALLOW_TEST}. 3722 * @param installerPackageName Optional package name of the application that 3723 * is performing the installation. This identifies which market 3724 * the package came from. 3725 * @param verificationParams an object that holds signal information to 3726 * assist verification. May be {@code null}. 3727 * @param encryptionParams if the package to be installed is encrypted, 3728 * these parameters describing the encryption and authentication 3729 * used. May be {@code null}. 3730 * 3731 * @hide 3732 */ 3733 public abstract void installPackageWithVerificationAndEncryption(Uri packageURI, 3734 PackageInstallObserver observer, int flags, String installerPackageName, 3735 VerificationParams verificationParams, ContainerEncryptionParams encryptionParams); 3736 3737 /** 3738 * If there is already an application with the given package name installed 3739 * on the system for other users, also install it for the calling user. 3740 * @hide 3741 */ 3742 // @SystemApi 3743 public abstract int installExistingPackage(String packageName) 3744 throws NameNotFoundException; 3745 3746 /** 3747 * Allows a package listening to the 3748 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 3749 * broadcast} to respond to the package manager. The response must include 3750 * the {@code verificationCode} which is one of 3751 * {@link PackageManager#VERIFICATION_ALLOW} or 3752 * {@link PackageManager#VERIFICATION_REJECT}. 3753 * 3754 * @param id pending package identifier as passed via the 3755 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 3756 * @param verificationCode either {@link PackageManager#VERIFICATION_ALLOW} 3757 * or {@link PackageManager#VERIFICATION_REJECT}. 3758 * @throws SecurityException if the caller does not have the 3759 * PACKAGE_VERIFICATION_AGENT permission. 3760 */ 3761 public abstract void verifyPendingInstall(int id, int verificationCode); 3762 3763 /** 3764 * Allows a package listening to the 3765 * {@link Intent#ACTION_PACKAGE_NEEDS_VERIFICATION package verification 3766 * broadcast} to extend the default timeout for a response and declare what 3767 * action to perform after the timeout occurs. The response must include 3768 * the {@code verificationCodeAtTimeout} which is one of 3769 * {@link PackageManager#VERIFICATION_ALLOW} or 3770 * {@link PackageManager#VERIFICATION_REJECT}. 3771 * 3772 * This method may only be called once per package id. Additional calls 3773 * will have no effect. 3774 * 3775 * @param id pending package identifier as passed via the 3776 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 3777 * @param verificationCodeAtTimeout either 3778 * {@link PackageManager#VERIFICATION_ALLOW} or 3779 * {@link PackageManager#VERIFICATION_REJECT}. If 3780 * {@code verificationCodeAtTimeout} is neither 3781 * {@link PackageManager#VERIFICATION_ALLOW} or 3782 * {@link PackageManager#VERIFICATION_REJECT}, then 3783 * {@code verificationCodeAtTimeout} will default to 3784 * {@link PackageManager#VERIFICATION_REJECT}. 3785 * @param millisecondsToDelay the amount of time requested for the timeout. 3786 * Must be positive and less than 3787 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. If 3788 * {@code millisecondsToDelay} is out of bounds, 3789 * {@code millisecondsToDelay} will be set to the closest in 3790 * bounds value; namely, 0 or 3791 * {@link PackageManager#MAXIMUM_VERIFICATION_TIMEOUT}. 3792 * @throws SecurityException if the caller does not have the 3793 * PACKAGE_VERIFICATION_AGENT permission. 3794 */ 3795 public abstract void extendVerificationTimeout(int id, 3796 int verificationCodeAtTimeout, long millisecondsToDelay); 3797 3798 /** 3799 * Allows a package listening to the 3800 * {@link Intent#ACTION_INTENT_FILTER_NEEDS_VERIFICATION intent filter verification 3801 * broadcast} to respond to the package manager. The response must include 3802 * the {@code verificationCode} which is one of 3803 * {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} or 3804 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 3805 * 3806 * @param verificationId pending package identifier as passed via the 3807 * {@link PackageManager#EXTRA_VERIFICATION_ID} Intent extra. 3808 * @param verificationCode either {@link PackageManager#INTENT_FILTER_VERIFICATION_SUCCESS} 3809 * or {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}. 3810 * @param outFailedDomains a list of failed domains if the verificationCode is 3811 * {@link PackageManager#INTENT_FILTER_VERIFICATION_FAILURE}, otherwise null; 3812 * @throws SecurityException if the caller does not have the 3813 * INTENT_FILTER_VERIFICATION_AGENT permission. 3814 * 3815 * @hide 3816 */ 3817 @SystemApi 3818 public abstract void verifyIntentFilter(int verificationId, int verificationCode, 3819 List<String> outFailedDomains); 3820 3821 /** 3822 * Get the status of a Domain Verification Result for an IntentFilter. This is 3823 * related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 3824 * {@link android.content.IntentFilter#getAutoVerify()} 3825 * 3826 * This is used by the ResolverActivity to change the status depending on what the User select 3827 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 3828 * for a domain. 3829 * 3830 * @param packageName The package name of the Activity associated with the IntentFilter. 3831 * @param userId The user id. 3832 * 3833 * @return The status to set to. This can be 3834 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 3835 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 3836 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} or 3837 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_UNDEFINED} 3838 * 3839 * @hide 3840 */ 3841 public abstract int getIntentVerificationStatus(String packageName, int userId); 3842 3843 /** 3844 * Allow to change the status of a Intent Verification status for all IntentFilter of an App. 3845 * This is related to the {@link android.content.IntentFilter#setAutoVerify(boolean)} and 3846 * {@link android.content.IntentFilter#getAutoVerify()} 3847 * 3848 * This is used by the ResolverActivity to change the status depending on what the User select 3849 * in the Disambiguation Dialog and also used by the Settings App for changing the default App 3850 * for a domain. 3851 * 3852 * @param packageName The package name of the Activity associated with the IntentFilter. 3853 * @param status The status to set to. This can be 3854 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ASK} or 3855 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_ALWAYS} or 3856 * {@link #INTENT_FILTER_DOMAIN_VERIFICATION_STATUS_NEVER} 3857 * @param userId The user id. 3858 * 3859 * @return true if the status has been set. False otherwise. 3860 * 3861 * @hide 3862 */ 3863 public abstract boolean updateIntentVerificationStatus(String packageName, int status, 3864 int userId); 3865 3866 /** 3867 * Get the list of IntentFilterVerificationInfo for a specific package and User. 3868 * 3869 * @param packageName the package name. When this parameter is set to a non null value, 3870 * the results will be filtered by the package name provided. 3871 * Otherwise, there will be no filtering and it will return a list 3872 * corresponding for all packages 3873 * 3874 * @return a list of IntentFilterVerificationInfo for a specific package. 3875 * 3876 * @hide 3877 */ 3878 public abstract List<IntentFilterVerificationInfo> getIntentFilterVerifications( 3879 String packageName); 3880 3881 /** 3882 * Get the list of IntentFilter for a specific package. 3883 * 3884 * @param packageName the package name. This parameter is set to a non null value, 3885 * the list will contain all the IntentFilter for that package. 3886 * Otherwise, the list will be empty. 3887 * 3888 * @return a list of IntentFilter for a specific package. 3889 * 3890 * @hide 3891 */ 3892 public abstract List<IntentFilter> getAllIntentFilters(String packageName); 3893 3894 /** 3895 * Get the default Browser package name for a specific user. 3896 * 3897 * @param userId The user id. 3898 * 3899 * @return the package name of the default Browser for the specified user. If the user id passed 3900 * is -1 (all users) it will return a null value. 3901 * 3902 * @hide 3903 */ 3904 public abstract String getDefaultBrowserPackageName(int userId); 3905 3906 /** 3907 * Set the default Browser package name for a specific user. 3908 * 3909 * @param packageName The package name of the default Browser. 3910 * @param userId The user id. 3911 * 3912 * @return true if the default Browser for the specified user has been set, 3913 * otherwise return false. If the user id passed is -1 (all users) this call will not 3914 * do anything and just return false. 3915 * 3916 * @hide 3917 */ 3918 public abstract boolean setDefaultBrowserPackageName(String packageName, int userId); 3919 3920 /** 3921 * Change the installer associated with a given package. There are limitations 3922 * on how the installer package can be changed; in particular: 3923 * <ul> 3924 * <li> A SecurityException will be thrown if <var>installerPackageName</var> 3925 * is not signed with the same certificate as the calling application. 3926 * <li> A SecurityException will be thrown if <var>targetPackage</var> already 3927 * has an installer package, and that installer package is not signed with 3928 * the same certificate as the calling application. 3929 * </ul> 3930 * 3931 * @param targetPackage The installed package whose installer will be changed. 3932 * @param installerPackageName The package name of the new installer. May be 3933 * null to clear the association. 3934 */ 3935 public abstract void setInstallerPackageName(String targetPackage, 3936 String installerPackageName); 3937 3938 /** 3939 * Attempts to delete a package. Since this may take a little while, the result will 3940 * be posted back to the given observer. A deletion will fail if the calling context 3941 * lacks the {@link android.Manifest.permission#DELETE_PACKAGES} permission, if the 3942 * named package cannot be found, or if the named package is a "system package". 3943 * (TODO: include pointer to documentation on "system packages") 3944 * 3945 * @param packageName The name of the package to delete 3946 * @param observer An observer callback to get notified when the package deletion is 3947 * complete. {@link android.content.pm.IPackageDeleteObserver#packageDeleted(boolean)} will be 3948 * called when that happens. observer may be null to indicate that no callback is desired. 3949 * @param flags - possible values: {@link #DELETE_KEEP_DATA}, 3950 * {@link #DELETE_ALL_USERS}. 3951 * 3952 * @hide 3953 */ 3954 // @SystemApi 3955 public abstract void deletePackage( 3956 String packageName, IPackageDeleteObserver observer, int flags); 3957 3958 /** 3959 * Retrieve the package name of the application that installed a package. This identifies 3960 * which market the package came from. 3961 * 3962 * @param packageName The name of the package to query 3963 */ 3964 public abstract String getInstallerPackageName(String packageName); 3965 3966 /** 3967 * Attempts to clear the user data directory of an application. 3968 * Since this may take a little while, the result will 3969 * be posted back to the given observer. A deletion will fail if the 3970 * named package cannot be found, or if the named package is a "system package". 3971 * 3972 * @param packageName The name of the package 3973 * @param observer An observer callback to get notified when the operation is finished 3974 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 3975 * will be called when that happens. observer may be null to indicate that 3976 * no callback is desired. 3977 * 3978 * @hide 3979 */ 3980 public abstract void clearApplicationUserData(String packageName, 3981 IPackageDataObserver observer); 3982 /** 3983 * Attempts to delete the cache files associated with an application. 3984 * Since this may take a little while, the result will 3985 * be posted back to the given observer. A deletion will fail if the calling context 3986 * lacks the {@link android.Manifest.permission#DELETE_CACHE_FILES} permission, if the 3987 * named package cannot be found, or if the named package is a "system package". 3988 * 3989 * @param packageName The name of the package to delete 3990 * @param observer An observer callback to get notified when the cache file deletion 3991 * is complete. 3992 * {@link android.content.pm.IPackageDataObserver#onRemoveCompleted(String, boolean)} 3993 * will be called when that happens. observer may be null to indicate that 3994 * no callback is desired. 3995 * 3996 * @hide 3997 */ 3998 public abstract void deleteApplicationCacheFiles(String packageName, 3999 IPackageDataObserver observer); 4000 4001 /** 4002 * Free storage by deleting LRU sorted list of cache files across 4003 * all applications. If the currently available free storage 4004 * on the device is greater than or equal to the requested 4005 * free storage, no cache files are cleared. If the currently 4006 * available storage on the device is less than the requested 4007 * free storage, some or all of the cache files across 4008 * all applications are deleted (based on last accessed time) 4009 * to increase the free storage space on the device to 4010 * the requested value. There is no guarantee that clearing all 4011 * the cache files from all applications will clear up 4012 * enough storage to achieve the desired value. 4013 * @param freeStorageSize The number of bytes of storage to be 4014 * freed by the system. Say if freeStorageSize is XX, 4015 * and the current free storage is YY, 4016 * if XX is less than YY, just return. if not free XX-YY number 4017 * of bytes if possible. 4018 * @param observer call back used to notify when 4019 * the operation is completed 4020 * 4021 * @hide 4022 */ 4023 // @SystemApi 4024 public void freeStorageAndNotify(long freeStorageSize, IPackageDataObserver observer) { 4025 freeStorageAndNotify(null, freeStorageSize, observer); 4026 } 4027 4028 /** {@hide} */ 4029 public abstract void freeStorageAndNotify(String volumeUuid, long freeStorageSize, 4030 IPackageDataObserver observer); 4031 4032 /** 4033 * Free storage by deleting LRU sorted list of cache files across 4034 * all applications. If the currently available free storage 4035 * on the device is greater than or equal to the requested 4036 * free storage, no cache files are cleared. If the currently 4037 * available storage on the device is less than the requested 4038 * free storage, some or all of the cache files across 4039 * all applications are deleted (based on last accessed time) 4040 * to increase the free storage space on the device to 4041 * the requested value. There is no guarantee that clearing all 4042 * the cache files from all applications will clear up 4043 * enough storage to achieve the desired value. 4044 * @param freeStorageSize The number of bytes of storage to be 4045 * freed by the system. Say if freeStorageSize is XX, 4046 * and the current free storage is YY, 4047 * if XX is less than YY, just return. if not free XX-YY number 4048 * of bytes if possible. 4049 * @param pi IntentSender call back used to 4050 * notify when the operation is completed.May be null 4051 * to indicate that no call back is desired. 4052 * 4053 * @hide 4054 */ 4055 public void freeStorage(long freeStorageSize, IntentSender pi) { 4056 freeStorage(null, freeStorageSize, pi); 4057 } 4058 4059 /** {@hide} */ 4060 public abstract void freeStorage(String volumeUuid, long freeStorageSize, IntentSender pi); 4061 4062 /** 4063 * Retrieve the size information for a package. 4064 * Since this may take a little while, the result will 4065 * be posted back to the given observer. The calling context 4066 * should have the {@link android.Manifest.permission#GET_PACKAGE_SIZE} permission. 4067 * 4068 * @param packageName The name of the package whose size information is to be retrieved 4069 * @param userHandle The user whose size information should be retrieved. 4070 * @param observer An observer callback to get notified when the operation 4071 * is complete. 4072 * {@link android.content.pm.IPackageStatsObserver#onGetStatsCompleted(PackageStats, boolean)} 4073 * The observer's callback is invoked with a PackageStats object(containing the 4074 * code, data and cache sizes of the package) and a boolean value representing 4075 * the status of the operation. observer may be null to indicate that 4076 * no callback is desired. 4077 * 4078 * @hide 4079 */ 4080 public abstract void getPackageSizeInfo(String packageName, int userHandle, 4081 IPackageStatsObserver observer); 4082 4083 /** 4084 * Like {@link #getPackageSizeInfo(String, int, IPackageStatsObserver)}, but 4085 * returns the size for the calling user. 4086 * 4087 * @hide 4088 */ 4089 public void getPackageSizeInfo(String packageName, IPackageStatsObserver observer) { 4090 getPackageSizeInfo(packageName, UserHandle.myUserId(), observer); 4091 } 4092 4093 /** 4094 * @deprecated This function no longer does anything; it was an old 4095 * approach to managing preferred activities, which has been superseded 4096 * by (and conflicts with) the modern activity-based preferences. 4097 */ 4098 @Deprecated 4099 public abstract void addPackageToPreferred(String packageName); 4100 4101 /** 4102 * @deprecated This function no longer does anything; it was an old 4103 * approach to managing preferred activities, which has been superseded 4104 * by (and conflicts with) the modern activity-based preferences. 4105 */ 4106 @Deprecated 4107 public abstract void removePackageFromPreferred(String packageName); 4108 4109 /** 4110 * Retrieve the list of all currently configured preferred packages. The 4111 * first package on the list is the most preferred, the last is the 4112 * least preferred. 4113 * 4114 * @param flags Additional option flags. Use any combination of 4115 * {@link #GET_ACTIVITIES}, 4116 * {@link #GET_GIDS}, 4117 * {@link #GET_CONFIGURATIONS}, 4118 * {@link #GET_INSTRUMENTATION}, 4119 * {@link #GET_PERMISSIONS}, 4120 * {@link #GET_PROVIDERS}, 4121 * {@link #GET_RECEIVERS}, 4122 * {@link #GET_SERVICES}, 4123 * {@link #GET_SIGNATURES}, to modify the data returned. 4124 * 4125 * @return Returns a list of PackageInfo objects describing each 4126 * preferred application, in order of preference. 4127 * 4128 * @see #GET_ACTIVITIES 4129 * @see #GET_GIDS 4130 * @see #GET_CONFIGURATIONS 4131 * @see #GET_INSTRUMENTATION 4132 * @see #GET_PERMISSIONS 4133 * @see #GET_PROVIDERS 4134 * @see #GET_RECEIVERS 4135 * @see #GET_SERVICES 4136 * @see #GET_SIGNATURES 4137 */ 4138 public abstract List<PackageInfo> getPreferredPackages(int flags); 4139 4140 /** 4141 * @deprecated This is a protected API that should not have been available 4142 * to third party applications. It is the platform's responsibility for 4143 * assigning preferred activities and this cannot be directly modified. 4144 * 4145 * Add a new preferred activity mapping to the system. This will be used 4146 * to automatically select the given activity component when 4147 * {@link Context#startActivity(Intent) Context.startActivity()} finds 4148 * multiple matching activities and also matches the given filter. 4149 * 4150 * @param filter The set of intents under which this activity will be 4151 * made preferred. 4152 * @param match The IntentFilter match category that this preference 4153 * applies to. 4154 * @param set The set of activities that the user was picking from when 4155 * this preference was made. 4156 * @param activity The component name of the activity that is to be 4157 * preferred. 4158 */ 4159 @Deprecated 4160 public abstract void addPreferredActivity(IntentFilter filter, int match, 4161 ComponentName[] set, ComponentName activity); 4162 4163 /** 4164 * Same as {@link #addPreferredActivity(IntentFilter, int, 4165 ComponentName[], ComponentName)}, but with a specific userId to apply the preference 4166 to. 4167 * @hide 4168 */ 4169 public void addPreferredActivity(IntentFilter filter, int match, 4170 ComponentName[] set, ComponentName activity, int userId) { 4171 throw new RuntimeException("Not implemented. Must override in a subclass."); 4172 } 4173 4174 /** 4175 * @deprecated This is a protected API that should not have been available 4176 * to third party applications. It is the platform's responsibility for 4177 * assigning preferred activities and this cannot be directly modified. 4178 * 4179 * Replaces an existing preferred activity mapping to the system, and if that were not present 4180 * adds a new preferred activity. This will be used 4181 * to automatically select the given activity component when 4182 * {@link Context#startActivity(Intent) Context.startActivity()} finds 4183 * multiple matching activities and also matches the given filter. 4184 * 4185 * @param filter The set of intents under which this activity will be 4186 * made preferred. 4187 * @param match The IntentFilter match category that this preference 4188 * applies to. 4189 * @param set The set of activities that the user was picking from when 4190 * this preference was made. 4191 * @param activity The component name of the activity that is to be 4192 * preferred. 4193 * @hide 4194 */ 4195 @Deprecated 4196 public abstract void replacePreferredActivity(IntentFilter filter, int match, 4197 ComponentName[] set, ComponentName activity); 4198 4199 /** 4200 * @hide 4201 */ 4202 @Deprecated 4203 public void replacePreferredActivityAsUser(IntentFilter filter, int match, 4204 ComponentName[] set, ComponentName activity, int userId) { 4205 throw new RuntimeException("Not implemented. Must override in a subclass."); 4206 } 4207 4208 /** 4209 * Remove all preferred activity mappings, previously added with 4210 * {@link #addPreferredActivity}, from the 4211 * system whose activities are implemented in the given package name. 4212 * An application can only clear its own package(s). 4213 * 4214 * @param packageName The name of the package whose preferred activity 4215 * mappings are to be removed. 4216 */ 4217 public abstract void clearPackagePreferredActivities(String packageName); 4218 4219 /** 4220 * Retrieve all preferred activities, previously added with 4221 * {@link #addPreferredActivity}, that are 4222 * currently registered with the system. 4223 * 4224 * @param outFilters A required list in which to place the filters of all of the 4225 * preferred activities. 4226 * @param outActivities A required list in which to place the component names of 4227 * all of the preferred activities. 4228 * @param packageName An optional package in which you would like to limit 4229 * the list. If null, all activities will be returned; if non-null, only 4230 * those activities in the given package are returned. 4231 * 4232 * @return Returns the total number of registered preferred activities 4233 * (the number of distinct IntentFilter records, not the number of unique 4234 * activity components) that were found. 4235 */ 4236 public abstract int getPreferredActivities(@NonNull List<IntentFilter> outFilters, 4237 @NonNull List<ComponentName> outActivities, String packageName); 4238 4239 /** 4240 * Ask for the set of available 'home' activities and the current explicit 4241 * default, if any. 4242 * @hide 4243 */ 4244 public abstract ComponentName getHomeActivities(List<ResolveInfo> outActivities); 4245 4246 /** 4247 * Set the enabled setting for a package component (activity, receiver, service, provider). 4248 * This setting will override any enabled state which may have been set by the component in its 4249 * manifest. 4250 * 4251 * @param componentName The component to enable 4252 * @param newState The new enabled state for the component. The legal values for this state 4253 * are: 4254 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4255 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 4256 * and 4257 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 4258 * The last one removes the setting, thereby restoring the component's state to 4259 * whatever was set in it's manifest (or enabled, by default). 4260 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 4261 */ 4262 public abstract void setComponentEnabledSetting(ComponentName componentName, 4263 int newState, int flags); 4264 4265 4266 /** 4267 * Return the enabled setting for a package component (activity, 4268 * receiver, service, provider). This returns the last value set by 4269 * {@link #setComponentEnabledSetting(ComponentName, int, int)}; in most 4270 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 4271 * the value originally specified in the manifest has not been modified. 4272 * 4273 * @param componentName The component to retrieve. 4274 * @return Returns the current enabled state for the component. May 4275 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4276 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 4277 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 4278 * component's enabled state is based on the original information in 4279 * the manifest as found in {@link ComponentInfo}. 4280 */ 4281 public abstract int getComponentEnabledSetting(ComponentName componentName); 4282 4283 /** 4284 * Set the enabled setting for an application 4285 * This setting will override any enabled state which may have been set by the application in 4286 * its manifest. It also overrides the enabled state set in the manifest for any of the 4287 * application's components. It does not override any enabled state set by 4288 * {@link #setComponentEnabledSetting} for any of the application's components. 4289 * 4290 * @param packageName The package name of the application to enable 4291 * @param newState The new enabled state for the component. The legal values for this state 4292 * are: 4293 * {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4294 * {@link #COMPONENT_ENABLED_STATE_DISABLED} 4295 * and 4296 * {@link #COMPONENT_ENABLED_STATE_DEFAULT} 4297 * The last one removes the setting, thereby restoring the applications's state to 4298 * whatever was set in its manifest (or enabled, by default). 4299 * @param flags Optional behavior flags: {@link #DONT_KILL_APP} or 0. 4300 */ 4301 public abstract void setApplicationEnabledSetting(String packageName, 4302 int newState, int flags); 4303 4304 /** 4305 * Return the enabled setting for an application. This returns 4306 * the last value set by 4307 * {@link #setApplicationEnabledSetting(String, int, int)}; in most 4308 * cases this value will be {@link #COMPONENT_ENABLED_STATE_DEFAULT} since 4309 * the value originally specified in the manifest has not been modified. 4310 * 4311 * @param packageName The package name of the application to retrieve. 4312 * @return Returns the current enabled state for the application. May 4313 * be one of {@link #COMPONENT_ENABLED_STATE_ENABLED}, 4314 * {@link #COMPONENT_ENABLED_STATE_DISABLED}, or 4315 * {@link #COMPONENT_ENABLED_STATE_DEFAULT}. The last one means the 4316 * application's enabled state is based on the original information in 4317 * the manifest as found in {@link ComponentInfo}. 4318 * @throws IllegalArgumentException if the named package does not exist. 4319 */ 4320 public abstract int getApplicationEnabledSetting(String packageName); 4321 4322 /** 4323 * Puts the package in a hidden state, which is almost like an uninstalled state, 4324 * making the package unavailable, but it doesn't remove the data or the actual 4325 * package file. Application can be unhidden by either resetting the hidden state 4326 * or by installing it, such as with {@link #installExistingPackage(String)} 4327 * @hide 4328 */ 4329 public abstract boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, 4330 UserHandle userHandle); 4331 4332 /** 4333 * Returns the hidden state of a package. 4334 * @see #setApplicationHiddenSettingAsUser(String, boolean, UserHandle) 4335 * @hide 4336 */ 4337 public abstract boolean getApplicationHiddenSettingAsUser(String packageName, 4338 UserHandle userHandle); 4339 4340 /** 4341 * Return whether the device has been booted into safe mode. 4342 */ 4343 public abstract boolean isSafeMode(); 4344 4345 /** 4346 * Adds a listener for permission changes for installed packages. 4347 * 4348 * @param listener The listener to add. 4349 * 4350 * @hide 4351 */ 4352 @SystemApi 4353 @RequiresPermission(Manifest.permission.OBSERVE_GRANT_REVOKE_PERMISSIONS) 4354 public abstract void addOnPermissionsChangeListener(OnPermissionsChangedListener listener); 4355 4356 /** 4357 * Remvoes a listener for permission changes for installed packages. 4358 * 4359 * @param listener The listener to remove. 4360 * 4361 * @hide 4362 */ 4363 @SystemApi 4364 public abstract void removeOnPermissionsChangeListener(OnPermissionsChangedListener listener); 4365 4366 /** 4367 * Return the {@link KeySet} associated with the String alias for this 4368 * application. 4369 * 4370 * @param alias The alias for a given {@link KeySet} as defined in the 4371 * application's AndroidManifest.xml. 4372 * @hide 4373 */ 4374 public abstract KeySet getKeySetByAlias(String packageName, String alias); 4375 4376 /** Return the signing {@link KeySet} for this application. 4377 * @hide 4378 */ 4379 public abstract KeySet getSigningKeySet(String packageName); 4380 4381 /** 4382 * Return whether the package denoted by packageName has been signed by all 4383 * of the keys specified by the {@link KeySet} ks. This will return true if 4384 * the package has been signed by additional keys (a superset) as well. 4385 * Compare to {@link #isSignedByExactly(String packageName, KeySet ks)}. 4386 * @hide 4387 */ 4388 public abstract boolean isSignedBy(String packageName, KeySet ks); 4389 4390 /** 4391 * Return whether the package denoted by packageName has been signed by all 4392 * of, and only, the keys specified by the {@link KeySet} ks. Compare to 4393 * {@link #isSignedBy(String packageName, KeySet ks)}. 4394 * @hide 4395 */ 4396 public abstract boolean isSignedByExactly(String packageName, KeySet ks); 4397 4398 /** 4399 * Attempts to move package resources from internal to external media or vice versa. 4400 * Since this may take a little while, the result will 4401 * be posted back to the given observer. This call may fail if the calling context 4402 * lacks the {@link android.Manifest.permission#MOVE_PACKAGE} permission, if the 4403 * named package cannot be found, or if the named package is a "system package". 4404 * 4405 * @param packageName The name of the package to delete 4406 * @param observer An observer callback to get notified when the package move is 4407 * complete. {@link android.content.pm.IPackageMoveObserver#packageMoved(boolean)} will be 4408 * called when that happens. observer may be null to indicate that no callback is desired. 4409 * @param flags To indicate install location {@link #MOVE_INTERNAL} or 4410 * {@link #MOVE_EXTERNAL_MEDIA} 4411 * 4412 * @hide 4413 */ 4414 @Deprecated 4415 public void movePackage(String packageName, IPackageMoveObserver observer, int flags) { 4416 throw new UnsupportedOperationException(); 4417 } 4418 4419 /** {@hide} */ 4420 public static boolean isMoveStatusFinished(int status) { 4421 return (status < 0 || status > 100); 4422 } 4423 4424 /** {@hide} */ 4425 public static abstract class MoveCallback { 4426 public void onCreated(int moveId, Bundle extras) {} 4427 public abstract void onStatusChanged(int moveId, int status, long estMillis); 4428 } 4429 4430 /** {@hide} */ 4431 public abstract int getMoveStatus(int moveId); 4432 4433 /** {@hide} */ 4434 public abstract void registerMoveCallback(MoveCallback callback, Handler handler); 4435 /** {@hide} */ 4436 public abstract void unregisterMoveCallback(MoveCallback callback); 4437 4438 /** {@hide} */ 4439 public abstract int movePackage(String packageName, VolumeInfo vol); 4440 /** {@hide} */ 4441 public abstract @Nullable VolumeInfo getPackageCurrentVolume(ApplicationInfo app); 4442 /** {@hide} */ 4443 public abstract @NonNull List<VolumeInfo> getPackageCandidateVolumes(ApplicationInfo app); 4444 4445 /** {@hide} */ 4446 public abstract int movePrimaryStorage(VolumeInfo vol); 4447 /** {@hide} */ 4448 public abstract @Nullable VolumeInfo getPrimaryStorageCurrentVolume(); 4449 /** {@hide} */ 4450 public abstract @NonNull List<VolumeInfo> getPrimaryStorageCandidateVolumes(); 4451 4452 /** 4453 * Returns the device identity that verifiers can use to associate their scheme to a particular 4454 * device. This should not be used by anything other than a package verifier. 4455 * 4456 * @return identity that uniquely identifies current device 4457 * @hide 4458 */ 4459 public abstract VerifierDeviceIdentity getVerifierDeviceIdentity(); 4460 4461 /** 4462 * Returns true if the device is upgrading, such as first boot after OTA. 4463 * 4464 * @hide 4465 */ 4466 public abstract boolean isUpgrade(); 4467 4468 /** 4469 * Return interface that offers the ability to install, upgrade, and remove 4470 * applications on the device. 4471 */ 4472 public abstract @NonNull PackageInstaller getPackageInstaller(); 4473 4474 /** 4475 * Adds a {@link CrossProfileIntentFilter}. After calling this method all intents sent from the 4476 * user with id sourceUserId can also be be resolved by activities in the user with id 4477 * targetUserId if they match the specified intent filter. 4478 * @param filter The {@link IntentFilter} the intent has to match 4479 * @param sourceUserId The source user id. 4480 * @param targetUserId The target user id. 4481 * @param flags The only possible value is {@link SKIP_CURRENT_PROFILE} 4482 * @hide 4483 */ 4484 public abstract void addCrossProfileIntentFilter(IntentFilter filter, int sourceUserId, 4485 int targetUserId, int flags); 4486 4487 /** 4488 * Clearing {@link CrossProfileIntentFilter}s which have the specified user as their 4489 * source, and have been set by the app calling this method. 4490 * @param sourceUserId The source user id. 4491 * @hide 4492 */ 4493 public abstract void clearCrossProfileIntentFilters(int sourceUserId); 4494 4495 /** 4496 * @hide 4497 */ 4498 public abstract Drawable loadItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 4499 4500 /** 4501 * @hide 4502 */ 4503 public abstract Drawable loadUnbadgedItemIcon(PackageItemInfo itemInfo, ApplicationInfo appInfo); 4504 4505 /** {@hide} */ 4506 public abstract boolean isPackageAvailable(String packageName); 4507 4508 /** {@hide} */ 4509 public static String installStatusToString(int status, String msg) { 4510 final String str = installStatusToString(status); 4511 if (msg != null) { 4512 return str + ": " + msg; 4513 } else { 4514 return str; 4515 } 4516 } 4517 4518 /** {@hide} */ 4519 public static String installStatusToString(int status) { 4520 switch (status) { 4521 case INSTALL_SUCCEEDED: return "INSTALL_SUCCEEDED"; 4522 case INSTALL_FAILED_ALREADY_EXISTS: return "INSTALL_FAILED_ALREADY_EXISTS"; 4523 case INSTALL_FAILED_INVALID_APK: return "INSTALL_FAILED_INVALID_APK"; 4524 case INSTALL_FAILED_INVALID_URI: return "INSTALL_FAILED_INVALID_URI"; 4525 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return "INSTALL_FAILED_INSUFFICIENT_STORAGE"; 4526 case INSTALL_FAILED_DUPLICATE_PACKAGE: return "INSTALL_FAILED_DUPLICATE_PACKAGE"; 4527 case INSTALL_FAILED_NO_SHARED_USER: return "INSTALL_FAILED_NO_SHARED_USER"; 4528 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return "INSTALL_FAILED_UPDATE_INCOMPATIBLE"; 4529 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return "INSTALL_FAILED_SHARED_USER_INCOMPATIBLE"; 4530 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return "INSTALL_FAILED_MISSING_SHARED_LIBRARY"; 4531 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return "INSTALL_FAILED_REPLACE_COULDNT_DELETE"; 4532 case INSTALL_FAILED_DEXOPT: return "INSTALL_FAILED_DEXOPT"; 4533 case INSTALL_FAILED_OLDER_SDK: return "INSTALL_FAILED_OLDER_SDK"; 4534 case INSTALL_FAILED_CONFLICTING_PROVIDER: return "INSTALL_FAILED_CONFLICTING_PROVIDER"; 4535 case INSTALL_FAILED_NEWER_SDK: return "INSTALL_FAILED_NEWER_SDK"; 4536 case INSTALL_FAILED_TEST_ONLY: return "INSTALL_FAILED_TEST_ONLY"; 4537 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return "INSTALL_FAILED_CPU_ABI_INCOMPATIBLE"; 4538 case INSTALL_FAILED_MISSING_FEATURE: return "INSTALL_FAILED_MISSING_FEATURE"; 4539 case INSTALL_FAILED_CONTAINER_ERROR: return "INSTALL_FAILED_CONTAINER_ERROR"; 4540 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return "INSTALL_FAILED_INVALID_INSTALL_LOCATION"; 4541 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return "INSTALL_FAILED_MEDIA_UNAVAILABLE"; 4542 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return "INSTALL_FAILED_VERIFICATION_TIMEOUT"; 4543 case INSTALL_FAILED_VERIFICATION_FAILURE: return "INSTALL_FAILED_VERIFICATION_FAILURE"; 4544 case INSTALL_FAILED_PACKAGE_CHANGED: return "INSTALL_FAILED_PACKAGE_CHANGED"; 4545 case INSTALL_FAILED_UID_CHANGED: return "INSTALL_FAILED_UID_CHANGED"; 4546 case INSTALL_FAILED_VERSION_DOWNGRADE: return "INSTALL_FAILED_VERSION_DOWNGRADE"; 4547 case INSTALL_PARSE_FAILED_NOT_APK: return "INSTALL_PARSE_FAILED_NOT_APK"; 4548 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return "INSTALL_PARSE_FAILED_BAD_MANIFEST"; 4549 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return "INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION"; 4550 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return "INSTALL_PARSE_FAILED_NO_CERTIFICATES"; 4551 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return "INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES"; 4552 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return "INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING"; 4553 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return "INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME"; 4554 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return "INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID"; 4555 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return "INSTALL_PARSE_FAILED_MANIFEST_MALFORMED"; 4556 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return "INSTALL_PARSE_FAILED_MANIFEST_EMPTY"; 4557 case INSTALL_FAILED_INTERNAL_ERROR: return "INSTALL_FAILED_INTERNAL_ERROR"; 4558 case INSTALL_FAILED_USER_RESTRICTED: return "INSTALL_FAILED_USER_RESTRICTED"; 4559 case INSTALL_FAILED_DUPLICATE_PERMISSION: return "INSTALL_FAILED_DUPLICATE_PERMISSION"; 4560 case INSTALL_FAILED_NO_MATCHING_ABIS: return "INSTALL_FAILED_NO_MATCHING_ABIS"; 4561 case INSTALL_FAILED_ABORTED: return "INSTALL_FAILED_ABORTED"; 4562 default: return Integer.toString(status); 4563 } 4564 } 4565 4566 /** {@hide} */ 4567 public static int installStatusToPublicStatus(int status) { 4568 switch (status) { 4569 case INSTALL_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 4570 case INSTALL_FAILED_ALREADY_EXISTS: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4571 case INSTALL_FAILED_INVALID_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 4572 case INSTALL_FAILED_INVALID_URI: return PackageInstaller.STATUS_FAILURE_INVALID; 4573 case INSTALL_FAILED_INSUFFICIENT_STORAGE: return PackageInstaller.STATUS_FAILURE_STORAGE; 4574 case INSTALL_FAILED_DUPLICATE_PACKAGE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4575 case INSTALL_FAILED_NO_SHARED_USER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4576 case INSTALL_FAILED_UPDATE_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4577 case INSTALL_FAILED_SHARED_USER_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4578 case INSTALL_FAILED_MISSING_SHARED_LIBRARY: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4579 case INSTALL_FAILED_REPLACE_COULDNT_DELETE: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4580 case INSTALL_FAILED_DEXOPT: return PackageInstaller.STATUS_FAILURE_INVALID; 4581 case INSTALL_FAILED_OLDER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4582 case INSTALL_FAILED_CONFLICTING_PROVIDER: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4583 case INSTALL_FAILED_NEWER_SDK: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4584 case INSTALL_FAILED_TEST_ONLY: return PackageInstaller.STATUS_FAILURE_INVALID; 4585 case INSTALL_FAILED_CPU_ABI_INCOMPATIBLE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4586 case INSTALL_FAILED_MISSING_FEATURE: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4587 case INSTALL_FAILED_CONTAINER_ERROR: return PackageInstaller.STATUS_FAILURE_STORAGE; 4588 case INSTALL_FAILED_INVALID_INSTALL_LOCATION: return PackageInstaller.STATUS_FAILURE_STORAGE; 4589 case INSTALL_FAILED_MEDIA_UNAVAILABLE: return PackageInstaller.STATUS_FAILURE_STORAGE; 4590 case INSTALL_FAILED_VERIFICATION_TIMEOUT: return PackageInstaller.STATUS_FAILURE_ABORTED; 4591 case INSTALL_FAILED_VERIFICATION_FAILURE: return PackageInstaller.STATUS_FAILURE_ABORTED; 4592 case INSTALL_FAILED_PACKAGE_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 4593 case INSTALL_FAILED_UID_CHANGED: return PackageInstaller.STATUS_FAILURE_INVALID; 4594 case INSTALL_FAILED_VERSION_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 4595 case INSTALL_FAILED_PERMISSION_MODEL_DOWNGRADE: return PackageInstaller.STATUS_FAILURE_INVALID; 4596 case INSTALL_PARSE_FAILED_NOT_APK: return PackageInstaller.STATUS_FAILURE_INVALID; 4597 case INSTALL_PARSE_FAILED_BAD_MANIFEST: return PackageInstaller.STATUS_FAILURE_INVALID; 4598 case INSTALL_PARSE_FAILED_UNEXPECTED_EXCEPTION: return PackageInstaller.STATUS_FAILURE_INVALID; 4599 case INSTALL_PARSE_FAILED_NO_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 4600 case INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES: return PackageInstaller.STATUS_FAILURE_INVALID; 4601 case INSTALL_PARSE_FAILED_CERTIFICATE_ENCODING: return PackageInstaller.STATUS_FAILURE_INVALID; 4602 case INSTALL_PARSE_FAILED_BAD_PACKAGE_NAME: return PackageInstaller.STATUS_FAILURE_INVALID; 4603 case INSTALL_PARSE_FAILED_BAD_SHARED_USER_ID: return PackageInstaller.STATUS_FAILURE_INVALID; 4604 case INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: return PackageInstaller.STATUS_FAILURE_INVALID; 4605 case INSTALL_PARSE_FAILED_MANIFEST_EMPTY: return PackageInstaller.STATUS_FAILURE_INVALID; 4606 case INSTALL_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 4607 case INSTALL_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4608 case INSTALL_FAILED_DUPLICATE_PERMISSION: return PackageInstaller.STATUS_FAILURE_CONFLICT; 4609 case INSTALL_FAILED_NO_MATCHING_ABIS: return PackageInstaller.STATUS_FAILURE_INCOMPATIBLE; 4610 case INSTALL_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 4611 default: return PackageInstaller.STATUS_FAILURE; 4612 } 4613 } 4614 4615 /** {@hide} */ 4616 public static String deleteStatusToString(int status, String msg) { 4617 final String str = deleteStatusToString(status); 4618 if (msg != null) { 4619 return str + ": " + msg; 4620 } else { 4621 return str; 4622 } 4623 } 4624 4625 /** {@hide} */ 4626 public static String deleteStatusToString(int status) { 4627 switch (status) { 4628 case DELETE_SUCCEEDED: return "DELETE_SUCCEEDED"; 4629 case DELETE_FAILED_INTERNAL_ERROR: return "DELETE_FAILED_INTERNAL_ERROR"; 4630 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return "DELETE_FAILED_DEVICE_POLICY_MANAGER"; 4631 case DELETE_FAILED_USER_RESTRICTED: return "DELETE_FAILED_USER_RESTRICTED"; 4632 case DELETE_FAILED_OWNER_BLOCKED: return "DELETE_FAILED_OWNER_BLOCKED"; 4633 case DELETE_FAILED_ABORTED: return "DELETE_FAILED_ABORTED"; 4634 default: return Integer.toString(status); 4635 } 4636 } 4637 4638 /** {@hide} */ 4639 public static int deleteStatusToPublicStatus(int status) { 4640 switch (status) { 4641 case DELETE_SUCCEEDED: return PackageInstaller.STATUS_SUCCESS; 4642 case DELETE_FAILED_INTERNAL_ERROR: return PackageInstaller.STATUS_FAILURE; 4643 case DELETE_FAILED_DEVICE_POLICY_MANAGER: return PackageInstaller.STATUS_FAILURE_BLOCKED; 4644 case DELETE_FAILED_USER_RESTRICTED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 4645 case DELETE_FAILED_OWNER_BLOCKED: return PackageInstaller.STATUS_FAILURE_BLOCKED; 4646 case DELETE_FAILED_ABORTED: return PackageInstaller.STATUS_FAILURE_ABORTED; 4647 default: return PackageInstaller.STATUS_FAILURE; 4648 } 4649 } 4650 4651 /** {@hide} */ 4652 public static String permissionFlagToString(int flag) { 4653 switch (flag) { 4654 case FLAG_PERMISSION_GRANTED_BY_DEFAULT: return "GRANTED_BY_DEFAULT"; 4655 case FLAG_PERMISSION_POLICY_FIXED: return "POLICY_FIXED"; 4656 case FLAG_PERMISSION_SYSTEM_FIXED: return "SYSTEM_FIXED"; 4657 case FLAG_PERMISSION_USER_SET: return "USER_SET"; 4658 case FLAG_PERMISSION_REVOKE_ON_UPGRADE: return "REVOKE_ON_UPGRADE"; 4659 case FLAG_PERMISSION_USER_FIXED: return "USER_FIXED"; 4660 default: return Integer.toString(flag); 4661 } 4662 } 4663 4664 /** {@hide} */ 4665 public static class LegacyPackageInstallObserver extends PackageInstallObserver { 4666 private final IPackageInstallObserver mLegacy; 4667 4668 public LegacyPackageInstallObserver(IPackageInstallObserver legacy) { 4669 mLegacy = legacy; 4670 } 4671 4672 @Override 4673 public void onPackageInstalled(String basePackageName, int returnCode, String msg, 4674 Bundle extras) { 4675 if (mLegacy == null) return; 4676 try { 4677 mLegacy.packageInstalled(basePackageName, returnCode); 4678 } catch (RemoteException ignored) { 4679 } 4680 } 4681 } 4682 4683 /** {@hide} */ 4684 public static class LegacyPackageDeleteObserver extends PackageDeleteObserver { 4685 private final IPackageDeleteObserver mLegacy; 4686 4687 public LegacyPackageDeleteObserver(IPackageDeleteObserver legacy) { 4688 mLegacy = legacy; 4689 } 4690 4691 @Override 4692 public void onPackageDeleted(String basePackageName, int returnCode, String msg) { 4693 if (mLegacy == null) return; 4694 try { 4695 mLegacy.packageDeleted(basePackageName, returnCode); 4696 } catch (RemoteException ignored) { 4697 } 4698 } 4699 } 4700} 4701