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