Loading core/jni/android_nfc.h +9 −0 Original line number Diff line number Diff line Loading @@ -22,8 +22,17 @@ #ifndef __ANDROID_NFC_H__ #define __ANDROID_NFC_H__ #define LOG_TAG "NdefMessage" #include <utils/Log.h> extern "C" { #if 0 #define TRACE(...) LOG(LOG_DEBUG, "NdefMessage", __VA_ARGS__) #else #define TRACE(...) #endif typedef struct phFriNfc_NdefRecord { uint8_t Flags; uint8_t Tnf; Loading core/jni/android_nfc_NdefMessage.cpp +6 −14 Original line number Diff line number Diff line Loading @@ -14,8 +14,6 @@ * limitations under the License. */ #define LOG_TAG "NdefMessage" #include <stdlib.h> #include "jni.h" Loading @@ -23,8 +21,6 @@ #include "android_nfc.h" #include <utils/Log.h> namespace android { static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, Loading Loading @@ -53,7 +49,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, return -1; /* Get the number of records in the message so we can allocate buffers */ LOGD("phFriNfc_NdefRecord_GetRecords(NULL)"); TRACE("phFriNfc_NdefRecord_GetRecords(NULL)"); status = phFriNfc_NdefRecord_GetRecords((uint8_t *)raw_msg, (uint32_t)raw_msg_size, NULL, NULL, &num_of_records); Loading @@ -62,9 +58,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, LOGE("phFriNfc_NdefRecord_GetRecords(NULL) returned 0x%04x", status); goto end; } LOGD("phFriNfc_NdefRecord_GetRecords(NULL) returned 0x%04x", status); LOGD("found %d records in message", num_of_records); TRACE("phFriNfc_NdefRecord_GetRecords(NULL) returned 0x%04x, with %d records", status, num_of_records); is_chunked = (uint8_t*)malloc(num_of_records); if (is_chunked == NULL) Loading @@ -74,7 +68,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, goto end; /* Now, actually retrieve records position in message */ LOGD("phFriNfc_NdefRecord_GetRecords()"); TRACE("phFriNfc_NdefRecord_GetRecords()"); status = phFriNfc_NdefRecord_GetRecords((uint8_t *)raw_msg, (uint32_t)raw_msg_size, records, is_chunked, &num_of_records); Loading @@ -83,7 +77,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, LOGE("phFriNfc_NdefRecord_GetRecords() returned 0x%04x", status); goto end; } LOGD("phFriNfc_NdefRecord_GetRecords() returned 0x%04x", status); TRACE("phFriNfc_NdefRecord_GetRecords() returned 0x%04x, with %d records", status, num_of_records); /* Build NDEF records array */ record_cls = e->FindClass("android/nfc/NdefRecord"); Loading @@ -94,13 +88,11 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, ctor = e->GetMethodID(record_cls, "<init>", "(S[B[B[B)V"); LOGD("NFC_Number of records = %d\n", num_of_records); for (i = 0; i < num_of_records; i++) { jbyteArray type, id, payload; jobject new_record; LOGD("phFriNfc_NdefRecord_Parse()"); TRACE("phFriNfc_NdefRecord_Parse()"); status = phFriNfc_NdefRecord_Parse(&record, records[i]); Loading @@ -108,7 +100,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, LOGE("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); goto end; } LOGD("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); TRACE("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); type = e->NewByteArray(record.TypeLength); if (type == NULL) { Loading core/jni/android_nfc_NdefRecord.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ static jbyteArray android_nfc_NdefRecord_generate( if (buf == NULL) goto end; LOGD("phFriNfc_NdefRecord_Generate()"); TRACE("phFriNfc_NdefRecord_Generate()"); status = phFriNfc_NdefRecord_Generate(&record, buf, buf_size, &record_size); Loading @@ -63,7 +63,7 @@ static jbyteArray android_nfc_NdefRecord_generate( LOGE("phFriNfc_NdefRecord_Generate() returned 0x%04x", status); goto end; } LOGD("phFriNfc_NdefRecord_Generate() returned 0x%04x", status); TRACE("phFriNfc_NdefRecord_Generate() returned 0x%04x", status); result = e->NewByteArray(record_size); if (result == NULL) Loading Loading @@ -104,13 +104,13 @@ static jint android_nfc_NdefRecord_parseNdefRecord(JNIEnv *e, jobject o, goto clean_and_return; } LOGD("phFriNfc_NdefRecord_Parse()"); TRACE("phFriNfc_NdefRecord_Parse()"); status = phFriNfc_NdefRecord_Parse(&record, (uint8_t *)raw_record); if (status) { LOGE("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); goto clean_and_return; } LOGD("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); TRACE("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); /* Set TNF field */ mTnf = e->GetFieldID(record_cls, "mTnf", "S"); Loading Loading
core/jni/android_nfc.h +9 −0 Original line number Diff line number Diff line Loading @@ -22,8 +22,17 @@ #ifndef __ANDROID_NFC_H__ #define __ANDROID_NFC_H__ #define LOG_TAG "NdefMessage" #include <utils/Log.h> extern "C" { #if 0 #define TRACE(...) LOG(LOG_DEBUG, "NdefMessage", __VA_ARGS__) #else #define TRACE(...) #endif typedef struct phFriNfc_NdefRecord { uint8_t Flags; uint8_t Tnf; Loading
core/jni/android_nfc_NdefMessage.cpp +6 −14 Original line number Diff line number Diff line Loading @@ -14,8 +14,6 @@ * limitations under the License. */ #define LOG_TAG "NdefMessage" #include <stdlib.h> #include "jni.h" Loading @@ -23,8 +21,6 @@ #include "android_nfc.h" #include <utils/Log.h> namespace android { static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, Loading Loading @@ -53,7 +49,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, return -1; /* Get the number of records in the message so we can allocate buffers */ LOGD("phFriNfc_NdefRecord_GetRecords(NULL)"); TRACE("phFriNfc_NdefRecord_GetRecords(NULL)"); status = phFriNfc_NdefRecord_GetRecords((uint8_t *)raw_msg, (uint32_t)raw_msg_size, NULL, NULL, &num_of_records); Loading @@ -62,9 +58,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, LOGE("phFriNfc_NdefRecord_GetRecords(NULL) returned 0x%04x", status); goto end; } LOGD("phFriNfc_NdefRecord_GetRecords(NULL) returned 0x%04x", status); LOGD("found %d records in message", num_of_records); TRACE("phFriNfc_NdefRecord_GetRecords(NULL) returned 0x%04x, with %d records", status, num_of_records); is_chunked = (uint8_t*)malloc(num_of_records); if (is_chunked == NULL) Loading @@ -74,7 +68,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, goto end; /* Now, actually retrieve records position in message */ LOGD("phFriNfc_NdefRecord_GetRecords()"); TRACE("phFriNfc_NdefRecord_GetRecords()"); status = phFriNfc_NdefRecord_GetRecords((uint8_t *)raw_msg, (uint32_t)raw_msg_size, records, is_chunked, &num_of_records); Loading @@ -83,7 +77,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, LOGE("phFriNfc_NdefRecord_GetRecords() returned 0x%04x", status); goto end; } LOGD("phFriNfc_NdefRecord_GetRecords() returned 0x%04x", status); TRACE("phFriNfc_NdefRecord_GetRecords() returned 0x%04x, with %d records", status, num_of_records); /* Build NDEF records array */ record_cls = e->FindClass("android/nfc/NdefRecord"); Loading @@ -94,13 +88,11 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, ctor = e->GetMethodID(record_cls, "<init>", "(S[B[B[B)V"); LOGD("NFC_Number of records = %d\n", num_of_records); for (i = 0; i < num_of_records; i++) { jbyteArray type, id, payload; jobject new_record; LOGD("phFriNfc_NdefRecord_Parse()"); TRACE("phFriNfc_NdefRecord_Parse()"); status = phFriNfc_NdefRecord_Parse(&record, records[i]); Loading @@ -108,7 +100,7 @@ static jint android_nfc_NdefMessage_parseNdefMessage(JNIEnv *e, jobject o, LOGE("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); goto end; } LOGD("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); TRACE("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); type = e->NewByteArray(record.TypeLength); if (type == NULL) { Loading
core/jni/android_nfc_NdefRecord.cpp +4 −4 Original line number Diff line number Diff line Loading @@ -54,7 +54,7 @@ static jbyteArray android_nfc_NdefRecord_generate( if (buf == NULL) goto end; LOGD("phFriNfc_NdefRecord_Generate()"); TRACE("phFriNfc_NdefRecord_Generate()"); status = phFriNfc_NdefRecord_Generate(&record, buf, buf_size, &record_size); Loading @@ -63,7 +63,7 @@ static jbyteArray android_nfc_NdefRecord_generate( LOGE("phFriNfc_NdefRecord_Generate() returned 0x%04x", status); goto end; } LOGD("phFriNfc_NdefRecord_Generate() returned 0x%04x", status); TRACE("phFriNfc_NdefRecord_Generate() returned 0x%04x", status); result = e->NewByteArray(record_size); if (result == NULL) Loading Loading @@ -104,13 +104,13 @@ static jint android_nfc_NdefRecord_parseNdefRecord(JNIEnv *e, jobject o, goto clean_and_return; } LOGD("phFriNfc_NdefRecord_Parse()"); TRACE("phFriNfc_NdefRecord_Parse()"); status = phFriNfc_NdefRecord_Parse(&record, (uint8_t *)raw_record); if (status) { LOGE("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); goto clean_and_return; } LOGD("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); TRACE("phFriNfc_NdefRecord_Parse() returned 0x%04x", status); /* Set TNF field */ mTnf = e->GetFieldID(record_cls, "mTnf", "S"); Loading