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