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