summaryrefslogtreecommitdiff
path: root/nci
diff options
context:
space:
mode:
authoranil.hiranniah <anil.hiranniah@nxp.com>2022-01-06 16:47:02 +0530
committeranil.hiranniah <anil.hiranniah@nxp.com>2022-03-18 17:59:50 +0530
commit8a1d737baa585d958dda589a31d4a119603c8571 (patch)
treec66af58663e89c9b604154ce68bf402a6579b1ec /nci
parentb10b3bc6b9439e561b42eba3c3a726e044010f63 (diff)
downloadNfc-8a1d737baa585d958dda589a31d4a119603c8571.tar.gz
Correct the parsing of historical bytes for multiprotocol tag.
Historical bytes(SAK,ATQA Value) were not updated correctly, which leads to Tag operations failure. Bug: 209522198 Test: Tag R/W Manual: Tag read with Multiprotocal tags and check historical bytes are updated correctly Change-Id: If3e9799297d9c4d5a079bc6fcbaac3b68a61296e
Diffstat (limited to 'nci')
-rwxr-xr-xnci/jni/NfcTag.cpp20
-rwxr-xr-xnci/src/com/android/nfc/dhimpl/NativeNfcTag.java9
2 files changed, 28 insertions, 1 deletions
diff --git a/nci/jni/NfcTag.cpp b/nci/jni/NfcTag.cpp
index 5af2b79e..e161e7f3 100755
--- a/nci/jni/NfcTag.cpp
+++ b/nci/jni/NfcTag.cpp
@@ -36,6 +36,7 @@ using android::base::StringPrintf;
extern bool nfc_debug_enabled;
static void deleteglobaldata(JNIEnv* e);
static jobjectArray sTechPollBytes;
+static jobjectArray gtechActBytes;
static int sLastSelectedTagId = 0;
/*******************************************************************************
@@ -558,6 +559,9 @@ static void deleteglobaldata(JNIEnv* e) {
if (sTechPollBytes != NULL) {
e->DeleteGlobalRef(sTechPollBytes);
}
+ if (gtechActBytes != NULL) {
+ e->DeleteGlobalRef(gtechActBytes);
+ }
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: exit", fn);
}
@@ -814,7 +818,16 @@ void NfcTag::fillNativeNfcTagMembers4(JNIEnv* e, jclass tag_cls, jobject tag,
e->SetObjectArrayElement(techActBytes.get(), i, actBytes.get());
}
}
-
+ jobject gtechActBytesObject;
+ if (mTechListTail == 0) {
+ gtechActBytes =
+ reinterpret_cast<jobjectArray>(e->NewGlobalRef(techActBytes.get()));
+ } else {
+ for (int j = 0; j < mTechListTail; j++) {
+ gtechActBytesObject = e->GetObjectArrayElement(gtechActBytes, j);
+ e->SetObjectArrayElement(techActBytes.get(), j, gtechActBytesObject);
+ }
+ }
for (int i = mTechListTail; i < mNumTechList; i++) {
DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s: index=%d", fn, i);
if (NFC_PROTOCOL_T1T == mTechLibNfcTypes[i] ||
@@ -922,6 +935,11 @@ void NfcTag::fillNativeNfcTagMembers4(JNIEnv* e, jclass tag_cls, jobject tag,
}
e->SetObjectArrayElement(techActBytes.get(), i, actBytes.get());
} // for: every technology in the array of current selected tag
+ if (gtechActBytes != NULL && mTechListTail != 0) {
+ e->DeleteGlobalRef(gtechActBytes);
+ gtechActBytes =
+ reinterpret_cast<jobjectArray>(e->NewGlobalRef(techActBytes.get()));
+ }
jfieldID f = e->GetFieldID(tag_cls, "mTechActBytes", "[[B");
e->SetObjectField(tag, f, techActBytes.get());
}
diff --git a/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java b/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java
index 117bf3ae..2b400344 100755
--- a/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java
+++ b/nci/src/com/android/nfc/dhimpl/NativeNfcTag.java
@@ -743,6 +743,15 @@ public class NativeNfcTag implements TagEndpoint {
break;
}
+ case TagTechnology.MIFARE_CLASSIC: {
+ byte[] actBytes = mTechActBytes[i];
+ if ((actBytes != null) && (actBytes.length > 0)) {
+ extras.putShort(NfcA.EXTRA_SAK, (short) (actBytes[0] & (short) 0xFF));
+ }
+ extras.putByteArray(NfcA.EXTRA_ATQA, mTechPollBytes[i]);
+ break;
+ }
+
case TagTechnology.NFC_BARCODE: {
// hard code this for now, this is the only valid type
extras.putInt(NfcBarcode.EXTRA_BARCODE_TYPE, NfcBarcode.TYPE_KOVIO);