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