summaryrefslogtreecommitdiffstats
path: root/nci
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2012-12-13 16:44:23 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2012-12-13 16:44:23 -0800
commitbe1939b4b6003ac7a65fcb95a3912f5e1ce8e75f (patch)
tree694dc2546dd2397528d4b78d067716f451792662 /nci
parent525c260303268a83da4c3413b953d13c9084e834 (diff)
downloadpackages_apps_nfc-be1939b4b6003ac7a65fcb95a3912f5e1ce8e75f.zip
packages_apps_nfc-be1939b4b6003ac7a65fcb95a3912f5e1ce8e75f.tar.gz
packages_apps_nfc-be1939b4b6003ac7a65fcb95a3912f5e1ce8e75f.tar.bz2
Snapshot b80adb2c263702442cf2f2d771168400e6ceb9f8
Change-Id: I391d8e1be1a61e68b01f0db371dbb4ed3e5b5933
Diffstat (limited to 'nci')
-rwxr-xr-xnci/jni/NativeNfcManager.cpp10
-rw-r--r--nci/jni/PeerToPeer.cpp4
-rwxr-xr-xnci/jni/SecureElement.cpp72
3 files changed, 43 insertions, 43 deletions
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp
index f15c92f..61fc052 100755
--- a/nci/jni/NativeNfcManager.cpp
+++ b/nci/jni/NativeNfcManager.cpp
@@ -1276,6 +1276,7 @@ static void nfcManager_doDeselectSecureElement(JNIEnv *e, jobject o)
{
ALOGD ("%s: enter", __FUNCTION__);
bool stat = false;
+ bool bRestartDiscovery = false;
if (! sIsSecElemSelected)
{
@@ -1290,6 +1291,12 @@ static void nfcManager_doDeselectSecureElement(JNIEnv *e, jobject o)
goto TheEnd;
}
+ if (sRfEnabled) {
+ // Stop RF Discovery if we were polling
+ startRfDiscovery (false);
+ bRestartDiscovery = true;
+ }
+
stat = SecureElement::getInstance().routeToDefault ();
sIsSecElemSelected = false;
@@ -1299,6 +1306,9 @@ static void nfcManager_doDeselectSecureElement(JNIEnv *e, jobject o)
SecureElement::getInstance().deactivate (0xABCDEF);
TheEnd:
+ if (bRestartDiscovery)
+ startRfDiscovery (true);
+
//if nothing is active after this, then tell the controller to power down
if (! PowerSwitch::getInstance ().setModeOff (PowerSwitch::SE_ROUTING))
PowerSwitch::getInstance ().setLevel (PowerSwitch::LOW_POWER);
diff --git a/nci/jni/PeerToPeer.cpp b/nci/jni/PeerToPeer.cpp
index 7994e2a..b40e366 100644
--- a/nci/jni/PeerToPeer.cpp
+++ b/nci/jni/PeerToPeer.cpp
@@ -1431,9 +1431,9 @@ void PeerToPeer::nfaClientCallback (tNFA_P2P_EVT p2pEvent, tNFA_P2P_EVT_DATA* ev
if ((pConn = sP2p.findConnection(eventData->disc.handle)) == NULL)
{
// If no connection, may be a client that is trying to connect
- if ((pClient = sP2p.findClientCon ((tNFA_HANDLE)NFA_HANDLE_INVALID)) == NULL)
+ if ((pClient = sP2p.findClient (eventData->disc.handle)) == NULL)
{
- ALOGE ("%s: NFA_P2P_DISC_EVT: can't find conn for NFA handle: 0x%04x", fn, eventData->disc.handle);
+ ALOGE ("%s: NFA_P2P_DISC_EVT: can't find client for NFA handle: 0x%04x", fn, eventData->disc.handle);
return;
}
// Unblock createDataLinkConn()
diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp
index 3c9256b..a4c4d57 100755
--- a/nci/jni/SecureElement.cpp
+++ b/nci/jni/SecureElement.cpp
@@ -156,12 +156,12 @@ bool SecureElement::initialize (nfc_jni_native_data* native)
if (GetNumValue("NFA_HCI_DEFAULT_DEST_GATE", &num, sizeof(num)))
mDestinationGate = num;
- ALOGD ("%s: Default destination gate: %d", fn, mDestinationGate);
+ ALOGD ("%s: Default destination gate: 0x%X", fn, mDestinationGate);
// active SE, if not set active all SEs
if (GetNumValue("ACTIVE_SE", &num, sizeof(num)))
mActiveSeOverride = num;
- ALOGD ("%s: Active SE override: %d", fn, mActiveSeOverride);
+ ALOGD ("%s: Active SE override: 0x%X", fn, mActiveSeOverride);
if (GetNumValue("OBERTHUR_WARM_RESET_COMMAND", &num, sizeof(num)))
{
@@ -442,7 +442,7 @@ jintArray SecureElement::getListOfEeHandles (JNIEnv* e)
** Function: activate
**
** Description: Turn on the secure element.
-** seID: ID of secure element.
+** seID: ID of secure element; 0xF3 or 0xF4.
**
** Returns: True if ok.
**
@@ -474,24 +474,16 @@ bool SecureElement::activate (jint seID)
return false;
}
- mActiveEeHandle = getDefaultEeHandle();
- ALOGD ("%s: active ee h=0x%X, override se=0x%X", fn, mActiveEeHandle, mActiveSeOverride);
- if (mActiveEeHandle == NFA_HANDLE_INVALID)
- {
- ALOGE ("%s: ee not found", fn);
- return false;
- }
-
- UINT16 override_se = 0;
+ UINT16 overrideEeHandle = 0;
if (mActiveSeOverride)
- override_se = NFA_HANDLE_GROUP_EE | mActiveSeOverride;
+ overrideEeHandle = NFA_HANDLE_GROUP_EE | mActiveSeOverride;
if (mRfFieldIsOn) {
ALOGE("%s: RF field indication still on, resetting", fn);
mRfFieldIsOn = false;
}
- ALOGD ("%s: override seid=0x%X", fn, override_se );
+ ALOGD ("%s: override ee h=0x%X", fn, overrideEeHandle );
//activate every discovered secure element
for (int index=0; index < mActualNumEe; index++)
{
@@ -499,7 +491,7 @@ bool SecureElement::activate (jint seID)
if ((eeItem.ee_handle == EE_HANDLE_0xF3) || (eeItem.ee_handle == EE_HANDLE_0xF4))
{
- if (override_se && (override_se != eeItem.ee_handle) )
+ if (overrideEeHandle && (overrideEeHandle != eeItem.ee_handle) )
continue; // do not enable all SEs; only the override one
if (eeItem.ee_status != NFC_NFCEE_STATUS_INACTIVE)
@@ -524,18 +516,11 @@ bool SecureElement::activate (jint seID)
}
} //for
- for (UINT8 xx = 0; xx < mActualNumEe; xx++)
- {
- if ((mEeInfo[xx].num_interface != 0) && (mEeInfo[xx].ee_interface[0] != NCI_NFCEE_INTERFACE_HCI_ACCESS) &&
- (mEeInfo[xx].ee_status != NFC_NFCEE_STATUS_INACTIVE))
- {
- mActiveEeHandle = mEeInfo[xx].ee_handle;
- break;
- }
- }
-
- ALOGD ("%s: exit; ok=%u", fn, numActivatedEe > 0);
- return numActivatedEe > 0;
+ mActiveEeHandle = getDefaultEeHandle();
+ if (mActiveEeHandle == NFA_HANDLE_INVALID)
+ ALOGE ("%s: ee handle not found", fn);
+ ALOGD ("%s: exit; active ee h=0x%X", fn, mActiveEeHandle);
+ return mActiveEeHandle != NFA_HANDLE_INVALID;
}
@@ -544,7 +529,7 @@ bool SecureElement::activate (jint seID)
** Function: deactivate
**
** Description: Turn off the secure element.
-** seID: ID of secure element.
+** seID: ID of secure element; 0xF3 or 0xF4.
**
** Returns: True if ok.
**
@@ -1417,7 +1402,7 @@ void SecureElement::adjustProtocolRoutes (RouteDataSet::Database* db, RouteSelec
{
tNFA_HANDLE eeHandle = NFA_EE_HANDLE_DH;
if (routeSelection == SecElemRoute)
- eeHandle = getDefaultEeHandle ();
+ eeHandle = mActiveEeHandle;
ALOGD ("%s: route to default EE h=0x%X", fn, eeHandle);
SyncEventGuard guard (mRoutingEvent);
nfaStat = NFA_EeSetDefaultProtoRouting (eeHandle, protoMask, 0, 0);
@@ -1573,7 +1558,7 @@ void SecureElement::adjustTechnologyRoutes (RouteDataSet::Database* db, RouteSel
{
tNFA_HANDLE eeHandle = NFA_EE_HANDLE_DH;
if (routeSelection == SecElemRoute)
- eeHandle = getDefaultEeHandle ();
+ eeHandle = mActiveEeHandle;
ALOGD ("%s: route to default EE h=0x%X", fn, eeHandle);
SyncEventGuard guard (mRoutingEvent);
nfaStat = NFA_EeSetDefaultTechRouting (eeHandle, techMask, 0, 0);
@@ -1975,26 +1960,31 @@ tNFA_EE_INFO *SecureElement::findEeByHandle (tNFA_HANDLE eeHandle)
*******************************************************************************/
tNFA_HANDLE SecureElement::getDefaultEeHandle ()
{
+ UINT16 overrideEeHandle = NFA_HANDLE_GROUP_EE | mActiveSeOverride;
// Find the first EE that is not the HCI Access i/f.
for (UINT8 xx = 0; xx < mActualNumEe; xx++)
{
- if ((mEeInfo[xx].num_interface != 0) && (mEeInfo[xx].ee_interface[0] != NCI_NFCEE_INTERFACE_HCI_ACCESS) )
+ if (mActiveSeOverride && (overrideEeHandle != mEeInfo[xx].ee_handle))
+ continue; //skip all the EE's that are ignored
+ if ((mEeInfo[xx].num_interface != 0) &&
+ (mEeInfo[xx].ee_interface[0] != NCI_NFCEE_INTERFACE_HCI_ACCESS) &&
+ (mEeInfo[xx].ee_status != NFC_NFCEE_STATUS_INACTIVE))
return (mEeInfo[xx].ee_handle);
}
return NFA_HANDLE_INVALID;
}
- /*******************************************************************************
- **
- ** Function: findUiccByHandle
- **
- ** Description: Find information about an execution environment.
- ** eeHandle: Handle of the execution environment.
- **
- ** Returns: Information about the execution environment.
- **
- *******************************************************************************/
+/*******************************************************************************
+**
+** Function: findUiccByHandle
+**
+** Description: Find information about an execution environment.
+** eeHandle: Handle of the execution environment.
+**
+** Returns: Information about the execution environment.
+**
+*******************************************************************************/
tNFA_EE_DISCOVER_INFO *SecureElement::findUiccByHandle (tNFA_HANDLE eeHandle)
{
for (UINT8 index = 0; index < mUiccInfo.num_ee; index++)