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