Un-deprecate some NFC methods
These were previously deprecated as part of the migration to the WALLET
role, but we've decided that deprecation isn't very helpful here.
Bug: 330327475
Test: `m docs`
Merged-In: Idb794a1bd79065bee0001c9a0950aa9e9226b5cb
Change-Id: Idb794a1bd79065bee0001c9a0950aa9e9226b5cb
diff --git a/nfc/api/current.txt b/nfc/api/current.txt
index 80b2be2..6d4cc3a 100644
--- a/nfc/api/current.txt
+++ b/nfc/api/current.txt
@@ -194,13 +194,13 @@
package android.nfc.cardemulation {
public final class CardEmulation {
- method @Deprecated public boolean categoryAllowsForegroundPreference(String);
+ method public boolean categoryAllowsForegroundPreference(String);
method @Nullable @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public java.util.List<java.lang.String> getAidsForPreferredPaymentService();
method public java.util.List<java.lang.String> getAidsForService(android.content.ComponentName, String);
- method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public CharSequence getDescriptionForPreferredPaymentService();
+ method @Nullable @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public CharSequence getDescriptionForPreferredPaymentService();
method public static android.nfc.cardemulation.CardEmulation getInstance(android.nfc.NfcAdapter);
- method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public String getRouteDestinationForPreferredPaymentService();
- method @Deprecated public int getSelectionModeForCategory(String);
+ method @Nullable @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public String getRouteDestinationForPreferredPaymentService();
+ method public int getSelectionModeForCategory(String);
method public boolean isDefaultServiceForAid(android.content.ComponentName, String);
method public boolean isDefaultServiceForCategory(android.content.ComponentName, String);
method public boolean registerAidsForService(android.content.ComponentName, String, java.util.List<java.lang.String>);
diff --git a/nfc/java/android/nfc/cardemulation/CardEmulation.java b/nfc/java/android/nfc/cardemulation/CardEmulation.java
index f3c4ea7..2fe2ce3 100644
--- a/nfc/java/android/nfc/cardemulation/CardEmulation.java
+++ b/nfc/java/android/nfc/cardemulation/CardEmulation.java
@@ -36,6 +36,7 @@
import android.nfc.Flags;
import android.nfc.INfcCardEmulation;
import android.nfc.NfcAdapter;
+import android.os.Build;
import android.os.RemoteException;
import android.os.UserHandle;
import android.provider.Settings;
@@ -271,30 +272,31 @@
}
/**
+ * <p>
* Returns whether the user has allowed AIDs registered in the
* specified category to be handled by a service that is preferred
* by the foreground application, instead of by a pre-configured default.
*
* Foreground applications can set such preferences using the
* {@link #setPreferredService(Activity, ComponentName)} method.
+ * <p class="note">
+ * Starting with {@link Build.VERSION_CODES#VANILLA_ICE_CREAM}, this method will always
+ * return true.
*
* @param category The category, e.g. {@link #CATEGORY_PAYMENT}
* @return whether AIDs in the category can be handled by a service
* specified by the foreground app.
- *
- * @deprecated see {@link android.app.role.RoleManager#ROLE_WALLET}. The definition of the
- * Preferred Payment service is no longer valid. All routings will be done in a AID
- * category agnostic manner.
*/
@SuppressWarnings("NonUserGetterCalled")
- @Deprecated
public boolean categoryAllowsForegroundPreference(String category) {
Context contextAsUser = mContext.createContextAsUser(
UserHandle.of(UserHandle.myUserId()), 0);
+
RoleManager roleManager = contextAsUser.getSystemService(RoleManager.class);
if (roleManager.isRoleAvailable(RoleManager.ROLE_WALLET)) {
return true;
}
+
if (CATEGORY_PAYMENT.equals(category)) {
boolean preferForeground = false;
try {
@@ -319,14 +321,14 @@
* every time what service they would like to use in this category.
* <p>{@link #SELECTION_MODE_ASK_IF_CONFLICT} the user will only be asked
* to pick a service if there is a conflict.
+ *
+ * <p class="note">
+ * Starting with {@link Build.VERSION_CODES#VANILLA_ICE_CREAM}, the default service defined
+ * by the holder of {@link android.app.role.RoleManager#ROLE_WALLET} and is category agnostic.
+ *
* @param category The category, for example {@link #CATEGORY_PAYMENT}
* @return the selection mode for the passed in category
- *
- * @deprecated see {@link android.app.role.RoleManager#ROLE_WALLET}. The definition of the
- * Preferred Payment service is no longer valid. All routings will be done in a AID
- * category agnostic manner.
*/
- @Deprecated
public int getSelectionModeForCategory(String category) {
if (CATEGORY_PAYMENT.equals(category)) {
boolean paymentRegistered = false;
@@ -919,6 +921,13 @@
/**
* Retrieves the route destination for the preferred payment service.
*
+ * <p class="note">
+ * Starting with {@link Build.VERSION_CODES#VANILLA_ICE_CREAM}, the preferred payment service
+ * no longer exists and is replaced by {@link android.app.role.RoleManager#ROLE_WALLET}. This
+ * will return the route for one of the services registered by the role holder (if any). If
+ * there are multiple services registered, it is unspecified which of those will be used to
+ * determine the route.
+ *
* @return The route destination secure element name of the preferred payment service.
* HCE payment: "Host"
* OffHost payment: 1. String with prefix SIM or prefix eSE string.
@@ -931,15 +940,8 @@
* (e.g. eSE/eSE1, eSE2, etc.).
* 2. "OffHost" if the payment service does not specify secure element
* name.
- *
- * @deprecated see {@link android.app.role.RoleManager#ROLE_WALLET}. The definition of the
- * Preferred Payment service is no longer valid. All routings will go to the Wallet Holder app.
- * A payment service will be selected automatically based on registered AIDs. In the case of
- * multiple services that register for the same payment AID, the selection will be done on
- * an alphabetical order based on the component names.
*/
@RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO)
- @Deprecated
@Nullable
public String getRouteDestinationForPreferredPaymentService() {
try {
@@ -981,16 +983,16 @@
/**
* Returns a user-visible description of the preferred payment service.
*
- * @return the preferred payment service description
+ * <p class="note">
+ * Starting with {@link Build.VERSION_CODES#VANILLA_ICE_CREAM}, the preferred payment service
+ * no longer exists and is replaced by {@link android.app.role.RoleManager#ROLE_WALLET}. This
+ * will return the description for one of the services registered by the role holder (if any).
+ * If there are multiple services registered, it is unspecified which of those will be used
+ * to obtain the service description here.
*
- * @deprecated see {@link android.app.role.RoleManager#ROLE_WALLET}. The definition of the
- * Preferred Payment service is no longer valid. All routings will go to the Wallet Holder app.
- * A payment service will be selected automatically based on registered AIDs. In the case of
- * multiple services that register for the same payment AID, the selection will be done on
- * an alphabetical order based on the component names.
+ * @return the preferred payment service description
*/
@RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO)
- @Deprecated
@Nullable
public CharSequence getDescriptionForPreferredPaymentService() {
try {