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