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