aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2018-01-20 23:41:16 -0700
committerLinux Build Service Account <lnxbuild@localhost>2018-01-20 23:41:16 -0700
commit2cced52655296783d172d7425adbfc439b410d95 (patch)
treee95ea128601400d8f4c7bcf8c3e464703cf8bcdc
parent06614a8f6550fc6045fbc000e75539043a8a9bff (diff)
parentac1f85f31ce47ca162e5a902f34b61645075e72f (diff)
downloadandroid_vendor_nxp_opensource_packages_apps_Nfc-2cced52655296783d172d7425adbfc439b410d95.tar.gz
android_vendor_nxp_opensource_packages_apps_Nfc-2cced52655296783d172d7425adbfc439b410d95.tar.bz2
android_vendor_nxp_opensource_packages_apps_Nfc-2cced52655296783d172d7425adbfc439b410d95.zip
Merge ac1f85f31ce47ca162e5a902f34b61645075e72f on remote branch
Change-Id: I9ce6b7a795df326b7274fb50d70676201f367a23
-rw-r--r--README.md4
-rw-r--r--nci/jni/Android.mk7
-rw-r--r--nci/jni/HciRFParams.cpp15
-rw-r--r--nci/jni/IntervalTimer.cpp14
-rw-r--r--nci/jni/IntervalTimer.h1
-rw-r--r--nci/jni/JcopManager.cpp369
-rw-r--r--nci/jni/JcopManager.h274
-rw-r--r--nci/jni/NativeNfcAla.cpp37
-rw-r--r--nci/jni/NativeNfcManager.cpp107
-rw-r--r--nci/jni/NativeNfcTag.cpp111
-rw-r--r--nci/jni/NativeSecureElement.cpp3
-rwxr-xr-x[-rw-r--r--]nci/jni/NfcTag.cpp12
-rw-r--r--nci/jni/RoutingManager.cpp27
-rw-r--r--nci/jni/RoutingManager.h2
-rwxr-xr-x[-rw-r--r--]nci/jni/SecureElement.cpp155
-rw-r--r--nci/jni/SecureElement.h6
-rwxr-xr-x[-rw-r--r--]nci/jni/TransactionController.cpp80
-rwxr-xr-x[-rw-r--r--]nci/jni/TransactionController.h195
-rw-r--r--src/com/android/nfc/NfcService.java30
-rw-r--r--src/com/android/nfc/cardemulation/HostNfcFEmulationManager.java2
20 files changed, 1152 insertions, 299 deletions
diff --git a/README.md b/README.md
index 46f881f6..c71c23a1 100644
--- a/README.md
+++ b/README.md
@@ -42,3 +42,7 @@
| 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 |
+| 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 |
diff --git a/nci/jni/Android.mk b/nci/jni/Android.mk
index 3e321bf8..97b12cd6 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,16 +29,13 @@ 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)
LOCAL_C_INCLUDES += \
frameworks/native/include \
+ libnativehelper/include/nativehelper \
$(NFA)/include \
$(NFA)/brcm \
$(NFC)/include \
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/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 100644
--- 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/JcopManager.cpp b/nci/jni/JcopManager.cpp
new file mode 100644
index 00000000..30d10a8c
--- /dev/null
+++ b/nci/jni/JcopManager.cpp
@@ -0,0 +1,369 @@
+/*
+ * 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.
+ * 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.
+ */
+
+#include "JcopManager.h"
+#include "_OverrideLog.h"
+#include <dlfcn.h>
+
+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 ()
+{
+ if(mJcpMgr != NULL)
+ {
+ delete mJcpMgr;
+ mJcpMgr = NULL;
+ }
+}
+
+/*******************************************************************************
+**
+** 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->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__);
+ }
+ 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_t *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_t *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..2e1ac349
--- /dev/null
+++ b/nci/jni/JcopManager.h
@@ -0,0 +1,274 @@
+/*
+ * 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.
+ * 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
+
+extern "C"{
+#include "nfa_api.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_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
+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_t *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_t *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 b6145283..99f14722 100644
--- a/nci/jni/NativeNfcAla.cpp
+++ b/nci/jni/NativeNfcAla.cpp
@@ -24,10 +24,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
@@ -85,7 +84,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))
@@ -158,7 +157,7 @@ int nfcManager_doAppletLoadApplet(JNIEnv* e, jobject o, jstring name, jbyteArray
startRfDiscovery (false);
}
DWPChannel_init(&Dwp);
- wStatus = ALA_Init(&Dwp);
+ wStatus = pJcopMgr->AlaInitialize(&Dwp);
if(wStatus != NFA_STATUS_OK)
{
ALOGE("%s: ALA initialization failed", __func__);
@@ -171,9 +170,9 @@ int nfcManager_doAppletLoadApplet(JNIEnv* e, jobject o, jstring name, jbyteArray
ScopedByteArrayRO bytes(e, data);
uint8_t* buf = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(&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);
@@ -240,7 +239,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__);
@@ -267,7 +266,7 @@ jbyteArray nfcManager_lsExecuteScript(JNIEnv* e, jobject o, jstring name, jstrin
ScopedByteArrayRO bytes(e, data);
uint8_t* buf = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(&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);
@@ -286,7 +285,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);
@@ -341,7 +340,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__);
@@ -349,7 +348,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
@@ -359,7 +358,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);
@@ -407,7 +406,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__);
@@ -415,7 +414,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
@@ -425,7 +424,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);
@@ -472,7 +471,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__);
@@ -480,7 +479,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]);
@@ -490,7 +489,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);
@@ -526,7 +525,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 73574ed8..132d99bb 100644
--- a/nci/jni/NativeNfcManager.cpp
+++ b/nci/jni/NativeNfcManager.cpp
@@ -48,6 +48,7 @@
#include "DwpChannel.h"
#include "TransactionController.h"
#include <fcntl.h>
+#include "JcopManager.h"
extern "C"
{
#include "nfc_api.h"
@@ -60,10 +61,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
@@ -96,6 +93,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;
@@ -529,7 +527,6 @@ void *enableThread(void *arg);
static IntervalTimer scleanupTimerProc_transaction;
static bool gIsDtaEnabled=false;
-tNfc_featureList nfcFL;
static void nfcManager_getFeatureList();
static jbyteArray nfcManager_getAdditionalConfigOptions(JNIEnv *e, jobject o);
static void register_signal_handler();
@@ -635,7 +632,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)
@@ -1632,7 +1629,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);
}
@@ -1821,12 +1828,21 @@ static jboolean nfcManager_routeAid (JNIEnv* e, jobject, jbyteArray aid, jint ro
ScopedByteArrayRO bytes(e, aid);
uint8_t* buf = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(&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;
@@ -2050,6 +2066,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;
@@ -2139,6 +2163,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)
@@ -2187,6 +2212,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 )
@@ -2229,6 +2259,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));
@@ -2286,6 +2318,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 ||
@@ -2300,8 +2345,6 @@ static jboolean nfcManager_doInitialize (JNIEnv* e, jobject o)
}
}
#endif
- //Create transaction controller
- (void)transactionController::controller();
pendingScreenState = false;
{
SyncEventGuard guard (android::sNfaGetConfigEvent);
@@ -2854,7 +2897,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);
@@ -3341,6 +3384,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();
@@ -5540,14 +5588,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())
{
@@ -5592,12 +5640,14 @@ static int nfcManager_doJcosDownload(JNIEnv* /* e */, jobject /* o */)
return NFA_STATUS_FAILED;
}
}
+ }
+ }
if (sRfEnabled) {
// Stop RF Discovery if we were polling
startRfDiscovery (false);
}
DWPChannel_init(&Dwp);
- status = JCDNLD_Init(&Dwp);
+ status = pJcopMgr->JCDnldInit(&Dwp);
if(status != NFA_STATUS_OK)
{
ALOGE("%s: JCDND initialization failed", __func__);
@@ -5606,7 +5656,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);
@@ -5623,7 +5673,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)
@@ -5633,8 +5683,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);
@@ -5704,11 +5752,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__);
@@ -5831,7 +5874,7 @@ static void nfcManager_doSetScreenState (JNIEnv* /* e */, jobject /* o */, jint
return;
}
#endif
-
+ pendingScreenState = false;
int prevScreenState = getScreenState();
if(prevScreenState == state) {
ALOGV("Screen state is not changed. ");
@@ -6005,13 +6048,13 @@ static void nfcManager_doSetScreenState (JNIEnv* /* e */, jobject /* o */, jint
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)
{
@@ -6041,7 +6084,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)))
{
@@ -6441,12 +6483,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/NativeNfcTag.cpp b/nci/jni/NativeNfcTag.cpp
index 4362e375..6e048396 100644
--- a/nci/jni/NativeNfcTag.cpp
+++ b/nci/jni/NativeNfcTag.cpp
@@ -1244,6 +1244,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);
@@ -1283,74 +1284,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
diff --git a/nci/jni/NativeSecureElement.cpp b/nci/jni/NativeSecureElement.cpp
index 93fd1a82..e41d0501 100644
--- a/nci/jni/NativeSecureElement.cpp
+++ b/nci/jni/NativeSecureElement.cpp
@@ -340,7 +340,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);
diff --git a/nci/jni/NfcTag.cpp b/nci/jni/NfcTag.cpp
index 7d6ba77c..0aa16bbd 100644..100755
--- a/nci/jni/NfcTag.cpp
+++ b/nci/jni/NfcTag.cpp
@@ -424,6 +424,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)
diff --git a/nci/jni/RoutingManager.cpp b/nci/jni/RoutingManager.cpp
index a6f8d188..c257d6be 100644
--- a/nci/jni/RoutingManager.cpp
+++ b/nci/jni/RoutingManager.cpp
@@ -787,9 +787,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);
@@ -2437,7 +2444,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);
@@ -3058,7 +3065,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)
@@ -3213,6 +3219,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 49d68d04..8898b6dc 100644..100755
--- a/nci/jni/SecureElement.cpp
+++ b/nci/jni/SecureElement.cpp
@@ -131,6 +131,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] =
{
@@ -347,6 +350,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)))
{
@@ -474,13 +478,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);
@@ -525,13 +525,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);
@@ -1459,28 +1456,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);
@@ -1784,7 +1781,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) {
@@ -2345,8 +2342,8 @@ bool SecureElement::getSeVerInfo(int seIndex, char * verInfo, int verInfoSz, uin
strlcpy(verInfo, "Version info not available", verInfoSz-2);
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)
@@ -2541,7 +2538,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
@@ -2590,7 +2587,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);
@@ -2611,7 +2608,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)
@@ -2733,6 +2730,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);
@@ -2833,17 +2848,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;
}
@@ -2870,21 +2886,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);
-#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))
+ 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);
+ }
-#endif
- &&
- (mEeInfo[xx].ee_status != NFC_NFCEE_STATUS_INACTIVE)&& (mEeInfo[xx].ee_handle == handle))
- return (mEeInfo[xx].ee_handle);
}
return NFA_HANDLE_INVALID;
}
@@ -3217,15 +3232,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
@@ -4028,6 +4034,10 @@ TheEnd:
return decoded_length;
}
#if(NXP_EXTNS == TRUE)
+void cleanupStack(void* p)
+{
+ return;
+}
/*******************************************************************************
**
** Function: spiEventHandlerThread
@@ -4039,6 +4049,10 @@ TheEnd:
*******************************************************************************/
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__);
return NULL;
@@ -4050,7 +4064,7 @@ void *spiEventHandlerThread(void *arg)
}
(void)arg;
uint16_t usEvent = 0, usEvtLen = 0;
-
+ tNFC_STATUS stat;
NFCSTATUS ese_status = NFA_STATUS_FAILED;
@@ -4079,6 +4093,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 ();
@@ -4092,6 +4108,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);
}
@@ -4103,6 +4121,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))
@@ -4126,6 +4148,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) ||
@@ -4167,6 +4193,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;
}
@@ -4221,6 +4250,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();
+ }
}
/*******************************************************************************
**
@@ -4379,6 +4412,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,
@@ -4722,9 +4756,14 @@ 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())
+ if(stat == NFA_STATUS_OK && !android::nfcManager_isNfcDisabling() &&
+ (android::nfcManager_getNfcState() != NFC_OFF))
{
sSecElem.mEeSetModeEvent.wait ();
}
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)
diff --git a/nci/jni/TransactionController.cpp b/nci/jni/TransactionController.cpp
index 7250523d..990ab592 100644..100755
--- 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);
-
+ requestor = NULL;
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,12 +283,17 @@ bool transactionController::transactionTerminate(const char* transactionRequest
(requestor == transactionRequestor || !strcmp(transactionRequestor,"exec_pending_req")))
{
pTransactionDetail->trans_in_progress = false;
- abortTimer->kill();
+ requestor = NULL;
+ killAbortTimer();
+
+ if(android::nfcManager_isRequestPending())
+ {
+ pendingTransHandleTimer->set(1, transactionHandlePendingCb);
+ }
sem_getvalue(&barrier, &val);
if(!val)
sem_post(&barrier);
-
ALOGD ("%s: Transaction terminated : %s ", __FUNCTION__, transactionRequestor);
return true;
}
@@ -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,18 @@ 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 d3965dd9..a0df7a1e 100644..100755
--- a/nci/jni/TransactionController.h
+++ b/nci/jni/TransactionController.h
@@ -1,96 +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 <semaphore.h>
-#include <NfcJniUtil.h>
-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
- 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 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 <semaphore.h>
+#include <NfcJniUtil.h>
+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();
+};
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index 92ebd44d..49fa0dff 100644
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -463,6 +463,7 @@ public class NfcService implements DeviceHostListener {
// as SE access is not granted for non-owner users.
HashSet<String> mSePackages = new HashSet<String>();
int mScreenState;
+ int mChipVer;
boolean mIsTaskBoot = false;
boolean mInProvisionMode; // whether we're in setup wizard and enabled NFC provisioning
boolean mIsNdefPushEnabled;
@@ -1294,7 +1295,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);
@@ -1456,9 +1456,9 @@ public class NfcService implements DeviceHostListener {
} finally {
watchDog.cancel();
}
- int chipVer = mDeviceHost.getChipVer();
- if((chipVer == PN80T_ID) || (chipVer == PN553_ID)) {
- ALL_SE_ID_TYPE |= UICC2_ID_TYPE;
+ mChipVer = mDeviceHost.getChipVer();
+ if(mChipVer < PN553_ID) {
+ ALL_SE_ID_TYPE &= ~UICC2_ID_TYPE;
}
checkSecureElementConfuration();
@@ -2213,7 +2213,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;
@@ -2253,6 +2255,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");
@@ -2265,6 +2270,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;
@@ -5267,17 +5276,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 {
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;