summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nci/jni/IMPORTANT_LICENSE50
-rwxr-xr-xnci/src/com/android/nfc/dhimpl/NativeNfcManager.java12
-rwxr-xr-x[-rw-r--r--]nxp/jni/com_android_nfc.cpp12
-rwxr-xr-x[-rw-r--r--]nxp/jni/com_android_nfc.h2
-rwxr-xr-x[-rw-r--r--]nxp/jni/com_android_nfc_NativeNfcManager.cpp1022
-rwxr-xr-x[-rw-r--r--]nxp/jni/com_android_nfc_NativeNfcTag.cpp610
-rwxr-xr-xnxp/src/com/android/nfc/dhimpl/NativeNfcManager.java20
-rw-r--r--res/values-nl/strings.xml36
-rwxr-xr-x[-rw-r--r--]src/com/android/nfc/DeviceHost.java8
-rwxr-xr-xsrc/com/android/nfc/NfcService.java33
10 files changed, 1436 insertions, 369 deletions
diff --git a/nci/jni/IMPORTANT_LICENSE b/nci/jni/IMPORTANT_LICENSE
new file mode 100644
index 0000000..2cc9a94
--- /dev/null
+++ b/nci/jni/IMPORTANT_LICENSE
@@ -0,0 +1,50 @@
+
+Copyright (C) 1999-2012 Broadcom Corporation
+
+This license applies to all underlying Broadcom proprietary code and all
+changes thereto committed to the AOSP on or before the
+commit eec15a2576fe8c6abf986996d6be20ae5b6afcfe ("Proprietary Files").
+
+In addition, this license applies to all Broadcom proprietary code that is NOT
+governed by the Apache License, Version 2.0, unless you originally licensed
+such Broadcom proprietary code under a license from Broadcom ("Broadcom SLA").
+If you have a Broadcom SLA, the terms and conditions of such SLA will continue
+to govern your use of the Broadcom proprietary code, including without
+limitation, the Proprietary Files.
+
+These Proprietary Files are the proprietary software of Broadcom Corporation
+and/or its licensors, and may only be duplicated or distributed (through
+multiple tiers) for internal evaluation purposes ("Authorized License"). Any
+commercial redistribution of the Proprietary Files is strictly prohibited.
+
+Except as set forth in this Authorized License, Broadcom grants no license
+(express or implied), right to use, or waiver of any kind with respect to the
+Authorized Files, and Broadcom expressly reserves all rights in and to the
+Authorized Files and all intellectual property rights therein.
+
+Except as expressly set forth in the Authorized License,
+
+1. These Proprietary Files, including its structure, sequence and organization,
+ constitutes the valuable trade secrets of Broadcom, and you shall use all
+ reasonable efforts to protect the confidentiality thereof, and to use this
+ information only for internal evaluation purposes.
+
+2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THESE PROPRIETARY FILES ARE PROVIDED
+ "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS
+ OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
+ RESPECT TO THE PROPRIETARY FILES. BROADCOM SPECIFICALLY DISCLAIMS ANY AND
+ ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS
+ FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET
+ ENJOYMENT, QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE
+ ENTIRE RISK ARISING OUT OF YOUR USE OF THE PROPRIETARY FILES UNDER THE
+ AUTHORIZED LICENSE. IF YOU VIOLATE THE AUTHORIZED LICENSE, THIS LICENSE WILL
+ BE IMMEDIATELY RESCINDED AND TERMINATED.
+
+3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
+ LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
+ EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
+ USE OF OR INABILITY TO USE THE PROPRIETARY FILES EVEN IF BROADCOM HAS BEEN
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF
+ THE AMOUNT ACTUALLY PAID FOR THE PROPRIETARY FILES ITSELF OR U.S. $1,
+ WHICHEVER IS GREATER. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY
+ FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
diff --git a/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java b/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
index 1437e5d..d045ae2 100755
--- a/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
+++ b/nci/src/com/android/nfc/dhimpl/NativeNfcManager.java
@@ -124,6 +124,18 @@ public class NativeNfcManager implements DeviceHost {
public native void disableDiscovery();
@Override
+ public void enableCE_A() { Log.e(TAG, "NFC Host Emulation not supported with NCI adapters"); return; };
+
+ @Override
+ public void disableCE_A() { Log.e(TAG, "NFC Host Emulation not supported with NCI adapters"); return; };
+
+ @Override
+ public void enableCE_B() { Log.e(TAG, "NFC Host Emulation not supported with NCI adapters"); return; };
+
+ @Override
+ public void disableCE_B() { Log.e(TAG, "NFC Host Emulation not supported with NCI adapters"); return; };
+
+ @Override
public native int[] doGetSecureElementList();
@Override
diff --git a/nxp/jni/com_android_nfc.cpp b/nxp/jni/com_android_nfc.cpp
index d794d6e..c0e1993 100644..100755
--- a/nxp/jni/com_android_nfc.cpp
+++ b/nxp/jni/com_android_nfc.cpp
@@ -471,6 +471,18 @@ void nfc_jni_get_technology_tree(JNIEnv* e, phLibNfc_RemoteDevList_t* devList,
int handle = devList[target].hTargetDev;
switch (type)
{
+ case phNfc_eISO14443_A_PCD:
+ {
+ index = addTechIfNeeded(technologies, handles, libnfctypes, index,
+ MAX_NUM_TECHNOLOGIES, TARGET_TYPE_ISO14443_4A_PCD, handle, type);
+ break;
+ }
+ case phNfc_eISO14443_B_PCD:
+ {
+ index = addTechIfNeeded(technologies, handles, libnfctypes, index,
+ MAX_NUM_TECHNOLOGIES, TARGET_TYPE_ISO14443_4B_PCD, handle, type);
+ break;
+ }
case phNfc_eISO14443_A_PICC:
case phNfc_eISO14443_4A_PICC:
{
diff --git a/nxp/jni/com_android_nfc.h b/nxp/jni/com_android_nfc.h
index b876dad..cca3e13 100644..100755
--- a/nxp/jni/com_android_nfc.h
+++ b/nxp/jni/com_android_nfc.h
@@ -100,6 +100,8 @@ extern "C" {
#define TARGET_TYPE_NDEF_FORMATABLE 7
#define TARGET_TYPE_MIFARE_CLASSIC 8
#define TARGET_TYPE_MIFARE_UL 9
+#define TARGET_TYPE_ISO14443_4A_PCD 10
+#define TARGET_TYPE_ISO14443_4B_PCD 11
#define SMX_SECURE_ELEMENT_ID 11259375
diff --git a/nxp/jni/com_android_nfc_NativeNfcManager.cpp b/nxp/jni/com_android_nfc_NativeNfcManager.cpp
index d82291b..af0e4fb 100644..100755
--- a/nxp/jni/com_android_nfc_NativeNfcManager.cpp
+++ b/nxp/jni/com_android_nfc_NativeNfcManager.cpp
@@ -30,6 +30,34 @@
#define ERROR_BUFFER_TOO_SMALL -12
#define ERROR_INSUFFICIENT_RESOURCES -9
+/****************************************************************
+* define CONFIG_CE_DEFAULT in order to always enable PCD A
+* discovery while the discovery loop is on.
+* The only case where this is an issue is when a remote device
+* is another android NFC device and has an activity triggered
+* on an intent of ISO14443 technology discovery.
+*
+* if this is the case then the P2P NDEF PUSH service will never
+* get notified there is another NDEF client because the client
+* will actually get discovered as a ISO14443 tag.
+*
+* if CONFIG_CE_DEFAULT is NOT defined, then the issue with
+* this case is mostly solved because the PCD A/B modes can
+* only be activated when the foreground activity calls for them in
+* enableForegroundDispatch
+* and they are de-activated whenever the device turns off
+* discovery loop
+*
+* HOST CARD EMULATION PATCH 1.01
+* Author: doug yeager (doug@simplytapp.com)
+******************************************************************/
+#define HOST_EMULATION
+//#define CONFIG_CE_DEFAULT
+#define TURN_CE_ON 1
+#define TURN_CE_OFF 0
+#define UNBLOCK_CE_CALLBACK 2
+#define INIT_CE 3
+
extern uint32_t libnfc_llc_error_count;
static phLibNfc_sConfig_t gDrvCfg;
@@ -39,6 +67,11 @@ static phNfc_sData_t gOutputParam;
uint8_t device_connected_flag;
static bool driverConfigured = FALSE;
+static bool ceAOn = FALSE;
+static bool ceBOn = FALSE;
+static bool turnCeAOn = FALSE;
+static bool turnCeBOn = FALSE;
+static bool discoveryOn = FALSE;
static phLibNfc_Handle hLlcpHandle;
static NFCSTATUS lastErrorStatus = NFCSTATUS_FAILED;
@@ -70,8 +103,13 @@ static void nfc_jni_deinit_callback(void *pContext, NFCSTATUS status);
static void nfc_jni_discover_callback(void *pContext, NFCSTATUS status);
static void nfc_jni_se_set_mode_callback(void *context,
phLibNfc_Handle handle, NFCSTATUS status);
+static void nfc_jni_CE_callback(void *context,
+ phLibNfc_eCE_EvtType_t evt_type, uint32_t handle, NFCSTATUS status);
static void nfc_jni_llcpcfg_callback(void *pContext, NFCSTATUS status);
+static void nfc_jni_CEcfg_callback(void *pContext, NFCSTATUS status);
static void nfc_jni_start_discovery_locked(struct nfc_jni_native_data *nat, bool resume);
+static void set_CE_A_mode(uint8_t mode, struct nfc_jni_native_data *nat);
+static void set_CE_B_mode(uint8_t mode, struct nfc_jni_native_data *nat);
static void nfc_jni_Discovery_notification_callback(void *pContext,
phLibNfc_RemoteDevList_t *psRemoteDevList,
uint8_t uNofRemoteDev, NFCSTATUS status);
@@ -86,7 +124,7 @@ static bool performDownload(struct nfc_jni_native_data *nat, bool takeLock);
static void client_kill_deferred_call(void* arg)
{
struct nfc_jni_native_data *nat = (struct nfc_jni_native_data *)arg;
-
+
nat->running = FALSE;
}
@@ -94,15 +132,15 @@ static void kill_client(nfc_jni_native_data *nat)
{
phDal4Nfc_Message_Wrapper_t wrapper;
phLibNfc_DeferredCall_t *pMsg;
-
+
usleep(50000);
ALOGD("Terminating client thread...");
-
+
pMsg = (phLibNfc_DeferredCall_t*)malloc(sizeof(phLibNfc_DeferredCall_t));
pMsg->pCallback = client_kill_deferred_call;
pMsg->pParameter = (void*)nat;
-
+
wrapper.msg.eMsgType = PH_LIBNFC_DEFERREDCALL_MSG;
wrapper.msg.pMsgData = pMsg;
wrapper.msg.Size = sizeof(phLibNfc_DeferredCall_t);
@@ -359,7 +397,7 @@ static int nfc_jni_initialize(struct nfc_jni_native_data *nat) {
goto force_download;
}
TRACE("phLibNfc_Mgt_Initialize returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
-
+
/* Wait for callback response */
if(sem_wait(&cb_data.sem))
{
@@ -553,18 +591,28 @@ force_download:
nat->discovery_cfg.Duration = 300000; /* in ms */
nat->discovery_cfg.NfcIP_Tgt_Disable = FALSE;
+#if defined (HOST_EMULATION)
/* Register for the card emulation mode */
REENTRANCE_LOCK();
- ret = phLibNfc_SE_NtfRegister(nfc_jni_transaction_callback,(void *)nat);
+ ret = phLibNfc_CE_NtfRegister(nfc_jni_CE_callback,(void *)nat);
REENTRANCE_UNLOCK();
if(ret != NFCSTATUS_SUCCESS)
{
- ALOGD("phLibNfc_SE_NtfRegister returned 0x%02x",ret);
- goto clean_and_return;
+ ALOGD("pphLibNfc_CE_RemoteDev_NtfRegister returned 0x%02x",ret);
}
- TRACE("phLibNfc_SE_NtfRegister returned 0x%x\n", ret);
-
-
+ TRACE("phLibNfc_CE_NtfRegister returned 0x%x\n", ret);
+#else
+ /* Register for the SE card emulation mode */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_NtfRegister(nfc_jni_transaction_callback,(void *)nat);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_SUCCESS)
+ {
+ ALOGD("phLibNfc_SE_NtfRegister returned 0x%02x",status);
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_NtfRegister returned 0x%x\n", status);
+#endif
/* ====== END ======= */
ALOGI("NFC Initialized");
@@ -724,7 +772,7 @@ static void *nfc_jni_client_thread(void *arg)
}
}
TRACE("NFC client stopped");
-
+
nat->vm->DetachCurrentThread();
return NULL;
@@ -738,7 +786,7 @@ static phLibNfc_sNfcIPCfg_t nfc_jni_nfcip1_cfg =
{
3,
{ 0x46, 0x66, 0x6D }
-};
+};
/*
* Callbacks
@@ -762,7 +810,7 @@ static void nfc_jni_llcp_linkStatus_callback(void *pContext,
TRACE("Callback: nfc_jni_llcp_linkStatus_callback()");
nat->vm->GetEnv( (void **)&e, nat->env_version);
-
+
/* Update link status */
g_eLinkStatus = eLinkStatus;
@@ -805,7 +853,7 @@ static void nfc_jni_llcp_linkStatus_callback(void *pContext,
{
ALOGE("Exception occured");
kill_client(nat);
- }
+ }
}
}
@@ -830,6 +878,16 @@ static void nfc_jni_llcpcfg_callback(void *pContext, NFCSTATUS status)
sem_post(&pCallbackData->sem);
}
+static void nfc_jni_CEcfg_callback(void *pContext, NFCSTATUS status)
+{
+ struct nfc_jni_callback_data * pCallbackData = (struct nfc_jni_callback_data *) pContext;
+ LOG_CALLBACK("nfc_jni_CEcfg_callback", status);
+
+ /* Report the callback status and wake up the caller */
+ pCallbackData->status = status;
+ sem_post(&pCallbackData->sem);
+}
+
static void nfc_jni_llcp_transport_listen_socket_callback(void *pContext,
phLibNfc_Handle hIncomingSocket)
{
@@ -887,6 +945,113 @@ static void nfc_jni_discover_callback(void *pContext, NFCSTATUS status)
sem_post(&pContextData->sem);
}
+static void nfc_jni_Discover_14443_4_PCD_callback(void *pContext, phLibNfc_Handle handle, phNfc_sData_t *data, NFCSTATUS status)
+{
+ JNIEnv *e;
+ NFCSTATUS ret;
+ jclass tag_cls = NULL;
+ jobject tag;
+ jmethodID ctor;
+ jfieldID f;
+ struct nfc_jni_native_data *nat;
+ uint16_t j;
+ phLibNfc_sRemoteDevInformation_t *psRemoteDevInfo = (phLibNfc_sRemoteDevInformation_t *) handle;
+ phLibNfc_RemoteDevList_t psRemoteDevList[1];
+ uint8_t *buffer;
+
+ nat = (struct nfc_jni_native_data *)pContext;
+
+ nat->vm->GetEnv( (void **)&e, nat->env_version);
+
+ if(status == NFCSTATUS_DESELECTED)
+ {
+ if(!device_connected_flag)
+ {
+ //free handle memory
+ phOsalNfc_FreeMemory(psRemoteDevInfo);
+ }
+ LOG_CALLBACK("nfc_jni_Discover_14443_4_PCD_callback: Target deselected", status);
+ }
+ else
+ {
+ LOG_CALLBACK("nfc_jni_discover_14443_4_PCD_callback", status);
+
+ storedHandle = handle;
+ /* Reset device connected flag */
+ device_connected_flag = 1;
+
+ //store the incoming data
+ if(psRemoteDevInfo!=NULL)
+ {
+ buffer = (uint8_t*)malloc(data->length);
+ memcpy(buffer, data->buffer, data->length);
+ psRemoteDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.buffer = buffer;
+ psRemoteDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.length = data->length;
+ }
+
+
+ tag_cls = e->GetObjectClass(nat->cached_NfcTag);
+ if(e->ExceptionCheck())
+ {
+ kill_client(nat);
+ return;
+ }
+
+ /* New tag instance */
+ ctor = e->GetMethodID(tag_cls, "<init>", "()V");
+ tag = e->NewObject(tag_cls, ctor);
+
+ /* Generate technology list */
+ jintArray techList;
+ jintArray handleList;
+ jintArray typeList;
+ psRemoteDevList[0].psRemoteDevInfo = psRemoteDevInfo;
+ psRemoteDevList[0].hTargetDev = handle;
+ nfc_jni_get_technology_tree(e, psRemoteDevList,
+ 1,
+ &techList, &handleList, &typeList);
+
+ /* Push the technology list into the java object */
+ f = e->GetFieldID(tag_cls, "mTechList", "[I");
+ e->SetObjectField(tag, f, techList);
+
+ f = e->GetFieldID(tag_cls, "mTechHandles", "[I");
+ e->SetObjectField(tag, f, handleList);
+
+ f = e->GetFieldID(tag_cls, "mTechLibNfcTypes", "[I");
+ e->SetObjectField(tag, f, typeList);
+
+ f = e->GetFieldID(tag_cls, "mConnectedTechIndex", "I");
+ e->SetIntField(tag, f,(jint)-1);
+
+ f = e->GetFieldID(tag_cls, "mConnectedHandle", "I");
+ e->SetIntField(tag, f,(jint)-1);
+
+ if(techList!=NULL)
+ e->DeleteLocalRef(techList);
+ if(handleList!=NULL)
+ e->DeleteLocalRef(handleList);
+ if(typeList!=NULL)
+ e->DeleteLocalRef(typeList);
+
+ if (nat->tag != NULL) {
+ e->DeleteGlobalRef(nat->tag);
+ }
+ nat->tag = e->NewGlobalRef(tag);
+
+ /* Notify the service */
+ TRACE("Notify Nfc Service");
+ /* Notify manager that new a tag was found */
+ e->CallVoidMethod(nat->manager, cached_NfcManager_notifyNdefMessageListeners, tag);
+ if(e->ExceptionCheck())
+ {
+ ALOGE("Exception occured");
+ kill_client(nat);
+ }
+ e->DeleteLocalRef(tag);
+ }
+}
+
static uint8_t find_preferred_target(phLibNfc_RemoteDevList_t *psRemoteDevList,
uint8_t uNoOfRemoteDev)
{
@@ -923,20 +1088,20 @@ static void nfc_jni_Discovery_notification_callback(void *pContext,
int target_index = 0; // Target that will be reported (if multiple can be >0)
nat = (struct nfc_jni_native_data *)pContext;
-
+
nat->vm->GetEnv( (void **)&e, nat->env_version);
-
+
if(status == NFCSTATUS_DESELECTED)
{
- LOG_CALLBACK("nfc_jni_Discovery_notification_callback: Target deselected", status);
-
+ LOG_CALLBACK("nfc_jni_Discovery_notification_callback: Target deselected", status);
+
/* Notify manager that a target was deselected */
e->CallVoidMethod(nat->manager, cached_NfcManager_notifyTargetDeselected);
if(e->ExceptionCheck())
{
ALOGE("Exception occured");
kill_client(nat);
- }
+ }
}
else
{
@@ -956,34 +1121,34 @@ static void nfc_jni_Discovery_notification_callback(void *pContext,
tag_cls = e->GetObjectClass(nat->cached_P2pDevice);
if(e->ExceptionCheck())
{
- ALOGE("Get Object Class Error");
+ ALOGE("Get Object Class Error");
kill_client(nat);
return;
- }
-
+ }
+
/* New target instance */
ctor = e->GetMethodID(tag_cls, "<init>", "()V");
tag = e->NewObject(tag_cls, ctor);
-
+
/* Set P2P Target mode */
- f = e->GetFieldID(tag_cls, "mMode", "I");
-
+ f = e->GetFieldID(tag_cls, "mMode", "I");
+
if(remDevInfo->RemDevType == phNfc_eNfcIP1_Initiator)
{
ALOGD("Discovered P2P Initiator");
e->SetIntField(tag, f, (jint)MODE_P2P_INITIATOR);
}
else
- {
+ {
ALOGD("Discovered P2P Target");
e->SetIntField(tag, f, (jint)MODE_P2P_TARGET);
}
-
+
if(remDevInfo->RemDevType == phNfc_eNfcIP1_Initiator)
{
/* Set General Bytes */
f = e->GetFieldID(tag_cls, "mGeneralBytes", "[B");
-
+
TRACE("General Bytes length =");
for(i=0;i<remDevInfo->RemoteDevInfo.NfcIP_Info.ATRInfo_Length;i++)
{
@@ -991,11 +1156,11 @@ static void nfc_jni_Discovery_notification_callback(void *pContext,
}
generalBytes = e->NewByteArray(remDevInfo->RemoteDevInfo.NfcIP_Info.ATRInfo_Length);
-
- e->SetByteArrayRegion(generalBytes, 0,
+
+ e->SetByteArrayRegion(generalBytes, 0,
remDevInfo->RemoteDevInfo.NfcIP_Info.ATRInfo_Length,
(jbyte *)remDevInfo->RemoteDevInfo.NfcIP_Info.ATRInfo);
-
+
e->SetObjectField(tag, f, generalBytes);
}
@@ -1066,21 +1231,21 @@ static void nfc_jni_Discovery_notification_callback(void *pContext,
}
nat->tag = e->NewGlobalRef(tag);
- /* Notify the service */
+ /* Notify the service */
TRACE("Notify Nfc Service");
if((remDevInfo->RemDevType == phNfc_eNfcIP1_Initiator)
|| (remDevInfo->RemDevType == phNfc_eNfcIP1_Target))
{
/* Store the hanlde of the P2P device */
hLlcpHandle = remDevHandle;
-
+
/* Notify manager that new a P2P device was found */
e->CallVoidMethod(nat->manager, cached_NfcManager_notifyLlcpLinkActivation, tag);
if(e->ExceptionCheck())
{
ALOGE("Exception occured");
kill_client(nat);
- }
+ }
}
else
{
@@ -1090,10 +1255,10 @@ static void nfc_jni_Discovery_notification_callback(void *pContext,
{
ALOGE("Exception occured");
kill_client(nat);
- }
+ }
}
e->DeleteLocalRef(tag);
- }
+ }
}
static void nfc_jni_init_callback(void *pContext, NFCSTATUS status)
@@ -1294,6 +1459,111 @@ static void nfc_jni_transaction_callback(void *context,
}
}
+/* Card Emulation callback */
+static void nfc_jni_CE_callback(void *context,
+ phLibNfc_eCE_EvtType_t evt_type, uint32_t handle,
+ NFCSTATUS status)
+{
+ JNIEnv *e;
+ jobject tmp_array = NULL;
+ jobject mifare_block = NULL;
+ struct nfc_jni_native_data *nat;
+ phNfc_sData_t *aid;
+ phNfc_sData_t *mifare_command;
+ int i=0;
+
+ LOG_CALLBACK("nfc_jni_CE_callback", status);
+ nat = (struct nfc_jni_native_data *)context;
+
+ nat->vm->GetEnv( (void **)&e, nat->env_version);
+
+ if(status == NFCSTATUS_SUCCESS)
+ {
+ switch(evt_type)
+ {
+ case phLibNfc_eCE_B_EvtActivated:
+ {
+ if(!device_connected_flag)
+ {
+ TRACE("> CE EVT B ACTIVATED");
+ /* Receive */
+ TRACE("phLibNfc_RemoteDev_CE_B_Receive()");
+ REENTRANCE_LOCK();
+ status = phLibNfc_RemoteDev_CE_B_Receive(nfc_jni_Discover_14443_4_PCD_callback,(void *)context);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_PENDING)
+ {
+ ALOGE("phLibNfc_RemoteDev_CE_B_Receive() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+ goto error;
+ }
+ }
+ }break;
+ case phLibNfc_eCE_A_EvtActivated:
+ {
+ if(!device_connected_flag)
+ {
+ TRACE("> CE EVT A ACTIVATED");
+ /* Receive */
+ TRACE("phLibNfc_RemoteDev_CE_A_Receive()");
+ REENTRANCE_LOCK();
+ status = phLibNfc_RemoteDev_CE_A_Receive(nfc_jni_Discover_14443_4_PCD_callback,(void *)context);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_PENDING)
+ {
+ ALOGE("phLibNfc_RemoteDev_CE_A_Receive() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+ goto error;
+ }
+ }
+ }break;
+ case phLibNfc_eCE_B_EvtDeActivated:
+ case phLibNfc_eCE_A_EvtDeActivated:
+ {
+ LOG_CALLBACK("nfc_jni_Discover_14443_4_PCD_callback: Target deselected", status);
+ if(!device_connected_flag || storedHandle!=handle)
+ {
+ //free handle memory
+ phLibNfc_sRemoteDevInformation_t *psRemoteDevInfo = (phLibNfc_sRemoteDevInformation_t *) handle;
+ phOsalNfc_FreeMemory(psRemoteDevInfo);
+ }
+ TRACE("> CE EVT A DEACTIVATED");
+ }break;
+ case phLibNfc_eCE_EvtFieldOn:
+ {
+ TRACE("> CE EVT_FIELD_ON");
+ }break;
+
+ case phLibNfc_eCE_EvtFieldOff:
+ {
+ TRACE("> CE EVT_FIELD_OFF");
+ }break;
+
+ default:
+ {
+ TRACE("Unknown CE event");
+ }break;
+ }
+ }
+ else
+ {
+ ALOGE("CE transaction notification error");
+ goto error;
+ }
+
+ /* Function finished, now clean and return */
+ goto clean_and_return;
+
+ error:
+ /* In case of error, just discard the notification */
+ ALOGE("Failed to send CE transaction notification");
+ e->ExceptionClear();
+
+ clean_and_return:
+ if(tmp_array != NULL)
+ {
+ e->DeleteLocalRef(tmp_array);
+ }
+}
+
static void nfc_jni_se_set_mode_callback(void *pContext,
phLibNfc_Handle handle, NFCSTATUS status)
{
@@ -1330,6 +1600,9 @@ static void nfc_jni_start_discovery_locked(struct nfc_jni_native_data *nat, bool
/* Reset device connected flag */
device_connected_flag = 0;
+ set_CE_A_mode(UNBLOCK_CE_CALLBACK, nat);
+ set_CE_B_mode(UNBLOCK_CE_CALLBACK, nat);
+
/* Start Polling loop */
TRACE("****** Start NFC Discovery ******");
REENTRANCE_LOCK();
@@ -1348,6 +1621,9 @@ static void nfc_jni_start_discovery_locked(struct nfc_jni_native_data *nat, bool
if(ret != NFCSTATUS_PENDING)
{
+ set_CE_A_mode(TURN_CE_OFF, nat);
+ set_CE_B_mode(TURN_CE_OFF, nat);
+ discoveryOn = FALSE;
emergency_recovery(nat);
goto clean_and_return;
}
@@ -1356,9 +1632,22 @@ static void nfc_jni_start_discovery_locked(struct nfc_jni_native_data *nat, bool
if(sem_wait(&cb_data.sem))
{
ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
+ set_CE_A_mode(TURN_CE_OFF, nat);
+ set_CE_B_mode(TURN_CE_OFF, nat);
+ discoveryOn = FALSE;
goto clean_and_return;
}
+ discoveryOn = TRUE;
+#ifndef CONFIG_CE_DEFAULT
+ if(turnCeAOn)
+ set_CE_A_mode(TURN_CE_ON, nat);
+ if(turnCeBOn)
+ set_CE_B_mode(TURN_CE_ON, nat);
+#else
+ set_CE_A_mode(TURN_CE_ON, nat);
+#endif
+
clean_and_return:
nfc_cb_data_deinit(&cb_data);
}
@@ -1369,6 +1658,9 @@ static void nfc_jni_stop_discovery_locked(struct nfc_jni_native_data *nat)
NFCSTATUS ret;
struct nfc_jni_callback_data cb_data;
+ set_CE_A_mode(TURN_CE_OFF, nat);
+ set_CE_B_mode(TURN_CE_OFF, nat);
+
/* Create the local semaphore */
if (!nfc_cb_data_init(&cb_data, NULL))
{
@@ -1379,7 +1671,7 @@ static void nfc_jni_stop_discovery_locked(struct nfc_jni_native_data *nat)
discovery_cfg.NfcIP_Mode = phNfc_eDefaultP2PMode;
discovery_cfg.NfcIP_Target_Mode = 0;
discovery_cfg.NfcIP_Tgt_Disable = TRUE;
-
+
/* Start Polling loop */
TRACE("****** Stop NFC Discovery ******");
REENTRANCE_LOCK();
@@ -1407,10 +1699,464 @@ static void nfc_jni_stop_discovery_locked(struct nfc_jni_native_data *nat)
goto clean_and_return;
}
+ discoveryOn = FALSE;
+
clean_and_return:
nfc_cb_data_deinit(&cb_data);
}
+static void set_CE_A_mode(uint8_t mode, struct nfc_jni_native_data *nat)
+{
+#if defined (HOST_EMULATION)
+ uint8_t unblocked = FALSE;
+ NFCSTATUS status;
+ struct nfc_jni_callback_data cb_data;
+
+ if(mode==INIT_CE)
+ {
+ ceAOn=FALSE;
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, NULL))
+ {
+ goto clean_and_return;
+ }
+ REENTRANCE_LOCK();
+ status = phLibNfc_Mgt_SetCE_A_14443_4_ConfigParams(TRUE,
+ nfc_jni_CEcfg_callback,
+ (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+ if(status == NFCSTATUS_PENDING)
+ {
+ sem_wait(&cb_data.sem);
+ }
+ TRACE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status,
+ nfc_jni_get_status_name(status));
+ REENTRANCE_LOCK();
+ status = phLibNfc_Mgt_SetCE_A_14443_4_ConfigParams(FALSE,
+ nfc_jni_CEcfg_callback,
+ (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+ if(status == NFCSTATUS_PENDING)
+ {
+ sem_wait(&cb_data.sem);
+ }
+ ceAOn=FALSE;
+
+ if(ceAOn==TRUE || ceBOn==TRUE)
+ {
+ /* Register for the SE card emulation mode */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_NtfUnregister();
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_SUCCESS)
+ {
+ ALOGD("phLibNfc_SE_NtfRegister returned 0x%02x",status);
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_NtfRegister returned 0x%x\n", status);
+ }
+ else
+ {
+ /* Register for the SE card emulation mode */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_NtfRegister(nfc_jni_transaction_callback,(void *)nat);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_SUCCESS)
+ {
+ ALOGD("phLibNfc_SE_NtfRegister returned 0x%02x",status);
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_NtfRegister returned 0x%x\n", status);
+ }
+
+ return;
+ }
+
+ if(mode==TURN_CE_ON || mode==TURN_CE_OFF)
+ turnCeAOn = FALSE; //reset flag
+
+ if(ceAOn==TRUE && mode==TURN_CE_ON)
+ return; //already on
+ if(ceAOn==FALSE && mode==TURN_CE_OFF)
+ return; //already off
+ if(ceAOn==FALSE && mode==UNBLOCK_CE_CALLBACK)
+ return; //can't block when it is already off
+
+ if(discoveryOn==FALSE && mode==TURN_CE_ON)
+ {
+ turnCeAOn = TRUE; //turn on when discovery turns on
+ return;
+ }
+
+ if(mode==TURN_CE_OFF || mode==UNBLOCK_CE_CALLBACK)
+ if(phLibNfc_Mgt_Unblock_Cb_CE_A_14443_4( )==NFCSTATUS_SUCCESS)
+ unblocked=TRUE;
+
+
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, NULL))
+ {
+ goto clean_and_return;
+ }
+
+ if(mode==TURN_CE_OFF || (mode==UNBLOCK_CE_CALLBACK && unblocked==TRUE))
+ {
+ REENTRANCE_LOCK();
+ status = phLibNfc_Mgt_SetCE_A_14443_4_ConfigParams(FALSE,
+ nfc_jni_CEcfg_callback,
+ (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_PENDING)
+ {
+ ALOGE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status,
+ nfc_jni_get_status_name(status));
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status,
+ nfc_jni_get_status_name(status));
+
+ /* Wait for callback response */
+ if(sem_wait(&cb_data.sem))
+ {
+ ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
+ goto clean_and_return;
+ }
+
+ ceAOn=FALSE;
+ }
+
+ if(mode==TURN_CE_ON || (mode==UNBLOCK_CE_CALLBACK && unblocked==TRUE && discoveryOn==TRUE))
+ {
+ TRACE("phLibNfc_SE_SetMode()");
+ /* Set SE mode - Default */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_SetMode(nat->seId, phLibNfc_SE_ActModeDefault,
+ nfc_jni_se_set_mode_callback, (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+
+ TRACE("phLibNfc_SE_SetMode returned 0x%02x", status);
+ if (status != NFCSTATUS_PENDING) {
+ ALOGE("phLibNfc_SE_SetMode() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_SetMode() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+
+ /* Wait for callback response */
+ if (sem_wait(&cb_data.sem)) {
+ ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
+ goto clean_and_return;
+ }
+
+ REENTRANCE_LOCK();
+ status = phLibNfc_Mgt_SetCE_A_14443_4_ConfigParams(TRUE,
+ nfc_jni_CEcfg_callback,
+ (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_PENDING)
+ {
+ ALOGE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status,
+ nfc_jni_get_status_name(status));
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status,
+ nfc_jni_get_status_name(status));
+ /* Wait for callback response */
+ if(sem_wait(&cb_data.sem))
+ {
+ ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
+ goto clean_and_return;
+ }
+
+ ceAOn=TRUE;
+ }
+
+clean_and_return:
+
+ if(ceAOn==TRUE || ceBOn==TRUE)
+ {
+ /* Register for the SE card emulation mode */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_NtfUnregister();
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_SUCCESS)
+ {
+ ALOGD("phLibNfc_SE_NtfRegister returned 0x%02x",status);
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_NtfRegister returned 0x%x\n", status);
+ }
+ else
+ {
+ /* Register for the SE card emulation mode */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_NtfRegister(nfc_jni_transaction_callback,(void *)nat);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_SUCCESS)
+ {
+ ALOGD("phLibNfc_SE_NtfRegister returned 0x%02x",status);
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_NtfRegister returned 0x%x\n", status);
+ }
+
+#endif //HOST_EMULATION
+}
+
+static void set_CE_B_mode(uint8_t mode, struct nfc_jni_native_data *nat)
+{
+#if defined (HOST_EMULATION)
+ uint8_t unblocked = FALSE;
+ NFCSTATUS status;
+ struct nfc_jni_callback_data cb_data;
+
+ if(mode==INIT_CE)
+ {
+ ceBOn=FALSE;
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, NULL))
+ {
+ goto clean_and_return;
+ }
+ REENTRANCE_LOCK();
+ status = phLibNfc_Mgt_SetCE_B_14443_4_ConfigParams(TRUE,
+ nfc_jni_CEcfg_callback,
+ (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+ if(status == NFCSTATUS_PENDING)
+ {
+ sem_wait(&cb_data.sem);
+ }
+ REENTRANCE_LOCK();
+ status = phLibNfc_Mgt_SetCE_B_14443_4_ConfigParams(FALSE,
+ nfc_jni_CEcfg_callback,
+ (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+ if(status == NFCSTATUS_PENDING)
+ {
+ sem_wait(&cb_data.sem);
+ }
+ ceBOn=FALSE;
+
+ if(ceAOn==TRUE || ceBOn==TRUE)
+ {
+ /* Register for the SE card emulation mode */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_NtfUnregister();
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_SUCCESS)
+ {
+ ALOGD("phLibNfc_SE_NtfRegister returned 0x%02x",status);
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_NtfRegister returned 0x%x\n", status);
+ }
+ else
+ {
+ /* Register for the SE card emulation mode */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_NtfRegister(nfc_jni_transaction_callback,(void *)nat);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_SUCCESS)
+ {
+ ALOGD("phLibNfc_SE_NtfRegister returned 0x%02x",status);
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_NtfRegister returned 0x%x\n", status);
+ }
+
+ return;
+ }
+
+ if(mode==TURN_CE_ON || mode==TURN_CE_OFF)
+ turnCeBOn = FALSE; //reset flag
+
+ if(ceBOn==TRUE && mode==TURN_CE_ON)
+ return; //already on
+ if(ceBOn==FALSE && mode==TURN_CE_OFF)
+ return; //already off
+ if(ceBOn==FALSE && mode==UNBLOCK_CE_CALLBACK)
+ return; //can't block when it is already off
+
+ if(discoveryOn==FALSE && mode==TURN_CE_ON)
+ {
+ turnCeBOn = TRUE; //turn on when discovery turns on
+ return;
+ }
+
+ if(mode==TURN_CE_OFF || mode==UNBLOCK_CE_CALLBACK)
+ if(phLibNfc_Mgt_Unblock_Cb_CE_B_14443_4( )==NFCSTATUS_SUCCESS)
+ unblocked=TRUE;
+
+
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, NULL))
+ {
+ goto clean_and_return;
+ }
+
+ if(mode==TURN_CE_OFF || (mode==UNBLOCK_CE_CALLBACK && unblocked==TRUE))
+ {
+ REENTRANCE_LOCK();
+ status = phLibNfc_Mgt_SetCE_B_14443_4_ConfigParams(FALSE,
+ nfc_jni_CEcfg_callback,
+ (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_PENDING)
+ {
+ ALOGE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status,
+ nfc_jni_get_status_name(status));
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status,
+ nfc_jni_get_status_name(status));
+
+ /* Wait for callback response */
+ if(sem_wait(&cb_data.sem))
+ {
+ ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
+ goto clean_and_return;
+ }
+
+ ceBOn=FALSE;
+ }
+
+ if(mode==TURN_CE_ON || (mode==UNBLOCK_CE_CALLBACK && unblocked==TRUE && discoveryOn==TRUE))
+ {
+ TRACE("phLibNfc_SE_SetMode()");
+ /* Set SE mode - Default */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_SetMode(nat->seId, phLibNfc_SE_ActModeDefault,
+ nfc_jni_se_set_mode_callback, (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+
+ TRACE("phLibNfc_SE_SetMode returned 0x%02x", status);
+ if (status != NFCSTATUS_PENDING) {
+ ALOGE("phLibNfc_SE_SetMode() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_SetMode() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+
+ /* Wait for callback response */
+ if (sem_wait(&cb_data.sem)) {
+ ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
+ goto clean_and_return;
+ }
+
+ REENTRANCE_LOCK();
+ status = phLibNfc_Mgt_SetCE_B_14443_4_ConfigParams(TRUE,
+ nfc_jni_CEcfg_callback,
+ (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_PENDING)
+ {
+ ALOGE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status,
+ nfc_jni_get_status_name(status));
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_Mgt_SetCE_14443_4_ConfigParams returned 0x%04x[%s]", status,
+ nfc_jni_get_status_name(status));
+
+ /* Wait for callback response */
+ if(sem_wait(&cb_data.sem))
+ {
+ ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
+ goto clean_and_return;
+ }
+
+ ceBOn=TRUE;
+ }
+
+clean_and_return:
+
+ if(ceAOn==TRUE || ceBOn==TRUE)
+ {
+ /* Register for the SE card emulation mode */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_NtfUnregister();
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_SUCCESS)
+ {
+ ALOGD("phLibNfc_SE_NtfRegister returned 0x%02x",status);
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_NtfRegister returned 0x%x\n", status);
+ }
+ else
+ {
+ /* Register for the SE card emulation mode */
+ REENTRANCE_LOCK();
+ status = phLibNfc_SE_NtfRegister(nfc_jni_transaction_callback,(void *)nat);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_SUCCESS)
+ {
+ ALOGD("phLibNfc_SE_NtfRegister returned 0x%02x",status);
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_SE_NtfRegister returned 0x%x\n", status);
+ }
+
+#endif //HOST EMULATION
+}
+
+static void com_android_nfc_NfcManager_disableCE_A(JNIEnv *e, jobject o)
+{
+#ifndef CONFIG_CE_DEFAULT
+ struct nfc_jni_native_data *nat;
+
+ CONCURRENCY_LOCK();
+
+ /* Retrieve native structure address */
+ nat = nfc_jni_get_nat(e, o);
+
+ set_CE_A_mode(TURN_CE_OFF, nat);
+ CONCURRENCY_UNLOCK();
+#endif
+ return;
+}
+
+static void com_android_nfc_NfcManager_enableCE_A(JNIEnv *e, jobject o)
+{
+#ifndef CONFIG_CE_DEFAULT
+ struct nfc_jni_native_data *nat;
+
+ CONCURRENCY_LOCK();
+
+ /* Retrieve native structure address */
+ nat = nfc_jni_get_nat(e, o);
+
+ set_CE_A_mode(TURN_CE_ON, nat);
+ CONCURRENCY_UNLOCK();
+#endif
+ return;
+}
+
+static void com_android_nfc_NfcManager_disableCE_B(JNIEnv *e, jobject o)
+{
+ struct nfc_jni_native_data *nat;
+
+ CONCURRENCY_LOCK();
+
+ /* Retrieve native structure address */
+ nat = nfc_jni_get_nat(e, o);
+
+ set_CE_B_mode(TURN_CE_OFF, nat);
+ CONCURRENCY_UNLOCK();
+ return;
+}
+
+static void com_android_nfc_NfcManager_enableCE_B(JNIEnv *e, jobject o)
+{
+ struct nfc_jni_native_data *nat;
+
+ CONCURRENCY_LOCK();
+
+ /* Retrieve native structure address */
+ nat = nfc_jni_get_nat(e, o);
+
+ set_CE_B_mode(TURN_CE_ON, nat);
+ CONCURRENCY_UNLOCK();
+ return;
+}
static void com_android_nfc_NfcManager_disableDiscovery(JNIEnv *e, jobject o)
{
@@ -1420,13 +2166,13 @@ static void com_android_nfc_NfcManager_disableDiscovery(JNIEnv *e, jobject o)
/* Retrieve native structure address */
nat = nfc_jni_get_nat(e, o);
-
+
nfc_jni_stop_discovery_locked(nat);
CONCURRENCY_UNLOCK();
}
-
+
static void com_android_nfc_NfcManager_enableDiscovery(JNIEnv *e, jobject o) {
NFCSTATUS ret;
struct nfc_jni_native_data *nat;
@@ -1624,31 +2370,31 @@ static jboolean com_android_nfc_NfcManager_init_native_struc(JNIEnv *e, jobject
jobject obj;
jfieldID f;
- TRACE("****** Init Native Structure ******");
+ TRACE("****** Init Native Structure ******");
/* Initialize native structure */
nat = (nfc_jni_native_data*)malloc(sizeof(struct nfc_jni_native_data));
if(nat == NULL)
{
ALOGD("malloc of nfc_jni_native_data failed");
- return FALSE;
+ return FALSE;
}
memset(nat, 0, sizeof(*nat));
e->GetJavaVM(&(nat->vm));
nat->env_version = e->GetVersion();
nat->manager = e->NewGlobalRef(o);
-
+
cls = e->GetObjectClass(o);
f = e->GetFieldID(cls, "mNative", "I");
e->SetIntField(o, f, (jint)nat);
-
+
/* Initialize native cached references */
cached_NfcManager_notifyNdefMessageListeners = e->GetMethodID(cls,
"notifyNdefMessageListeners","(Lcom/android/nfc/dhimpl/NativeNfcTag;)V");
cached_NfcManager_notifyTransactionListeners = e->GetMethodID(cls,
"notifyTransactionListeners", "([B)V");
-
+
cached_NfcManager_notifyLlcpLinkActivation = e->GetMethodID(cls,
"notifyLlcpLinkActivation","(Lcom/android/nfc/dhimpl/NativeP2pDevice;)V");
@@ -1682,7 +2428,7 @@ static jboolean com_android_nfc_NfcManager_init_native_struc(JNIEnv *e, jobject
if(nfc_jni_cache_object(e,"com/android/nfc/dhimpl/NativeP2pDevice",&(nat->cached_P2pDevice)) == -1)
{
ALOGD("Native Structure initialization failed");
- return FALSE;
+ return FALSE;
}
TRACE("****** Init Native Structure OK ******");
return TRUE;
@@ -1698,7 +2444,7 @@ static jboolean com_android_nfc_NfcManager_initialize(JNIEnv *e, jobject o)
char value[PROPERTY_VALUE_MAX];
#endif
jboolean result;
-
+
CONCURRENCY_LOCK();
#ifdef TNFC_EMULATOR_ONLY
@@ -1744,6 +2490,12 @@ static jboolean com_android_nfc_NfcManager_initialize(JNIEnv *e, jobject o)
/* Perform the initialization */
init_result = nfc_jni_initialize(nat);
+ if(init_result==TRUE)
+ {
+ set_CE_A_mode(INIT_CE, nat);
+ set_CE_B_mode(INIT_CE, nat);
+ }
+
clean_and_return:
CONCURRENCY_UNLOCK();
@@ -1835,7 +2587,7 @@ static jintArray com_android_nfc_NfcManager_doGetSecureElementList(JNIEnv *e, jo
uint8_t i, se_count = PHLIBNFC_MAXNO_OF_SE;
TRACE("****** Get Secure Element List ******");
-
+
TRACE("phLibNfc_SE_GetSecureElementList()");
REENTRANCE_LOCK();
ret = phLibNfc_SE_GetSecureElementList(se_list, &se_count);
@@ -1876,6 +2628,9 @@ static void com_android_nfc_NfcManager_doSelectSecureElement(JNIEnv *e, jobject
/* Retrieve native structure address */
nat = nfc_jni_get_nat(e, o);
+ set_CE_A_mode(TURN_CE_OFF, nat);
+ set_CE_B_mode(TURN_CE_OFF, nat);
+
/* Create the local semaphore */
if (!nfc_cb_data_init(&cb_data, NULL)) {
goto clean_and_return;
@@ -1916,6 +2671,9 @@ static void com_android_nfc_NfcManager_doDeselectSecureElement(JNIEnv *e, jobjec
/* Retrieve native structure address */
nat = nfc_jni_get_nat(e, o);
+ set_CE_A_mode(UNBLOCK_CE_CALLBACK, nat);
+ set_CE_B_mode(UNBLOCK_CE_CALLBACK, nat);
+
/* Create the local semaphore */
if (!nfc_cb_data_init(&cb_data, NULL)) {
goto clean_and_return;
@@ -1929,7 +2687,7 @@ static void com_android_nfc_NfcManager_doDeselectSecureElement(JNIEnv *e, jobjec
ret = phLibNfc_SE_SetMode(nat->seId, phLibNfc_SE_ActModeDefault,
nfc_jni_se_set_mode_callback, (void *)&cb_data);
REENTRANCE_UNLOCK();
-
+
TRACE("phLibNfc_SE_SetMode returned 0x%02x", ret);
if (ret != NFCSTATUS_PENDING) {
ALOGE("phLibNfc_SE_SetMode() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
@@ -2031,7 +2789,7 @@ static jboolean com_android_nfc_NfcManager_doActivateLlcp(JNIEnv *e, jobject o)
else
{
ALOGE("phLibNfc_Llcp_Activate() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
- return JNI_FALSE;
+ return JNI_FALSE;
}
}
@@ -2049,10 +2807,10 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpConnectionlessSocket(JNIEn
phLibNfc_Llcp_sLinkParameters_t sParams;
jclass clsNativeConnectionlessSocket;
jfieldID f;
-
+
/* Retrieve native structure address */
- nat = nfc_jni_get_nat(e, o);
-
+ nat = nfc_jni_get_nat(e, o);
+
/* Allocate Working buffer length */
phLibNfc_Llcp_GetLocalInfo(hLlcpHandle, &sParams);
sWorkingBuffer.length = sParams.miu + 1; // extra byte for SAP
@@ -2068,7 +2826,7 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpConnectionlessSocket(JNIEn
nfc_jni_llcp_transport_socket_err_callback,
(void*)nat);
REENTRANCE_UNLOCK();
-
+
if(ret != NFCSTATUS_SUCCESS)
{
lastErrorStatus = ret;
@@ -2085,7 +2843,7 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpConnectionlessSocket(JNIEn
serviceName.buffer = (uint8_t*)e->GetStringUTFChars(sn, NULL);
serviceName.length = (uint32_t)e->GetStringUTFLength(sn);
}
-
+
/* Bind socket */
TRACE("phLibNfc_Llcp_Bind(hSocket=0x%08x, nSap=0x%02x)", hLlcpSocket, nSap);
REENTRANCE_LOCK();
@@ -2097,41 +2855,41 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpConnectionlessSocket(JNIEn
ALOGE("phLibNfc_Llcp_Bind() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
/* Close socket created */
REENTRANCE_LOCK();
- ret = phLibNfc_Llcp_Close(hLlcpSocket);
+ ret = phLibNfc_Llcp_Close(hLlcpSocket);
REENTRANCE_UNLOCK();
goto error;
}
TRACE("phLibNfc_Llcp_Bind() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
-
-
+
+
/* Create new NativeLlcpConnectionlessSocket object */
if(nfc_jni_cache_object(e,"com/android/nfc/dhimpl/NativeLlcpConnectionlessSocket",&(connectionlessSocket)) == -1)
{
goto error;
- }
-
+ }
+
/* Get NativeConnectionless class object */
clsNativeConnectionlessSocket = e->GetObjectClass(connectionlessSocket);
if(e->ExceptionCheck())
{
goto error;
}
-
+
/* Set socket handle */
f = e->GetFieldID(clsNativeConnectionlessSocket, "mHandle", "I");
e->SetIntField(connectionlessSocket, f,(jint)hLlcpSocket);
- TRACE("Connectionless socket Handle = %02x\n",hLlcpSocket);
-
+ TRACE("Connectionless socket Handle = %02x\n",hLlcpSocket);
+
/* Set the miu link of the connectionless socket */
f = e->GetFieldID(clsNativeConnectionlessSocket, "mLinkMiu", "I");
e->SetIntField(connectionlessSocket, f,(jint)PHFRINFC_LLCP_MIU_DEFAULT);
- TRACE("Connectionless socket Link MIU = %d\n",PHFRINFC_LLCP_MIU_DEFAULT);
-
+ TRACE("Connectionless socket Link MIU = %d\n",PHFRINFC_LLCP_MIU_DEFAULT);
+
/* Set socket SAP */
f = e->GetFieldID(clsNativeConnectionlessSocket, "mSap", "I");
e->SetIntField(connectionlessSocket, f,(jint)nSap);
- TRACE("Connectionless socket SAP = %d\n",nSap);
-
+ TRACE("Connectionless socket SAP = %d\n",nSap);
+
return connectionlessSocket;
error:
if (serviceName.buffer != NULL) {
@@ -2155,20 +2913,20 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpServiceSocket(JNIEnv *e, j
struct nfc_jni_native_data *nat;
jobject serviceSocket = NULL;
jclass clsNativeLlcpServiceSocket;
- jfieldID f;
-
+ jfieldID f;
+
/* Retrieve native structure address */
- nat = nfc_jni_get_nat(e, o);
-
+ nat = nfc_jni_get_nat(e, o);
+
/* Set Connection Oriented socket options */
sOptions.miu = miu;
- sOptions.rw = rw;
-
+ sOptions.rw = rw;
+
/* Allocate Working buffer length */
sWorkingBuffer.length = (miu*rw)+ miu + linearBufferLength;
sWorkingBuffer.buffer = (uint8_t*)malloc(sWorkingBuffer.length);
-
+
/* Create socket */
TRACE("phLibNfc_Llcp_Socket(hRemoteDevice=0x%08x, eType=phFriNfc_LlcpTransport_eConnectionOriented, ...)", hLlcpHandle);
REENTRANCE_LOCK();
@@ -2179,7 +2937,7 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpServiceSocket(JNIEnv *e, j
nfc_jni_llcp_transport_socket_err_callback,
(void*)nat);
REENTRANCE_UNLOCK();
-
+
if(ret != NFCSTATUS_SUCCESS)
{
ALOGE("phLibNfc_Llcp_Socket() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
@@ -2207,7 +2965,7 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpServiceSocket(JNIEnv *e, j
lastErrorStatus = ret;
ALOGE("phLibNfc_Llcp_Bind() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
/* Close socket created */
- ret = phLibNfc_Llcp_Close(hLlcpSocket);
+ ret = phLibNfc_Llcp_Close(hLlcpSocket);
goto error;
}
TRACE("phLibNfc_Llcp_Bind() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
@@ -2218,53 +2976,53 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpServiceSocket(JNIEnv *e, j
nfc_jni_llcp_transport_listen_socket_callback,
(void*)hLlcpSocket);
REENTRANCE_UNLOCK();
-
+
if(ret != NFCSTATUS_SUCCESS)
{
ALOGE("phLibNfc_Llcp_Listen() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
lastErrorStatus = ret;
/* Close created socket */
REENTRANCE_LOCK();
- ret = phLibNfc_Llcp_Close(hLlcpSocket);
+ ret = phLibNfc_Llcp_Close(hLlcpSocket);
REENTRANCE_UNLOCK();
goto error;
- }
+ }
TRACE("phLibNfc_Llcp_Listen() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
-
+
/* Create new NativeLlcpServiceSocket object */
if(nfc_jni_cache_object(e,"com/android/nfc/dhimpl/NativeLlcpServiceSocket",&(serviceSocket)) == -1)
{
ALOGE("Llcp Socket object creation error");
goto error;
- }
-
+ }
+
/* Get NativeLlcpServiceSocket class object */
clsNativeLlcpServiceSocket = e->GetObjectClass(serviceSocket);
if(e->ExceptionCheck())
{
ALOGE("Llcp Socket get object class error");
goto error;
- }
-
+ }
+
/* Set socket handle */
f = e->GetFieldID(clsNativeLlcpServiceSocket, "mHandle", "I");
e->SetIntField(serviceSocket, f,(jint)hLlcpSocket);
- TRACE("Service socket Handle = %02x\n",hLlcpSocket);
-
+ TRACE("Service socket Handle = %02x\n",hLlcpSocket);
+
/* Set socket linear buffer length */
f = e->GetFieldID(clsNativeLlcpServiceSocket, "mLocalLinearBufferLength", "I");
e->SetIntField(serviceSocket, f,(jint)linearBufferLength);
- TRACE("Service socket Linear buffer length = %02x\n",linearBufferLength);
-
+ TRACE("Service socket Linear buffer length = %02x\n",linearBufferLength);
+
/* Set socket MIU */
f = e->GetFieldID(clsNativeLlcpServiceSocket, "mLocalMiu", "I");
e->SetIntField(serviceSocket, f,(jint)miu);
- TRACE("Service socket MIU = %d\n",miu);
-
+ TRACE("Service socket MIU = %d\n",miu);
+
/* Set socket RW */
f = e->GetFieldID(clsNativeLlcpServiceSocket, "mLocalRw", "I");
e->SetIntField(serviceSocket, f,(jint)rw);
- TRACE("Service socket RW = %d\n",rw);
+ TRACE("Service socket RW = %d\n",rw);
return serviceSocket;
error:
@@ -2284,14 +3042,14 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpSocket(JNIEnv *e, jobject
struct nfc_jni_native_data *nat;
jclass clsNativeLlcpSocket;
jfieldID f;
-
+
/* Retrieve native structure address */
- nat = nfc_jni_get_nat(e, o);
-
+ nat = nfc_jni_get_nat(e, o);
+
/* Set Connection Oriented socket options */
sOptions.miu = miu;
sOptions.rw = rw;
-
+
/* Allocate Working buffer length */
sWorkingBuffer.length = (miu*rw)+ miu + linearBufferLength;
sWorkingBuffer.buffer = (uint8_t*)malloc(sWorkingBuffer.length);
@@ -2314,22 +3072,22 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpSocket(JNIEnv *e, jobject
return NULL;
}
TRACE("phLibNfc_Llcp_Socket() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
-
+
/* Create new NativeLlcpSocket object */
if(nfc_jni_cache_object(e,"com/android/nfc/dhimpl/NativeLlcpSocket",&(clientSocket)) == -1)
{
- ALOGE("Llcp socket object creation error");
- return NULL;
- }
-
+ ALOGE("Llcp socket object creation error");
+ return NULL;
+ }
+
/* Get NativeConnectionless class object */
clsNativeLlcpSocket = e->GetObjectClass(clientSocket);
if(e->ExceptionCheck())
{
- ALOGE("Get class object error");
- return NULL;
+ ALOGE("Get class object error");
+ return NULL;
}
-
+
/* Test if an SAP number is present */
if(nSap != 0)
{
@@ -2344,41 +3102,41 @@ static jobject com_android_nfc_NfcManager_doCreateLlcpSocket(JNIEnv *e, jobject
ALOGE("phLibNfc_Llcp_Bind() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
/* Close socket created */
REENTRANCE_LOCK();
- ret = phLibNfc_Llcp_Close(hLlcpSocket);
+ ret = phLibNfc_Llcp_Close(hLlcpSocket);
REENTRANCE_UNLOCK();
return NULL;
}
TRACE("phLibNfc_Llcp_Bind() returned 0x%04x[%s]", ret, nfc_jni_get_status_name(ret));
-
+
/* Set socket SAP */
f = e->GetFieldID(clsNativeLlcpSocket, "mSap", "I");
e->SetIntField(clientSocket, f,(jint)nSap);
- TRACE("socket SAP = %d\n",nSap);
- }
-
+ TRACE("socket SAP = %d\n",nSap);
+ }
+
/* Set socket handle */
f = e->GetFieldID(clsNativeLlcpSocket, "mHandle", "I");
e->SetIntField(clientSocket, f,(jint)hLlcpSocket);
- TRACE("socket Handle = %02x\n",hLlcpSocket);
-
+ TRACE("socket Handle = %02x\n",hLlcpSocket);
+
/* Set socket MIU */
f = e->GetFieldID(clsNativeLlcpSocket, "mLocalMiu", "I");
e->SetIntField(clientSocket, f,(jint)miu);
- TRACE("socket MIU = %d\n",miu);
-
+ TRACE("socket MIU = %d\n",miu);
+
/* Set socket RW */
f = e->GetFieldID(clsNativeLlcpSocket, "mLocalRw", "I");
e->SetIntField(clientSocket, f,(jint)rw);
- TRACE("socket RW = %d\n",rw);
-
-
+ TRACE("socket RW = %d\n",rw);
+
+
return clientSocket;
}
static jint com_android_nfc_NfcManager_doGetLastError(JNIEnv *e, jobject o)
{
TRACE("Last Error Status = 0x%02x",lastErrorStatus);
-
+
if(lastErrorStatus == NFCSTATUS_BUFFER_TOO_SMALL)
{
return ERROR_BUFFER_TOO_SMALL;
@@ -2544,25 +3302,25 @@ static JNINativeMethod gMethods[] =
{"doInitialize", "()Z",
(void *)com_android_nfc_NfcManager_initialize},
-
+
{"doDeinitialize", "()Z",
(void *)com_android_nfc_NfcManager_deinitialize},
-
+
{"enableDiscovery", "()V",
(void *)com_android_nfc_NfcManager_enableDiscovery},
{"doGetSecureElementList", "()[I",
(void *)com_android_nfc_NfcManager_doGetSecureElementList},
-
+
{"doSelectSecureElement", "()V",
(void *)com_android_nfc_NfcManager_doSelectSecureElement},
-
+
{"doDeselectSecureElement", "()V",
(void *)com_android_nfc_NfcManager_doDeselectSecureElement},
-
+
{"doCheckLlcp", "()Z",
(void *)com_android_nfc_NfcManager_doCheckLlcp},
-
+
{"doActivateLlcp", "()Z",
(void *)com_android_nfc_NfcManager_doActivateLlcp},
@@ -2574,10 +3332,22 @@ static JNINativeMethod gMethods[] =
{"doCreateLlcpSocket", "(IIII)Lcom/android/nfc/dhimpl/NativeLlcpSocket;",
(void *)com_android_nfc_NfcManager_doCreateLlcpSocket},
-
+
{"doGetLastError", "()I",
(void *)com_android_nfc_NfcManager_doGetLastError},
+ {"disableCE_A", "()V",
+ (void *)com_android_nfc_NfcManager_disableCE_A},
+
+ {"enableCE_A", "()V",
+ (void *)com_android_nfc_NfcManager_enableCE_A},
+
+ {"enableCE_B", "()V",
+ (void *)com_android_nfc_NfcManager_enableCE_B},
+
+ {"disableCE_B", "()V",
+ (void *)com_android_nfc_NfcManager_disableCE_B},
+
{"disableDiscovery", "()V",
(void *)com_android_nfc_NfcManager_disableDiscovery},
@@ -2601,9 +3371,9 @@ static JNINativeMethod gMethods[] =
{"doDump", "()Ljava/lang/String;",
(void *)com_android_nfc_NfcManager_doDump},
-};
-
-
+};
+
+
int register_com_android_nfc_NativeNfcManager(JNIEnv *e)
{
nfc_jni_native_monitor_t *nfc_jni_native_monitor;
diff --git a/nxp/jni/com_android_nfc_NativeNfcTag.cpp b/nxp/jni/com_android_nfc_NativeNfcTag.cpp
index a621d2a..94e56c2 100644..100755
--- a/nxp/jni/com_android_nfc_NativeNfcTag.cpp
+++ b/nxp/jni/com_android_nfc_NativeNfcTag.cpp
@@ -452,15 +452,35 @@ static jint com_android_nfc_NativeNfcTag_doConnect(JNIEnv *e,
jint status;
struct nfc_jni_callback_data cb_data;
phLibNfc_sRemoteDevInformation_t* pRemDevInfo = NULL;
-
- CONCURRENCY_LOCK();
-
- /* Create the local semaphore */
- if (!nfc_cb_data_init(&cb_data, &pRemDevInfo))
+ phLibNfc_sRemoteDevInformation_t* pRemDevInfoPCD = (phLibNfc_sRemoteDevInformation_t *) handle;
+ if(pRemDevInfoPCD!=NULL &&
+ (pRemDevInfoPCD->RemDevType == phNfc_eISO14443_A_PCD ||
+ pRemDevInfoPCD->RemDevType == phNfc_eISO14443_B_PCD)
+ )
{
- status = NFCSTATUS_NOT_ENOUGH_MEMORY;
- goto clean_and_return;
- }
+ if(pRemDevInfoPCD->SessionOpened==TRUE)
+ {
+ storedHandle = handle;
+ pRemDevInfo = pRemDevInfoPCD;
+ // Success, set poll & act bytes
+ set_target_pollBytes(e, o, pRemDevInfo);
+ set_target_activationBytes(e, o, pRemDevInfo);
+ status = NFCSTATUS_SUCCESS;
+ }
+ else
+ {
+ status = NFCSTATUS_FAILED;
+ }
+ }
+ else
+ {
+ CONCURRENCY_LOCK();
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, &pRemDevInfo))
+ {
+ status = NFCSTATUS_NOT_ENOUGH_MEMORY;
+ goto clean_and_return;
+ }
TRACE("phLibNfc_RemoteDev_Connect(RW)");
REENTRANCE_LOCK();
@@ -485,9 +505,10 @@ static jint com_android_nfc_NativeNfcTag_doConnect(JNIEnv *e,
status = cb_data.status;
TRACE("phLibNfc_RemoteDev_Connect() - Status code = %d", status);
- /* Connect Status */
- if(status != NFCSTATUS_SUCCESS)
- {
+ nfc_cb_data_deinit(&cb_data);
+ /* Connect Status */
+ if(status != NFCSTATUS_SUCCESS)
+ {
goto clean_and_return;
}
@@ -496,9 +517,11 @@ static jint com_android_nfc_NativeNfcTag_doConnect(JNIEnv *e,
set_target_activationBytes(e, o, pRemDevInfo);
clean_and_return:
- nfc_cb_data_deinit(&cb_data);
- CONCURRENCY_UNLOCK();
- return status;
+
+ CONCURRENCY_UNLOCK();
+ }
+
+ return status;
}
static jint com_android_nfc_NativeNfcTag_doHandleReconnect(JNIEnv *e,
@@ -509,46 +532,65 @@ static jint com_android_nfc_NativeNfcTag_doHandleReconnect(JNIEnv *e,
jint status;
struct nfc_jni_callback_data cb_data;
phLibNfc_sRemoteDevInformation_t* pRemDevInfo = NULL;
- CONCURRENCY_LOCK();
+ phLibNfc_sRemoteDevInformation_t* pRemDevInfoPCD = (phLibNfc_sRemoteDevInformation_t *) handle;
- /* Create the local semaphore */
- if (!nfc_cb_data_init(&cb_data, &pRemDevInfo))
+ if(pRemDevInfoPCD!=NULL &&
+ (pRemDevInfoPCD->RemDevType == phNfc_eISO14443_A_PCD ||
+ pRemDevInfoPCD->RemDevType == phNfc_eISO14443_B_PCD)
+ )
{
- status = NFCSTATUS_NOT_ENOUGH_MEMORY;
- goto clean_and_return;
+ if(pRemDevInfoPCD->SessionOpened==TRUE)
+ {
+ storedHandle = handle;
+ pRemDevInfo = pRemDevInfoPCD;
+ status = NFCSTATUS_SUCCESS;
+ }
+ else
+ status = NFCSTATUS_FAILED;
}
-
- TRACE("phLibNfc_RemoteDev_ReConnect(RW)");
- REENTRANCE_LOCK();
- storedHandle = handle;
- status = phLibNfc_RemoteDev_ReConnect(handle, nfc_jni_connect_callback,(void *)&cb_data);
- REENTRANCE_UNLOCK();
- if(status != NFCSTATUS_PENDING)
+ else
{
- ALOGE("phLibNfc_RemoteDev_ReConnect(RW) returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
- goto clean_and_return;
- }
- TRACE("phLibNfc_RemoteDev_ReConnect(RW) returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+ CONCURRENCY_LOCK();
- /* Wait for callback response */
- if(sem_wait(&cb_data.sem))
- {
- ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
- status = NFCSTATUS_ABORTED;
- goto clean_and_return;
- }
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, &pRemDevInfo))
+ {
+ status = NFCSTATUS_NOT_ENOUGH_MEMORY;
+ goto clean_and_return;
+ }
+
+ TRACE("phLibNfc_RemoteDev_ReConnect(RW)");
+ REENTRANCE_LOCK();
+ storedHandle = handle;
+ status = phLibNfc_RemoteDev_ReConnect(handle, nfc_jni_connect_callback,(void *)&cb_data);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_PENDING)
+ {
+ ALOGE("phLibNfc_RemoteDev_ReConnect(RW) returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_RemoteDev_ReConnect(RW) returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+
+ /* Wait for callback response */
+ if(sem_wait(&cb_data.sem))
+ {
+ ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
+ status = NFCSTATUS_ABORTED;
+ goto clean_and_return;
+ }
- status = cb_data.status;
+ status = cb_data.status;
- /* Connect Status */
- if(status != NFCSTATUS_SUCCESS)
- {
- goto clean_and_return;
- }
+ /* Connect Status */
+ if(status != NFCSTATUS_SUCCESS)
+ {
+ goto clean_and_return;
+ }
clean_and_return:
- nfc_cb_data_deinit(&cb_data);
- CONCURRENCY_UNLOCK();
+ nfc_cb_data_deinit(&cb_data);
+ CONCURRENCY_UNLOCK();
+ }
return status;
}
@@ -587,6 +629,7 @@ static jboolean com_android_nfc_NativeNfcTag_doDisconnect(JNIEnv *e, jobject o)
CONCURRENCY_LOCK();
handle = nfc_jni_get_connected_handle(e, o);
+ phLibNfc_sRemoteDevInformation_t* pRemDevInfo = (phLibNfc_sRemoteDevInformation_t *) storedHandle;
/* Create the local semaphore */
if (!nfc_cb_data_init(&cb_data, NULL))
@@ -601,49 +644,64 @@ static jboolean com_android_nfc_NativeNfcTag_doDisconnect(JNIEnv *e, jobject o)
/* Disconnect */
TRACE("Disconnecting from tag (%x)", handle);
-
- if (handle == -1) {
+
+ if(pRemDevInfo!=NULL &&
+ (pRemDevInfo->RemDevType == phNfc_eISO14443_A_PCD ||
+ pRemDevInfo->RemDevType == phNfc_eISO14443_B_PCD))
+ {
+ if(pRemDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.buffer!=NULL &&
+ pRemDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.length>0)
+ {
+ free(pRemDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.buffer);
+ pRemDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.buffer = NULL;
+ pRemDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.length = 0;
+ }
+ phOsalNfc_FreeMemory(pRemDevInfo);
+ }
+ else if(handle==-1)
+ {
// Was never connected to any tag, exit
result = JNI_TRUE;
ALOGE("doDisconnect() - Target already disconnected");
nfc_jni_restart_discovery_locked(nfc_jni_get_nat_ext(e));
goto clean_and_return;
}
+ else
+ {
+ TRACE("phLibNfc_RemoteDev_Disconnect(%x)", handle);
+ REENTRANCE_LOCK();
+ status = phLibNfc_RemoteDev_Disconnect(handle, NFC_DISCOVERY_CONTINUE,
+ nfc_jni_disconnect_callback, (void *)&cb_data);
+ REENTRANCE_UNLOCK();
- TRACE("phLibNfc_RemoteDev_Disconnect(%x)", handle);
- REENTRANCE_LOCK();
- status = phLibNfc_RemoteDev_Disconnect(handle, NFC_DISCOVERY_CONTINUE,
- nfc_jni_disconnect_callback, (void *)&cb_data);
- REENTRANCE_UNLOCK();
-
- if(status == NFCSTATUS_TARGET_NOT_CONNECTED)
- {
- result = JNI_TRUE;
- TRACE("phLibNfc_RemoteDev_Disconnect() - Target already disconnected");
- goto clean_and_return;
- }
- if(status != NFCSTATUS_PENDING)
- {
- ALOGE("phLibNfc_RemoteDev_Disconnect(%x) returned 0x%04x[%s]", handle, status, nfc_jni_get_status_name(status));
- nfc_jni_restart_discovery_locked(nfc_jni_get_nat_ext(e));
- goto clean_and_return;
- }
- TRACE("phLibNfc_RemoteDev_Disconnect(%x) returned 0x%04x[%s]", handle, status, nfc_jni_get_status_name(status));
+ if(status == NFCSTATUS_TARGET_NOT_CONNECTED)
+ {
+ result = JNI_TRUE;
+ TRACE("phLibNfc_RemoteDev_Disconnect() - Target already disconnected");
+ goto clean_and_return;
+ }
+ if(status != NFCSTATUS_PENDING)
+ {
+ ALOGE("phLibNfc_RemoteDev_Disconnect(%x) returned 0x%04x[%s]", handle, status, nfc_jni_get_status_name(status));
+ nfc_jni_restart_discovery_locked(nfc_jni_get_nat_ext(e));
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_RemoteDev_Disconnect(%x) returned 0x%04x[%s]", handle, status, nfc_jni_get_status_name(status));
- /* Wait for callback response */
- if(sem_wait(&cb_data.sem))
- {
- ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
- goto clean_and_return;
- }
-
- /* Disconnect Status */
- if(cb_data.status != NFCSTATUS_SUCCESS)
- {
- goto clean_and_return;
- }
+ /* Wait for callback response */
+ if(sem_wait(&cb_data.sem))
+ {
+ ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
+ goto clean_and_return;
+ }
- result = JNI_TRUE;
+ /* Disconnect Status */
+ if(cb_data.status != NFCSTATUS_SUCCESS)
+ {
+ goto clean_and_return;
+ }
+ }
+ result = JNI_TRUE;
clean_and_return:
/* Reset device connected flag */
@@ -721,6 +779,7 @@ static jbyteArray com_android_nfc_NativeNfcTag_doTransceive(JNIEnv *e,
jbyteArray result = NULL;
int res;
phLibNfc_Handle handle = nfc_jni_get_connected_handle(e, o);
+ phLibNfc_sRemoteDevInformation_t* psRemoteDevInfo = (phLibNfc_sRemoteDevInformation_t *) handle;
NFCSTATUS status;
struct nfc_jni_callback_data cb_data;
int selectedTech = 0;
@@ -739,50 +798,56 @@ static jbyteArray com_android_nfc_NativeNfcTag_doTransceive(JNIEnv *e,
}
memset(&transceive_info, 0, sizeof(transceive_info));
- CONCURRENCY_LOCK();
-
- /* Create the local semaphore */
- if (!nfc_cb_data_init(&cb_data, NULL))
+ selectedTech = nfc_jni_get_connected_technology(e, o);
+ buf = (uint8_t *)e->GetByteArrayElements(data, NULL);
+ if((selectedTech == TARGET_TYPE_ISO14443_4A_PCD ||
+ selectedTech == TARGET_TYPE_ISO14443_4B_PCD) &&
+ psRemoteDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.buffer!=NULL &&
+ psRemoteDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.length>0
+ )
{
- goto clean_and_return;
+ if(psRemoteDevInfo->SessionOpened==TRUE)
+ {
+ result = e->NewByteArray(psRemoteDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.length);
+ if (result != NULL) {
+ e->SetByteArrayRegion(result, 0,
+ psRemoteDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.length,
+ (jbyte *)psRemoteDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.buffer);
+ free(psRemoteDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.buffer);
+ psRemoteDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.buffer = NULL;
+ psRemoteDevInfo->RemoteDevInfo.Iso14443_4_PCD_Info.length = 0;
+ status = NFCSTATUS_SUCCESS;
+ }
+ else
+ status = NFCSTATUS_FAILED;
+ }
+ else
+ status = NFCSTATUS_FAILED;
}
+ else
+ {
- selectedTech = nfc_jni_get_connected_technology(e, o);
- selectedLibNfcType = nfc_jni_get_connected_technology_libnfc_type(e, o);
-
- buf = outbuf = (uint8_t *)e->GetByteArrayElements(data, NULL);
- buflen = outlen = (uint32_t)e->GetArrayLength(data);
-
- switch (selectedTech) {
- case TARGET_TYPE_FELICA:
- transceive_info.cmd.FelCmd = phNfc_eFelica_Raw;
- transceive_info.addr = 0;
- break;
- case TARGET_TYPE_MIFARE_CLASSIC:
- case TARGET_TYPE_MIFARE_UL:
- if (raw) {
- transceive_info.cmd.MfCmd = phHal_eMifareRaw;
- transceive_info.addr = 0;
- // Need to add in the crc here
- outbuf = (uint8_t*)malloc(buflen + 2);
- outlen += 2;
- memcpy(outbuf, buf, buflen);
- nfc_insert_crc_a(outbuf, buflen);
-
- checkResponseCrc = true;
- } else {
- offset = 2;
- transceive_info.cmd.MfCmd = (phNfc_eMifareCmdList_t)buf[0];
- transceive_info.addr = (uint8_t)buf[1];
- }
- break;
- case TARGET_TYPE_ISO14443_3A:
- // Check which libnfc type
- if (selectedLibNfcType == phNfc_eJewel_PICC) {
- // For the Jewel pipe, CRC is automatically computed
- transceive_info.cmd.JewelCmd = phNfc_eJewel_Raw;
+ CONCURRENCY_LOCK();
+
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, NULL))
+ {
+ goto clean_and_return;
+ }
+
+ outbuf = buf;
+
+ buflen = outlen = (uint32_t)e->GetArrayLength(data);
+
+ selectedLibNfcType = nfc_jni_get_connected_technology_libnfc_type(e, o);
+
+ switch (selectedTech) {
+ case TARGET_TYPE_FELICA:
+ transceive_info.cmd.FelCmd = phNfc_eFelica_Raw;
transceive_info.addr = 0;
- } else {
+ break;
+ case TARGET_TYPE_MIFARE_CLASSIC:
+ case TARGET_TYPE_MIFARE_UL:
if (raw) {
// Use Mifare Raw to implement a standard
// ISO14443-3A transceive, with CRC added
@@ -801,94 +866,129 @@ static jbyteArray com_android_nfc_NativeNfcTag_doTransceive(JNIEnv *e,
transceive_info.cmd.MfCmd = (phNfc_eMifareCmdList_t)buf[0];
transceive_info.addr = (uint8_t)buf[1];
}
+ break;
+ case TARGET_TYPE_ISO14443_3A:
+ // Check which libnfc type
+ if (selectedLibNfcType == phNfc_eJewel_PICC) {
+ // For the Jewel pipe, CRC is automatically computed
+ transceive_info.cmd.JewelCmd = phNfc_eJewel_Raw;
+ transceive_info.addr = 0;
+ } else {
+ if (raw) {
+ // Use Mifare Raw to implement a standard
+ // ISO14443-3A transceive, with CRC added
+ transceive_info.cmd.MfCmd = phHal_eMifareRaw;
+ transceive_info.addr = 0;
+ // Need to add in the crc here
+ outbuf = (uint8_t*)malloc(buflen + 2);
+ outlen += 2;
+ memcpy(outbuf, buf, buflen);
+ nfc_insert_crc_a(outbuf, buflen);
+
+ checkResponseCrc = true;
+ } else {
+ // Use the mifare pipe
+ offset = 2;
+ transceive_info.cmd.MfCmd = (phNfc_eMifareCmdList_t)buf[0];
+ transceive_info.addr = (uint8_t)buf[1];
+ }
- }
- break;
- case TARGET_TYPE_ISO14443_4:
- transceive_info.cmd.Iso144434Cmd = phNfc_eIso14443_4_Raw;
- transceive_info.addr = 0;
- break;
- case TARGET_TYPE_ISO15693:
- transceive_info.cmd.Iso15693Cmd = phNfc_eIso15693_Cmd;
- transceive_info.addr = 0;
- break;
- case TARGET_TYPE_UNKNOWN:
- case TARGET_TYPE_ISO14443_3B:
- // Not supported
- goto clean_and_return;
- default:
- break;
- }
+ }
+ break;
+ case TARGET_TYPE_ISO14443_4A_PCD:
+ case TARGET_TYPE_ISO14443_4B_PCD:
+ case TARGET_TYPE_ISO14443_4:
+ transceive_info.cmd.Iso144434Cmd = phNfc_eIso14443_4_Raw;
+ transceive_info.addr = 0;
+ break;
+ case TARGET_TYPE_ISO15693:
+ transceive_info.cmd.Iso15693Cmd = phNfc_eIso15693_Cmd;
+ transceive_info.addr = 0;
+ break;
+ case TARGET_TYPE_UNKNOWN:
+ case TARGET_TYPE_ISO14443_3B:
+ // Not supported
+ goto clean_and_return;
+ default:
+ break;
+ }
- transceive_info.sSendData.buffer = outbuf + offset;
- transceive_info.sSendData.length = outlen - offset;
- transceive_info.sRecvData.buffer = (uint8_t*)malloc(1024);
- transceive_info.sRecvData.length = 1024;
- if(transceive_info.sRecvData.buffer == NULL)
- {
- goto clean_and_return;
- }
+ transceive_info.sSendData.buffer = outbuf + offset;
+ transceive_info.sSendData.length = outlen - offset;
+ transceive_info.sRecvData.buffer = (uint8_t*)malloc(1024);
+ transceive_info.sRecvData.length = 1024;
+ if(transceive_info.sRecvData.buffer == NULL)
+ {
+ goto clean_and_return;
+ }
- TRACE("phLibNfc_RemoteDev_Transceive()");
- REENTRANCE_LOCK();
- status = phLibNfc_RemoteDev_Transceive(handle, &transceive_info,
- nfc_jni_transceive_callback, (void *)&cb_data);
- REENTRANCE_UNLOCK();
- if(status != NFCSTATUS_PENDING)
- {
- ALOGE("phLibNfc_RemoteDev_Transceive() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
- if ((targetLost != NULL) && (status == NFCSTATUS_TARGET_LOST)) {
- *targetLost = 1;
- }
- goto clean_and_return;
- }
- TRACE("phLibNfc_RemoteDev_Transceive() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+ TRACE("phLibNfc_RemoteDev_Transceive()");
+ REENTRANCE_LOCK();
+ status = phLibNfc_RemoteDev_Transceive(handle, &transceive_info,
+ nfc_jni_transceive_callback, (void *)&cb_data);
+ REENTRANCE_UNLOCK();
+ if(status != NFCSTATUS_PENDING)
+ {
+ ALOGE("phLibNfc_RemoteDev_Transceive() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
+ if ((targetLost != NULL) &&
+ (status == NFCSTATUS_TARGET_LOST || selectedTech == TARGET_TYPE_ISO14443_4A_PCD || selectedTech == TARGET_TYPE_ISO14443_4B_PCD)
+ ) {
+ *targetLost = 1;
+ }
+ goto clean_and_return;
+ }
+ TRACE("phLibNfc_RemoteDev_Transceive() returned 0x%04x[%s]", status, nfc_jni_get_status_name(status));
- /* Wait for callback response */
- if(sem_wait(&cb_data.sem))
- {
- ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
- goto clean_and_return;
- }
+ /* Wait for callback response */
+ if(sem_wait(&cb_data.sem))
+ {
+ ALOGE("Failed to wait for semaphore (errno=0x%08x)", errno);
+ goto clean_and_return;
+ }
- if(cb_data.status != NFCSTATUS_SUCCESS)
- {
- if ((targetLost != NULL) && (cb_data.status == NFCSTATUS_TARGET_LOST)) {
- *targetLost = 1;
+ if(cb_data.status != NFCSTATUS_SUCCESS)
+ {
+ if ((targetLost != NULL) && (cb_data.status == NFCSTATUS_TARGET_LOST)) {
+ *targetLost = 1;
+ }
+ goto clean_and_return;
}
- goto clean_and_return;
- }
- /* Copy results back to Java *
- * In case of NfcA and raw, also check the CRC in the response
- * and cut it off in the returned data.
- */
- if ((nfc_jni_transceive_buffer->length > 2) && checkResponseCrc) {
- if (crc_valid(nfc_jni_transceive_buffer->buffer, nfc_jni_transceive_buffer->length)) {
- result = e->NewByteArray(nfc_jni_transceive_buffer->length - 2);
+ /* Copy results back to Java *
+ * In case of NfcA and raw, also check the CRC in the response
+ * and cut it off in the returned data.
+ */
+ if ((nfc_jni_transceive_buffer->length > 2) && checkResponseCrc) {
+ if (crc_valid(nfc_jni_transceive_buffer->buffer, nfc_jni_transceive_buffer->length)) {
+ result = e->NewByteArray(nfc_jni_transceive_buffer->length - 2);
+ if (result != NULL) {
+ e->SetByteArrayRegion(result, 0,
+ nfc_jni_transceive_buffer->length - 2,
+ (jbyte *)nfc_jni_transceive_buffer->buffer);
+ }
+ }
+ } else {
+ result = e->NewByteArray(nfc_jni_transceive_buffer->length);
if (result != NULL) {
e->SetByteArrayRegion(result, 0,
- nfc_jni_transceive_buffer->length - 2,
+ nfc_jni_transceive_buffer->length,
(jbyte *)nfc_jni_transceive_buffer->buffer);
}
}
- } else {
- result = e->NewByteArray(nfc_jni_transceive_buffer->length);
- if (result != NULL) {
- e->SetByteArrayRegion(result, 0,
- nfc_jni_transceive_buffer->length,
- (jbyte *)nfc_jni_transceive_buffer->buffer);
- }
- }
clean_and_return:
- if(transceive_info.sRecvData.buffer != NULL)
- {
- free(transceive_info.sRecvData.buffer);
- }
+ nfc_cb_data_deinit(&cb_data);
+
+ CONCURRENCY_UNLOCK();
+
+ if(transceive_info.sRecvData.buffer != NULL)
+ {
+ free(transceive_info.sRecvData.buffer);
+ }
- if ((outbuf != buf) && (outbuf != NULL)) {
- // Buf was extended and re-alloced with crc bytes, free separately
- free(outbuf);
+ if ((outbuf != buf) && (outbuf != NULL)) {
+ // Buf was extended and re-alloced with crc bytes, free separately
+ free(outbuf);
+ }
}
e->ReleaseByteArrayElements(data,
@@ -898,10 +998,6 @@ clean_and_return:
e->ReleaseIntArrayElements(statusTargetLost, targetLost, 0);
}
- nfc_cb_data_deinit(&cb_data);
-
- CONCURRENCY_UNLOCK();
-
return result;
}
@@ -951,18 +1047,27 @@ static jint com_android_nfc_NativeNfcTag_doCheckNdef(JNIEnv *e, jobject o, jintA
struct nfc_jni_callback_data cb_data;
jint *ndef = e->GetIntArrayElements(ndefinfo, 0);
int apiCardState = NDEF_MODE_UNKNOWN;
+ handle = nfc_jni_get_connected_handle(e, o);
+ phLibNfc_sRemoteDevInformation_t* pRemDevInfoPCD = (phLibNfc_sRemoteDevInformation_t *) handle;
- CONCURRENCY_LOCK();
-
- /* Create the local semaphore */
- if (!nfc_cb_data_init(&cb_data, NULL))
+ if(pRemDevInfoPCD!=NULL &&
+ (pRemDevInfoPCD->RemDevType == phNfc_eISO14443_A_PCD ||
+ pRemDevInfoPCD->RemDevType == phNfc_eISO14443_B_PCD)
+ )
{
- status = NFCSTATUS_NOT_ENOUGH_MEMORY;
- goto clean_and_return;
+ status = NFCSTATUS_FAILED;
}
- cb_data.pContext = &sNdefInfo;
+ else
+ {
+ CONCURRENCY_LOCK();
- handle = nfc_jni_get_connected_handle(e, o);
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, NULL))
+ {
+ status = NFCSTATUS_NOT_ENOUGH_MEMORY;
+ goto clean_and_return;
+ }
+ cb_data.pContext = &sNdefInfo;
TRACE("phLibNfc_Ndef_CheckNdef()");
REENTRANCE_LOCK();
@@ -1010,9 +1115,11 @@ static jint com_android_nfc_NativeNfcTag_doCheckNdef(JNIEnv *e, jobject o, jintA
ndef[1] = apiCardState;
clean_and_return:
+ nfc_cb_data_deinit(&cb_data);
+ CONCURRENCY_UNLOCK();
+ }
+
e->ReleaseIntArrayElements(ndefinfo, ndef, 0);
- nfc_cb_data_deinit(&cb_data);
- CONCURRENCY_UNLOCK();
return status;
}
@@ -1022,16 +1129,32 @@ static jboolean com_android_nfc_NativeNfcTag_doPresenceCheck(JNIEnv *e, jobject
NFCSTATUS status;
jboolean result = JNI_FALSE;
struct nfc_jni_callback_data cb_data;
+ handle = nfc_jni_get_connected_handle(e, o);
+ phLibNfc_sRemoteDevInformation_t* pRemDevInfoPCD = (phLibNfc_sRemoteDevInformation_t *) handle;
- CONCURRENCY_LOCK();
-
- /* Create the local semaphore */
- if (!nfc_cb_data_init(&cb_data, NULL))
+ if(pRemDevInfoPCD!=NULL &&
+ (pRemDevInfoPCD->RemDevType == phNfc_eISO14443_A_PCD ||
+ pRemDevInfoPCD->RemDevType == phNfc_eISO14443_B_PCD)
+ )
{
- goto clean_and_return;
+ if(pRemDevInfoPCD->SessionOpened==TRUE)
+ {
+ result = JNI_TRUE;
+ }
+ else
+ {
+ result = JNI_FALSE;
+ }
}
+ else
+ {
+ CONCURRENCY_LOCK();
- handle = nfc_jni_get_connected_handle(e, o);
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, NULL))
+ {
+ goto clean_and_return;
+ }
TRACE("phLibNfc_RemoteDev_CheckPresence()");
REENTRANCE_LOCK();
@@ -1060,7 +1183,8 @@ static jboolean com_android_nfc_NativeNfcTag_doPresenceCheck(JNIEnv *e, jobject
clean_and_return:
nfc_cb_data_deinit(&cb_data);
- CONCURRENCY_UNLOCK();
+ CONCURRENCY_UNLOCK();
+ }
return result;
}
@@ -1118,16 +1242,25 @@ static jboolean com_android_nfc_NativeNfcTag_doNdefFormat(JNIEnv *e, jobject o,
phNfc_sData_t keyBuffer;
jboolean result = JNI_FALSE;
struct nfc_jni_callback_data cb_data;
+ handle = nfc_jni_get_connected_handle(e, o);
+ phLibNfc_sRemoteDevInformation_t* pRemDevInfoPCD = (phLibNfc_sRemoteDevInformation_t *) handle;
- CONCURRENCY_LOCK();
-
- /* Create the local semaphore */
- if (!nfc_cb_data_init(&cb_data, NULL))
+ if(pRemDevInfoPCD!=NULL &&
+ (pRemDevInfoPCD->RemDevType == phNfc_eISO14443_A_PCD ||
+ pRemDevInfoPCD->RemDevType == phNfc_eISO14443_B_PCD)
+ )
{
- goto clean_and_return;
+ result = JNI_FALSE;
}
+ else
+ {
+ CONCURRENCY_LOCK();
- handle = nfc_jni_get_connected_handle(e, o);
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, NULL))
+ {
+ goto clean_and_return;
+ }
keyBuffer.buffer = (uint8_t *)e->GetByteArrayElements(key, NULL);
keyBuffer.length = e->GetArrayLength(key);
@@ -1150,15 +1283,16 @@ static jboolean com_android_nfc_NativeNfcTag_doNdefFormat(JNIEnv *e, jobject o,
goto clean_and_return;
}
- if (cb_data.status == NFCSTATUS_SUCCESS)
- {
- result = JNI_TRUE;
+ if (cb_data.status == NFCSTATUS_SUCCESS)
+ {
+ result = JNI_TRUE;
+ }
+clean_and_return:
+ nfc_cb_data_deinit(&cb_data);
+ CONCURRENCY_UNLOCK();
}
-clean_and_return:
e->ReleaseByteArrayElements(key, (jbyte *)keyBuffer.buffer, JNI_ABORT);
- nfc_cb_data_deinit(&cb_data);
- CONCURRENCY_UNLOCK();
return result;
}
@@ -1169,16 +1303,26 @@ static jboolean com_android_nfc_NativeNfcTag_doMakeReadonly(JNIEnv *e, jobject o
jboolean result = JNI_FALSE;
struct nfc_jni_callback_data cb_data;
phNfc_sData_t keyBuffer;
+ handle = nfc_jni_get_connected_handle(e, o);
+ phLibNfc_sRemoteDevInformation_t* pRemDevInfoPCD = (phLibNfc_sRemoteDevInformation_t *) handle;
- CONCURRENCY_LOCK();
-
- /* Create the local semaphore */
- if (!nfc_cb_data_init(&cb_data, NULL))
+ if(pRemDevInfoPCD!=NULL &&
+ (pRemDevInfoPCD->RemDevType == phNfc_eISO14443_A_PCD ||
+ pRemDevInfoPCD->RemDevType == phNfc_eISO14443_B_PCD)
+ )
{
- goto clean_and_return;
+ result = JNI_FALSE;
}
+ else
+ {
+ CONCURRENCY_LOCK();
+
+ /* Create the local semaphore */
+ if (!nfc_cb_data_init(&cb_data, NULL))
+ {
+ goto clean_and_return;
+ }
- handle = nfc_jni_get_connected_handle(e, o);
keyBuffer.buffer = (uint8_t *)e->GetByteArrayElements(key, NULL);
keyBuffer.length = e->GetArrayLength(key);
TRACE("phLibNfc_ConvertToReadOnlyNdef()");
@@ -1210,6 +1354,8 @@ clean_and_return:
e->ReleaseByteArrayElements(key, (jbyte *)keyBuffer.buffer, JNI_ABORT);
nfc_cb_data_deinit(&cb_data);
CONCURRENCY_UNLOCK();
+ }
+
return result;
}
/*
diff --git a/nxp/src/com/android/nfc/dhimpl/NativeNfcManager.java b/nxp/src/com/android/nfc/dhimpl/NativeNfcManager.java
index dc6ea7c..0446390 100755
--- a/nxp/src/com/android/nfc/dhimpl/NativeNfcManager.java
+++ b/nxp/src/com/android/nfc/dhimpl/NativeNfcManager.java
@@ -38,6 +38,8 @@ public class NativeNfcManager implements DeviceHost {
private static final String NFC_CONTROLLER_FIRMWARE_FILE_NAME = "/vendor/firmware/libpn544_fw.so";
+ private static final String NFC_CONTROLLER_FIRMWARE_FILE_NAME_2 = "/system/lib/libpn544_fw.so";
+
static final String PREF = "NxpDeviceHost";
private static final String PREF_FIRMWARE_MODTIME = "firmware_modtime";
@@ -101,6 +103,9 @@ public class NativeNfcManager implements DeviceHost {
int nbRetry = 0;
try {
firmwareFile = new File(NFC_CONTROLLER_FIRMWARE_FILE_NAME);
+ if (!firmwareFile.exists()) {
+ firmwareFile = new File(NFC_CONTROLLER_FIRMWARE_FILE_NAME_2);
+ }
} catch(NullPointerException npe) {
Log.e(TAG,"path to firmware file was null");
return;
@@ -174,6 +179,19 @@ public class NativeNfcManager implements DeviceHost {
public native void disableDiscovery();
@Override
+ public native void enableCE_A();
+
+ @Override
+ public native void disableCE_A();
+
+ @Override
+ public native void enableCE_B();
+
+ @Override
+ public native void disableCE_B();
+
+
+ @Override
public native int[] doGetSecureElementList();
@Override
@@ -302,6 +320,8 @@ public class NativeNfcManager implements DeviceHost {
return 0; // PN544 does not support transceive of raw NfcB
case (TagTechnology.NFC_V):
return 253; // PN544 RF buffer = 255 bytes, subtract two for CRC
+ case (TagTechnology.ISO_PCD_A):
+ case (TagTechnology.ISO_PCD_B):
case (TagTechnology.ISO_DEP):
/* The maximum length of a normal IsoDep frame consists of:
* CLA, INS, P1, P2, LC, LE + 255 payload bytes = 261 bytes
diff --git a/res/values-nl/strings.xml b/res/values-nl/strings.xml
index 7b62289..3f5b501 100644
--- a/res/values-nl/strings.xml
+++ b/res/values-nl/strings.xml
@@ -1,30 +1,44 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The CyanogenMod 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.
+ -->
<resources xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string name="app_name" msgid="78565911793142902">"NFC-service"</string>
<string name="nfcUserLabel" msgid="7708535817084357357">"NFC"</string>
<string name="inbound_me_profile_title" msgid="6146013785225412693">"Contact ontvangen via NFC"</string>
- <string name="inbound_me_profile_text" msgid="2342757196108092923">"Raak aan om deze persoon toe te voegen als contact."</string>
+ <string name="inbound_me_profile_text" msgid="2342757196108092923">"Tik om deze persoon toe te voegen als contact."</string>
<string name="outbound_me_profile_title" msgid="2523625031572784769">"NFC-interactie voltooid"</string>
- <string name="outbound_me_profile_text" msgid="5594998841143667989">"Raak aan om deze persoon uw contactgegevens te geven."</string>
+ <string name="outbound_me_profile_text" msgid="5594998841143667989">"Tik om deze persoon uw contactgegevens te geven."</string>
<string name="accessibility_nfc_enabled" msgid="7796246979948787735">"NFC ingeschakeld."</string>
- <string name="touch" msgid="4727218133711188355">"Tikken om uit te zenden"</string>
- <string name="beam_progress" msgid="7453634884807323920">"Inkomende beam..."</string>
+ <string name="touch" msgid="4727218133711188355">"Tik om uit te zenden"</string>
+ <string name="beam_progress" msgid="7453634884807323920">"Inkomende beam\u2026"</string>
<string name="beam_complete" msgid="477026736424637435">"Beam voltooid"</string>
- <string name="beam_failed" msgid="5116241718189888630">"Beam niet voltooid"</string>
+ <string name="beam_failed" msgid="5116241718189888630">"Beam mislukt"</string>
<string name="beam_canceled" msgid="5425192751826544741">"Beam geannuleerd"</string>
<string name="cancel" msgid="61873902552555096">"Annuleren"</string>
- <string name="beam_touch_to_view" msgid="7853129156831642630">"Raak aan om te bekijken"</string>
- <string name="beam_handover_not_supported" msgid="4083165921751489015">"Het apparaat van de ontvanger ondersteunt de overdracht van grote bestanden via beam niet."</string>
+ <string name="beam_touch_to_view" msgid="7853129156831642630">"Tik om te bekijken"</string>
+ <string name="beam_handover_not_supported" msgid="4083165921751489015">"Het apparaat van de ontvanger ondersteunt de overdracht van grote bestanden via Beam niet."</string>
<string name="connecting_headset" msgid="3929250919225573008">"Verbinding maken"</string>
<string name="connected_headset" msgid="4047751837023241955">"Verbonden"</string>
- <string name="connect_headset_failed" msgid="7500801585498094863">"Kan niet verbinden"</string>
+ <string name="connect_headset_failed" msgid="7500801585498094863">"Kan geen verbinding maken"</string>
<string name="disconnecting_headset" msgid="868262189044372780">"Loskoppelen"</string>
<string name="disconnected_headset" msgid="4066109452701733916">"Losgekoppeld"</string>
<string name="pairing_headset" msgid="6443461444755646137">"Koppelen"</string>
<string name="pairing_headset_failed" msgid="6509629663883514688">"Kan niet koppelen"</string>
- <string name="failed_to_enable_bt" msgid="7229153323594758077">"Kan Bluetooth niet inschakelen"</string>
- <string name="confirm_pairing" msgid="4112568077038265363">"Weet u zeker dat u het Bluetooth-apparaat <xliff:g id="DEVICE_NAME">%1$s</xliff:g> wilt koppelen?"</string>
+ <string name="failed_to_enable_bt" msgid="7229153323594758077">"Kan bluetooth niet inschakelen"</string>
+ <string name="confirm_pairing" msgid="4112568077038265363">"Weet u zeker dat u het bluetoothapparaat <xliff:g id="DEVICE_NAME">%1$s</xliff:g> wilt koppelen?"</string>
<string name="pair_yes" msgid="3525614878559994448">"Ja"</string>
<string name="pair_no" msgid="5022308368904055020">"Nee"</string>
</resources>
diff --git a/src/com/android/nfc/DeviceHost.java b/src/com/android/nfc/DeviceHost.java
index e514bb6..bfd5d9c 100644..100755
--- a/src/com/android/nfc/DeviceHost.java
+++ b/src/com/android/nfc/DeviceHost.java
@@ -191,6 +191,14 @@ public interface DeviceHost {
public void disableDiscovery();
+ public void enableCE_A();
+
+ public void disableCE_A();
+
+ public void enableCE_B();
+
+ public void disableCE_B();
+
public int[] doGetSecureElementList();
public void doSelectSecureElement();
diff --git a/src/com/android/nfc/NfcService.java b/src/com/android/nfc/NfcService.java
index d63f84f..952b391 100755
--- a/src/com/android/nfc/NfcService.java
+++ b/src/com/android/nfc/NfcService.java
@@ -864,6 +864,39 @@ public class NfcService implements DeviceHostListener {
}
mNfcDispatcher.setForegroundDispatch(intent, filters, techLists);
+
+ //check for PCD A or PCD B technology
+ //turn on if in list
+ //turn off if not
+ boolean PCD_A = false;
+ boolean PCD_B = false;
+ if(techLists!=null)
+ {
+ for(short j=0;j<techLists.length;j++)
+ {
+ if(techLists[j]!=null)
+ {
+ for(short k=0;k<techLists[j].length;k++)
+ {
+ if(techLists[j][k]!=null)
+ {
+ if(techLists[j][k].equals("android.nfc.tech.IsoPcdA"))
+ PCD_A = true;
+ if(techLists[j][k].equals("android.nfc.tech.IsoPcdB"))
+ PCD_B = true;
+ }
+ }
+ }
+ }
+ }
+ if(PCD_A)
+ mDeviceHost.enableCE_A();
+ else
+ mDeviceHost.disableCE_A();
+ if(PCD_B)
+ mDeviceHost.enableCE_B();
+ else
+ mDeviceHost.disableCE_B();
}
@Override