diff options
| author | 2024-03-25 17:06:48 +0000 | |
|---|---|---|
| committer | 2024-03-25 17:06:48 +0000 | |
| commit | 30ec015ea58d83e7ad22aab5b631f843fae99b5d (patch) | |
| tree | 5de9ca15e995ee1fdd99ea6e525b5cdba803564f | |
| parent | cfdf25ed5f7f42b92d47c3f0a652fb4bf8d64678 (diff) | |
| parent | b2d0a68b2953e7df4206058c5caf004ca270f90b (diff) | |
Merge "Un-deprecate some NFC methods" into main
| -rw-r--r-- | nfc/api/current.txt | 8 | ||||
| -rw-r--r-- | nfc/java/android/nfc/cardemulation/CardEmulation.java | 50 |
2 files changed, 30 insertions, 28 deletions
diff --git a/nfc/api/current.txt b/nfc/api/current.txt index 80b2be2567a7..6d4cc3a9ca44 100644 --- a/nfc/api/current.txt +++ b/nfc/api/current.txt @@ -194,13 +194,13 @@ package android.nfc { 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 67697a429a32..de9eada18104 100644 --- a/nfc/java/android/nfc/cardemulation/CardEmulation.java +++ b/nfc/java/android/nfc/cardemulation/CardEmulation.java @@ -36,6 +36,7 @@ import android.nfc.Constants; 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 @@ public final class CardEmulation { } /** + * <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 @@ public final class CardEmulation { * 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 @@ public final class CardEmulation { /** * 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 @@ public final class CardEmulation { * (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 @@ public final class CardEmulation { /** * 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 { |