diff options
author | Martijn Coenen <maco@google.com> | 2012-10-09 15:21:49 -0700 |
---|---|---|
committer | Martijn Coenen <maco@google.com> | 2012-10-09 15:29:16 -0700 |
commit | accbb8c908d764c5f0b8030480f3e84f0f319ff5 (patch) | |
tree | af7388610317a9cbf8b4614bc5443cc7e87da21a /nci | |
parent | 7bb9229c66e38ce9e3fbb8c5364ca3416e19c5bc (diff) | |
download | packages_apps_nfc-accbb8c908d764c5f0b8030480f3e84f0f319ff5.zip packages_apps_nfc-accbb8c908d764c5f0b8030480f3e84f0f319ff5.tar.gz packages_apps_nfc-accbb8c908d764c5f0b8030480f3e84f0f319ff5.tar.bz2 |
Don't return target lost in case of NACK for T2T.
Causes applications such as TagInfo to report the tag
as being lost. Also fixed a small memory leak triggered
in this case.
Bug: 7294613
Change-Id: I260e02896e534b23de5c7e0278609e27a9a20e7f
Diffstat (limited to 'nci')
-rwxr-xr-x | nci/jni/NativeNfcTag.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/nci/jni/NativeNfcTag.cpp b/nci/jni/NativeNfcTag.cpp index 8c0426b..0ba7b21 100755 --- a/nci/jni/NativeNfcTag.cpp +++ b/nci/jni/NativeNfcTag.cpp @@ -806,6 +806,7 @@ static jbyteArray nativeNfcTag_doTransceive (JNIEnv *e, jobject o, jbyteArray da bool fNeedToSwitchBack = false; nfc_jni_native_data *nat = getNative (0, 0); bool waitOk = false; + bool isNack = false; uint8_t *buf = NULL; uint32_t bufLen = 0; jint *targetLost = NULL; @@ -884,24 +885,21 @@ static jbyteArray nativeNfcTag_doTransceive (JNIEnv *e, jobject o, jbyteArray da if ((natTag.getProtocol () == NFA_PROTOCOL_T2T) && natTag.isT2tNackResponse (sTransceiveData, sTransceiveDataLen)) { - if (targetLost) - { - ALOGD ("%s: t2t nack", __FUNCTION__); - *targetLost = 1; //causes NFC service to throw TagLostException - } - break; + isNack = true; } if (sTransceiveDataLen) { - // marshall data to java for return - result = e->NewByteArray (sTransceiveDataLen); - if (result != NULL) - { - e->SetByteArrayRegion (result, 0, sTransceiveDataLen, (jbyte *) sTransceiveData); - } - else - ALOGE ("%s: Failed to allocate java byte array", __FUNCTION__); + if (!isNack) { + // marshall data to java for return + result = e->NewByteArray (sTransceiveDataLen); + if (result != NULL) + { + e->SetByteArrayRegion (result, 0, sTransceiveDataLen, (jbyte *) sTransceiveData); + } + else + ALOGE ("%s: Failed to allocate java byte array", __FUNCTION__); + } // else a nack is treated as a transceive failure to the upper layers free (sTransceiveData); sTransceiveData = NULL; |