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