From 3f2a91f92c3f965634789eda19fb32d69a1999b8 Mon Sep 17 00:00:00 2001 From: suraj Date: Fri, 15 Sep 2017 15:37:06 +0530 Subject: MW handling of NFCEE_STATUS_NTF with unrecoverable error . --- nci/jni/RoutingManager.cpp | 11 +++++++++++ nci/jni/RoutingManager.h | 2 +- nci/jni/SecureElement.cpp | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/nci/jni/RoutingManager.cpp b/nci/jni/RoutingManager.cpp index 68fff427..97b0524d 100644 --- a/nci/jni/RoutingManager.cpp +++ b/nci/jni/RoutingManager.cpp @@ -3227,6 +3227,17 @@ bool RoutingManager::is_ee_recovery_ongoing() return recovery; } +void RoutingManager::setEERecovery(bool value) +{ + static const char fn [] = "RoutingManager::setEERecovery"; + if(!nfcFL.nfccFL._NFCEE_REMOVED_NTF_RECOVERY) { + ALOGV("%s : NFCEE_REMOVED_NTF_RECOVERY not avaialble.Returning",__func__); + return; + } + ALOGV("%s: value %x", __func__,value); + recovery = value; +} + /******************************************************************************* ** ** Function: getRouting diff --git a/nci/jni/RoutingManager.h b/nci/jni/RoutingManager.h index aef6f8fd..fc3e8dc8 100644 --- a/nci/jni/RoutingManager.h +++ b/nci/jni/RoutingManager.h @@ -185,7 +185,7 @@ public: uint8_t apduDataLen ,const uint8_t* apduMask, uint8_t apduMaskLen); bool removeApduRouting(uint8_t apduDataLen, const uint8_t* apduData); - + void setEERecovery(bool value); void cleanRouting(); bool removeAidRouting(const uint8_t* aid, uint8_t aidLen); bool commitRouting(); diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp index ee59bae9..6dc97f2f 100644 --- a/nci/jni/SecureElement.cpp +++ b/nci/jni/SecureElement.cpp @@ -2745,6 +2745,24 @@ void SecureElement::nfaHciCallback (tNFA_HCI_EVT event, tNFA_HCI_EVT_DATA* event sSecElem.mNfceeInitCbEvent.notifyOne(); break; } + case NFA_HCI_EE_RECOVERY_EVT: + { + tNFA_HCI_EE_RECOVERY_EVT &ee_recovery = eventData->ee_recovery; + ALOGV("%s: NFA_HCI_EE_RECOVERY_EVT; status=0x%X", fn, ee_recovery.status); + if(ee_recovery.status == NFA_HCI_EE_RECOVERY_STARTED) + RoutingManager::getInstance().setEERecovery(true); + else if(ee_recovery.status == NFA_HCI_EE_RECOVERY_COMPLETED) + { + ALOGV("%s: NFA_HCI_EE_RECOVERY_EVT; recovery completed status=0x%X", fn, ee_recovery.status); + RoutingManager::getInstance().setEERecovery(false); + if(active_ese_reset_control & TRANS_WIRED_ONGOING) + { + SyncEventGuard guard(sSecElem.mTransceiveEvent); + sSecElem.mTransceiveEvent.notifyOne(); + } + } + break; + } case NFA_HCI_ADD_STATIC_PIPE_EVT: { ALOGV("%s: NFA_HCI_ADD_STATIC_PIPE_EVT; status=0x%X", fn, eventData->admin_rsp_rcvd.status); -- cgit v1.2.3 From fb29951e170dc3e7115dc1cbc183a65a21b137cc Mon Sep 17 00:00:00 2001 From: suraj Date: Fri, 15 Sep 2017 16:50:07 +0530 Subject: Adding missing changes. --- nci/jni/NativeNfcManager.cpp | 1 - nci/jni/RoutingManager.cpp | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index 91d1feea..b221d8c2 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -540,7 +540,6 @@ void *enableThread(void *arg); static IntervalTimer scleanupTimerProc_transaction; static bool gIsDtaEnabled=false; -tNfc_featureList nfcFL; static void nfcManager_getFeatureList(); static void register_signal_handler(); ///////////////////////////////////////////////////////////// diff --git a/nci/jni/RoutingManager.cpp b/nci/jni/RoutingManager.cpp index 97b0524d..83df3bee 100644 --- a/nci/jni/RoutingManager.cpp +++ b/nci/jni/RoutingManager.cpp @@ -2450,7 +2450,7 @@ void RoutingManager::nfaEeCallback (tNFA_EE_EVT event, tNFA_EE_CBACK_DATA* event se.mPwrLinkCtrlEvent.notifyOne(); } break; - +#endif case NFA_EE_SET_TECH_CFG_EVT: { ALOGV("%s: NFA_EE_SET_TECH_CFG_EVT; status=0x%X", fn, eventData->status); @@ -3072,7 +3072,6 @@ void *ee_removed_ntf_handler_thread(void *data) ALOGV("%s: power link command failed", __func__); } } -#endif stat = NFA_EeModeSet(SecureElement::EE_HANDLE_0xF3, NFA_EE_MD_DEACTIVATE); if(stat == NFA_STATUS_OK) -- cgit v1.2.3 From 08cbb6bd0abb97d64cdb2ebf35f547d02f458fa1 Mon Sep 17 00:00:00 2001 From: suraj Date: Fri, 15 Sep 2017 17:34:58 +0530 Subject: Adding missing changes for init failure. --- nci/jni/RoutingManager.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/nci/jni/RoutingManager.cpp b/nci/jni/RoutingManager.cpp index 83df3bee..06c1215b 100644 --- a/nci/jni/RoutingManager.cpp +++ b/nci/jni/RoutingManager.cpp @@ -800,9 +800,16 @@ void RoutingManager::setCeRouteStrictDisable(uint32_t state) ********************************************************************************/ void RoutingManager::nfaEEConnect() { - if(NFA_STATUS_OK == NFA_EeConnect(EE_HCI_DEFAULT_HANDLE, - NFC_NFCEE_INTERFACE_HCI_ACCESS, - nfaEeCallback)) + 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 wait for gNfceeDiscCbEvent %d", __FUNCTION__, gdisc_timeout); -- cgit v1.2.3 From 8521b747de118caec6233ebc2af4dc5273c30ada Mon Sep 17 00:00:00 2001 From: ubuntu Date: Tue, 19 Sep 2017 15:38:00 +0530 Subject: Fix for PWR LINK with NFCC_DECIDES being sent when SPI is ongoing PWR link command with NFCC_DECIDES shall not be issued when DWP open fails while SPI interface is active. --- nci/jni/NativeSecureElement.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nci/jni/NativeSecureElement.cpp b/nci/jni/NativeSecureElement.cpp index bfabff2d..9efe9344 100644 --- a/nci/jni/NativeSecureElement.cpp +++ b/nci/jni/NativeSecureElement.cpp @@ -353,7 +353,8 @@ if(nfcFL.nfcNxpEse && stat) if(status != NFA_STATUS_OK) { - if(nfcFL.eseFL._WIRED_MODE_STANDBY && (se.mNfccPowerMode == 1)) { + if(nfcFL.eseFL._WIRED_MODE_STANDBY && (se.mNfccPowerMode == 1) && + !(p61_current_state & (P61_STATE_SPI | P61_STATE_SPI_PRIO))) { se.setNfccPwrConfig(se.NFCC_DECIDES); } se.disconnectEE (secElemHandle); -- cgit v1.2.3 From 7f44d4d82404955e7d6bce3c5a4ff86436785cfb Mon Sep 17 00:00:00 2001 From: Love Khanna Date: Wed, 20 Sep 2017 18:50:40 +0530 Subject: Added null check for response data from FelicaApp to avoid NullPointerException. --- src/com/android/nfc/cardemulation/HostNfcFEmulationManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/android/nfc/cardemulation/HostNfcFEmulationManager.java b/src/com/android/nfc/cardemulation/HostNfcFEmulationManager.java index d79a1ec8..398f1bd9 100644 --- a/src/com/android/nfc/cardemulation/HostNfcFEmulationManager.java +++ b/src/com/android/nfc/cardemulation/HostNfcFEmulationManager.java @@ -310,7 +310,7 @@ public class HostNfcFEmulationManager { return; } */ - if (data.length == 0) { + if (data == null || data.length == 0) { Log.e(TAG, "Empty response packet"); sendEmptyData(); return; -- cgit v1.2.3 From ec0c3a7a68e97453aa478a373ad4a3c2eff6fc39 Mon Sep 17 00:00:00 2001 From: Suhas Suresh Date: Thu, 21 Sep 2017 18:00:04 +0530 Subject: Fix for NFC service died for NFC on/off stabilty with tag in proximity disconnect() is called inside the thread whenever tag is removed from proximity which waits for thread join. Since join is called inside same thread, it is infinitely waiting to join. Removed calling disconnect inside the presence check thread. --- nci/src/com/android/nfc/dhimpl/NativeNfcTag.java | 1 - 1 file changed, 1 deletion(-) diff --git a/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java b/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java index 1febec9f..610a7394 100755 --- a/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java +++ b/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java @@ -160,7 +160,6 @@ public class NativeNfcTag implements TagEndpoint { if (tagDisconnectedCallback != null) { tagDisconnectedCallback.onTagDisconnected(mConnectedHandle); } - disconnect(); if (DBG) Log.d(TAG, "Stopping background presence check"); } } -- cgit v1.2.3 From 89973849a15dbebd24ac39737557283d7dbcb13f Mon Sep 17 00:00:00 2001 From: Yerriswamy Date: Thu, 21 Sep 2017 20:08:50 +0530 Subject: Fix for T4T presence check issue --- nci/jni/NativeNfcTag.cpp | 111 ++++++++++++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/nci/jni/NativeNfcTag.cpp b/nci/jni/NativeNfcTag.cpp index e5186894..63ad7743 100644 --- a/nci/jni/NativeNfcTag.cpp +++ b/nci/jni/NativeNfcTag.cpp @@ -1255,6 +1255,7 @@ static jint nativeNfcTag_doReconnect (JNIEnv*, jobject) uint8_t* uid; uint32_t uid_len; + tNFC_STATUS stat; ALOGV("%s: enter; handle=%x", __func__, handle); natTag.getTypeATagUID(&uid,&uid_len); @@ -1294,74 +1295,84 @@ static jint nativeNfcTag_doReconnect (JNIEnv*, jobject) uid_len > 0 && uid[0] == 0x08)) ) { - ALOGV("%s: reconnect for TypeB / TypeA random uid", __func__); - sReconnectNtfTimer.set(500, sReconnectTimerProc); + if(NFA_GetNCIVersion() != NCI_VERSION_2_0) + { + ALOGV("%s: reconnect for TypeB / TypeA random uid", __func__); + sReconnectNtfTimer.set(500, sReconnectTimerProc); - tNFC_STATUS stat = NFA_RegVSCback (true,nfaVSCNtfCallback); //Register CallBack for VS NTF - if(NFA_STATUS_OK != stat) - { - retCode = 0x01; - goto TheEnd; - } + tNFC_STATUS stat = NFA_RegVSCback (true,nfaVSCNtfCallback); //Register CallBack for VS NTF + if(NFA_STATUS_OK != stat) + { + retCode = 0x01; + goto TheEnd; + } - SyncEventGuard guard (sNfaVSCResponseEvent); - stat = NFA_SendVsCommand (0x11,0x00,NULL,nfaVSCCallback); - if(NFA_STATUS_OK == stat) - { - sIsReconnecting = true; - ALOGV("%s: reconnect for TypeB - wait for NFA VS command to finish", __func__); - sNfaVSCResponseEvent.wait(); //wait for NFA VS command to finish - ALOGV("%s: reconnect for TypeB - Got RSP", __func__); - } + SyncEventGuard guard (sNfaVSCResponseEvent); + stat = NFA_SendVsCommand (0x11,0x00,NULL,nfaVSCCallback); + if(NFA_STATUS_OK == stat) + { + sIsReconnecting = true; + ALOGV("%s: reconnect for TypeB - wait for NFA VS command to finish", __func__); + sNfaVSCResponseEvent.wait(); //wait for NFA VS command to finish + ALOGV("%s: reconnect for TypeB - Got RSP", __func__); + } - if(false == sVSCRsp) - { - retCode = 0x01; - sIsReconnecting = false; - } - else - { + if(false == sVSCRsp) { - ALOGV("%s: reconnect for TypeB - wait for NFA VS NTF to come", __func__); - SyncEventGuard guard (sNfaVSCNotificationEvent); - sNfaVSCNotificationEvent.wait(); //wait for NFA VS NTF to come - ALOGV("%s: reconnect for TypeB - GOT NFA VS NTF", __func__); - sReconnectNtfTimer.kill(); + retCode = 0x01; sIsReconnecting = false; } - - if(false == sIsTagInField) + else { - ALOGV("%s: NxpNci: TAG OUT OF FIELD", __func__); - retCode = STATUS_CODE_TARGET_LOST; - - SyncEventGuard g (gDeactivatedEvent); + { + ALOGV("%s: reconnect for TypeB - wait for NFA VS NTF to come", __func__); + SyncEventGuard guard (sNfaVSCNotificationEvent); + sNfaVSCNotificationEvent.wait(); //wait for NFA VS NTF to come + ALOGV("%s: reconnect for TypeB - GOT NFA VS NTF", __func__); + sReconnectNtfTimer.kill(); + sIsReconnecting = false; + } - //Tag not present, deactivate the TAG. - stat = NFA_Deactivate (false); - if (stat == NFA_STATUS_OK) + if(false == sIsTagInField) { - gDeactivatedEvent.wait (); + ALOGV("%s: NxpNci: TAG OUT OF FIELD", __func__); + retCode = STATUS_CODE_TARGET_LOST; + + SyncEventGuard g (gDeactivatedEvent); + + //Tag not present, deactivate the TAG. + stat = NFA_Deactivate (false); + if (stat == NFA_STATUS_OK) + { + gDeactivatedEvent.wait (); + } + else + { + ALOGE("%s: deactivate failed; error=0x%X", __func__, stat); + } } + else { - ALOGE("%s: deactivate failed; error=0x%X", __func__, stat); + retCode = 0x00; } } - else + stat = NFA_RegVSCback (false,nfaVSCNtfCallback); //DeRegister CallBack for VS NTF + if(NFA_STATUS_OK != stat) { - retCode = 0x00; + retCode = 0x01; } + ALOGV("%s: reconnect for TypeB - return", __func__); + }else{ + SyncEventGuard guard (sPresenceCheckEvent); + stat = NFA_RwPresenceCheck (NfcTag::getInstance().getPresenceCheckAlgorithm()); + if (stat == NFA_STATUS_OK) + { + sPresenceCheckEvent.wait (); + retCode = sIsTagPresent ? NCI_STATUS_OK : NCI_STATUS_FAILED; + } } - - stat = NFA_RegVSCback (false,nfaVSCNtfCallback); //DeRegister CallBack for VS NTF - if(NFA_STATUS_OK != stat) - { - retCode = 0x01; - } - ALOGV("%s: reconnect for TypeB - return", __func__); - goto TheEnd; } // this is only supported for type 2 or 4 (ISO_DEP) tags -- cgit v1.2.3 From 70bfbcde6ac4f25021217e79559ba247812c0251 Mon Sep 17 00:00:00 2001 From: Yerriswamy Date: Wed, 27 Sep 2017 22:38:42 +0530 Subject: Single binary macro changes --- nci/jni/SecureElement.cpp | 91 +++++++++++++++++++++++------------------------ nci/jni/SecureElement.h | 6 +--- 2 files changed, 45 insertions(+), 52 deletions(-) diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp index 6dc97f2f..92f4f999 100644 --- a/nci/jni/SecureElement.cpp +++ b/nci/jni/SecureElement.cpp @@ -142,6 +142,9 @@ namespace android #if(NXP_EXTNS == TRUE) #define NFC_NUM_INTERFACE_MAP 3 #define NFC_SWP_RD_NUM_INTERFACE_MAP 1 +#define STATIC_PIPE_0x19 0x19 //PN54X Gemalto's proprietary static pipe +#define STATIC_PIPE_0x70 0x70 //Broadcom's proprietary static pipe +uint8_t SecureElement::mStaticPipeProp; static const tNCI_DISCOVER_MAPS nfc_interface_mapping_default[NFC_NUM_INTERFACE_MAP] = { @@ -358,6 +361,7 @@ bool SecureElement::initialize (nfc_jni_native_data* native) mDestinationGate = num; ALOGV("%s: Default destination gate: 0x%X", fn, mDestinationGate); + mStaticPipeProp = nfcFL.nfccFL._GEMALTO_SE_SUPPORT ? STATIC_PIPE_0x19 : STATIC_PIPE_0x70; // active SE, if not set active all SEs, use the first one. if (GetNumValue("ACTIVE_SE", &num, sizeof(num))) { @@ -485,13 +489,9 @@ bool SecureElement::initialize (nfc_jni_native_data* native) for (size_t xx = 0; xx < MAX_NUM_EE; xx++) { -#ifdef GEMALTO_SE_SUPPORT - if ((mEeInfo[xx].ee_handle != EE_HANDLE_0xF4 ) ) -#else - if (((mEeInfo[xx].ee_interface[0] == NCI_NFCEE_INTERFACE_HCI_ACCESS) - &&(mEeInfo[xx].ee_status == NFC_NFCEE_STATUS_ACTIVE)) || (NFA_GetNCIVersion() == NCI_VERSION_2_0)) -#endif - + if((!nfcFL.nfccFL._GEMALTO_SE_SUPPORT && mEeInfo[xx].ee_handle != EE_HANDLE_0xF4) + || (nfcFL.nfccFL._GEMALTO_SE_SUPPORT && (((mEeInfo[xx].ee_interface[0] == NCI_NFCEE_INTERFACE_HCI_ACCESS) + && (mEeInfo[xx].ee_status == NFC_NFCEE_STATUS_ACTIVE)) || (NFA_GetNCIVersion() == NCI_VERSION_2_0)))) { ALOGV("%s: Found HCI network, try hci register", fn); @@ -536,13 +536,10 @@ bool SecureElement::updateEEStatus () // If the controller has an HCI Network, register for that for (size_t xx = 0; xx < mActualNumEe; xx++) { -#ifdef GEMALTO_SE_SUPPORT - if ((mEeInfo[xx].ee_handle != EE_HANDLE_0xF4 ) ) -#else - if (((mEeInfo[xx].ee_interface[0] == NCI_NFCEE_INTERFACE_HCI_ACCESS)) - || (NFA_GetNCIVersion() == NCI_VERSION_2_0)) -#endif - { + if((!nfcFL.nfccFL._GEMALTO_SE_SUPPORT && (mEeInfo[xx].ee_handle != EE_HANDLE_0xF4 )) + || (nfcFL.nfccFL._GEMALTO_SE_SUPPORT && (((mEeInfo[xx].ee_interface[0] == NCI_NFCEE_INTERFACE_HCI_ACCESS)) + || (NFA_GetNCIVersion() == NCI_VERSION_2_0)))) + { ALOGV("%s: Found HCI network, try hci register", __func__); SyncEventGuard guard (mHciRegisterEvent); @@ -1470,28 +1467,28 @@ bool SecureElement::connectEE () uint8_t host; if(mActiveEeHandle == EE_HANDLE_0xF3) { - host = (mNewPipeId == STATIC_PIPE_0x70) ? 0xC0 : 0x03; + host = (mNewPipeId == mStaticPipeProp) ? 0xC0 : 0x03; } else { host = (mNewPipeId == STATIC_PIPE_UICC) ? 0x02 : 0x03; } #else - uint8_t host = (mNewPipeId == STATIC_PIPE_0x70) ? 0x02 : 0x03; + uint8_t host = (mNewPipeId == mStaticPipeProp) ? 0x02 : 0x03; #endif //TODO according ETSI12 APDU Gate #if(NXP_EXTNS == TRUE) uint8_t gate; if(mActiveEeHandle == EE_HANDLE_0xF3) { - gate = (mNewPipeId == STATIC_PIPE_0x70) ? 0xF0 : 0xF1; + gate = (mNewPipeId == mStaticPipeProp) ? 0xF0 : 0xF1; } else { gate = (mNewPipeId == STATIC_PIPE_UICC) ? 0x30 : 0x31; } #else - uint8_t gate = (mNewPipeId == STATIC_PIPE_0x70) ? 0xF0 : 0xF1; + uint8_t gate = (mNewPipeId == mStaticPipeProp) ? 0xF0 : 0xF1; #endif #if(NXP_EXTNS == TRUE) ALOGV("%s: Using host id : 0x%X,gate id : 0x%X,pipe id : 0x%X", __func__,host,gate, mNewPipeId); @@ -1795,7 +1792,7 @@ bool SecureElement::transceive (uint8_t* xmitBuffer, int32_t xmitBufferSize, uin } } #endif - if ((mNewPipeId == STATIC_PIPE_0x70) || (mNewPipeId == STATIC_PIPE_0x71)) + if ((mNewPipeId == mStaticPipeProp) || (mNewPipeId == STATIC_PIPE_0x71)) #if(NXP_EXTNS == TRUE) { if (nfcFL.nfccFL._NFCEE_REMOVED_NTF_RECOVERY) { @@ -2357,8 +2354,8 @@ bool SecureElement::getSeVerInfo(int seIndex, char * verInfo, int verInfoSz, uin verInfo[verInfoSz-1] = '\0'; uint8_t pipe = (mEeInfo[seIndex].ee_handle == EE_HANDLE_0xF3) ? 0x70 : 0x71; - uint8_t host = (pipe == STATIC_PIPE_0x70) ? 0x02 : 0x03; - uint8_t gate = (pipe == STATIC_PIPE_0x70) ? 0xF0 : 0xF1; + uint8_t host = (pipe == mStaticPipeProp) ? 0x02 : 0x03; + uint8_t gate = (pipe == mStaticPipeProp) ? 0xF0 : 0xF1; tNFA_STATUS nfaStat = NFA_HciAddStaticPipe(mNfaHciHandle, host, gate, pipe); if (nfaStat != NFA_STATUS_OK) @@ -2553,7 +2550,7 @@ void SecureElement::nfaHciCallback (tNFA_HCI_EVT event, tNFA_HCI_EVT_DATA* event sSecElem.mAtrStatus = eventData->registry.status; sSecElem.mGetRegisterEvent.notifyOne(); } - else if (eventData->registry.data_len >= 19 && ((eventData->registry.pipe == STATIC_PIPE_0x70) || (eventData->registry.pipe == STATIC_PIPE_0x71))) + else if (eventData->registry.data_len >= 19 && ((eventData->registry.pipe == mStaticPipeProp) || (eventData->registry.pipe == STATIC_PIPE_0x71))) { SyncEventGuard guard (sSecElem.mVerInfoEvent); // Oberthur OS version is in bytes 16,17, and 18 @@ -2602,7 +2599,7 @@ void SecureElement::nfaHciCallback (tNFA_HCI_EVT event, tNFA_HCI_EVT_DATA* event } #if(NXP_EXTNS == TRUE) else if (((eventData->rcvd_evt.evt_code == NFA_HCI_ABORT) || (eventData->rcvd_evt.last_SentEvtType == EVT_ABORT)) - &&(eventData->rcvd_evt.pipe == STATIC_PIPE_0x70)) + &&(eventData->rcvd_evt.pipe == mStaticPipeProp)) { ALOGV("%s: NFA_HCI_EVENT_RCVD_EVT: NFA_HCI_ABORT; status:0x%X, pipe:0x%X, len:%d", fn,\ eventData->rcvd_evt.status, eventData->rcvd_evt.pipe, eventData->rcvd_evt.evt_len); @@ -2623,7 +2620,7 @@ void SecureElement::nfaHciCallback (tNFA_HCI_EVT event, tNFA_HCI_EVT_DATA* event } } #endif - else if ((eventData->rcvd_evt.pipe == STATIC_PIPE_0x70) || (eventData->rcvd_evt.pipe == STATIC_PIPE_0x71)) + else if ((eventData->rcvd_evt.pipe == mStaticPipeProp) || (eventData->rcvd_evt.pipe == STATIC_PIPE_0x71)) { ALOGV("%s: NFA_HCI_EVENT_RCVD_EVT; data from static pipe", fn); #if (NXP_EXTNS == TRUE) @@ -2863,17 +2860,18 @@ tNFA_HANDLE SecureElement::getDefaultEeHandle () continue; //skip all the EE's that are ignored ALOGV("%s: - mEeInfo[xx].ee_handle = 0x%02x, mEeInfo[xx].ee_status = 0x%02x", fn,mEeInfo[xx].ee_handle, mEeInfo[xx].ee_status); + if((nfcFL.nfccFL._GEMALTO_SE_SUPPORT && (mEeInfo[xx].ee_interface[0] != NCI_NFCEE_INTERFACE_HCI_ACCESS))) + { + return (mEeInfo[xx].ee_handle); + } + else if((!nfcFL.nfccFL._GEMALTO_SE_SUPPORT && ((mEeInfo[xx].ee_handle == EE_HANDLE_0xF3 + || mEeInfo[xx].ee_handle == SecureElement::getInstance().EE_HANDLE_0xF4 + || (mEeInfo[xx].ee_handle == EE_HANDLE_0xF8 && nfcFL.nfccFL._NFCC_DYNAMIC_DUAL_UICC)) + && (mEeInfo[xx].ee_status != NFC_NFCEE_STATUS_INACTIVE)))) + { + return (mEeInfo[xx].ee_handle); + } -#ifndef GEMALTO_SE_SUPPORT - - if((mEeInfo[xx].ee_interface[0] != NCI_NFCEE_INTERFACE_HCI_ACCESS) -#else - if(((mEeInfo[xx].ee_handle == EE_HANDLE_0xF3 || mEeInfo[xx].ee_handle == SecureElement::getInstance().EE_HANDLE_0xF4 - || (mEeInfo[xx].ee_handle == EE_HANDLE_0xF8 && nfcFL.nfccFL._NXP_NFCC_DYNAMIC_DUAL_UICC)) - && (mEeInfo[xx].ee_status != NFC_NFCEE_STATUS_INACTIVE)) -#endif - ) - return (mEeInfo[xx].ee_handle); } return NFA_HANDLE_INVALID; } @@ -2900,21 +2898,20 @@ tNFA_HANDLE SecureElement::getActiveEeHandle (tNFA_HANDLE handle) for (uint8_t xx = 0; xx < mActualNumEe; xx++) { if ( (mActiveSeOverride != ACTIVE_SE_USE_ANY) && (overrideEeHandle != mEeInfo[xx].ee_handle)) - ALOGE("%s: - mEeInfo[xx].ee_handle = 0x%02x, mEeInfo[xx].ee_status = 0x%02x", fn,mEeInfo[xx].ee_handle, mEeInfo[xx].ee_status); + ALOGE("%s: - mEeInfo[xx].ee_handle = 0x%02x, mEeInfo[xx].ee_status = 0x%02x", fn,mEeInfo[xx].ee_handle, mEeInfo[xx].ee_status); + if(nfcFL.nfccFL._GEMALTO_SE_SUPPORT && (mEeInfo[xx].ee_interface[0] != NCI_NFCEE_INTERFACE_HCI_ACCESS) + && (mEeInfo[xx].ee_status != NFC_NFCEE_STATUS_INACTIVE) && (mEeInfo[xx].ee_handle == handle)) + { + return (mEeInfo[xx].ee_handle); + } + else if (!nfcFL.nfccFL._GEMALTO_SE_SUPPORT && (mEeInfo[xx].ee_handle == EE_HANDLE_0xF3 || mEeInfo[xx].ee_handle == SecureElement::getInstance().EE_HANDLE_0xF4 + || (mEeInfo[xx].ee_handle == EE_HANDLE_0xF8 && nfcFL.nfccFL._NFCC_DYNAMIC_DUAL_UICC)) + && (mEeInfo[xx].ee_status != NFC_NFCEE_STATUS_INACTIVE) && (mEeInfo[xx].ee_handle == handle)) + { + return (mEeInfo[xx].ee_handle); + } -#ifndef GEMALTO_SE_SUPPORT - - if((mEeInfo[xx].ee_interface[0] != NCI_NFCEE_INTERFACE_HCI_ACCESS) -#else - - if((mEeInfo[xx].ee_handle == EE_HANDLE_0xF3 || mEeInfo[xx].ee_handle == SecureElement::getInstance().EE_HANDLE_0xF4 - || (mEeInfo[xx].ee_handle == EE_HANDLE_0xF8 && nfcFL.nfccFL._NXP_NFCC_DYNAMIC_DUAL_UICC)) - -#endif - && - (mEeInfo[xx].ee_status != NFC_NFCEE_STATUS_INACTIVE)&& (mEeInfo[xx].ee_handle == handle)) - return (mEeInfo[xx].ee_handle); } return NFA_HANDLE_INVALID; } diff --git a/nci/jni/SecureElement.h b/nci/jni/SecureElement.h index 479862c3..5043726b 100644 --- a/nci/jni/SecureElement.h +++ b/nci/jni/SecureElement.h @@ -817,13 +817,9 @@ public: #endif private: + static uint8_t mStaticPipeProp; static const unsigned int MAX_RESPONSE_SIZE = 0x8800;//1024; //34K enum RouteSelection {NoRoute, DefaultRoute, SecElemRoute}; -#ifndef GEMATO_SE_SUPPORT - static const uint8_t STATIC_PIPE_0x70 = 0x19; //PN54X Gemalto's proprietary static pipe -#else - static const uint8_t STATIC_PIPE_0x70 = 0x70; //Broadcom's proprietary static pipe -#endif static const uint8_t STATIC_PIPE_0x71 = 0x71; //Broadcom's proprietary static pipe static const uint8_t EVT_SEND_DATA = 0x10; //see specification ETSI TS 102 622 v9.0.0 (Host Controller Interface); section 9.3.3.3 #if(NXP_EXTNS == TRUE) -- cgit v1.2.3 From e67b679e8d719b11d25c5e39a8d6e211ed0cb57c Mon Sep 17 00:00:00 2001 From: ubuntu Date: Wed, 27 Sep 2017 18:59:09 +0530 Subject: SPI open syncronization with DWP interface --- nci/jni/SecureElement.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp index 92f4f999..f7d8ac68 100644 --- a/nci/jni/SecureElement.cpp +++ b/nci/jni/SecureElement.cpp @@ -4077,7 +4077,7 @@ void *spiEventHandlerThread(void *arg) } (void)arg; uint16_t usEvent = 0, usEvtLen = 0; - + tNFC_STATUS stat; NFCSTATUS ese_status = NFA_STATUS_FAILED; @@ -4130,6 +4130,8 @@ void *spiEventHandlerThread(void *arg) (usEvent & P61_STATE_SPI)) { nfaVSC_ForceDwpOnOff(true); + if(android::nfcManager_getNfcState() != NFC_OFF) + NFC_RelForceDwpOnOffWait((void*)&stat); } else if((usEvent & P61_STATE_SPI_PRIO_END) || (usEvent & P61_STATE_SPI_END)) @@ -4153,6 +4155,8 @@ void *spiEventHandlerThread(void *arg) (usEvent & P61_STATE_SPI))) { nfaVSC_ForceDwpOnOff(true); + if(android::nfcManager_getNfcState() != NFC_OFF) + NFC_RelForceDwpOnOffWait((void*)&stat); } else if(nfcFL.eseFL._ESE_DWP_SPI_SYNC_ENABLE && ((usEvent & P61_STATE_SPI_PRIO_END) || @@ -4248,6 +4252,10 @@ void releaseSPIEvtHandlerThread() /* Notifying the signal handler thread to exit if it is waiting */ SyncEventGuard guard(sSPISignalHandlerEvent); sSPISignalHandlerEvent.notifyOne (); + { + SyncEventGuard guard(SecureElement::getInstance().mModeSetNtf); + SecureElement::getInstance().mModeSetNtf.notifyOne(); + } } /******************************************************************************* ** @@ -4751,7 +4759,8 @@ tNFA_STATUS SecureElement::SecElem_EeModeSet(uint16_t handle, uint8_t mode) } SyncEventGuard guard (sSecElem.mEeSetModeEvent); stat = NFA_EeModeSet(handle, mode); - if(stat == NFA_STATUS_OK && !android::nfcManager_isNfcDisabling()) + if(stat == NFA_STATUS_OK && !android::nfcManager_isNfcDisabling() && + (android::nfcManager_getNfcState() != NFC_OFF)) { sSecElem.mEeSetModeEvent.wait (); } -- cgit v1.2.3 From b7194d6863d714078d65ccd9d14dc66d28bbe926 Mon Sep 17 00:00:00 2001 From: nxpandroid Date: Mon, 16 Oct 2017 15:13:03 +0530 Subject: NFC died issue seen during screen off in between ETSI transaction --- nci/jni/IntervalTimer.cpp | 14 +++++++++ nci/jni/IntervalTimer.h | 1 + nci/jni/NativeNfcManager.cpp | 7 +---- nci/jni/TransactionController.cpp | 64 +++++++++++++++++++++++++++++++++------ nci/jni/TransactionController.h | 2 ++ 5 files changed, 73 insertions(+), 15 deletions(-) mode change 100644 => 100755 nci/jni/TransactionController.cpp mode change 100644 => 100755 nci/jni/TransactionController.h diff --git a/nci/jni/IntervalTimer.cpp b/nci/jni/IntervalTimer.cpp index e5644bdf..5f034f42 100644 --- a/nci/jni/IntervalTimer.cpp +++ b/nci/jni/IntervalTimer.cpp @@ -118,3 +118,17 @@ bool IntervalTimer::create(TIMER_FUNC cb) ALOGE("fail create timer"); return stat == 0; } + +bool IntervalTimer::isRunning(void) +{ + if (mTimerId == 0) + return false; + + int stat = 0; + struct itimerspec ts; + + stat = timer_gettime(mTimerId, &ts); + if (stat != 0) + return false; + return ((ts.it_value.tv_sec > 0 || ts.it_value.tv_nsec > 0) ? true : false); +} diff --git a/nci/jni/IntervalTimer.h b/nci/jni/IntervalTimer.h index 66e345d3..b6bbd5a9 100755 --- a/nci/jni/IntervalTimer.h +++ b/nci/jni/IntervalTimer.h @@ -31,6 +31,7 @@ public: bool set(int ms, TIMER_FUNC cb); void kill(); bool create(TIMER_FUNC ); + bool isRunning(void); //This function returns true if a valid timer is running(curTime > 0) private: timer_t mTimerId; diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index b221d8c2..b58d8356 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -6453,12 +6453,7 @@ void *enableThread(void *arg) if(nfcFL.chipType != pn547C2) { set_AGC_process_state(false); } -#if (NXP_EXTNS == TRUE) - if(!pTransactionController->transactionTerminate(TRANSACTION_REQUESTOR(exec_pending_req))) - { - ALOGE("%s: Transaction in progress. Can not reset", __func__); - } -#endif + bool screen_lock_flag = false; bool disable_discovery = false; diff --git a/nci/jni/TransactionController.cpp b/nci/jni/TransactionController.cpp old mode 100644 new mode 100755 index 7250523d..e2e745f2 --- a/nci/jni/TransactionController.cpp +++ b/nci/jni/TransactionController.cpp @@ -61,7 +61,24 @@ void transactionController::lastRequestResume(void) pthread_attr_destroy(&attr); pTransactionDetail->current_transcation_state = NFA_TRANS_DM_RF_TRANS_END; } +/******************************************************************************* + ** + ** Function: transactionHandlePendingCb + ** + ** Description: This is a callback function registered against + ** pendingTransHandleTimer timer. This timer handler + ** triggers enable_thread for handling pending transactions + ** + ** Returns: None + ** + *******************************************************************************/ + +extern "C" void transactionController::transactionHandlePendingCb(union sigval) +{ + ALOGD("Inside %s", __FUNCTION__); + pInstance->lastRequestResume(); +} /******************************************************************************* ** ** Function: transactionAbortTimerCb @@ -76,7 +93,8 @@ extern "C" void transactionController::transactionAbortTimerCb(union sigval) { ALOGD("Inside %s", __FUNCTION__); - pInstance->lastRequestResume(); + pInstance->transactionTerminate(TRANSACTION_REQUESTOR(exec_pending_req)); + } /******************************************************************************* @@ -97,6 +115,7 @@ transactionController::transactionController(void) pTransactionDetail = android::nfcManager_transactionDetail(); abortTimer = new IntervalTimer(); + pendingTransHandleTimer = new IntervalTimer(); requestor = NULL; } /******************************************************************************* @@ -139,6 +158,11 @@ bool transactionController::transactionAttempt(const char* transactionRequestor, sem_getvalue(&barrier, &semVal); ALOGD ("%s: Transaction attempted : %s when barrier is: %d", __FUNCTION__, transactionRequestor, semVal); + if(pendingTransHandleTimer->isRunning()) + { + ALOGD ("%s: Transaction denied due to pending transaction: %s ", __FUNCTION__, transactionRequestor); + return false; + } //Block wait on barrier if(sem_timedwait(&barrier, &timeout) != 0) { @@ -177,6 +201,12 @@ bool transactionController::transactionAttempt(const char* transactionRequestor) sem_getvalue(&barrier, &semVal); ALOGD ("%s: Transaction attempted : %s when barrier is: %d", __FUNCTION__, transactionRequestor, semVal); + if(pendingTransHandleTimer->isRunning()) + { + ALOGD ("%s: Transaction denied due to pending transaction: %s ", __FUNCTION__, transactionRequestor); + return false; + } + if(sem_trywait(&barrier) == 0) { pTransactionDetail->trans_in_progress = true; @@ -210,13 +240,14 @@ void transactionController::transactionEnd(const char* transactionRequestor) if(requestor == transactionRequestor) { + /*If any abort timer is running for this transaction then stop it*/ + if(abortTimer != NULL && abortTimer->isRunning()) + { + ALOGD ("%s: Transaction control timer killed", __FUNCTION__); + killAbortTimer(); + } pTransactionDetail->trans_in_progress = false; - sem_getvalue(&barrier, &val); - - if(!val) - sem_post(&barrier); - ALOGD ("%s: Transaction ended : %s ", __FUNCTION__, transactionRequestor); /* @@ -224,9 +255,12 @@ void transactionController::transactionEnd(const char* transactionRequestor) **/ if(android::nfcManager_isRequestPending()) { - abortTimer->set(5, transactionAbortTimerCb); + pendingTransHandleTimer->set(1, transactionHandlePendingCb); } + sem_getvalue(&barrier, &val); + if(!val) + sem_post(&barrier); } } /******************************************************************************* @@ -249,7 +283,12 @@ bool transactionController::transactionTerminate(const char* transactionRequest (requestor == transactionRequestor || !strcmp(transactionRequestor,"exec_pending_req"))) { pTransactionDetail->trans_in_progress = false; - abortTimer->kill(); + killAbortTimer(); + + if(android::nfcManager_isRequestPending()) + { + pendingTransHandleTimer->set(1, transactionHandlePendingCb); + } sem_getvalue(&barrier, &val); if(!val) @@ -308,6 +347,10 @@ transactionController* transactionController::controller(void) pInstance->requestor = NULL; pInstance->abortTimer->kill(); + pInstance->pendingTransHandleTimer->kill(); + + pInstance->abortTimer = new IntervalTimer(); + pInstance->pendingTransHandleTimer = new IntervalTimer(); sem_destroy(&pInstance->barrier); @@ -332,7 +375,10 @@ void transactionController::killAbortTimer(void) ALOGD ("%s: transaction controller abort timer killed", __FUNCTION__); if(transactionInProgress()) + { abortTimer->kill(); + abortTimer = new IntervalTimer(); + } } /******************************************************************************* ** @@ -349,4 +395,4 @@ void transactionController::setAbortTimer(unsigned int msec) if(transactionInProgress()) abortTimer->set(msec, transactionAbortTimerCb); -} \ No newline at end of file +} diff --git a/nci/jni/TransactionController.h b/nci/jni/TransactionController.h old mode 100644 new mode 100755 index d3965dd9..8402db28 --- a/nci/jni/TransactionController.h +++ b/nci/jni/TransactionController.h @@ -76,6 +76,7 @@ class transactionController static transactionController* pInstance; //Reference to controller sem_t barrier; //barrier: Guard for controlling access to NFCC when profile switch happening IntervalTimer* abortTimer; //abortTimer: Used for aborting a stuck transaction + IntervalTimer* pendingTransHandleTimer; //pendingTransHandleTimer: Used to schedule pending transaction handler thread Transcation_Check_t* pTransactionDetail; //transactionDetail: holds last transaction detail const char* requestor; //requestor: Identifier of transaction trigger @@ -91,6 +92,7 @@ class transactionController void killAbortTimer(void); void setAbortTimer(unsigned int msec); static void transactionAbortTimerCb(union sigval); + static void transactionHandlePendingCb(union sigval); static transactionController* controller(void); static transactionController* getInstance(void); }; -- cgit v1.2.3 From 153daa8fd095dd8d90508e9a3c6159d1882d6c1d Mon Sep 17 00:00:00 2001 From: Suhas Suresh Date: Thu, 5 Oct 2017 15:37:36 +0530 Subject: Fix for GetNumNFCEEConfigured function failure. If dynamic dual UICC feature is not available(66T/67T) configurations are being done for dynamic dual UICC. This causes wrong value update for available EEs in JNI. Fix : Send configurations only if dynamic dual UICC feature is available --- nci/jni/NativeNxpFeature.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nci/jni/NativeNxpFeature.cpp b/nci/jni/NativeNxpFeature.cpp index 35d19ecb..a80de316 100644 --- a/nci/jni/NativeNxpFeature.cpp +++ b/nci/jni/NativeNxpFeature.cpp @@ -678,11 +678,13 @@ tNFA_STATUS GetNumNFCEEConfigured(void) uint8_t num_config_params = 0x02; uint8_t config_param_len = 0x05; uint8_t buf_offset = 0x08; + if(nfcFL.nfccFL._NFCC_DYNAMIC_DUAL_UICC) { cmd_buf[buf_offset++] = NXP_NFC_SET_CONFIG_PARAM_EXT; cmd_buf[buf_offset++] = NXP_NFC_PARAM_ID_SWP1A; cmd_buf_len += 0x02; num_config_params++; config_param_len += 0x02; +} cmd_buf[2] = config_param_len; cmd_buf[3] = num_config_params; -- cgit v1.2.3 From 41d9de578ba8cc3cb11f93d29b7b83d8c7f1f52f Mon Sep 17 00:00:00 2001 From: Suhas Suresh Date: Thu, 28 Sep 2017 15:02:13 +0530 Subject: Fix for Timer at JNI layer waiting for SetModeNtf always expires SyncEvent mEeSetModeEvent is used to wait at 2 places during mode Set for single notification. When mode set Ntf is received ,first wait gets notified and second wait with timeout 500ms expires. Fix : Removed second timer as it not required. --- nci/jni/SecureElement.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp index f7d8ac68..d7037482 100644 --- a/nci/jni/SecureElement.cpp +++ b/nci/jni/SecureElement.cpp @@ -3244,15 +3244,6 @@ bool SecureElement::SecEle_Modeset(uint8_t type) retval = true; } #endif - /*Mode set on wait for ntf*/ - if(type) - { - SyncEventGuard guard (SecureElement::getInstance().mEeSetModeEvent); - if(SecureElement::getInstance().mEeSetModeEvent.wait(500) == false) - { - ALOGE("%s: timeout waiting for setModeNtf", __func__); - } - } } else #endif -- cgit v1.2.3 From 9294ce089fff8d0f595d9c3a06ec2a5a6d474825 Mon Sep 17 00:00:00 2001 From: Love Khanna Date: Fri, 6 Oct 2017 14:23:57 +0530 Subject: eSE contactless interface is mute In case eSE CE RF params are dirty, initiate full eSE init sequence. --- nci/jni/HciRFParams.cpp | 15 +++++++++++++++ nci/jni/NativeNfcManager.cpp | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/nci/jni/HciRFParams.cpp b/nci/jni/HciRFParams.cpp index 391a1b91..38a9d8f9 100644 --- a/nci/jni/HciRFParams.cpp +++ b/nci/jni/HciRFParams.cpp @@ -16,12 +16,18 @@ #include "HciRFParams.h" +#include "SecureElement.h" #define VAL_START_IDX 4 #define MAX_AID_SIZE 10 #define MAX_APP_DATA_SIZE 15 #define MAX_HIGHER_LAYER_RSP_SIZE 15 +#if(NXP_EXTNS == true) +#define ESE_HANDLE 0x4C0 +bool IsEseCeDisabled; +#endif + HciRFParams HciRFParams::sHciRFParams; /******************************************************************************* @@ -118,6 +124,15 @@ bool HciRFParams::initialize () ALOGV("%s: tlv_size %d", __func__,get_config->tlv_size); ALOGV("%s: param_tlvs %x", __func__,get_config->param_tlvs[0]); +#if(NXP_EXTNS == true) + if((get_config->param_tlvs[1] == 0xA0 && get_config->param_tlvs[2] == 0xF0) && + (get_config->param_tlvs[5] == 0xFF || get_config->param_tlvs[43] == 0xFF) && + SecureElement::getInstance().getEeStatus(ESE_HANDLE) == NFA_EE_STATUS_ACTIVE) { + ALOGV("%s: CE with ESE is disabled", __func__); + IsEseCeDisabled = true; + } +#endif + uint8_t *params = get_config->param_tlvs; params+=VAL_START_IDX; diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index b58d8356..17048fd3 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -107,6 +107,7 @@ extern bool recovery; extern uint8_t swp_getconfig_status; extern int gUICCVirtualWiredProtectMask; extern int gEseVirtualWiredProtectMask; +extern bool IsEseCeDisabled; static int32_t gNfcInitTimeout; int32_t gdisc_timeout; int32_t gSeDiscoverycount = 0; @@ -2148,6 +2149,7 @@ static jboolean nfcManager_doInitialize (JNIEnv* e, jobject o) tNFA_PMID ven_config_addr[] = {0xA0, 0x07}; bool isSuccess = false; sNfcee_disc_state = UICC_SESSION_NOT_INTIALIZED; + IsEseCeDisabled = false; /* NFC initialization in progress */ if(NFC_OFF == sNfcState) @@ -2295,6 +2297,19 @@ static jboolean nfcManager_doInitialize (JNIEnv* e, jobject o) ///////////////////////////////////////////////////////////////////////////////// // Add extra configuration here (work-arounds, etc.) #if (NXP_EXTNS == TRUE) + if(IsEseCeDisabled) + { + ALOGV("CE with ESE is disable, Hence reset the session"); + stat = android::ResetEseSession(); + if(stat == NFA_STATUS_OK) + { + SecureElement::getInstance().SecEle_Modeset(0x00); + usleep(50*1000); + SecureElement::getInstance().SecEle_Modeset(0x01); + } + IsEseCeDisabled = false; + } + if(nfcFL.nfcNxpEse) { if(nfcFL.eseFL._ESE_SVDD_SYNC || nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION || nfcFL.nfccFL._NFCC_SPI_FW_DOWNLOAD_SYNC || -- cgit v1.2.3 From c3bdf1b8befc4ab473e598f750708e6da74bbaf8 Mon Sep 17 00:00:00 2001 From: ubuntu Date: Tue, 10 Oct 2017 16:55:38 +0530 Subject: AC trigger observed in SPAY payment transaction FIx: Avoid sending mode set off command during NFC off when SPI session is still active --- nci/jni/SecureElement.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp index d7037482..26184488 100644 --- a/nci/jni/SecureElement.cpp +++ b/nci/jni/SecureElement.cpp @@ -4748,6 +4748,10 @@ tNFA_STATUS SecureElement::SecElem_EeModeSet(uint16_t handle, uint8_t mode) sSecElem.mResetEvent.wait(); } } + if((dual_mode_current_state & SPI_ON) && (handle == EE_HANDLE_0xF3) && + (mode == NFA_EE_MD_DEACTIVATE)) + return NFA_STATUS_OK; + SyncEventGuard guard (sSecElem.mEeSetModeEvent); stat = NFA_EeModeSet(handle, mode); if(stat == NFA_STATUS_OK && !android::nfcManager_isNfcDisabling() && -- cgit v1.2.3 From 63527d2246cd2511b0adad5665fd632084d8de9b Mon Sep 17 00:00:00 2001 From: ubuntu Date: Wed, 11 Oct 2017 14:27:02 +0530 Subject: pthread_exit crashed during SPI open and transceive continuously Description: The pthread_exit API makes use of cleanup pointer variable, which in this case, contains invalid address and thus causes segmentation fault on pthread_exit" --- nci/jni/SecureElement.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp index 26184488..b77ee527 100644 --- a/nci/jni/SecureElement.cpp +++ b/nci/jni/SecureElement.cpp @@ -4046,6 +4046,10 @@ TheEnd: return decoded_length; } #if(NXP_EXTNS == TRUE) +void cleanupStack(void* p) +{ + return; +} /******************************************************************************* ** ** Function: spiEventHandlerThread @@ -4057,6 +4061,9 @@ TheEnd: *******************************************************************************/ void *spiEventHandlerThread(void *arg) { + void (*pCleanupRoutine)(void* ptr) = cleanupStack; + __pthread_cleanup_t __cleanup; + if(!nfcFL.nfcNxpEse) { ALOGV("%s: nfcNxpEse not available. Returning", __func__); return NULL; @@ -4189,6 +4196,9 @@ void *spiEventHandlerThread(void *arg) } } ALOGV("%s: exit", __func__); + /*Explicit cleanup to avoid any issue due to pthread datastructure corruption*/ + __pthread_cleanup_push(&__cleanup, pCleanupRoutine, NULL); + __pthread_cleanup_pop(&__cleanup, 0); pthread_exit(NULL); return NULL; } -- cgit v1.2.3 From f76b89a9326f3ed6761cccb5853e9f4ff152afcf Mon Sep 17 00:00:00 2001 From: ubuntu Date: Tue, 10 Oct 2017 15:49:21 +0530 Subject: PN553 no response after send APDU response timeout Description: MW continues sending data packets even though RF timeout error has occurred. For ISODEP protocol and NFC A technology transceive timeout shall be set as per FWI received in RF_INTF_ACTIVATED_NTF. --- nci/jni/NfcTag.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nci/jni/NfcTag.cpp b/nci/jni/NfcTag.cpp index fe70087b..ff0395da 100644 --- a/nci/jni/NfcTag.cpp +++ b/nci/jni/NfcTag.cpp @@ -437,6 +437,18 @@ void NfcTag::discoverTechnologies (tNFA_ACTIVATED& activationData) } else if(NFC_PROTOCOL_ISO_DEP == rfDetail.protocol) { + if((rfDetail.rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_A) || + (rfDetail.rf_tech_param.mode == NFC_DISCOVERY_TYPE_POLL_A_ACTIVE)) + { + uint8_t fwi = rfDetail.intf_param.intf_param.pa_iso.fwi; + if(fwi > 0 && fwi < 15) + { + // fwt = (((2^fwi) * 256 * 16 ) / (13.56 * 10^6)) * 1000msec + double fwt = (((2 << (fwi - 1)) * 256 * 16) / 13560000) * 1000; + ALOGD ("Setting the Xceive timeout = %f, fwi = %0#x", fwt, fwi); + setTransceiveTimeout(mTechList[mNumTechList], fwt); + } + } //type-4 tag uses technology ISO-DEP and technology A or B mTechList [mNumTechList] = TARGET_TYPE_ISO14443_4; //is TagTechnology.ISO_DEP by Java API #if(NXP_EXTNS == TRUE) -- cgit v1.2.3 From 2c6614c02a8b017146885e06623c01a3116ff31e Mon Sep 17 00:00:00 2001 From: nxpandroid Date: Mon, 16 Oct 2017 16:43:02 +0530 Subject: NFC_NCIHALx_AR18C0.8.2.3_O_OpnSrc --- nci/jni/NfcTag.cpp | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 nci/jni/NfcTag.cpp diff --git a/nci/jni/NfcTag.cpp b/nci/jni/NfcTag.cpp old mode 100644 new mode 100755 -- cgit v1.2.3 From 57a34d903fe90a1e33e9a413175f7e52af8140c1 Mon Sep 17 00:00:00 2001 From: nxpandroid Date: Mon, 16 Oct 2017 17:33:36 +0530 Subject: NFC_NCIHALx_AR18C0.8.2.3_O_OpnSrc --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 46f881f6..8e3a3c3a 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,5 @@ | android-o-preview2 | 8.0.C_O (PN553/PN557) | NFC_NCIHALx_AR1800.8.0.C_O_OpnSrc | | android-o-preview2 | 8.0.13_O (PN553/PN557) | NFC_NCIHALx_AR18C0.8.0.13_O_OpnSrc | | android-8.0.0_r4 | 8.1.0_O (PN553) | NFC_NCIHALx_AR00C0.8.1.0_O_OpnSrc | +| android-8.0.0_r4 | 8.2.0_O (PN557) | NFC_NCIHALx_AR18C0.8.2.0_O_OpnSrc | +| android-8.0.0_r4 | 8.2.3_O (PN557) | NFC_NCIHALx_AR18C0.8.2.3_O_OpnSrc | -- cgit v1.2.3 From 1754ee0df13f110ab544744bb65f52a17301f230 Mon Sep 17 00:00:00 2001 From: nxf32288 Date: Tue, 24 Oct 2017 13:33:24 +0530 Subject: NFCEE_MODE_SET_CMD to eSE disabled during NFC init in 6Xt. Updated ALL_SE_ID_TYPE properly depends on chip type. --- src/com/android/nfc/NfcService.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 716cf4a4..58e88f5a 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -1298,7 +1298,6 @@ public class NfcService implements DeviceHostListener { mNxpPrefs.getInt(PREF_SECURE_ELEMENT_ID, SECURE_ELEMENT_ID_DEFAULT); if (seList != null) { - if (secureElementId != ALL_SE_ID_TYPE/* SECURE_ELEMENT_ALL */) { mDeviceHost.doDeselectSecureElement(UICC_ID_TYPE); mDeviceHost.doDeselectSecureElement(UICC2_ID_TYPE); @@ -1461,8 +1460,8 @@ public class NfcService implements DeviceHostListener { watchDog.cancel(); } int chipVer = mDeviceHost.getChipVer(); - if((chipVer == PN80T_ID) || (chipVer == PN553_ID)) { - ALL_SE_ID_TYPE |= UICC2_ID_TYPE; + if(chipVer < PN553_ID) { + ALL_SE_ID_TYPE &= ~UICC2_ID_TYPE; } checkSecureElementConfuration(); -- cgit v1.2.3 From f3dd540730594f503867445384235f2089f0aa7b Mon Sep 17 00:00:00 2001 From: Yerriswamy Date: Mon, 23 Oct 2017 16:53:35 +0530 Subject: p61-jcop-lib library dynamic loading implementation --- nci/jni/AlaLib.h | 107 ++++++++++++ nci/jni/Android.mk | 15 -- nci/jni/IChannel.h | 87 ++++++++++ nci/jni/JcDnld.h | 78 +++++++++ nci/jni/JcopManager.cpp | 388 +++++++++++++++++++++++++++++++++++++++++++ nci/jni/JcopManager.h | 289 ++++++++++++++++++++++++++++++++ nci/jni/NativeNfcAla.cpp | 37 ++--- nci/jni/NativeNfcManager.cpp | 21 ++- 8 files changed, 981 insertions(+), 41 deletions(-) create mode 100644 nci/jni/AlaLib.h create mode 100644 nci/jni/IChannel.h create mode 100644 nci/jni/JcDnld.h create mode 100644 nci/jni/JcopManager.cpp create mode 100644 nci/jni/JcopManager.h diff --git a/nci/jni/AlaLib.h b/nci/jni/AlaLib.h new file mode 100644 index 00000000..0ad3b417 --- /dev/null +++ b/nci/jni/AlaLib.h @@ -0,0 +1,107 @@ + /* + * Copyright (C) 2015 NXP Semiconductors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifdef __cplusplus + +extern "C" { + +#endif + + +#ifndef ALALIB_H_ +#define ALALIB_H_ + +#include +#include +#include +#include "IChannel.h" + +/******************************************************************************* +** +** Function: ALA_Init +** +** Description: Initializes the ALA library and opens the DWP communication channel +** +** Returns: SUCCESS if ok. +** +*******************************************************************************/ +unsigned char ALA_Init(IChannel *channel); + +/******************************************************************************* +** +** Function: ALA_Start +** +** Description: Starts the ALA over DWP +** +** Returns: SUCCESS if ok. +** +*******************************************************************************/ +#if(NXP_LDR_SVC_VER_2 == TRUE) +unsigned char ALA_Start(const char *name, const char *dest, uint8_t *pdata, uint16_t len, uint8_t *respSW); +#else +unsigned char ALA_Start(const char *name, uint8_t *pdata, uint16_t len); +#endif + +/******************************************************************************* +** +** Function: ALA_DeInit +** +** Description: Deinitializes the ALA Lib +** +** Returns: true if ok. +** +*******************************************************************************/ +bool ALA_DeInit(); + +#if(NXP_LDR_SVC_VER_2 == TRUE) +/******************************************************************************* +** +** Function: ALA_lsGetVersion +** +** Description: Get the Loader service Applet and cleint version +** +** Returns: byte[] array. +** +*******************************************************************************/ +unsigned char ALA_lsGetVersion(uint8_t *pVersion); +unsigned char ALA_lsGetStatus(uint8_t *pVersion); +unsigned char ALA_lsGetAppletStatus(uint8_t *pVersion); +#else +void ALA_GetlistofApplets(char *list[], uint8_t* num); +unsigned char ALA_GetCertificateKey(uint8_t *pKey, int32_t *pKeylen); +#endif + +inline int FSCANF_BYTE(FILE *stream, const char *format, void* pVal) +{ + int Result = 0; + + if((NULL != stream) && (NULL != format) && (NULL != pVal)) + { + unsigned int dwVal; + unsigned char* pTmp = (unsigned char*)pVal; + Result = fscanf(stream, format, &dwVal); + + (*pTmp) = (unsigned char)(dwVal & 0x000000FF); + } + return Result; +} + +#endif /* ALALIB_H_ */ + +#ifdef __cplusplus + +} + +#endif diff --git a/nci/jni/Android.mk b/nci/jni/Android.mk index c1a8223c..0c87dee2 100644 --- a/nci/jni/Android.mk +++ b/nci/jni/Android.mk @@ -22,8 +22,6 @@ LOCAL_CFLAGS += -DNFC_NXP_HFO_SETTINGS=FALSE #Enable HCE-F specific LOCAL_CFLAGS += -DNXP_NFCC_HCE_F=TRUE -NFC_NXP_ESE:= TRUE - NFC_POWER_MANAGEMENT:= TRUE ifeq ($(NFC_POWER_MANAGEMENT),TRUE) LOCAL_CFLAGS += -DNFC_POWER_MANAGEMENT=TRUE @@ -31,11 +29,7 @@ else LOCAL_CFLAGS += -DNFC_POWER_MANAGEMENT=FALSE endif -ifeq ($(NFC_NXP_ESE),TRUE) LOCAL_CFLAGS += -DNXP_LDR_SVC_VER_2=TRUE -else -LOCAL_CFLAGS += -DNXP_LDR_SVC_VER_2=FALSE -endif LOCAL_SRC_FILES := $(call all-subdir-cpp-files) $(call all-subdir-c-files) @@ -53,11 +47,6 @@ LOCAL_C_INCLUDES += \ $(VOB_COMPONENTS)/gki/common \ vendor/nxp/opensource/hardware/interfaces/nxpnfc/1.0/default/ -ifeq ($(NFC_NXP_ESE),TRUE) -LOCAL_C_INCLUDES +=external/p61-jcop-kit/include - -endif - LOCAL_SHARED_LIBRARIES := \ libicuuc \ libnativehelper \ @@ -68,10 +57,6 @@ LOCAL_SHARED_LIBRARIES := \ android.hardware.nfc@1.0\ vendor.nxp.nxpnfc@1.0 -ifeq ($(NFC_NXP_ESE),TRUE) -LOCAL_SHARED_LIBRARIES += libp61-jcop-kit -endif - #LOCAL_STATIC_LIBRARIES := libxml2 ifeq (true,$(TARGET_IS_64_BIT)) LOCAL_MULTILIB := 64 diff --git a/nci/jni/IChannel.h b/nci/jni/IChannel.h new file mode 100644 index 00000000..4e42242e --- /dev/null +++ b/nci/jni/IChannel.h @@ -0,0 +1,87 @@ + /* + * Copyright (C) 2015 NXP Semiconductors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ICHANNEL_H_ +#define ICHANNEL_H_ + +typedef struct IChannel +{ +/******************************************************************************* +** +** Function: Open +** +** Description: Initialize the channel. +** +** Returns: True if ok. +** +*******************************************************************************/ +int16_t (*open)(); +/******************************************************************************* +** +** Function: close +** +** Description: Close the channel. +** +** Returns: True if ok. +** +*******************************************************************************/ +bool (*close)(int16_t mHandle); + +/******************************************************************************* +** +** Function: transceive +** +** Description: Send data to the secure element; read it's response. +** xmitBuffer: Data to transmit. +** xmitBufferSize: Length of data. +** recvBuffer: Buffer to receive response. +** recvBufferMaxSize: Maximum size of buffer. +** recvBufferActualSize: Actual length of response. +** timeoutMillisec: timeout in millisecond +** +** Returns: True if ok. +** +*******************************************************************************/ +bool (*transceive) (uint8_t* xmitBuffer, int32_t xmitBufferSize, uint8_t* recvBuffer, + int32_t recvBufferMaxSize, int32_t& recvBufferActualSize, int32_t timeoutMillisec); + +/******************************************************************************* +** +** Function: doeSE_Reset +** +** Description: Power OFF and ON to eSE +** +** Returns: None. +** +*******************************************************************************/ + +void (*doeSE_Reset)(); +/******************************************************************************* +** +** Function: doeSE_JcopDownLoadReset +** +** Description: Power OFF and ON to eSE during JCOP Update +** +** Returns: None. +** +*******************************************************************************/ + +void (*doeSE_JcopDownLoadReset)(); + +}IChannel_t; + + +#endif /* ICHANNEL_H_ */ diff --git a/nci/jni/JcDnld.h b/nci/jni/JcDnld.h new file mode 100644 index 00000000..630dd7d8 --- /dev/null +++ b/nci/jni/JcDnld.h @@ -0,0 +1,78 @@ + /* + * Copyright (C) 2015 NXP Semiconductors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifdef __cplusplus + +extern "C" { + +#endif + + +#ifndef JCDNLD_H_ +#define JCDNLD_H_ + +#include "IChannel.h" +/******************************************************************************* +** +** Function: JCDNLD_Init +** +** Description: Initializes the JCOP library and opens the DWP communication channel +** +** Returns: SUCCESS if ok. +** +*******************************************************************************/ +unsigned char JCDNLD_Init(IChannel *channel); + +/******************************************************************************* +** +** Function: JCDNLD_StartDownload +** +** Description: Starts the JCOP update +** +** Returns: SUCCESS if ok. +** +*******************************************************************************/ +unsigned char JCDNLD_StartDownload(); + +/******************************************************************************* +** +** Function: JCDNLD_DeInit +** +** Description: Deinitializes the JCOP Lib +** +** Returns: true if ok. +** +*******************************************************************************/ +bool JCDNLD_DeInit(); + +/******************************************************************************* +** +** Function: JCDNLD_CheckVersion +** +** Description: Check the existing JCOP OS version +** +** Returns: true if ok. +** +*******************************************************************************/ +bool JCDNLD_CheckVersion(); + + +#endif /* JCDNLD_H_ */ + +#ifdef __cplusplus + +} + +#endif diff --git a/nci/jni/JcopManager.cpp b/nci/jni/JcopManager.cpp new file mode 100644 index 00000000..336fbcf8 --- /dev/null +++ b/nci/jni/JcopManager.cpp @@ -0,0 +1,388 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/****************************************************************************** + * + * The original Work has been changed by NXP Semiconductors. + * + * Copyright (C) 2015 NXP Semiconductors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.Pgpx_Jcop_handle + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +/* + * Communicate with secure elements that are attached to the NFC + * controller. + */ + +#include "JcopManager.h" +#include "_OverrideLog.h" +#include + +JcopManager* JcopManager::mJcpMgr = NULL; +static void* Pgpx_JCP_handle = NULL; +static phJcop_Context_t g_mPhJcpCtxt; +static phJcop_Context_t *pg_mPhJcpCtxt = &g_mPhJcpCtxt; +static void *Pgpx_Jcop_handle = NULL; +#define DL_STATUS_OK 0x00 + +JcopManager::JcopManager() +{ +} + +JcopManager::~JcopManager() +{ +} + +/******************************************************************************* +** +** Function: getInstance +** +** Description: Get the JcopManager singleton object. +** +** Returns: JcopManager object. +** +*******************************************************************************/ +JcopManager* JcopManager::getInstance () +{ + if(mJcpMgr == NULL){ + mJcpMgr = new JcopManager(); + } + return mJcpMgr; +} + +/******************************************************************************* +** +** Function: deleteInstance +** +** Description: Delete the JcopManager singleton object. +** +*******************************************************************************/ +void JcopManager::deleteInstance () +{ + delete mJcpMgr; +} + +/******************************************************************************* +** +** Function: JcopInitialize +** +** Description: Load the library and initialize the symbols and variables. +** +** Returns: STATUS_OK if Success. +** STATUS_FAILED if unSuccessfull +** +*******************************************************************************/ +tNFA_STATUS JcopManager::JcopInitialize () +{ + tNFA_STATUS wStatus = NFA_STATUS_OK; + //Getting pointer to JCOP module + Pgpx_Jcop_handle = dlopen("system/lib64/libp61-jcop-kit.so",RTLD_NOW); + if(Pgpx_Jcop_handle == NULL){ + ALOGE("%s: Error : opening (system/lib64/libp61-jcop-kit.so) !!", __func__); + return NFA_STATUS_FAILED; + } + // Getting pointer to ALA_Init function + if((pg_mPhJcpCtxt->ala_init = (tJCOP_INIT_CBACK *)dlsym(Pgpx_Jcop_handle, "ALA_Init")) == NULL){ + ALOGE("%s: Error while linking JCOP context (ALA_Init) !!", __func__); + return NFA_STATUS_FAILED; + } + // Getting pointer to ALA_Start function + if((pg_mPhJcpCtxt->ala_start = (tALA_START_CBACK *)dlsym(Pgpx_Jcop_handle, "ALA_Start")) == NULL){ + wStatus = NFA_STATUS_FAILED; + ALOGE("%s: Error while linking JCOP context (ALA_Start) !!", __func__); + } + +#if (NXP_LDR_SVC_VER_2 == FALSE) + // Getting pointer to ALA_GetlistofApplets function + if((pg_mPhJcpCtxt->ala_applets_list = (tALA_APPLET_LIST_CBACK *)dlsym(Pgpx_Jcop_handle, "ALA_GetlistofApplets")) == NULL){ + wStatus = NFA_STATUS_FAILED; + ALOGE("%s: Error while linking JCOP context (ALA_GetlistofApplets) !!", __func__); + } + // Getting pointer to ALA_GetCertificateKey function + if((pg_mPhJcpCtxt->ala_get_certkey = (tALA_GET_CERTKEY_CBACK *)dlsym(Pgpx_Jcop_handle, "ALA_GetCertificateKey")) == NULL){ + wStatus = NFA_STATUS_FAILED; + ALOGE("%s: Error while linking JCOP context (ALA_GetCertificateKey) !!", __func__); + } +#endif + + // Getting pointer to ALA_DeInit function + if((pg_mPhJcpCtxt->ala_deinit = (tJCOP_DEINIT_CBACK *)dlsym(Pgpx_Jcop_handle, "ALA_DeInit")) == NULL){ + wStatus = NFA_STATUS_FAILED; + ALOGE("%s: Error while linking JCOP context (ALA_DeInit) !!", __func__); + } + // Getting pointer to ALA_lsGetVersion function + if((pg_mPhJcpCtxt->ala_lsgetversion = (tALA_LS_CBACK *)dlsym(Pgpx_Jcop_handle, "ALA_lsGetVersion")) == NULL){ + wStatus = NFA_STATUS_FAILED; + ALOGE("%s: Error while linking JCOP context (ALA_lsGetVersion) !!", __func__); + } + // Getting pointer to ALA_lsGetStatus function + if((pg_mPhJcpCtxt->ala_lsgetstatus = (tALA_LS_CBACK *)dlsym(Pgpx_Jcop_handle, "ALA_lsGetStatus")) == NULL){ + wStatus = NFA_STATUS_FAILED; + ALOGE("%s: Error while linking JCOP context (ALA_lsGetStatus) !!", __func__); + } + // Getting pointer to ALA_lsGetAppletStatus function + if((pg_mPhJcpCtxt->ala_lsgetappletstatus = (tALA_LS_CBACK *)dlsym(Pgpx_Jcop_handle, "ALA_lsGetAppletStatus")) == NULL){ + wStatus = NFA_STATUS_FAILED; + ALOGE("%s: Error while linking JCOP context (ALA_lsGetAppletStatus) !!", __func__); + } + // Getting pointer to JCDNLD_Init function + if((pg_mPhJcpCtxt->jcop_init = (tJCOP_INIT_CBACK *)dlsym(Pgpx_Jcop_handle, "JCDNLD_Init")) == NULL){ + wStatus = NFA_STATUS_FAILED; + ALOGE("%s: Error while linking JCOP context (JCDNLD_Init) !!", __func__); + } + // Getting pointer to JCDNLD_StartDownload function + if((pg_mPhJcpCtxt->jcdnld_startdnld = (tJCDNLD_DWLD_CBACK *)dlsym(Pgpx_Jcop_handle, "JCDNLD_StartDownload")) == NULL){ + wStatus = NFA_STATUS_FAILED; + ALOGE("%s: Error while linking JCOP context (JCDNLD_StartDownload) !!", __func__); + } + // Getting pointer to JCDNLD_DeInit function + if((pg_mPhJcpCtxt->ala_deinit = (tJCOP_DEINIT_CBACK *)dlsym(Pgpx_Jcop_handle, "JCDNLD_DeInit")) == NULL){ + wStatus = NFA_STATUS_FAILED; + ALOGE("%s: Error while linking JCOP context (JCDNLD_DeInit) !!", __func__); + } + return wStatus; +} + +/******************************************************************************* +** +** Function: JcopDeInitialize +** +** Description: De-initialize the library +** +** Returns: STATUS_OK if Success. +** STATUS_FAILED if unSuccessfull +** +*******************************************************************************/ +tNFA_STATUS JcopManager::JcopDeInitialize () +{ + if(Pgpx_Jcop_handle != NULL){ + if((dlclose(Pgpx_Jcop_handle)) != DL_STATUS_OK){ + ALOGE("%s: Error : closing (system/lib64/libp61-jcop-kit.so) !!", __func__); + return NFA_STATUS_FAILED; + } + }else{ + ALOGE("%s: Invalid handle !!", __func__); + } + return NFA_STATUS_OK; +} + +/******************************************************************************* +** +** Function: AlaInitialize +** +** Description: Initializes the ALA library and opens the DWP communication channel +** +** Returns: STATUS_OK if Success. +** STATUS_FAILED if unSuccessfull +** +*******************************************************************************/ +tNFC_JBL_STATUS JcopManager::AlaInitialize (IChannel *channel) +{ + if(channel == NULL) + { + ALOGE("%s: Invalid handle !!", __func__); + return NFA_STATUS_FAILED; + } + return pg_mPhJcpCtxt->ala_init(channel); +} + +/******************************************************************************* +** +** Function: AlaDeInitialize +** +** Description: Deinitializes the ALA Lib +** +** Returns: True if ok. +** +*******************************************************************************/ +bool JcopManager::AlaDeInitialize () { return pg_mPhJcpCtxt->ala_deinit(); } + +/******************************************************************************* +** +** Function: AlaStart +** +** Description: Starts the ALA over DWP +** +** Returns: STATUS_OK if Success. +** STATUS_FAILED if unSuccessfull +** +*******************************************************************************/ +#if (NXP_LDR_SVC_VER_2 == TRUE) +tNFC_JBL_STATUS JcopManager::AlaStart (const char *name, const char *dest, uint8_t *pdata, uint16_t len, uint8_t *respSW) +{ + if( !name || !dest || !pdata || !respSW){ + ALOGE("%s: Invalid Params !!", __func__); + return NFA_STATUS_FAILED; + } + return pg_mPhJcpCtxt->ala_start(name, dest, pdata, len, respSW); +} +#else +tNFC_JBL_STATUS JcopManager::AlaStart (const char *name, uint8_t *pdata, uint16_t len) +{ + if( !name || !pdata ){ + ALOGE("%s: Invalid Params !!", __func__); + return NFA_STATUS_FAILED; + } + return pg_mPhJcpCtxt->ala_start(name, dest, pdata, len, respSW); +} +#endif + +#if (NXP_LDR_SVC_VER_2 == FALSE) +/******************************************************************************* +** +** Function: AlaGetlistofApplets +** +** Description: list all the applets. +** +*******************************************************************************/ +void JcopManager::AlaGetlistofApplets (char *list[], uint8_t* num) +{ + if(!list || !num){ + ALOGE("%s: Invalid Params !!", __func__); + return; + } + pg_mPhJcpCtxt->ala_applets_list(list, num); +} + +/******************************************************************************* +** +** Function: AlaGetCertificateKey +** +** Description: Get the certification key +** +** Returns: True if ok. +** +*******************************************************************************/ +tNFC_JBL_STATUS JcopManager::AlaGetCertificateKey (uint8_t *pKey, int32_t *pKeylen) +{ + if(!pKey || !pKeylen){ + ALOGE("%s: Invalid Params !!", __func__); + return NFA_STATUS_FAILED; + } + return pg_mPhJcpCtxt->ala_get_certkey(pKey, pKeylen); +} +#endif + +/******************************************************************************* +** +** Function: AlaLsGetVersion +** +** Description: Get the version of the loader version +** +** Returns: STATUS_OK if Success. +** STATUS_FAILED if unSuccessfull +** +*******************************************************************************/ +tNFC_JBL_STATUS JcopManager::AlaLsGetVersion (uint8_t *pVersion) +{ + if(!pVersion){ + ALOGE("%s: Invalid Params !!", __func__); + return NFA_STATUS_FAILED; + } + return pg_mPhJcpCtxt->ala_lsgetversion(pVersion); +} + +/******************************************************************************* +** +** Function: AlaLsGetAppletStatus +** +** Description: Get the status of the loader service version +** +** Returns: STATUS_OK if Success. +** STATUS_FAILED if unSuccessfull +** +*******************************************************************************/ +tNFC_JBL_STATUS JcopManager::AlaLsGetAppletStatus (uint8_t *pVersion) +{ + if(!pVersion){ + ALOGE("%s: Invalid Params !!", __func__); + return NFA_STATUS_FAILED; + } + return pg_mPhJcpCtxt->ala_lsgetappletstatus(pVersion); +} + +/******************************************************************************* +** +** Function: AlaLsGetAppletStatus +** +** Description: Get the status of the loader service +** +** Returns: STATUS_OK if Success. +** STATUS_FAILED if unSuccessfull +** +*******************************************************************************/ +tNFC_JBL_STATUS JcopManager::AlaLsGetStatus (uint8_t *pVersion) +{ + if(!pVersion){ + ALOGE("%s: Invalid Params !!", __func__); + return NFA_STATUS_FAILED; + } + return pg_mPhJcpCtxt->ala_lsgetstatus(pVersion); +} + +/******************************************************************************* +** +** Function: JCDnldInit +** +** Description: Initializes the JCOP library and opens the DWP communication channel +** +** Returns: STATUS_OK if Success. +** STATUS_FAILED if unSuccessfull +** +*******************************************************************************/ +tNFC_JBL_STATUS JcopManager::JCDnldInit (IChannel *channel) +{ + if(!channel){ + ALOGE("%s: Invalid Params !!", __func__); + return NFA_STATUS_FAILED; + } + return pg_mPhJcpCtxt->jcop_init(channel); +} + +/******************************************************************************* +** +** Function: JCDnldStartDownload +** +** Description: Starts the JCOP update +** +** Returns: STATUS_OK if Success. +** STATUS_FAILED if unSuccessfull +** +*******************************************************************************/ +tNFC_JBL_STATUS JcopManager::JCDnldStartDownload () { return pg_mPhJcpCtxt->jcdnld_startdnld(); } + +/******************************************************************************* +** +** Function: JCDnldDeInit +** +** Description: De-initializes the JCOP Library +** +** Returns: True if ok. +** +*******************************************************************************/ +bool JcopManager::JCDnldDeInit () { return pg_mPhJcpCtxt->jcdnld_deinit(); } + + diff --git a/nci/jni/JcopManager.h b/nci/jni/JcopManager.h new file mode 100644 index 00000000..609a17d2 --- /dev/null +++ b/nci/jni/JcopManager.h @@ -0,0 +1,289 @@ +/* + * Copyright (C) 2012 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/****************************************************************************** + * + * The original Work has been changed by NXP Semiconductors. + * + * Copyright (C) 2015 NXP Semiconductors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +/* + * Communicate with secure elements that are attached to the NFC + * controller. + */ + +#pragma once + +extern "C"{ +#include "nfa_api.h" +#include "AlaLib.h" +#include "JcDnld.h" +#include "IChannel.h" +} + +#define pJcopMgr (JcopManager::getInstance ()) +typedef unsigned char (tJCOP_INIT_CBACK)(IChannel *channel); +#if (NXP_LDR_SVC_VER_2 == TRUE) +typedef unsigned char (tALA_START_CBACK)(const char *name, const char *dest, uint8_t *pdata, uint16_t len, uint8_t *respSW); +#else +typedef unsigned char (tALA_START_CBACK)(const char *name, uint8_t *pdata, uint16_t len); +typedef unsigned char (tALA_GET_CERTKEY_CBACK)(uint8_t *pKey, int32_t *pKeylen); +typedef void (tALA_APPLET_LIST_CBACK)(char *list[], uint8_t* num); +#endif +typedef unsigned char (tALA_LS_CBACK)(uint8_t *pVersion); +typedef unsigned char (tJCDNLD_DWLD_CBACK)(); +typedef bool (tJCOP_DEINIT_CBACK)(); + +typedef struct phJcop_Context +{ + /* Call backs */ + tJCOP_INIT_CBACK *jcop_init; + tJCOP_INIT_CBACK *ala_init; + tALA_START_CBACK *ala_start; +#if (NXP_LDR_SVC_VER_2 == FALSE) + tALA_APPLET_LIST_CBACK *ala_applets_list; + tALA_GET_CERTKEY_CBACK *ala_get_certkey; +#endif + tALA_LS_CBACK *ala_lsgetversion; + tALA_LS_CBACK *ala_lsgetstatus; + tALA_LS_CBACK *ala_lsgetappletstatus; + tJCDNLD_DWLD_CBACK *jcdnld_startdnld; + tJCOP_DEINIT_CBACK *ala_deinit; + tJCOP_DEINIT_CBACK *jcdnld_deinit; +}phJcop_Context_t; +typedef unsigned char tNFC_JBL_STATUS; + +class JcopManager +{ +private: + static JcopManager *mJcpMgr; + /******************************************************************************* + ** + ** Function: JcopManager + ** + ** Description: Initialize member variables. + ** + ** Returns: None + ** + *******************************************************************************/ + JcopManager (); + + + /******************************************************************************* + ** + ** Function: ~JcopManager + ** + ** Description: Release all resources. + ** + ** Returns: None + ** + *******************************************************************************/ + ~JcopManager (); + +public: + /******************************************************************************* + ** + ** Function: getInstance + ** + ** Description: Get the JcopManager singleton object. + ** + ** Returns: JcopManager object. + ** + *******************************************************************************/ + static JcopManager* getInstance (); + + /******************************************************************************* + ** + ** Function: deleteInstance + ** + ** Description: Delete the JcopManager singleton object. + ** + *******************************************************************************/ + void deleteInstance (); + + /******************************************************************************* + ** + ** Function: JcopInitialize + ** + ** Description: Load the library and initialize the symbols and variables. + ** + ** Returns: STATUS_OK if Success. + ** STATUS_FAILED if unSuccessfull + ** + *******************************************************************************/ + tNFA_STATUS JcopInitialize (); + + /******************************************************************************* + ** + ** Function: JcopDeInitialize + ** + ** Description: De-initialize the library + ** + ** Returns: STATUS_OK if Success. + ** STATUS_FAILED if unSuccessfull + ** + *******************************************************************************/ + tNFA_STATUS JcopDeInitialize (); + + /******************************************************************************* + ** + ** Function: AlaInitialize + ** + ** Description: Initializes the ALA library and opens the DWP communication channel + ** + ** Returns: STATUS_OK if Success. + ** STATUS_FAILED if unSuccessfull + ** + *******************************************************************************/ + tNFC_JBL_STATUS AlaInitialize (IChannel *channel); + + /******************************************************************************* + ** + ** Function: AlaDeInitialize + ** + ** Description: Deinitializes the ALA Lib + ** + ** Returns: True if ok. + ** + *******************************************************************************/ + bool AlaDeInitialize (); + + /******************************************************************************* + ** + ** Function: AlaStart + ** + ** Description: Starts the ALA over DWP + ** + ** Returns: STATUS_OK if Success. + ** STATUS_FAILED if unSuccessfull + ** + *******************************************************************************/ +#if (NXP_LDR_SVC_VER_2 == TRUE) + tNFC_JBL_STATUS AlaStart (const char *name, const char *dest, uint8_t *pdata, uint16_t len, uint8_t *respSW); +#else + tNFC_JBL_STATUS AlaStart (const char *name, uint8_t *pdata, uint16_t len); +#endif + + /******************************************************************************* + ** + ** Function: AlaLsGetVersion + ** + ** Description: Get the version of the loader version + ** + ** Returns: STATUS_OK if Success. + ** STATUS_FAILED if unSuccessfull + ** + *******************************************************************************/ + tNFC_JBL_STATUS AlaLsGetVersion (uint8_t *pVersion); + + /******************************************************************************* + ** + ** Function: AlaLsGetAppletStatus + ** + ** Description: Get the status of the loader service version + ** + ** Returns: STATUS_OK if Success. + ** STATUS_FAILED if unSuccessfull + ** + *******************************************************************************/ + tNFC_JBL_STATUS AlaLsGetAppletStatus (uint8_t *pVersion); + + /******************************************************************************* + ** + ** Function: AlaLsGetAppletStatus + ** + ** Description: Get the status of the loader service + ** + ** Returns: STATUS_OK if Success. + ** STATUS_FAILED if unSuccessfull + ** + *******************************************************************************/ + tNFC_JBL_STATUS AlaLsGetStatus (uint8_t *pVersion); + +#if (NXP_LDR_SVC_VER_2 == FALSE) + /******************************************************************************* + ** + ** Function: AlaGetlistofApplets + ** + ** Description: list all the applets. + ** + *******************************************************************************/ + + void AlaGetlistofApplets (char *list[], uint8_t* num); + + + /******************************************************************************* + ** + ** Function: AlaGetCertificateKey + ** + ** Description: Get the certification key + ** + ** Returns: True if ok. + ** + *******************************************************************************/ + tNFC_JBL_STATUS AlaGetCertificateKey (uint8_t *pKey, int32_t *pKeylen); +#endif + + + + /******************************************************************************* + ** + ** Function: JCDnldInit + ** + ** Description: Initializes the JCOP library and opens the DWP communication channel + ** + ** Returns: STATUS_OK if Success. + ** STATUS_FAILED if unSuccessfull + ** + *******************************************************************************/ + tNFC_JBL_STATUS JCDnldInit (IChannel *channel); + + /******************************************************************************* + ** + ** Function: JCDnldStartDownload + ** + ** Description: Starts the JCOP update + ** + ** Returns: STATUS_OK if Success. + ** STATUS_FAILED if unSuccessfull + ** + *******************************************************************************/ + tNFC_JBL_STATUS JCDnldStartDownload (); + + /******************************************************************************* + ** + ** Function: JCDnldDeInit + ** + ** Description: De-initializes the JCOP Library + ** + ** Returns: True if ok. + ** + *******************************************************************************/ + bool JCDnldDeInit (); + +}; diff --git a/nci/jni/NativeNfcAla.cpp b/nci/jni/NativeNfcAla.cpp index 705737bf..c331672c 100644 --- a/nci/jni/NativeNfcAla.cpp +++ b/nci/jni/NativeNfcAla.cpp @@ -21,10 +21,9 @@ #include "DwpChannel.h" #include "SecureElement.h" #include "TransactionController.h" +#include "JcopManager.h" extern "C" { - #include "AlaLib.h" - #include "IChannel.h" #include "phNxpConfig.h" } #define LS_DEFAULT_VERSION 0x20 @@ -82,7 +81,7 @@ int nfcManager_GetAppletsList(JNIEnv* e, jobject o, jobjectArray list) startRfDiscovery (false); } ALOGV("%s: list_len=0x%x", __func__, list_len); - ALA_GetlistofApplets(name, &num); + pJcopMgr->AlaGetlistofApplets(name, &num); if((num != 0) && (list_len >= num)) @@ -155,7 +154,7 @@ int nfcManager_doAppletLoadApplet(JNIEnv* e, jobject o, jstring name, jbyteArray startRfDiscovery (false); } DWPChannel_init(&Dwp); - wStatus = ALA_Init(&Dwp); + wStatus = JcopManager::getInstance().AlaInitialize(&Dwp); if(wStatus != NFA_STATUS_OK) { ALOGE("%s: ALA initialization failed", __func__); @@ -168,9 +167,9 @@ int nfcManager_doAppletLoadApplet(JNIEnv* e, jobject o, jstring name, jbyteArray ScopedByteArrayRO bytes(e, data); uint8_t* buf = const_cast(reinterpret_cast(&bytes[0])); size_t bufLen = bytes.size(); - wStatus = ALA_Start(choice, buf, bufLen); + wStatus = pJcopMgr->AlaStart(choice, buf, bufLen); } - stat = ALA_DeInit(); + stat = pJcopMgr->AlaDeInitialize(); if(choice != NULL) e->ReleaseStringUTFChars(name, choice); @@ -237,7 +236,7 @@ jbyteArray nfcManager_lsExecuteScript(JNIEnv* e, jobject o, jstring name, jstrin startRfDiscovery (false); } DWPChannel_init(&Dwp); - wStatus = ALA_Init(&Dwp); + wStatus = pJcopMgr->AlaInitialize(&Dwp); if(wStatus != NFA_STATUS_OK) { ALOGE("%s: ALA initialization failed", __func__); @@ -264,7 +263,7 @@ jbyteArray nfcManager_lsExecuteScript(JNIEnv* e, jobject o, jstring name, jstrin ScopedByteArrayRO bytes(e, data); uint8_t* buf = const_cast(reinterpret_cast(&bytes[0])); size_t bufLen = bytes.size(); - wStatus = ALA_Start(choice,destpath, buf, bufLen,resSW); + wStatus = pJcopMgr->AlaStart(choice,destpath, buf, bufLen,resSW); //copy results back to java result = e->NewByteArray(lsExecuteResponseSize); @@ -283,7 +282,7 @@ jbyteArray nfcManager_lsExecuteScript(JNIEnv* e, jobject o, jstring name, jstrin sNfaVSCResponseEvent.wait(); //wait for NFA VS command to finish }*/ - stat = ALA_DeInit(); + stat = pJcopMgr->AlaDeInitialize(); if(choice != NULL) e->ReleaseStringUTFChars(name, choice); @@ -338,7 +337,7 @@ jbyteArray nfcManager_GetCertificateKey(JNIEnv* e, jobject) startRfDiscovery (false); } DWPChannel_init(&Dwp); - wStatus = ALA_Init(&Dwp); + wStatus = pJcopMgr->AlaInitialize(&Dwp); if(wStatus != NFA_STATUS_OK) { ALOGE("%s: ALA initialization failed", __func__); @@ -346,7 +345,7 @@ jbyteArray nfcManager_GetCertificateKey(JNIEnv* e, jobject) else { ALOGE("%s: start Get reference Certificate Key", __func__); - wStatus = ALA_GetCertificateKey(recvBuffer, &recvBufferActualSize); + wStatus = pJcopMgr->AlaGetCertificateKey(recvBuffer, &recvBufferActualSize); } //copy results back to java @@ -356,7 +355,7 @@ jbyteArray nfcManager_GetCertificateKey(JNIEnv* e, jobject) e->SetByteArrayRegion(result, 0, recvBufferActualSize, (jbyte *) recvBuffer); } - stat = ALA_DeInit(); + stat = pJcopMgr->AlaDeInitialize(); startRfDiscovery (true); ALOGV("%s: exit: recv len=%ld", __func__, recvBufferActualSize); @@ -404,7 +403,7 @@ jbyteArray nfcManager_lsGetVersion(JNIEnv* e, jobject) startRfDiscovery (false); } DWPChannel_init(&Dwp); - wStatus = ALA_Init(&Dwp); + wStatus = pJcopMgr->AlaInitialize(&Dwp); if(wStatus != NFA_STATUS_OK) { ALOGE("%s: ALA initialization failed", __func__); @@ -412,7 +411,7 @@ jbyteArray nfcManager_lsGetVersion(JNIEnv* e, jobject) else { ALOGE("%s: start Get reference Certificate Key", __func__); - wStatus = ALA_lsGetVersion(recvBuffer); + wStatus = pJcopMgr->AlaLsGetVersion(recvBuffer); } //copy results back to java @@ -422,7 +421,7 @@ jbyteArray nfcManager_lsGetVersion(JNIEnv* e, jobject) e->SetByteArrayRegion(result, 0, recvBufferMaxSize, (jbyte *) recvBuffer); } - stat = ALA_DeInit(); + stat = pJcopMgr->AlaDeInitialize(); if(dwpChannelForceClose == false) startRfDiscovery (true); @@ -469,7 +468,7 @@ jbyteArray nfcManager_lsGetAppletStatus(JNIEnv* e, jobject) startRfDiscovery (false); } DWPChannel_init(&Dwp); - wStatus = ALA_Init(&Dwp); + wStatus = pJcopMgr->AlaInitialize(&Dwp); if(wStatus != NFA_STATUS_OK) { ALOGE("%s: ALA initialization failed", __func__); @@ -477,7 +476,7 @@ jbyteArray nfcManager_lsGetAppletStatus(JNIEnv* e, jobject) else { ALOGE("%s: start Get reference Certificate Key", __func__); - wStatus = ALA_lsGetAppletStatus(recvBuffer); + wStatus = pJcopMgr->AlaLsGetAppletStatus(recvBuffer); } ALOGV("%s: lsGetAppletStatus values %x %x", __func__, recvBuffer[0], recvBuffer[1]); @@ -487,7 +486,7 @@ jbyteArray nfcManager_lsGetAppletStatus(JNIEnv* e, jobject) { e->SetByteArrayRegion(result, 0, recvBufferMaxSize, (jbyte *) recvBuffer); } - stat = ALA_DeInit(); + stat = pJcopMgr->AlaDeInitialize(); if(dwpChannelForceClose == false) startRfDiscovery (true); @@ -523,7 +522,7 @@ jbyteArray nfcManager_lsGetStatus(JNIEnv* e, jobject) const int32_t recvBufferMaxSize = 2; uint8_t recvBuffer [recvBufferMaxSize] = {0x63,0x40}; - wStatus = ALA_lsGetStatus(recvBuffer); + wStatus = pJcopMgr->AlaLsGetStatus(recvBuffer); ALOGV("%s: lsGetStatus values %x %x", __func__, recvBuffer[0], recvBuffer[1]); //copy results back to java diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index 17048fd3..880d93c5 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -59,6 +59,7 @@ #include "DwpChannel.h" #include "TransactionController.h" #include +#include "JcopManager.h" extern "C" { #include "nfc_api.h" @@ -71,10 +72,6 @@ extern "C" #include "phNxpExtns.h" #include "phNxpConfig.h" -#if(NXP_EXTNS == TRUE) - #include "JcDnld.h" - #include "IChannel.h" -#endif } #define ALOGV ALOGD #define SAK_VALUE_AT 17 @@ -2198,6 +2195,11 @@ static jboolean nfcManager_doInitialize (JNIEnv* e, jobject o) #endif stat = nfcManagerEnableNfc(theInstance); nfcManager_getFeatureList(); + if(nfcFL.nfcNxpEse){ + ALOGV("ESE Present Loading p61-jcop-lib"); + pJcopMgr->JcopInitialize(); + }else + ALOGV("ESE Not Present"); EXTNS_Init (nfaDeviceManagementCallback, nfaConnectionCallback); if (stat == NFA_STATUS_OK ) @@ -3365,6 +3367,11 @@ if(nfcFL.eseFL._JCOP_WA_ENABLE) { if(nfcFL.eseFL._JCOP_WA_ENABLE) { NFA_HciW4eSETransaction_Complete(Wait); } + if(nfcFL.nfcNxpEse){ + ALOGV("De-Initializing p61-jcop-lib library"); + pJcopMgr->JcopDeInitialize(); + pJcopMgr->deleteInstance(); + } pn544InteropAbortNow (); RoutingManager::getInstance().onNfccShutdown(); @@ -5624,7 +5631,7 @@ static int nfcManager_doJcosDownload(JNIEnv* e, jobject o) startRfDiscovery (false); } DWPChannel_init(&Dwp); - status = JCDNLD_Init(&Dwp); + status = pJcopMgr->JCDnldInit(&Dwp); if(status != NFA_STATUS_OK) { ALOGE("%s: JCDND initialization failed", __func__); @@ -5633,7 +5640,7 @@ static int nfcManager_doJcosDownload(JNIEnv* e, jobject o) { ALOGE("%s: start JcopOs_Download", __func__); se.mDownloadMode = JCOP_DOWNLOAD; - status = JCDNLD_StartDownload(); + status = pJcopMgr->JCDnldStartDownload(); } if(nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION) { ret_val = NFC_SetP61Status ((void *)&ese_status, JCP_DWP_DWNLD_COMPLETE); @@ -5650,7 +5657,7 @@ static int nfcManager_doJcosDownload(JNIEnv* e, jobject o) } } } - stat = JCDNLD_DeInit(); + stat = pJcopMgr->JCDnldDeInit(); if(nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION) { pTransactionController->transactionEnd(TRANSACTION_REQUESTOR(jcosDownload)); if(pendingScreenState == true) -- cgit v1.2.3 From c60a9acc4d3a05723aeb8a3831c77de1fe70769f Mon Sep 17 00:00:00 2001 From: Suhas Suresh Date: Tue, 24 Oct 2017 18:49:41 +0530 Subject: Code correction in p2p_prio_logic_multiprotocol Corrected the wrong condition check for screenState --- nci/jni/NativeNfcManager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index 880d93c5..a0428fdf 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -642,7 +642,7 @@ void *p2p_prio_logic_multiprotocol(void *arg) ALOGD ("%s: enter", __FUNCTION__); /* Do not need if it is already in screen off state */ - if ((getScreenState() != (NFA_SCREEN_STATE_OFF_LOCKED || NFA_SCREEN_STATE_OFF_UNLOCKED))) + if (!(getScreenState() & (NFA_SCREEN_STATE_OFF_LOCKED | NFA_SCREEN_STATE_OFF_UNLOCKED))) { /* Stop polling */ if (sRfEnabled) -- cgit v1.2.3 From 093b983fe1f92736fe140f07701877713d491741 Mon Sep 17 00:00:00 2001 From: Yerriswamy Date: Tue, 24 Oct 2017 19:39:27 +0530 Subject: p61-jcop-kit library dynamic loading improvements --- nci/jni/AlaLib.h | 107 ------------------------------------------------ nci/jni/IChannel.h | 87 --------------------------------------- nci/jni/JcDnld.h | 78 ----------------------------------- nci/jni/JcopManager.cpp | 4 +- nci/jni/JcopManager.h | 20 ++++++--- 5 files changed, 16 insertions(+), 280 deletions(-) delete mode 100644 nci/jni/AlaLib.h delete mode 100644 nci/jni/IChannel.h delete mode 100644 nci/jni/JcDnld.h diff --git a/nci/jni/AlaLib.h b/nci/jni/AlaLib.h deleted file mode 100644 index 0ad3b417..00000000 --- a/nci/jni/AlaLib.h +++ /dev/null @@ -1,107 +0,0 @@ - /* - * Copyright (C) 2015 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifdef __cplusplus - -extern "C" { - -#endif - - -#ifndef ALALIB_H_ -#define ALALIB_H_ - -#include -#include -#include -#include "IChannel.h" - -/******************************************************************************* -** -** Function: ALA_Init -** -** Description: Initializes the ALA library and opens the DWP communication channel -** -** Returns: SUCCESS if ok. -** -*******************************************************************************/ -unsigned char ALA_Init(IChannel *channel); - -/******************************************************************************* -** -** Function: ALA_Start -** -** Description: Starts the ALA over DWP -** -** Returns: SUCCESS if ok. -** -*******************************************************************************/ -#if(NXP_LDR_SVC_VER_2 == TRUE) -unsigned char ALA_Start(const char *name, const char *dest, uint8_t *pdata, uint16_t len, uint8_t *respSW); -#else -unsigned char ALA_Start(const char *name, uint8_t *pdata, uint16_t len); -#endif - -/******************************************************************************* -** -** Function: ALA_DeInit -** -** Description: Deinitializes the ALA Lib -** -** Returns: true if ok. -** -*******************************************************************************/ -bool ALA_DeInit(); - -#if(NXP_LDR_SVC_VER_2 == TRUE) -/******************************************************************************* -** -** Function: ALA_lsGetVersion -** -** Description: Get the Loader service Applet and cleint version -** -** Returns: byte[] array. -** -*******************************************************************************/ -unsigned char ALA_lsGetVersion(uint8_t *pVersion); -unsigned char ALA_lsGetStatus(uint8_t *pVersion); -unsigned char ALA_lsGetAppletStatus(uint8_t *pVersion); -#else -void ALA_GetlistofApplets(char *list[], uint8_t* num); -unsigned char ALA_GetCertificateKey(uint8_t *pKey, int32_t *pKeylen); -#endif - -inline int FSCANF_BYTE(FILE *stream, const char *format, void* pVal) -{ - int Result = 0; - - if((NULL != stream) && (NULL != format) && (NULL != pVal)) - { - unsigned int dwVal; - unsigned char* pTmp = (unsigned char*)pVal; - Result = fscanf(stream, format, &dwVal); - - (*pTmp) = (unsigned char)(dwVal & 0x000000FF); - } - return Result; -} - -#endif /* ALALIB_H_ */ - -#ifdef __cplusplus - -} - -#endif diff --git a/nci/jni/IChannel.h b/nci/jni/IChannel.h deleted file mode 100644 index 4e42242e..00000000 --- a/nci/jni/IChannel.h +++ /dev/null @@ -1,87 +0,0 @@ - /* - * Copyright (C) 2015 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ICHANNEL_H_ -#define ICHANNEL_H_ - -typedef struct IChannel -{ -/******************************************************************************* -** -** Function: Open -** -** Description: Initialize the channel. -** -** Returns: True if ok. -** -*******************************************************************************/ -int16_t (*open)(); -/******************************************************************************* -** -** Function: close -** -** Description: Close the channel. -** -** Returns: True if ok. -** -*******************************************************************************/ -bool (*close)(int16_t mHandle); - -/******************************************************************************* -** -** Function: transceive -** -** Description: Send data to the secure element; read it's response. -** xmitBuffer: Data to transmit. -** xmitBufferSize: Length of data. -** recvBuffer: Buffer to receive response. -** recvBufferMaxSize: Maximum size of buffer. -** recvBufferActualSize: Actual length of response. -** timeoutMillisec: timeout in millisecond -** -** Returns: True if ok. -** -*******************************************************************************/ -bool (*transceive) (uint8_t* xmitBuffer, int32_t xmitBufferSize, uint8_t* recvBuffer, - int32_t recvBufferMaxSize, int32_t& recvBufferActualSize, int32_t timeoutMillisec); - -/******************************************************************************* -** -** Function: doeSE_Reset -** -** Description: Power OFF and ON to eSE -** -** Returns: None. -** -*******************************************************************************/ - -void (*doeSE_Reset)(); -/******************************************************************************* -** -** Function: doeSE_JcopDownLoadReset -** -** Description: Power OFF and ON to eSE during JCOP Update -** -** Returns: None. -** -*******************************************************************************/ - -void (*doeSE_JcopDownLoadReset)(); - -}IChannel_t; - - -#endif /* ICHANNEL_H_ */ diff --git a/nci/jni/JcDnld.h b/nci/jni/JcDnld.h deleted file mode 100644 index 630dd7d8..00000000 --- a/nci/jni/JcDnld.h +++ /dev/null @@ -1,78 +0,0 @@ - /* - * Copyright (C) 2015 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#ifdef __cplusplus - -extern "C" { - -#endif - - -#ifndef JCDNLD_H_ -#define JCDNLD_H_ - -#include "IChannel.h" -/******************************************************************************* -** -** Function: JCDNLD_Init -** -** Description: Initializes the JCOP library and opens the DWP communication channel -** -** Returns: SUCCESS if ok. -** -*******************************************************************************/ -unsigned char JCDNLD_Init(IChannel *channel); - -/******************************************************************************* -** -** Function: JCDNLD_StartDownload -** -** Description: Starts the JCOP update -** -** Returns: SUCCESS if ok. -** -*******************************************************************************/ -unsigned char JCDNLD_StartDownload(); - -/******************************************************************************* -** -** Function: JCDNLD_DeInit -** -** Description: Deinitializes the JCOP Lib -** -** Returns: true if ok. -** -*******************************************************************************/ -bool JCDNLD_DeInit(); - -/******************************************************************************* -** -** Function: JCDNLD_CheckVersion -** -** Description: Check the existing JCOP OS version -** -** Returns: true if ok. -** -*******************************************************************************/ -bool JCDNLD_CheckVersion(); - - -#endif /* JCDNLD_H_ */ - -#ifdef __cplusplus - -} - -#endif diff --git a/nci/jni/JcopManager.cpp b/nci/jni/JcopManager.cpp index 336fbcf8..e5ddb7d5 100644 --- a/nci/jni/JcopManager.cpp +++ b/nci/jni/JcopManager.cpp @@ -199,7 +199,7 @@ tNFA_STATUS JcopManager::JcopDeInitialize () ** STATUS_FAILED if unSuccessfull ** *******************************************************************************/ -tNFC_JBL_STATUS JcopManager::AlaInitialize (IChannel *channel) +tNFC_JBL_STATUS JcopManager::AlaInitialize (IChannel_t *channel) { if(channel == NULL) { @@ -353,7 +353,7 @@ tNFC_JBL_STATUS JcopManager::AlaLsGetStatus (uint8_t *pVersion) ** STATUS_FAILED if unSuccessfull ** *******************************************************************************/ -tNFC_JBL_STATUS JcopManager::JCDnldInit (IChannel *channel) +tNFC_JBL_STATUS JcopManager::JCDnldInit (IChannel_t *channel) { if(!channel){ ALOGE("%s: Invalid Params !!", __func__); diff --git a/nci/jni/JcopManager.h b/nci/jni/JcopManager.h index 609a17d2..8947f3b9 100644 --- a/nci/jni/JcopManager.h +++ b/nci/jni/JcopManager.h @@ -41,13 +41,21 @@ extern "C"{ #include "nfa_api.h" -#include "AlaLib.h" -#include "JcDnld.h" -#include "IChannel.h" } +typedef struct IChannel +{ + int16_t (*open)(); /* Initialize the channel. */ + bool (*close)(int16_t mHandle); /* Close the channel. */ + bool (*transceive) (uint8_t* xmitBuffer, int32_t xmitBufferSize, uint8_t* recvBuffer, + int32_t recvBufferMaxSize, int32_t& recvBufferActualSize, int32_t timeoutMillisec); /* Send/receive data to the secure element*/ + void (*doeSE_Reset)(); /* Power OFF and ON to eSE */ + void (*doeSE_JcopDownLoadReset)(); /* Power OFF and ON to eSE during JCOP Update */ +}IChannel_t; + + #define pJcopMgr (JcopManager::getInstance ()) -typedef unsigned char (tJCOP_INIT_CBACK)(IChannel *channel); +typedef unsigned char (tJCOP_INIT_CBACK)(IChannel_t *channel); #if (NXP_LDR_SVC_VER_2 == TRUE) typedef unsigned char (tALA_START_CBACK)(const char *name, const char *dest, uint8_t *pdata, uint16_t len, uint8_t *respSW); #else @@ -160,7 +168,7 @@ public: ** STATUS_FAILED if unSuccessfull ** *******************************************************************************/ - tNFC_JBL_STATUS AlaInitialize (IChannel *channel); + tNFC_JBL_STATUS AlaInitialize (IChannel_t *channel); /******************************************************************************* ** @@ -261,7 +269,7 @@ public: ** STATUS_FAILED if unSuccessfull ** *******************************************************************************/ - tNFC_JBL_STATUS JCDnldInit (IChannel *channel); + tNFC_JBL_STATUS JCDnldInit (IChannel_t *channel); /******************************************************************************* ** -- cgit v1.2.3 From e50fb5ecb7aa411e7659faec0b232752fd7885b0 Mon Sep 17 00:00:00 2001 From: nxf32288 Date: Thu, 26 Oct 2017 18:27:31 +0530 Subject: SPI open failing in PN6xt NFC_RelForceDwpOnOff IOCTL call should be called only in PN8xt. --- nci/jni/SecureElement.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp index b77ee527..4d190f2c 100644 --- a/nci/jni/SecureElement.cpp +++ b/nci/jni/SecureElement.cpp @@ -4128,8 +4128,10 @@ void *spiEventHandlerThread(void *arg) (usEvent & P61_STATE_SPI)) { nfaVSC_ForceDwpOnOff(true); + if(nfcFL.eseFL._WIRED_MODE_STANDBY) { if(android::nfcManager_getNfcState() != NFC_OFF) NFC_RelForceDwpOnOffWait((void*)&stat); + } } else if((usEvent & P61_STATE_SPI_PRIO_END) || (usEvent & P61_STATE_SPI_END)) @@ -4153,8 +4155,10 @@ void *spiEventHandlerThread(void *arg) (usEvent & P61_STATE_SPI))) { nfaVSC_ForceDwpOnOff(true); + if(nfcFL.eseFL._WIRED_MODE_STANDBY) { if(android::nfcManager_getNfcState() != NFC_OFF) NFC_RelForceDwpOnOffWait((void*)&stat); + } } else if(nfcFL.eseFL._ESE_DWP_SPI_SYNC_ENABLE && ((usEvent & P61_STATE_SPI_PRIO_END) || -- cgit v1.2.3 From f0bf98fd90c599312e7233d0f54e869cf5979411 Mon Sep 17 00:00:00 2001 From: nxf32288 Date: Fri, 27 Oct 2017 19:00:14 +0530 Subject: JCOP Download over SPI interface failing in PN6xt, If NFC is On spiDwpSyncState state machine updated properly during SPI close. --- nci/jni/SecureElement.cpp | 6 ++++++ 1 file changed, 6 insertions(+) mode change 100644 => 100755 nci/jni/SecureElement.cpp diff --git a/nci/jni/SecureElement.cpp b/nci/jni/SecureElement.cpp old mode 100644 new mode 100755 index 4d190f2c..16157a1e --- a/nci/jni/SecureElement.cpp +++ b/nci/jni/SecureElement.cpp @@ -4063,6 +4063,7 @@ void *spiEventHandlerThread(void *arg) { void (*pCleanupRoutine)(void* ptr) = cleanupStack; __pthread_cleanup_t __cleanup; + SecureElement &se = SecureElement::getInstance(); if(!nfcFL.nfcNxpEse) { ALOGV("%s: nfcNxpEse not available. Returning", __func__); @@ -4104,6 +4105,8 @@ void *spiEventHandlerThread(void *arg) { ALOGV("%s: SPI PRIO End Signal\n", __func__); hold_the_transceive = false; + if(!se.mIsWiredModeOpen) + spiDwpSyncState = STATE_DWP_CLOSE; setSPIState(false); SyncEventGuard guard (sSPIPrioSessionEndEvent); sSPIPrioSessionEndEvent.notifyOne (); @@ -4117,6 +4120,8 @@ void *spiEventHandlerThread(void *arg) { ALOGV("%s: SPI End Signal\n", __func__); hold_the_transceive = false; + if(!se.mIsWiredModeOpen) + spiDwpSyncState = STATE_DWP_CLOSE; setSPIState(false); } @@ -4419,6 +4424,7 @@ static void nfaVSC_ForceDwpOnOff(bool type) /*If DWP session is closed*/ (void)SecureElement::getInstance().setNfccPwrConfig(SecureElement::getInstance().NFCC_DECIDES); } + if(spiDwpSyncState & STATE_DWP_CLOSE) { stat = NFA_HciSendEvent (NFA_HANDLE_GROUP_HCI, 0x19, EVT_END_OF_APDU_TRANSFER, -- cgit v1.2.3 From e84753c3361e1f3ee68d7b42a68b98974dff043e Mon Sep 17 00:00:00 2001 From: Suhas Suresh Date: Tue, 31 Oct 2017 12:59:50 +0530 Subject: Fix for NFC init fail when DUAL_UICC Flag is enabled TransactionController is used during doSelectUicc beofre its initialization Initialization of trasactionController is done before doSelectUicc during NfcInit. --- nci/jni/NativeNfcManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index a0428fdf..4a857626 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -2242,6 +2242,8 @@ static jboolean nfcManager_doInitialize (JNIEnv* e, jobject o) ALOGV("All ESE are discovered "); } } + //Create transaction controller + (void)transactionController::controller(); if(nfcFL.nfccFL._NFC_NXP_STAT_DUAL_UICC_EXT_SWITCH) { checkforESERemoval(); GetNxpNumValue (NAME_NXP_DUAL_UICC_ENABLE, (void*)&dualUiccInfo.dualUiccEnable, sizeof(dualUiccInfo.dualUiccEnable)); @@ -2326,8 +2328,6 @@ static jboolean nfcManager_doInitialize (JNIEnv* e, jobject o) } } #endif - //Create transaction controller - (void)transactionController::controller(); pendingScreenState = false; { SyncEventGuard guard (android::sNfaGetConfigEvent); -- cgit v1.2.3 From 2af0fa35547ad20b5a2f33c8f2bfb7b73efc3b5d Mon Sep 17 00:00:00 2001 From: Manjunatha Venkatesh Date: Tue, 31 Oct 2017 18:25:18 +0530 Subject: Jcop download failed on DWP interface. During Jcop download Jcop download protection macro handled properly and jcop download deinit issue identified run time. --- nci/jni/Android.mk | 1 + nci/jni/JcopManager.cpp | 2 +- nci/jni/NativeNfcManager.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/nci/jni/Android.mk b/nci/jni/Android.mk index 0c87dee2..ab8e6631 100644 --- a/nci/jni/Android.mk +++ b/nci/jni/Android.mk @@ -35,6 +35,7 @@ LOCAL_SRC_FILES := $(call all-subdir-cpp-files) $(call all-subdir-c-files) LOCAL_C_INCLUDES += \ frameworks/native/include \ + libnativehelper/include/nativehelper \ $(NFA)/include \ $(NFA)/brcm \ $(NFC)/include \ diff --git a/nci/jni/JcopManager.cpp b/nci/jni/JcopManager.cpp index e5ddb7d5..4181e4e1 100644 --- a/nci/jni/JcopManager.cpp +++ b/nci/jni/JcopManager.cpp @@ -159,7 +159,7 @@ tNFA_STATUS JcopManager::JcopInitialize () ALOGE("%s: Error while linking JCOP context (JCDNLD_StartDownload) !!", __func__); } // Getting pointer to JCDNLD_DeInit function - if((pg_mPhJcpCtxt->ala_deinit = (tJCOP_DEINIT_CBACK *)dlsym(Pgpx_Jcop_handle, "JCDNLD_DeInit")) == NULL){ + if((pg_mPhJcpCtxt->jcdnld_deinit = (tJCOP_DEINIT_CBACK *)dlsym(Pgpx_Jcop_handle, "JCDNLD_DeInit")) == NULL){ wStatus = NFA_STATUS_FAILED; ALOGE("%s: Error while linking JCOP context (JCDNLD_DeInit) !!", __func__); } diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index 4a857626..d15f7254 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -5574,14 +5574,14 @@ static int nfcManager_doJcosDownload(JNIEnv* e, jobject o) if(nfcFL.nfcNxpEse) { ALOGV("%s: enter", __func__); bool stat = false; + int ret_val = -1; + NFCSTATUS ese_status = NFA_STATUS_FAILED; + p61_access_state_t p61_current_state = P61_STATE_INVALID; + eScreenState_t last_screen_state_request = get_lastScreenStateRequest(); SecureElement &se = SecureElement::getInstance(); if(nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION) { - int ret_val = -1; - NFCSTATUS ese_status = NFA_STATUS_FAILED; - p61_access_state_t p61_current_state = P61_STATE_INVALID; - eScreenState_t last_screen_state_request = get_lastScreenStateRequest(); if (sIsDisabling || !sIsNfaEnabled || nfcManager_checkNfcStateBusy()) { @@ -5626,6 +5626,8 @@ static int nfcManager_doJcosDownload(JNIEnv* e, jobject o) return NFA_STATUS_FAILED; } } + } + } if (sRfEnabled) { // Stop RF Discovery if we were polling startRfDiscovery (false); @@ -5667,8 +5669,6 @@ static int nfcManager_doJcosDownload(JNIEnv* e, jobject o) nfcManager_doSetScreenState(NULL,NULL,last_screen_state_request); } } - } - } startRfDiscovery (true); se.mDownloadMode = NONE; ALOGV("%s: exit; status =0x%X", __func__,status); -- cgit v1.2.3 From 2747c62b9241ea83f94d19d488c15d64709b6cb8 Mon Sep 17 00:00:00 2001 From: nxpandroid Date: Thu, 16 Nov 2017 09:40:18 +0530 Subject: Fix for atr not working for conflict AID sent in screen lock state after selecting corresponding application --- nci/jni/NativeNfcManager.cpp | 32 ++++++- nci/jni/TransactionController.cpp | 18 +++- nci/jni/TransactionController.h | 197 +++++++++++++++++++------------------- 3 files changed, 144 insertions(+), 103 deletions(-) diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index d15f7254..b2b95468 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -1639,7 +1639,17 @@ void nfaDeviceManagementCallback (uint8_t dmEvent, tNFA_DM_CBACK_DATA* eventData } else { - pTransactionController->transactionEnd(TRANSACTION_REQUESTOR(RF_FIELD_EVT)); + /*In case of 66T/67T if Field On is not received before activation, consider NFA_ACTIVATED_EVENT for + locking the transaction and use Field Off received while removing the reader from proximity to end the lock*/ + if(((nfcFL.chipType == pn548C2) || (nfcFL.chipType == pn551)) && + pTransactionController->getCurTransactionRequestor() == TRANSACTION_REQUESTOR(NFA_ACTIVATED_EVENT)) + { + pTransactionController->transactionEnd(TRANSACTION_REQUESTOR(NFA_ACTIVATED_EVENT)); + } + else + { + pTransactionController->transactionEnd(TRANSACTION_REQUESTOR(RF_FIELD_EVT)); + } sRfFieldOff = true; e->CallVoidMethod (nat->manager, android::gCachedNfcManagerNotifyRfFieldDeactivated); } @@ -1828,12 +1838,21 @@ static jboolean nfcManager_routeAid (JNIEnv* e, jobject, jbyteArray aid, jint ro ScopedByteArrayRO bytes(e, aid); uint8_t* buf = const_cast(reinterpret_cast(&bytes[0])); size_t bufLen = bytes.size(); + #if (NXP_EXTNS == TRUE) if((nfcFL.nfccFL._NFC_NXP_STAT_DUAL_UICC_WO_EXT_SWITCH) && (route == 2 || route == 4)) { //UICC or UICC2 HANDLE ALOGV("sCurrentSelectedUICCSlot: %d", sCurrentSelectedUICCSlot); route = (sCurrentSelectedUICCSlot != 0x02) ? 0x02 : 0x04; } + /*In case of 66T/67T field on is observed as last field event once reader + is removed from proximity, which will hold the transaction lock unnecessarily + In such cases end the lock as it is not required*/ + if(((nfcFL.chipType == pn548C2) || (nfcFL.chipType == pn551)) && + pTransactionController->getCurTransactionRequestor() == TRANSACTION_REQUESTOR(RF_FIELD_EVT)) + { + pTransactionController->transactionEnd(TRANSACTION_REQUESTOR(RF_FIELD_EVT)); + } if(nfcManager_isTransanctionOnGoing(true)) { return false; @@ -2057,6 +2076,14 @@ static jint nfcManager_getRemainingAidTableSize (JNIEnv* , jobject ) static bool nfcManager_clearAidTable (JNIEnv*, jobject) { #if(NXP_EXTNS == TRUE) + /*In case of 66T/67T field on is observed as last field event once reader + is removed from proximity, which will hold the transaction lock unnecessarily + In such cases end the lock as it is not required*/ + if(((nfcFL.chipType == pn548C2) || (nfcFL.chipType == pn551)) && + pTransactionController->getCurTransactionRequestor() == TRANSACTION_REQUESTOR(RF_FIELD_EVT)) + { + pTransactionController->transactionEnd(TRANSACTION_REQUESTOR(RF_FIELD_EVT)); + } if(nfcManager_isTransanctionOnGoing(true)) { return false; @@ -5865,7 +5892,7 @@ static void nfcManager_doSetScreenState (JNIEnv* e, jobject o, jint screen_state return; } #endif - + pendingScreenState = false; int prevScreenState = getScreenState(); if(prevScreenState == state) { ALOGV("Screen state is not changed. "); @@ -6075,7 +6102,6 @@ static void nfcManager_doSetScreenOrPowerState (JNIEnv* e, jobject o, jint state bool nfcManager_isRequestPending(void) { bool isPending = false; - if((transaction_data.current_transcation_state != NFA_TRANS_ACTIVATED_EVT) && ((pendingScreenState == true) || (get_last_request() != 0x00))) { diff --git a/nci/jni/TransactionController.cpp b/nci/jni/TransactionController.cpp index e2e745f2..990ab592 100755 --- a/nci/jni/TransactionController.cpp +++ b/nci/jni/TransactionController.cpp @@ -247,7 +247,7 @@ void transactionController::transactionEnd(const char* transactionRequestor) killAbortTimer(); } pTransactionDetail->trans_in_progress = false; - + requestor = NULL; ALOGD ("%s: Transaction ended : %s ", __FUNCTION__, transactionRequestor); /* @@ -283,6 +283,7 @@ bool transactionController::transactionTerminate(const char* transactionRequest (requestor == transactionRequestor || !strcmp(transactionRequestor,"exec_pending_req"))) { pTransactionDetail->trans_in_progress = false; + requestor = NULL; killAbortTimer(); if(android::nfcManager_isRequestPending()) @@ -293,7 +294,6 @@ bool transactionController::transactionTerminate(const char* transactionRequest sem_getvalue(&barrier, &val); if(!val) sem_post(&barrier); - ALOGD ("%s: Transaction terminated : %s ", __FUNCTION__, transactionRequestor); return true; } @@ -396,3 +396,17 @@ void transactionController::setAbortTimer(unsigned int msec) if(transactionInProgress()) abortTimer->set(msec, transactionAbortTimerCb); } + +/******************************************************************************* + ** + ** Function: getCurTransactionRequestor + ** + ** Description: This function returns current active requestor + ** + ** Returns: active requestor + ** + *******************************************************************************/ +const char * transactionController::getCurTransactionRequestor() +{ + return requestor; +} \ No newline at end of file diff --git a/nci/jni/TransactionController.h b/nci/jni/TransactionController.h index 8402db28..a0df7a1e 100755 --- a/nci/jni/TransactionController.h +++ b/nci/jni/TransactionController.h @@ -1,98 +1,99 @@ -/****************************************************************************** - * - * Copyright (C) 2015 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ -#pragma once -#include -#include -extern "C" -{ - #include "nfa_api.h" -} -#define TRANSACTION_REQUESTOR(name) #name -#define TRANSACTION_ATTEMPT_FOR_SECONDS(seconds) (seconds) -#define pTransactionController (transactionController::getInstance()) - - - -/* Transaction Events in order */ -typedef enum transcation_events -{ - NFA_TRANS_DEFAULT = 0x00, - NFA_TRANS_ACTIVATED_EVT, - NFA_TRANS_EE_ACTION_EVT, - NFA_TRANS_DM_RF_FIELD_EVT, - NFA_TRANS_DM_RF_FIELD_EVT_ON, - NFA_TRANS_DM_RF_TRANS_START, - NFA_TRANS_DM_RF_FIELD_EVT_OFF, - NFA_TRANS_DM_RF_TRANS_PROGRESS, - NFA_TRANS_DM_RF_TRANS_END, - NFA_TRANS_MIFARE_ACT_EVT, - NFA_TRANS_CE_ACTIVATED = 0x18, - NFA_TRANS_CE_DEACTIVATED = 0x19, -}eTranscation_events_t; -/*Structure to store discovery parameters*/ -typedef struct discovery_Parameters -{ - int technologies_mask; - bool enable_lptd; - bool reader_mode; - bool enable_p2p; - bool restart; -}discovery_Parameters_t; -/*Structure to store transcation result*/ -typedef struct Transcation_Check -{ - bool trans_in_progress; - char last_request; - struct nfc_jni_native_data *transaction_nat; - eScreenState_t last_screen_state_request; - eTranscation_events_t current_transcation_state; - discovery_Parameters_t discovery_params; -#if(NXP_EXTNS == TRUE) -#if(NXP_NFCC_HCE_F == TRUE) - int t3thandle; - bool isInstallRequest; -#endif -#endif -} Transcation_Check_t; - -class transactionController -{ - private: - static transactionController* pInstance; //Reference to controller - sem_t barrier; //barrier: Guard for controlling access to NFCC when profile switch happening - IntervalTimer* abortTimer; //abortTimer: Used for aborting a stuck transaction - IntervalTimer* pendingTransHandleTimer; //pendingTransHandleTimer: Used to schedule pending transaction handler thread - Transcation_Check_t* pTransactionDetail; //transactionDetail: holds last transaction detail - const char* requestor; //requestor: Identifier of transaction trigger - - transactionController(void); //Constructor - bool transactionLiveLockable(const char* transactionRequestor); - public: - void lastRequestResume(void); - bool transactionAttempt(const char* transactionRequestor, unsigned int timeoutInMsec); - bool transactionAttempt(const char* transactionRequestor); - bool transactionTerminate(const char* transactionRequestor); - void transactionEnd(const char* transactionRequestor); - bool transactionInProgress(void); - void killAbortTimer(void); - void setAbortTimer(unsigned int msec); - static void transactionAbortTimerCb(union sigval); - static void transactionHandlePendingCb(union sigval); - static transactionController* controller(void); - static transactionController* getInstance(void); -}; +/****************************************************************************** + * + * Copyright (C) 2015 NXP Semiconductors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +#pragma once +#include +#include +extern "C" +{ + #include "nfa_api.h" +} +#define TRANSACTION_REQUESTOR(name) #name +#define TRANSACTION_ATTEMPT_FOR_SECONDS(seconds) (seconds) +#define pTransactionController (transactionController::getInstance()) + + + +/* Transaction Events in order */ +typedef enum transcation_events +{ + NFA_TRANS_DEFAULT = 0x00, + NFA_TRANS_ACTIVATED_EVT, + NFA_TRANS_EE_ACTION_EVT, + NFA_TRANS_DM_RF_FIELD_EVT, + NFA_TRANS_DM_RF_FIELD_EVT_ON, + NFA_TRANS_DM_RF_TRANS_START, + NFA_TRANS_DM_RF_FIELD_EVT_OFF, + NFA_TRANS_DM_RF_TRANS_PROGRESS, + NFA_TRANS_DM_RF_TRANS_END, + NFA_TRANS_MIFARE_ACT_EVT, + NFA_TRANS_CE_ACTIVATED = 0x18, + NFA_TRANS_CE_DEACTIVATED = 0x19, +}eTranscation_events_t; +/*Structure to store discovery parameters*/ +typedef struct discovery_Parameters +{ + int technologies_mask; + bool enable_lptd; + bool reader_mode; + bool enable_p2p; + bool restart; +}discovery_Parameters_t; +/*Structure to store transcation result*/ +typedef struct Transcation_Check +{ + bool trans_in_progress; + char last_request; + struct nfc_jni_native_data *transaction_nat; + eScreenState_t last_screen_state_request; + eTranscation_events_t current_transcation_state; + discovery_Parameters_t discovery_params; +#if(NXP_EXTNS == TRUE) +#if(NXP_NFCC_HCE_F == TRUE) + int t3thandle; + bool isInstallRequest; +#endif +#endif +} Transcation_Check_t; + +class transactionController +{ + private: + static transactionController* pInstance; //Reference to controller + sem_t barrier; //barrier: Guard for controlling access to NFCC when profile switch happening + IntervalTimer* abortTimer; //abortTimer: Used for aborting a stuck transaction + IntervalTimer* pendingTransHandleTimer; //pendingTransHandleTimer: Used to schedule pending transaction handler thread + Transcation_Check_t* pTransactionDetail; //transactionDetail: holds last transaction detail + const char* requestor; //requestor: Identifier of transaction trigger + + transactionController(void); //Constructor + bool transactionLiveLockable(const char* transactionRequestor); + public: + void lastRequestResume(void); + bool transactionAttempt(const char* transactionRequestor, unsigned int timeoutInMsec); + bool transactionAttempt(const char* transactionRequestor); + bool transactionTerminate(const char* transactionRequestor); + void transactionEnd(const char* transactionRequestor); + bool transactionInProgress(void); + void killAbortTimer(void); + void setAbortTimer(unsigned int msec); + static void transactionAbortTimerCb(union sigval); + static void transactionHandlePendingCb(union sigval); + static transactionController* controller(void); + static transactionController* getInstance(void); + const char * getCurTransactionRequestor(); +}; -- cgit v1.2.3 From 6e22d113a6929208f302f0f833663f141a51e09a Mon Sep 17 00:00:00 2001 From: Yerriswamy Date: Fri, 3 Nov 2017 15:03:08 +0530 Subject: Code cleanup, Removed redundant commitRouting API calling --- nci/jni/NativeNfcManager.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index b2b95468..8af2fbab 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -5765,11 +5765,6 @@ static void nfcManager_doCommitRouting(JNIEnv* e, jobject o) startRfDiscovery(true); #if(NXP_EXTNS == TRUE && NXP_NFCC_HCE_F == TRUE) } -#endif - - RoutingManager::getInstance().commitRouting(); - startRfDiscovery(true); -#if(NXP_EXTNS == TRUE && NXP_NFCC_HCE_F == TRUE) pTransactionController->transactionEnd(TRANSACTION_REQUESTOR(commitRouting)); #endif ALOGV("%s: exit", __func__); -- cgit v1.2.3 From d8a71d2a82af02ffd52675e1d37bfab89a51fbbf Mon Sep 17 00:00:00 2001 From: Suhas Suresh Date: Mon, 6 Nov 2017 18:48:14 +0530 Subject: Fix for HCE F failure 1.Corrected Wrong screen State check in enableDiscovery in case of enable p2pListening. 2.Corrected set screen state and Discovery sequence in NfcService --- nci/jni/NativeNfcManager.cpp | 2 +- src/com/android/nfc/NfcService.java | 11 ++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index 8af2fbab..e387c782 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -2907,7 +2907,7 @@ static void nfcManager_enableDiscovery (JNIEnv* e, jobject o, jint technologies_ handle = SecureElement::getInstance().getEseHandleFromGenericId(SecureElement::UICC_ID); #if(NXP_EXTNS == TRUE) - if((getScreenState() == (NFA_SCREEN_STATE_ON_LOCKED)) || sProvisionMode) + if((getScreenState() == (NFA_SCREEN_STATE_ON_UNLOCKED)) || sProvisionMode) { ALOGV("%s: Enable p2pListening", __func__); PeerToPeer::getInstance().enableP2pListening (true); diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 58e88f5a..996903e9 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -5231,17 +5231,14 @@ public class NfcService implements DeviceHostListener { case MSG_APPLY_SCREEN_STATE: mScreenState = (int)msg.obj; - - if(mScreenState == ScreenStateHelper.SCREEN_STATE_ON_UNLOCKED) - { - applyRouting(false); - } int screen_state_mask = (mNfcUnlockManager.isLockscreenPollingEnabled()) ? (ScreenStateHelper.SCREEN_POLLING_TAG_MASK | mScreenState) : mScreenState; + mDeviceHost.doSetScreenOrPowerState(screen_state_mask); - if(mNfcUnlockManager.isLockscreenPollingEnabled()) + if(mScreenState == ScreenStateHelper.SCREEN_STATE_ON_UNLOCKED + || mNfcUnlockManager.isLockscreenPollingEnabled()) { applyRouting(false); - mDeviceHost.doSetScreenOrPowerState(screen_state_mask); + } /* mRoutingWakeLock.acquire(); try { -- cgit v1.2.3 From 8aca387751a9caf69551db11a9bce620151ff538 Mon Sep 17 00:00:00 2001 From: Yerriswamy Date: Thu, 19 Oct 2017 15:58:30 +0530 Subject: Corrected screen state condition checking --- nci/jni/NativeNfcManager.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nci/jni/NativeNfcManager.cpp b/nci/jni/NativeNfcManager.cpp index e387c782..a0ee86df 100755 --- a/nci/jni/NativeNfcManager.cpp +++ b/nci/jni/NativeNfcManager.cpp @@ -6061,13 +6061,13 @@ static void nfcManager_doSetScreenState (JNIEnv* e, jobject o, jint screen_state static void nfcManager_doSetScreenOrPowerState (JNIEnv* e, jobject o, jint state) { ALOGE("%s: Enter", __func__); - if (state <= NFA_SCREEN_STATE_ON_UNLOCKED ) // SCREEN_STATE + if ((state & NFA_SCREEN_STATE_MASK) <= NFA_SCREEN_STATE_ON_UNLOCKED ) // SCREEN_STATE nfcManager_doSetScreenState(e, o, state); - else if (state == VEN_POWER_STATE_ON) // POWER_ON NFC_OFF + else if ((state & NFA_SCREEN_STATE_MASK) == VEN_POWER_STATE_ON) // POWER_ON NFC_OFF { nfcManager_doSetNfcMode(e , o, NFC_MODE_OFF); } - else if (state == VEN_POWER_STATE_OFF) // POWER_OFF + else if ((state & NFA_SCREEN_STATE_MASK) == VEN_POWER_STATE_OFF) // POWER_OFF { if(sIsNfaEnabled) { -- cgit v1.2.3 From 322d6ec7198f688943c919d65107e8c4754c489c Mon Sep 17 00:00:00 2001 From: Manjunatha Venkatesh Date: Fri, 17 Nov 2017 12:18:11 +0530 Subject: Nfc service died during Nfc on/off steability test. Run nfc on/off stress test during that dangling pointer issue observed and causing heap corruption. Issue fixed by doing null check and assign to null after freeing the pointer. --- nci/jni/JcopManager.cpp | 31 ++++++------------------------- nci/jni/JcopManager.h | 25 +------------------------ nci/jni/NativeNfcAla.cpp | 2 +- 3 files changed, 8 insertions(+), 50 deletions(-) diff --git a/nci/jni/JcopManager.cpp b/nci/jni/JcopManager.cpp index 4181e4e1..30d10a8c 100644 --- a/nci/jni/JcopManager.cpp +++ b/nci/jni/JcopManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 The Android Open Source Project + * Copyright (C) 2017 NXP Semiconductors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,29 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/****************************************************************************** - * - * The original Work has been changed by NXP Semiconductors. - * - * Copyright (C) 2015 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.Pgpx_Jcop_handle - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ -/* - * Communicate with secure elements that are attached to the NFC - * controller. - */ #include "JcopManager.h" #include "_OverrideLog.h" @@ -82,7 +59,11 @@ JcopManager* JcopManager::getInstance () *******************************************************************************/ void JcopManager::deleteInstance () { - delete mJcpMgr; + if(mJcpMgr != NULL) + { + delete mJcpMgr; + mJcpMgr = NULL; + } } /******************************************************************************* diff --git a/nci/jni/JcopManager.h b/nci/jni/JcopManager.h index 8947f3b9..2e1ac349 100644 --- a/nci/jni/JcopManager.h +++ b/nci/jni/JcopManager.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2012 The Android Open Source Project + * Copyright (C) 2017 NXP Semiconductors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,29 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/****************************************************************************** - * - * The original Work has been changed by NXP Semiconductors. - * - * Copyright (C) 2015 NXP Semiconductors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ -/* - * Communicate with secure elements that are attached to the NFC - * controller. - */ #pragma once diff --git a/nci/jni/NativeNfcAla.cpp b/nci/jni/NativeNfcAla.cpp index c331672c..47501438 100644 --- a/nci/jni/NativeNfcAla.cpp +++ b/nci/jni/NativeNfcAla.cpp @@ -154,7 +154,7 @@ int nfcManager_doAppletLoadApplet(JNIEnv* e, jobject o, jstring name, jbyteArray startRfDiscovery (false); } DWPChannel_init(&Dwp); - wStatus = JcopManager::getInstance().AlaInitialize(&Dwp); + wStatus = pJcopMgr->AlaInitialize(&Dwp); if(wStatus != NFA_STATUS_OK) { ALOGE("%s: ALA initialization failed", __func__); -- cgit v1.2.3 From d12785b52c41c51371b44954191c03c215702ede Mon Sep 17 00:00:00 2001 From: nxf32288 Date: Fri, 17 Nov 2017 15:18:31 +0530 Subject: SE Preference is set wrongly while calling selectSecureElement API in PN6xT. seId type updated Depends on chip type. --- src/com/android/nfc/NfcService.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java index 996903e9..7b3b3cdd 100755 --- a/src/com/android/nfc/NfcService.java +++ b/src/com/android/nfc/NfcService.java @@ -469,6 +469,7 @@ public class NfcService implements DeviceHostListener { // as SE access is not granted for non-owner users. HashSet mSePackages = new HashSet(); int mScreenState; + int mChipVer; boolean mIsTaskBoot = false; boolean mInProvisionMode; // whether we're in setup wizard and enabled NFC provisioning boolean mIsNdefPushEnabled; @@ -1459,8 +1460,8 @@ public class NfcService implements DeviceHostListener { } finally { watchDog.cancel(); } - int chipVer = mDeviceHost.getChipVer(); - if(chipVer < PN553_ID) { + mChipVer = mDeviceHost.getChipVer(); + if(mChipVer < PN553_ID) { ALL_SE_ID_TYPE &= ~UICC2_ID_TYPE; } checkSecureElementConfuration(); @@ -2204,7 +2205,9 @@ public class NfcService implements DeviceHostListener { @Override public int deselectSecureElement(String pkg) throws RemoteException { NfcService.this.enforceNfcSeAdminPerm(pkg); - + if(mChipVer < PN553_ID) { + mSelectedSeId &= ~UICC2_ID_TYPE; + } // Check if NFC is enabled if (!isNfcEnabled()) { return ErrorCodes.ERROR_NOT_INITIALIZED; @@ -2244,6 +2247,9 @@ public class NfcService implements DeviceHostListener { @Override public void storeSePreference(int seId) { + if(mChipVer < PN553_ID) { + seId &= ~UICC2_ID_TYPE; + } NfcPermissions.enforceAdminPermissions(mContext); /* store */ Log.d(TAG, "SE Preference stored"); @@ -2256,6 +2262,10 @@ public class NfcService implements DeviceHostListener { public int selectSecureElement(String pkg,int seId) throws RemoteException { NfcService.this.enforceNfcSeAdminPerm(pkg); + if(mChipVer < PN553_ID) { + seId &= ~UICC2_ID_TYPE; + } + // Check if NFC is enabled if (!isNfcEnabled()) { return ErrorCodes.ERROR_NOT_INITIALIZED; -- cgit v1.2.3 From ba9f5fa739255b0b3a69e44cb9e7f58808d13303 Mon Sep 17 00:00:00 2001 From: nxpandroid Date: Fri, 24 Nov 2017 18:04:43 +0530 Subject: NFC_NCIHALx_AR180C.8.3.0_O_OpnSrc --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8e3a3c3a..60639ccc 100644 --- a/README.md +++ b/README.md @@ -44,3 +44,4 @@ | android-8.0.0_r4 | 8.1.0_O (PN553) | NFC_NCIHALx_AR00C0.8.1.0_O_OpnSrc | | android-8.0.0_r4 | 8.2.0_O (PN557) | NFC_NCIHALx_AR18C0.8.2.0_O_OpnSrc | | android-8.0.0_r4 | 8.2.3_O (PN557) | NFC_NCIHALx_AR18C0.8.2.3_O_OpnSrc | +| android-8.0.0_r4 | 8.3.0_O (PN551/PN548C2) | NFC_NCIHALx_AR180C.8.3.0_O_OpnSrc | -- cgit v1.2.3 From 3fd328b5e5e1e39a0347c77d221437b9bd2ad2da Mon Sep 17 00:00:00 2001 From: nxpandroid Date: Fri, 24 Nov 2017 18:24:50 +0530 Subject: Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60639ccc..2fd31350 100644 --- a/README.md +++ b/README.md @@ -44,4 +44,4 @@ | android-8.0.0_r4 | 8.1.0_O (PN553) | NFC_NCIHALx_AR00C0.8.1.0_O_OpnSrc | | android-8.0.0_r4 | 8.2.0_O (PN557) | NFC_NCIHALx_AR18C0.8.2.0_O_OpnSrc | | android-8.0.0_r4 | 8.2.3_O (PN557) | NFC_NCIHALx_AR18C0.8.2.3_O_OpnSrc | -| android-8.0.0_r4 | 8.3.0_O (PN551/PN548C2) | NFC_NCIHALx_AR180C.8.3.0_O_OpnSrc | + -- cgit v1.2.3 From cc829601643d9fb531b099de660b84c650f60244 Mon Sep 17 00:00:00 2001 From: nxpandroid Date: Wed, 29 Nov 2017 13:24:38 +0530 Subject: NFC_NCIHALx_AR0054.8.3.0_O_OpnSrc --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2fd31350..691d59e9 100644 --- a/README.md +++ b/README.md @@ -44,4 +44,4 @@ | android-8.0.0_r4 | 8.1.0_O (PN553) | NFC_NCIHALx_AR00C0.8.1.0_O_OpnSrc | | android-8.0.0_r4 | 8.2.0_O (PN557) | NFC_NCIHALx_AR18C0.8.2.0_O_OpnSrc | | android-8.0.0_r4 | 8.2.3_O (PN557) | NFC_NCIHALx_AR18C0.8.2.3_O_OpnSrc | - +| android-8.0.0_r4 | 8.3.0_O (PN548C2/PN551/PN553) | NFC_NCIHALx_AR0054.8.3.0_O_OpnSrc | -- cgit v1.2.3 From c4f876a0c96a0695e5a98e6d17f8517858e09124 Mon Sep 17 00:00:00 2001 From: nxpandroid Date: Thu, 14 Dec 2017 19:16:59 +0530 Subject: NFC_NCIHALx_AR003C.8.3.0_O_OpnSrc --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 691d59e9..c71c23a1 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,4 @@ | android-8.0.0_r4 | 8.2.0_O (PN557) | NFC_NCIHALx_AR18C0.8.2.0_O_OpnSrc | | android-8.0.0_r4 | 8.2.3_O (PN557) | NFC_NCIHALx_AR18C0.8.2.3_O_OpnSrc | | android-8.0.0_r4 | 8.3.0_O (PN548C2/PN551/PN553) | NFC_NCIHALx_AR0054.8.3.0_O_OpnSrc | +| android-8.0.0_r4 | 8.3.0_O (PN548C2/PN551) | NFC_NCIHALx_AR003C.8.3.0_O_OpnSrc | -- cgit v1.2.3