Deprecate methods on CardEmulation in favor of Wallet Role.
Bug: 315194263
Test: local
Change-Id: I1fe8d6a7cc05086040ea662a3bc57b50aff4916c
diff --git a/nfc/Android.bp b/nfc/Android.bp
index 7136866..767d156 100644
--- a/nfc/Android.bp
+++ b/nfc/Android.bp
@@ -37,6 +37,7 @@
name: "framework-nfc",
libs: [
"unsupportedappusage", // for android.compat.annotation.UnsupportedAppUsage
+ "framework-permission-s",
],
static_libs: [
"android.nfc.flags-aconfig-java",
diff --git a/nfc/api/current.txt b/nfc/api/current.txt
index 845a8f9..aaf41af 100644
--- a/nfc/api/current.txt
+++ b/nfc/api/current.txt
@@ -194,13 +194,13 @@
package android.nfc.cardemulation {
public final class CardEmulation {
- method public boolean categoryAllowsForegroundPreference(String);
+ method @Deprecated 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 @Nullable @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public CharSequence getDescriptionForPreferredPaymentService();
+ method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public CharSequence getDescriptionForPreferredPaymentService();
method public static android.nfc.cardemulation.CardEmulation getInstance(android.nfc.NfcAdapter);
- method @Nullable @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public String getRouteDestinationForPreferredPaymentService();
- method public int getSelectionModeForCategory(String);
+ method @Deprecated @Nullable @RequiresPermission(android.Manifest.permission.NFC_PREFERRED_PAYMENT_INFO) public String getRouteDestinationForPreferredPaymentService();
+ method @Deprecated 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 1f41b81..4fc71b70 100644
--- a/nfc/java/android/nfc/cardemulation/CardEmulation.java
+++ b/nfc/java/android/nfc/cardemulation/CardEmulation.java
@@ -27,6 +27,7 @@
import android.annotation.UserHandleAware;
import android.annotation.UserIdInt;
import android.app.Activity;
+import android.app.role.RoleManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -278,13 +279,22 @@
* @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;
- Context contextAsUser = mContext.createContextAsUser(
- UserHandle.of(UserHandle.myUserId()), 0);
try {
preferForeground = Settings.Secure.getInt(
contextAsUser.getContentResolver(),
@@ -309,7 +319,12 @@
* to pick a service if there is a conflict.
* @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;
@@ -778,8 +793,15 @@
* (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 {
@@ -822,8 +844,15 @@
* Returns a user-visible description of the preferred payment service.
*
* @return the preferred payment service description
+ *
+ * @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 CharSequence getDescriptionForPreferredPaymentService() {
try {