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