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