summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2012-10-04 16:52:51 -0700
committerMartijn Coenen <maco@google.com>2012-10-11 15:17:24 -0700
commita949c74321b17f8ef1c93692064969f60815c7e4 (patch)
tree4cc361632b88b096357b1d51f4466eece1423ab3 /src
parentae1b16cf81e49a438b7a86efcdd8d83c1c0666d1 (diff)
downloadpackages_apps_nfc-a949c74321b17f8ef1c93692064969f60815c7e4.zip
packages_apps_nfc-a949c74321b17f8ef1c93692064969f60815c7e4.tar.gz
packages_apps_nfc-a949c74321b17f8ef1c93692064969f60815c7e4.tar.bz2
Fast-fail SE open if it's activated in listen mode.
Users of the NFC-extras API usually want to talk to the SE once it has completed a transaction. The hard part is knowing when it is safe to connect to the SE, as it will break the connection to any reader. And when relinquishing the connection to the SE, the reader may find the device again and process another transaction. This patch adds the following two conditions for allowing to open the SE from the DH: 1) The SE may not be activated in listen mode 2) The RF field must have been off for at least 50 ms Bug: 7275484 Change-Id: Ibde32a8e2aef045c17ab76ef08c72f96edfedaef
Diffstat (limited to 'src')
-rw-r--r--src/com/android/nfc/DeviceHost.java10
-rwxr-xr-xsrc/com/android/nfc/NfcService.java34
2 files changed, 44 insertions, 0 deletions
diff --git a/src/com/android/nfc/DeviceHost.java b/src/com/android/nfc/DeviceHost.java
index b7336ad..fa3d17c 100644
--- a/src/com/android/nfc/DeviceHost.java
+++ b/src/com/android/nfc/DeviceHost.java
@@ -49,6 +49,16 @@ public interface DeviceHost {
public void onRemoteFieldDeactivated();
+ /**
+ * Notifies that the SE has been activated in listen mode
+ */
+ public void onSeListenActivated();
+
+ /**
+ * Notifies that the SE has been deactivated
+ */
+ public void onSeListenDeactivated();
+
public void onSeApduReceived(byte[] apdu);
public void onSeEmvCardRemoval();
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index 62512e5..d7bb2ef 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -112,6 +112,8 @@ public class NfcService extends Application implements DeviceHostListener {
static final int MSG_SE_APDU_RECEIVED = 10;
static final int MSG_SE_EMV_CARD_REMOVAL = 11;
static final int MSG_SE_MIFARE_ACCESS = 12;
+ static final int MSG_SE_LISTEN_ACTIVATED = 13;
+ static final int MSG_SE_LISTEN_DEACTIVATED = 14;
static final int TASK_ENABLE = 1;
static final int TASK_DISABLE = 2;
@@ -158,6 +160,11 @@ public class NfcService extends Application implements DeviceHostListener {
public static final String EXTRA_MIFARE_BLOCK =
"com.android.nfc_extras.extra.MIFARE_BLOCK";
+ public static final String ACTION_SE_LISTEN_ACTIVATED =
+ "com.android.nfc_extras.action.SE_LISTEN_ACTIVATED";
+ public static final String ACTION_SE_LISTEN_DEACTIVATED =
+ "com.android.nfc_extras.action.SE_LISTEN_DEACTIVATED";
+
// NFC Execution Environment
// fields below are protected by this
private NativeNfcSecureElement mSecureElement;
@@ -275,6 +282,17 @@ public class NfcService extends Application implements DeviceHostListener {
}
@Override
+ public void onSeListenActivated() {
+ sendMessage(NfcService.MSG_SE_LISTEN_ACTIVATED, null);
+ }
+
+ @Override
+ public void onSeListenDeactivated() {
+ sendMessage(NfcService.MSG_SE_LISTEN_DEACTIVATED, null);
+ }
+
+
+ @Override
public void onSeApduReceived(byte[] apdu) {
sendMessage(NfcService.MSG_SE_APDU_RECEIVED, apdu);
}
@@ -1743,6 +1761,22 @@ public class NfcService extends Application implements DeviceHostListener {
break;
}
+ case MSG_SE_LISTEN_ACTIVATED: {
+ if (DBG) Log.d(TAG, "SE LISTEN MODE ACTIVATED");
+ Intent listenModeActivated = new Intent();
+ listenModeActivated.setAction(ACTION_SE_LISTEN_ACTIVATED);
+ sendSeBroadcast(listenModeActivated);
+ break;
+ }
+
+ case MSG_SE_LISTEN_DEACTIVATED: {
+ if (DBG) Log.d(TAG, "SE LISTEN MODE DEACTIVATED");
+ Intent listenModeDeactivated = new Intent();
+ listenModeDeactivated.setAction(ACTION_SE_LISTEN_DEACTIVATED);
+ sendSeBroadcast(listenModeDeactivated);
+ break;
+ }
+
default:
Log.e(TAG, "Unknown message received");
break;