summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jack Yu <jackcwyu@google.com> 2019-04-18 14:34:28 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2019-04-18 14:34:28 +0000
commit74c8818d79b9276e70566cdffb86c15ed435b0e7 (patch)
tree4bd996e5f240f48e55c53e3f30af8ce342d13d5e
parentb5fa3532db05f05bf03fa00034e95e87e4bed3bc (diff)
parentc48f223018ccdb1ed63bff1c410cbf41a6fcb322 (diff)
Merge "Update Multi-OffHost related API definition" into qt-dev
-rw-r--r--api/current.txt5
-rw-r--r--core/java/android/nfc/NfcAdapter.java1
-rw-r--r--core/java/android/nfc/cardemulation/ApduServiceInfo.java16
-rw-r--r--core/java/android/nfc/cardemulation/CardEmulation.java23
-rw-r--r--core/res/res/values/attrs.xml2
5 files changed, 36 insertions, 11 deletions
diff --git a/api/current.txt b/api/current.txt
index cb38e1220276..b434776a4403 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -30624,7 +30624,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();
@@ -30718,10 +30717,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 1be6c4bce36a..bc698f97738a 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 6f9858ced34c..4675600fe1d6 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 c13f64e833c5..aa93611062f5 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;
@@ -362,6 +363,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) {
@@ -393,7 +396,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
@@ -405,9 +410,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;
@@ -423,6 +438,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 ce1e5c3cf794..4c7f503ceb0f 100644
--- a/core/res/res/values/attrs.xml
+++ b/core/res/res/values/attrs.xml
@@ -3778,7 +3778,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