summaryrefslogtreecommitdiffstats
path: root/nci
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2014-07-25 14:46:11 -0700
committerMartijn Coenen <maco@google.com>2014-07-25 16:11:52 -0700
commitf5c979220fadb2c3ac0bca09e16d0d281ed20eb2 (patch)
treeaabb813a8f798539075175f3d2d99cc8b2fd4ca1 /nci
parent977869cd2777729c16beeb6b10d6fe31ca9c122b (diff)
downloadandroid_packages_apps_Nfc-f5c979220fadb2c3ac0bca09e16d0d281ed20eb2.tar.gz
android_packages_apps_Nfc-f5c979220fadb2c3ac0bca09e16d0d281ed20eb2.tar.bz2
android_packages_apps_Nfc-f5c979220fadb2c3ac0bca09e16d0d281ed20eb2.zip
Support for configuring SE listen technologies.
If the config file specified an SE to use, configure its listen technologies correctly. Also, fix commitRouting() to actually commit the configuration. Bug: 16517161 Change-Id: I1283fcb3f855c89a8b238be857bd56f06a14138f
Diffstat (limited to 'nci')
-rwxr-xr-xnci/jni/NativeNfcManager.cpp19
-rw-r--r--nci/jni/RoutingManager.cpp55
-rw-r--r--nci/jni/RoutingManager.h4
-rwxr-xr-xnci/src/com/android/nfc/dhimpl/NativeNfcManager.java2
4 files changed, 76 insertions, 4 deletions
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp
index c02bd677..fa1b2d21 100755
--- a/nci/jni/NativeNfcManager.cpp
+++ b/nci/jni/NativeNfcManager.cpp
@@ -772,6 +772,22 @@ static jboolean nfcManager_unrouteAid (JNIEnv* e, jobject, jbyteArray aid)
/*******************************************************************************
**
+** Function: nfcManager_commitRouting
+**
+** Description: Sends the AID routing table to the controller
+** e: JVM environment.
+** o: Java object.
+**
+** Returns: True if ok.
+**
+*******************************************************************************/
+static jboolean nfcManager_commitRouting (JNIEnv* e, jobject)
+{
+ return RoutingManager::getInstance().commitRouting();
+}
+
+/*******************************************************************************
+**
** Function: nfcManager_doInitialize
**
** Description: Turn on NFC.
@@ -1574,6 +1590,9 @@ static JNINativeMethod gMethods[] =
{"unrouteAid", "([B)Z",
(void*) nfcManager_unrouteAid},
+ {"commitRouting", "()Z",
+ (void*) nfcManager_commitRouting},
+
{"doEnableDiscovery", "(IZZZZ)V",
(void*) nfcManager_enableDiscovery},
diff --git a/nci/jni/RoutingManager.cpp b/nci/jni/RoutingManager.cpp
index 6ecf6309..3a0e744c 100644
--- a/nci/jni/RoutingManager.cpp
+++ b/nci/jni/RoutingManager.cpp
@@ -42,13 +42,19 @@ RoutingManager::RoutingManager ()
static const char fn [] = "RoutingManager::RoutingManager()";
unsigned long num = 0;
+ // Get the active SE
+ if (GetNumValue("ACTIVE_SE", &num, sizeof(num)))
+ mActiveSe = num;
+ else
+ mActiveSe = 0x00;
+
// Get the "default" route
if (GetNumValue("DEFAULT_ISODEP_ROUTE", &num, sizeof(num)))
mDefaultEe = num;
else
mDefaultEe = 0x00;
-
ALOGD("%s: default route is 0x%02X", fn, mDefaultEe);
+
// Get the default "off-host" route. This is hard-coded at the Java layer
// but we can override it here to avoid forcing Java changes.
if (GetNumValue("DEFAULT_OFFHOST_ROUTE", &num, sizeof(num)))
@@ -57,6 +63,9 @@ RoutingManager::RoutingManager ()
mOffHostEe = 0xf4;
ALOGD("%s: mOffHostEe=0x%02X", fn, mOffHostEe);
+
+ memset (&mEeInfo, 0, sizeof(mEeInfo));
+ mReceivedEeInfo = false;
}
RoutingManager::~RoutingManager ()
@@ -84,8 +93,39 @@ bool RoutingManager::initialize (nfc_jni_native_data* native)
mRxDataBuffer.clear ();
+ if (mActiveSe != 0) {
+ {
+ // Wait for EE info if needed
+ SyncEventGuard guard (mEeInfoEvent);
+ if (!mReceivedEeInfo)
+ {
+ ALOGE("Waiting for EE info");
+ mEeInfoEvent.wait();
+ }
+ }
+ for (UINT8 i = 0; i < mEeInfo.num_ee; i++)
+ {
+ ALOGD ("%s EE[%u] Handle: 0x%04x techA: 0x%02x techB: 0x%02x techF: 0x%02x techBprime: 0x%02x",
+ fn, i, mEeInfo.ee_disc_info[i].ee_handle,
+ mEeInfo.ee_disc_info[i].la_protocol,
+ mEeInfo.ee_disc_info[i].lb_protocol,
+ mEeInfo.ee_disc_info[i].lf_protocol,
+ mEeInfo.ee_disc_info[i].lbp_protocol);
+ if (mEeInfo.ee_disc_info[i].ee_handle == (mActiveSe | NFA_HANDLE_GROUP_EE))
+ {
+ int tech_mask = 0x00;
+ if (mEeInfo.ee_disc_info[i].la_protocol != 0) tech_mask |= NFA_TECHNOLOGY_MASK_A;
+ if (mEeInfo.ee_disc_info[i].lb_protocol != 0) tech_mask |= NFA_TECHNOLOGY_MASK_B;
+ ALOGD("Configuring tech mask 0x%02x on EE 0x%04x", tech_mask, mEeInfo.ee_disc_info[i].ee_handle);
+ nfaStat = NFA_CeConfigureUiccListenTech(mEeInfo.ee_disc_info[i].ee_handle, tech_mask);
+ if (nfaStat != NFA_STATUS_OK)
+ ALOGE ("Failed to configure UICC listen technologies.");
+ }
+ }
+ }
+
// Tell the host-routing to only listen on Nfc-A
- nfaStat = NFA_CeSetIsoDepListenTech(0x01);
+ nfaStat = NFA_CeSetIsoDepListenTech(NFA_TECHNOLOGY_MASK_A);
if (nfaStat != NFA_STATUS_OK)
ALOGE ("Failed to configure CE IsoDep technologies");
@@ -93,6 +133,7 @@ bool RoutingManager::initialize (nfc_jni_native_data* native)
nfaStat = NFA_CeRegisterAidOnDH (NULL, 0, stackCallback);
if (nfaStat != NFA_STATUS_OK)
ALOGE("Failed to register wildcard AID for DH");
+
return true;
}
@@ -404,8 +445,14 @@ void RoutingManager::nfaEeCallback (tNFA_EE_EVT event, tNFA_EE_CBACK_DATA* event
break;
case NFA_EE_DISCOVER_REQ_EVT:
- ALOGD ("%s: NFA_EE_DISCOVER_REQ_EVT; status=0x%X; num ee=%u", __FUNCTION__,
- eventData->discover_req.status, eventData->discover_req.num_ee);
+ {
+ ALOGD ("%s: NFA_EE_DISCOVER_REQ_EVT; status=0x%X; num ee=%u", __FUNCTION__,
+ eventData->discover_req.status, eventData->discover_req.num_ee);
+ SyncEventGuard guard (routingManager.mEeInfoEvent);
+ memcpy (&routingManager.mEeInfo, &eventData->discover_req, sizeof(routingManager.mEeInfo));
+ routingManager.mReceivedEeInfo = true;
+ routingManager.mEeInfoEvent.notifyOne();
+ }
break;
case NFA_EE_NO_CB_ERR_EVT:
diff --git a/nci/jni/RoutingManager.h b/nci/jni/RoutingManager.h
index bf516d86..ccd497fa 100644
--- a/nci/jni/RoutingManager.h
+++ b/nci/jni/RoutingManager.h
@@ -62,9 +62,13 @@ private:
nfc_jni_native_data* mNativeData;
int mDefaultEe;
int mOffHostEe;
+ int mActiveSe;
+ bool mReceivedEeInfo;
+ tNFA_EE_DISCOVER_REQ mEeInfo;
static const JNINativeMethod sMethods [];
SyncEvent mEeRegisterEvent;
SyncEvent mRoutingEvent;
SyncEvent mEeUpdateEvent;
+ SyncEvent mEeInfoEvent;
};
diff --git a/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java b/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
index 650417a4..080bca01 100755
--- a/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
+++ b/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
@@ -95,6 +95,8 @@ public class NativeNfcManager implements DeviceHost {
@Override
public native boolean unrouteAid(byte[] aid);
+ @Override
+ public native boolean commitRouting();
private native void doEnableDiscovery(int techMask,
boolean enableLowPowerPolling,