Fixed failed to handle empty tag issue 57/23957/1 accepted/tizen_3.0.2014.q3_common accepted/tizen_3.0.m14.3_ivi tizen_3.0.2014.q3_common tizen_3.0.m14.3_ivi accepted/tizen/common/20140724.002300 accepted/tizen/ivi/20140729.134623 submit/tizen/20140721.062718 submit/tizen_ivi/20140729.000000 tizen_3.0.2014.q3_common_release tizen_3.0.m14.3_ivi_release
authorArron Wang <arron.wang@intel.com>
Mon, 7 Jul 2014 06:17:55 +0000 (14:17 +0800)
committerArron Wang <arron.wang@intel.com>
Mon, 7 Jul 2014 06:18:09 +0000 (14:18 +0800)
Some NFC tag has empty record, we should also handle
them properly and allow use the write new data to it
Fixed TC-173

Change-Id: I26c712ec0939ee82a6a154865412d5c1f9411aaa

client/net_nfc_client_ndef_message.c
client/net_nfc_neard.c
common/net_nfc_util_ndef_message.c

index 7f561a9..4634f1b 100644 (file)
@@ -91,7 +91,7 @@ API net_nfc_error_e net_nfc_get_ndef_message_byte_length(
        RETV_IF(NULL == length, NET_NFC_NULL_PARAMETER);
 
        *length = net_nfc_util_get_ndef_message_length(ndef_message);
-       if (*length > 0)
+       if (*length >= 0)
                result = NET_NFC_OK;
        else
                result = NET_NFC_INVALID_PARAM;
index c2eafe1..ed3bee8 100644 (file)
@@ -303,7 +303,7 @@ static void _tag_found_cb(const char *tagName, void *user_data)
 
        if (neardal_get_tag_properties(tagName, &tag) != NEARDAL_SUCCESS)
                return;
-       if (tag == NULL || tag->records == NULL)
+       if (tag == NULL)
                return;
 
        net_nfc_manager_util_play_sound(NET_NFC_TASK_START);
@@ -425,7 +425,7 @@ static void _read_completed_cb(GVariant *ret, void *user_data)
 
        rawNDEF->length = (int)length;
        rawNDEF->buffer = g_try_malloc0(rawNDEF->length);
-       if (rawNDEF->buffer == NULL) {
+       if (rawNDEF->length > 0 && rawNDEF->buffer == NULL) {
                g_free(rawNDEF);
                goto exit;
        }
@@ -768,7 +768,10 @@ net_nfc_error_e net_nfc_neard_write_ndef(net_nfc_target_handle_s *handle,
        if (record == NULL)
                return NET_NFC_ALLOC_FAIL;
 
-       record->name = g_strdup(tag->records[0]);
+       if (tag->records != NULL)
+               record->name = g_strdup(tag->records[0]);
+       else
+               record->name = g_strdup(tag->name);
        record->type = g_strdup("Raw");
        record->rawNDEF = g_try_malloc0(data->length);
        if (record->rawNDEF == NULL) {
index 1bbb629..35f254e 100644 (file)
@@ -35,7 +35,7 @@ net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message(
 
        RETV_IF(NULL == ndef, NET_NFC_NULL_PARAMETER);
        RETV_IF(NULL == rawdata, NET_NFC_NULL_PARAMETER);
-       RETV_IF(rawdata->length < 3, NET_NFC_INVALID_FORMAT);
+       RETV_IF(rawdata->length < 0, NET_NFC_INVALID_FORMAT);
 
        current = rawdata->buffer;
        last = current + rawdata->length;
@@ -200,7 +200,7 @@ net_nfc_error_e net_nfc_util_convert_rawdata_to_ndef_message(
 
        ndef->recordCount++;
 
-       if((current != last) || ((ndef_header & NET_NFC_NDEF_RECORD_MASK_ME) == 0))
+       if((current != last) || (((ndef_header & NET_NFC_NDEF_RECORD_MASK_ME) == 0) && (rawdata->length != 0)))
        {
                result = NET_NFC_INVALID_FORMAT;
                goto error;