aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornxpandroid <srikrishna.pramoda@nxp.com>2017-09-14 12:39:32 +0530
committernxpandroid <srikrishna.pramoda@nxp.com>2017-09-14 12:39:32 +0530
commit90b301b2b94db88e69eca279c1e6053748a8ed92 (patch)
tree19370393169b4a4a2d08f1f5a8e86398cf52006c
parent1577646576f0e2e11366d22666657f4be26a1180 (diff)
downloadandroid_vendor_nxp_opensource_packages_apps_Nfc-90b301b2b94db88e69eca279c1e6053748a8ed92.tar.gz
android_vendor_nxp_opensource_packages_apps_Nfc-90b301b2b94db88e69eca279c1e6053748a8ed92.tar.bz2
android_vendor_nxp_opensource_packages_apps_Nfc-90b301b2b94db88e69eca279c1e6053748a8ed92.zip
NFC init is not proper after FW update
-rwxr-xr-xnci/jni/NativeNfcManager.cpp77
-rw-r--r--nci/jni/NativeNxpFeature.cpp3
-rw-r--r--nci/jni/RoutingManager.cpp111
-rw-r--r--nci/jni/RoutingManager.h2
4 files changed, 148 insertions, 45 deletions
diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp
index dd50f286..91d1feea 100755
--- a/nci/jni/NativeNfcManager.cpp
+++ b/nci/jni/NativeNfcManager.cpp
@@ -165,10 +165,9 @@ namespace android
bool nfcManager_isTransanctionOnGoing(bool isInstallRequest);
bool nfcManager_isRequestPending(void);
extern tNFA_STATUS enableSWPInterface();
- jmethodID gCachedNfcManagerNotifyFwDwnldRequested;
-
+ extern tNFA_STATUS NxpNfc_Send_CoreResetInit_Cmd(void);
+ jmethodID gCachedNfcManagerNotifyFwDwnldRequested;
extern tNFA_STATUS SendAGCDebugCommand();
- extern tNFA_STATUS NxpNfc_Send_CoreResetInit_Cmd();
extern tNFA_STATUS Set_EERegisterValue(uint16_t RegAddr, uint8_t bitVal);
extern void nativeNfcTag_cacheNonNciCardDetection();
extern void nativeNfcTag_handleNonNciCardDetection(tNFA_CONN_EVT_DATA* eventData);
@@ -435,7 +434,7 @@ static void write_uicc_context(uint8_t *uiccContext, uint16_t uiccContextLen, ui
static uint16_t calc_crc16(uint8_t* pBuff, uint16_t wLen);
static int nfcManager_staticDualUicc_Precondition(int uiccSlot);
-
+void checkforESERemoval();
bool nfcManager_sendEmptyDataMsg();
bool gIsEmptyRspSentByHceFApk = false;
@@ -2241,6 +2240,7 @@ static jboolean nfcManager_doInitialize (JNIEnv* e, jobject o)
}
}
if(nfcFL.nfccFL._NFC_NXP_STAT_DUAL_UICC_EXT_SWITCH) {
+ checkforESERemoval();
GetNxpNumValue (NAME_NXP_DUAL_UICC_ENABLE, (void*)&dualUiccInfo.dualUiccEnable, sizeof(dualUiccInfo.dualUiccEnable));
if(dualUiccInfo.dualUiccEnable == 0x01)
{
@@ -3294,7 +3294,7 @@ static jboolean nfcManager_doDeinitialize (JNIEnv* e, jobject obj)
nfcFL.nfccFL._NFCC_SPI_FW_DOWNLOAD_SYNC)) {
/* NFC state is put to NFC_OFF, no more request on NFC accepted(no signal events)*/
sNfcState = NFC_OFF;
- NFC_ResetNfcServicePid();
+ NFC_ResetNfcServicePid();
releaseSPIEvtHandlerThread();
}
@@ -7141,6 +7141,9 @@ static void performHCIInitialization (JNIEnv* e, jobject o)
status = android::enableSWPInterface();
if(status == NFA_STATUS_OK)
{
+ RoutingManager::getInstance().nfaEEDisconnect();
+ usleep(1000 * 1000);
+ android::NxpNfc_Send_CoreResetInit_Cmd();
/*Update Actual SE count gActualSeCount*/
GetNumNFCEEConfigured();
RoutingManager::getInstance().nfaEEConnect();
@@ -7153,6 +7156,70 @@ static void performHCIInitialization (JNIEnv* e, jobject o)
ALOGE("No UICC update required/failed to enable SWP interfaces");
}
}
+
+void checkforESERemoval()
+{
+ ALOGD("checkforESERemoval enter");
+
+ bool nfaEseRemovedNtf = true;
+ uint8_t numNfceePresent = SecureElement::getInstance().mNfceeData_t.mNfceePresent;
+ tNFA_HANDLE nfceeHandle[MAX_NFCEE];
+ tNFA_EE_STATUS nfceeStatus[MAX_NFCEE];
+
+ uint8_t retry = 0;
+ uint8_t mActualNumEe = SecureElement::MAX_NUM_EE;
+ tNFA_EE_INFO mEeInfo[mActualNumEe];
+ uint8_t eseDetected = 0;
+
+ for(int i = 1; i <= numNfceePresent; i++)
+ {
+ nfceeHandle[i] = SecureElement::getInstance().mNfceeData_t.mNfceeHandle[i];
+ nfceeStatus[i] = SecureElement::getInstance().mNfceeData_t.mNfceeHandle[i];
+
+ if(nfceeHandle[i] == (SecureElement::EE_HANDLE_0xF3) && nfceeStatus[i] == 0x0)
+ {
+ nfaEseRemovedNtf = false;
+ break;
+ }
+ }
+ if(nfaEseRemovedNtf)
+ {
+ ALOGD("nfaEseRemovedNtf true");
+ tNFA_STATUS configstatus = NFA_STATUS_FAILED;
+ do {
+ if ((configstatus = NFA_AllEeGetInfo (&mActualNumEe, mEeInfo)) != NFA_STATUS_OK)
+ {
+ ALOGE ("unable to get the EE status");
+ }
+ else
+ {
+ for(int xx = 0; xx < mActualNumEe; xx++)
+ {
+ ALOGE("xx=%d, ee_handle=0x0%x, status=0x0%x", xx, mEeInfo[xx].ee_handle,mEeInfo[xx].ee_status);
+ if (mEeInfo[xx].ee_handle == 0x4C0)
+ {
+ if(mEeInfo[xx].ee_status == 0x02)
+ {
+ configstatus = ResetEseSession();
+ RoutingManager::getInstance().nfaEEDisconnect();
+ usleep(1000 *1000);
+ android::NxpNfc_Send_CoreResetInit_Cmd();
+ RoutingManager::getInstance().nfaEEConnect();
+ usleep(1000 * 1000);
+ }
+ else
+ {
+ eseDetected = 0x01;
+ }
+ break;
+ }
+ }
+ }
+ }while((eseDetected == 0x00) && (retry++ < 1));
+ }
+ usleep(1000 * 1000);
+}
+
/**********************************************************************************
**
** Function: getUiccContext
diff --git a/nci/jni/NativeNxpFeature.cpp b/nci/jni/NativeNxpFeature.cpp
index c164532a..35d19ecb 100644
--- a/nci/jni/NativeNxpFeature.cpp
+++ b/nci/jni/NativeNxpFeature.cpp
@@ -876,8 +876,7 @@ tNFA_STATUS enableSWPInterface()
status = GetCbStatus();
if (NFA_STATUS_OK == status)
{
- ALOGV("%s: Enable interface SWP1 & SWP1A is Success", __func__);
- status = NxpNfc_Send_CoreResetInit_Cmd();
+ ALOGV("%s: GetCbStatus():%d", __func__, status);
}
}
}
diff --git a/nci/jni/RoutingManager.cpp b/nci/jni/RoutingManager.cpp
index 3092036d..68fff427 100644
--- a/nci/jni/RoutingManager.cpp
+++ b/nci/jni/RoutingManager.cpp
@@ -788,6 +788,47 @@ void RoutingManager::setCeRouteStrictDisable(uint32_t state)
mCeRouteStrictDisable = state;
}
+/******************************************************************************
+ ** Function: nfaEEConnect
+ **
+ ** Description: This function is invoked in case of eSE session reset.
+ ** in this case we already discovered eSE earlierhence eSE the eSE count is
+ ** decremented from gSeDiscoveryCount so that only pending NFCEE(UICC1 & UICC2)
+ ** would be rediscovered.
+ **
+ ** Returns: None
+ ********************************************************************************/
+void RoutingManager::nfaEEConnect()
+{
+ if(NFA_STATUS_OK == NFA_EeConnect(EE_HCI_DEFAULT_HANDLE,
+ NFC_NFCEE_INTERFACE_HCI_ACCESS,
+ nfaEeCallback))
+ {
+ SyncEventGuard g(gNfceeDiscCbEvent);
+ ALOGV("%s, Sem wait for gNfceeDiscCbEvent %d", __FUNCTION__, gdisc_timeout);
+ gNfceeDiscCbEvent.wait(gdisc_timeout);
+ }
+
+}
+
+/******************************************************************************
+ ** Function: nfaEEDisconnect
+ **
+ ** Description: This function can be called to delete the core logical connection
+ ** already created , to create connection again.
+ **
+ ** Returns: None
+ ********************************************************************************/
+void RoutingManager::nfaEEDisconnect()
+{
+ if(NFA_STATUS_OK == NFA_EeDisconnect(EE_HCI_DEFAULT_HANDLE))
+ {
+ SyncEventGuard guard(mEEDisconnectEvt);
+ ALOGV("%s, Sem wait for mEEDisconnectEvt", __FUNCTION__);
+ mEEDisconnectEvt.wait(1000);
+ }
+}
+
void RoutingManager::printMemberData()
{
ALOGV("%s: ACTIVE_SE = 0x%0X", __func__, mActiveSe);
@@ -2391,6 +2432,15 @@ void RoutingManager::nfaEeCallback (tNFA_EE_EVT event, tNFA_EE_CBACK_DATA* event
}
}
break;
+
+ case NFA_EE_DISCONNECT_EVT:
+ {
+ ALOGV("%s: NFA_EE_DISCONNECT_EVT received", fn);
+ SyncEventGuard guard(routingManager.mEEDisconnectEvt);
+ routingManager.mEEDisconnectEvt.notifyOne();
+ }
+ break;
+
case NFA_EE_PWR_LINK_CTRL_EVT:
if(nfcFL.eseFL._WIRED_MODE_STANDBY) {
ALOGV("%s: NFA_EE_PWR_LINK_CTRL_EVT; status: 0x%04X ", fn,
@@ -2480,24 +2530,31 @@ void RoutingManager::nfaEeCallback (tNFA_EE_EVT event, tNFA_EE_CBACK_DATA* event
uint8_t num_ee = eventData->ee_discover.num_ee;
tNFA_EE_DISCOVER ee_disc_info = eventData->ee_discover;
ALOGV("%s: NFA_EE_DISCOVER_EVT; status=0x%X; num ee=%u", __func__,eventData->status, eventData->ee_discover.num_ee);
- if((nfcFL.nfccFL._NFCEE_REMOVED_NTF_RECOVERY) &&
- ((mChipId == pn80T || mChipId == pn65T || mChipId == pn66T || mChipId == pn67T || mChipId == pn81T) && android::isNfcInitializationDone() == true)) {
- for(int xx = 0; xx < num_ee; xx++)
+ if( (nfcFL.nfccFL._NFCEE_REMOVED_NTF_RECOVERY) &&
+ ( ( (mChipId != pn80T) && (android::isNfcInitializationDone() == true) ) ||
+ ( (mChipId == pn80T) && (SecureElement::getInstance().mETSI12InitStatus == NFA_STATUS_OK) )
+ )
+ )
+ {
+ if((mChipId == pn65T || mChipId == pn66T || mChipId == pn67T || mChipId == pn80T || mChipId == pn81T))
{
- ALOGE("xx=%d, ee_handle=0x0%x, status=0x0%x", xx, ee_disc_info.ee_info[xx].ee_handle,ee_disc_info.ee_info[xx].ee_status);
- if (ee_disc_info.ee_info[xx].ee_handle == SecureElement::EE_HANDLE_0xF3)
+ for(int xx = 0; xx < num_ee; xx++)
{
- if(ee_disc_info.ee_info[xx].ee_status == NFA_EE_STATUS_REMOVED)
- {
- recovery=true;
- routingManager.ee_removed_disc_ntf_handler(ee_disc_info.ee_info[xx].ee_handle, ee_disc_info.ee_info[xx].ee_status);
- break;
- }
- else if((ee_disc_info.ee_info[xx].ee_status == NFA_EE_STATUS_ACTIVE) && (recovery == true))
+ ALOGE("xx=%d, ee_handle=0x0%x, status=0x0%x", xx, ee_disc_info.ee_info[xx].ee_handle,ee_disc_info.ee_info[xx].ee_status);
+ if (ee_disc_info.ee_info[xx].ee_handle == SecureElement::EE_HANDLE_0xF3)
{
- recovery = false;
- SyncEventGuard guard(se.mEEdatapacketEvent);
- se.mEEdatapacketEvent.notifyOne();
+ if(ee_disc_info.ee_info[xx].ee_status == NFA_EE_STATUS_REMOVED)
+ {
+ recovery=true;
+ routingManager.ee_removed_disc_ntf_handler(ee_disc_info.ee_info[xx].ee_handle, ee_disc_info.ee_info[xx].ee_status);
+ break;
+ }
+ else if((ee_disc_info.ee_info[xx].ee_status == NFA_EE_STATUS_ACTIVE) && (recovery == true))
+ {
+ recovery = false;
+ SyncEventGuard guard(se.mEEdatapacketEvent);
+ se.mEEdatapacketEvent.notifyOne();
+ }
}
}
}
@@ -3169,29 +3226,7 @@ bool RoutingManager::is_ee_recovery_ongoing()
ALOGV("%s := %s", fn, ((recovery==true) ? "true" : "false" ));
return recovery;
}
-void RoutingManager::nfaEEConnect()
-{
- /*This function is invoked in case of
- * eSE session reset, in this case we already discovered eSE before
- * hence decrement eSE count from gSeDiscoveryCount so that only
- * pending NFCEE(UICC1 & UICC2) would be rediscovered
- * */
- tNFA_STATUS nfaStat = NFA_STATUS_FAILED;
- if(NFA_GetNCIVersion() != NCI_VERSION_2_0)
- {
- nfaStat = NFA_EeConnect(EE_HCI_DEFAULT_HANDLE, NFC_NFCEE_INTERFACE_HCI_ACCESS, nfaEeCallback);
- }
- else
- {
- nfaStat = NFA_EeDiscover(nfaEeCallback);
- }
- if(nfaStat == NFA_STATUS_OK)
- {
- SyncEventGuard g (gNfceeDiscCbEvent);
- ALOGV("%s: Sem Post for gNfceeDiscCbEvent", __func__);
- gNfceeDiscCbEvent.wait (gdisc_timeout);
- }
-}
+
/*******************************************************************************
**
** Function: getRouting
diff --git a/nci/jni/RoutingManager.h b/nci/jni/RoutingManager.h
index 3219c96a..aef6f8fd 100644
--- a/nci/jni/RoutingManager.h
+++ b/nci/jni/RoutingManager.h
@@ -159,6 +159,8 @@ public:
void setDefaultProtoRouting (int seId, int proto_switchon,int proto_switchoff);
void processGetRoutingRsp(tNFA_DM_CBACK_DATA* eventData, uint8_t* sRoutingBuff);
void nfaEEConnect();
+ void nfaEEDisconnect();
+ SyncEvent mEEDisconnectEvt;
bool setRoutingEntry(int type, int value, int route, int power);
bool clearRoutingEntry(int type);
bool setDefaultRoute(const int defaultRoute, const int protoRoute, const int techRoute);