diff options
| author | 2019-03-26 21:56:28 +0800 | |
|---|---|---|
| committer | 2019-04-16 16:55:07 -0700 | |
| commit | dbca60beb9f7c6ea17d49f022f1b0abc670f40ff (patch) | |
| tree | b8e26d48ddec5f9442d89ca1e7447d6e2f1a02db | |
| parent | bc17e4b328a4ce1146c7b23798c7aa7f03ee0c6d (diff) | |
Update Multi-OffHost related API definition
Test: build pass
Bug: 128831640
Change-Id: Ia0a8ec38b0c4e60df18f727b0f5a7fdba84fe9e1
| -rwxr-xr-x | api/current.txt | 5 | ||||
| -rw-r--r-- | core/java/android/nfc/NfcAdapter.java | 1 | ||||
| -rw-r--r-- | core/java/android/nfc/cardemulation/ApduServiceInfo.java | 16 | ||||
| -rw-r--r-- | core/java/android/nfc/cardemulation/CardEmulation.java | 23 | ||||
| -rw-r--r-- | core/res/res/values/attrs.xml | 2 |
5 files changed, 36 insertions, 11 deletions
diff --git a/api/current.txt b/api/current.txt index b7df38068263..4dcba8348d8c 100755 --- a/api/current.txt +++ b/api/current.txt @@ -29116,7 +29116,6 @@ package android.nfc { method @Deprecated public void enableForegroundNdefPush(android.app.Activity, android.nfc.NdefMessage); method public void enableReaderMode(android.app.Activity, android.nfc.NfcAdapter.ReaderCallback, int, android.os.Bundle); method public static android.nfc.NfcAdapter getDefaultAdapter(android.content.Context); - method @NonNull public java.util.List<java.lang.String> getSupportedOffHostSecureElements(); method public boolean ignore(android.nfc.Tag, int, android.nfc.NfcAdapter.OnTagRemovedListener, android.os.Handler); method @Deprecated public boolean invokeBeam(android.app.Activity); method public boolean isEnabled(); @@ -29209,10 +29208,10 @@ package android.nfc.cardemulation { method public boolean isDefaultServiceForCategory(android.content.ComponentName, String); method public boolean registerAidsForService(android.content.ComponentName, String, java.util.List<java.lang.String>); method public boolean removeAidsForService(android.content.ComponentName, String); - method public boolean setOffHostForService(@NonNull android.content.ComponentName, @NonNull String); + method @RequiresPermission(android.Manifest.permission.NFC) @NonNull public boolean setOffHostForService(@NonNull android.content.ComponentName, @NonNull String); method public boolean setPreferredService(android.app.Activity, android.content.ComponentName); method public boolean supportsAidPrefixRegistration(); - method public boolean unsetOffHostForService(@NonNull android.content.ComponentName); + method @RequiresPermission(android.Manifest.permission.NFC) @NonNull public boolean unsetOffHostForService(@NonNull android.content.ComponentName); method public boolean unsetPreferredService(android.app.Activity); field public static final String ACTION_CHANGE_DEFAULT = "android.nfc.cardemulation.action.ACTION_CHANGE_DEFAULT"; field public static final String CATEGORY_OTHER = "other"; diff --git a/core/java/android/nfc/NfcAdapter.java b/core/java/android/nfc/NfcAdapter.java index b90a60e5bca0..eb347e7e253e 100644 --- a/core/java/android/nfc/NfcAdapter.java +++ b/core/java/android/nfc/NfcAdapter.java @@ -526,6 +526,7 @@ public final class NfcAdapter { * @return List<String> containing secure elements on the device which supports * off host card emulation. eSE for Embedded secure element, * SIM for UICC and so on. + * @hide */ public @NonNull List<String> getSupportedOffHostSecureElements() { List<String> offHostSE = new ArrayList<String>(); diff --git a/core/java/android/nfc/cardemulation/ApduServiceInfo.java b/core/java/android/nfc/cardemulation/ApduServiceInfo.java index 911ec8430ddd..ab0a0ef517c7 100644 --- a/core/java/android/nfc/cardemulation/ApduServiceInfo.java +++ b/core/java/android/nfc/cardemulation/ApduServiceInfo.java @@ -432,7 +432,15 @@ public final class ApduServiceInfo implements Parcelable { mDynamicAidGroups.put(aidGroup.getCategory(), aidGroup); } - @UnsupportedAppUsage + /** + * Sets the off host Secure Element. + * @param offHost Secure Element to set. Only accept strings with prefix SIM or prefix eSE. + * Ref: GSMA TS.26 - NFC Handset Requirements + * TS26_NFC_REQ_069: For UICC, Secure Element Name SHALL be SIM[smartcard slot] + * (e.g. SIM/SIM1, SIM2… SIMn). + * TS26_NFC_REQ_070: For embedded SE, Secure Element Name SHALL be eSE[number] + * (e.g. eSE/eSE1, eSE2, etc.). + */ public void setOffHostSecureElement(String offHost) { mOffHostName = offHost; } @@ -441,7 +449,6 @@ public final class ApduServiceInfo implements Parcelable { * Resets the off host Secure Element to statically defined * by the service in the manifest file. */ - @UnsupportedAppUsage public void unsetOffHostSecureElement() { mOffHostName = mStaticOffHostName; } @@ -581,10 +588,9 @@ public final class ApduServiceInfo implements Parcelable { pw.println(" On Host Service"); } else { pw.println(" Off-host Service"); - pw.println(" " + "Current off-host SE" + mOffHostName - + " static off-host: " + mOffHostName); + pw.println(" " + "Current off-host SE:" + mOffHostName + + " static off-host SE:" + mStaticOffHostName); } - pw.println(" Static off-host Secure Element:"); pw.println(" Static AID groups:"); for (AidGroup group : mStaticAidGroups.values()) { pw.println(" Category: " + group.category); diff --git a/core/java/android/nfc/cardemulation/CardEmulation.java b/core/java/android/nfc/cardemulation/CardEmulation.java index f23dc2da291a..4c9885c402fa 100644 --- a/core/java/android/nfc/cardemulation/CardEmulation.java +++ b/core/java/android/nfc/cardemulation/CardEmulation.java @@ -17,6 +17,7 @@ package android.nfc.cardemulation; import android.annotation.NonNull; +import android.annotation.RequiresPermission; import android.annotation.SdkConstant; import android.annotation.SdkConstant.SdkConstantType; import android.app.Activity; @@ -360,6 +361,8 @@ public final class CardEmulation { * @param service The component name of the service * @return whether the registration was successful. */ + @RequiresPermission(android.Manifest.permission.NFC) + @NonNull public boolean unsetOffHostForService(@NonNull ComponentName service) { NfcAdapter adapter = NfcAdapter.getDefaultAdapter(mContext); if (adapter == null) { @@ -391,7 +394,9 @@ public final class CardEmulation { * through the manifest, or dynamically by using this API), * it will be replaced with this one. All AIDs registered by * this service will be re-routed to this Secure Element if - * successful. + * successful. AIDs that was statically assigned using manifest + * will re-route to off-host SE that stated in manifest after NFC + * toggle. * * <p>Note that you can only set off-host SE for a service that * is running under the same UID as the caller of this API. Typically @@ -403,9 +408,19 @@ public final class CardEmulation { * exists on the device. * * @param service The component name of the service - * @param offHostSecureElement Secure Element to register the AID to + * @param offHostSecureElement Secure Element to register the AID to. Only accept strings with + * prefix SIM or prefix eSE. + * Ref: GSMA TS.26 - NFC Handset Requirements + * TS26_NFC_REQ_069: For UICC, Secure Element Name SHALL be + * SIM[smartcard slot] + * (e.g. SIM/SIM1, SIM2… SIMn). + * TS26_NFC_REQ_070: For embedded SE, Secure Element Name SHALL be + * eSE[number] + * (e.g. eSE/eSE1, eSE2, etc.). * @return whether the registration was successful. */ + @RequiresPermission(android.Manifest.permission.NFC) + @NonNull public boolean setOffHostForService(@NonNull ComponentName service, @NonNull String offHostSecureElement) { boolean validSecureElement = false; @@ -421,6 +436,10 @@ public final class CardEmulation { return false; } + if (!offHostSecureElement.startsWith("eSE") && !offHostSecureElement.startsWith("SIM")) { + return false; + } + if (offHostSecureElement.equals("eSE")) { offHostSecureElement = "eSE1"; } else if (offHostSecureElement.equals("SIM")) { diff --git a/core/res/res/values/attrs.xml b/core/res/res/values/attrs.xml index 3fe8689b8552..e074db603f04 100644 --- a/core/res/res/values/attrs.xml +++ b/core/res/res/values/attrs.xml @@ -3691,7 +3691,7 @@ the settings for this service. --> <attr name="settingsActivity"/> <!-- Secure Element which the AIDs should be routed to --> - <attr name="secureElementName"/> + <attr name="secureElementName" format="string"/> </declare-styleable> <!-- Specify one or more <code>aid-group</code> elements inside a |