Fix payload copy functions
authorAbhay agarwal <ay.agarwal@samsung.com>
Tue, 24 Dec 2019 13:34:28 +0000 (19:04 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Mon, 30 Dec 2019 07:29:56 +0000 (16:29 +0900)
Signed-off-by: Abhay agarwal <ay.agarwal@samsung.com>
ua-daemon/src/pm/ua-pm-util.c
ua-daemon/src/ua-manager-core.c

index 82c749a..b935548 100644 (file)
@@ -138,9 +138,9 @@ void _pm_util_uam_db_payload_to_uas_payload(
                dst_payload->primary_key = src_payload->primary_key;
                dst_payload->device_icon = src_payload->device_icon;
                dst_payload->secondary_key = src_payload->secondary_key;
-               dst_payload->device_uid = g_memdup(&(src_payload->device_uid),
+               dst_payload->device_uid = g_memdup((src_payload->device_uid),
                                                UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
-               dst_payload->bt_mac = g_memdup(&(src_payload->bt_mac),
+               dst_payload->bt_mac = g_memdup((src_payload->bt_mac),
                                                UAM_BT_MAC_ADDRESS_STRING_LEN);
        }
        UAM_DBG("payload primary key: [%d]", dst_payload->primary_key);
@@ -236,7 +236,7 @@ void _pm_util_uam_db_dev_to_uas_dev(unsigned int tech_type,
                        if (!payload)
                                continue;
 
-                       _pm_util_uam_db_payload_to_uas_payload(&(*device)->payload[i], payload);
+                       _pm_util_uam_db_payload_to_uas_payload(&((*device)->payload[i]), payload);
                        i++;
                }
        }
index 5f8c69d..7726818 100644 (file)
@@ -237,6 +237,15 @@ static void __print_svc_dev(gpointer data, gpointer user_data)
        FUNC_EXIT;
 }
 
+void __print_payload(uam_ble_payload_s *payload)
+{
+       ret_if(NULL == payload);
+       UAM_DBG("Payload primary key: [%d], secondary_key: [%d], device_icon: [%d]",
+               payload->primary_key, payload->secondary_key, payload->device_icon);
+       for (int i = 0; i < UAM_BLE_PAYLOAD_DEVICE_UID_LEN; i++)
+               UAM_DBG("Device uid [0x%2.2x]", payload->device_uid[i]);
+}
+
 static void __add_service_to_dev_tech_mapping(
                uam_db_tech_info_t *tech, uam_db_service_info_t *service)
 {
@@ -693,6 +702,8 @@ static void __uam_copy_db_payload_info(uam_ble_payload_s *dst_payload,
                dst_payload->primary_key = src_payload->primary_key;
                dst_payload->device_icon = src_payload->device_icon;
                dst_payload->secondary_key = src_payload->secondary_key;
+               memset(dst_payload->device_uid, 0, UAM_BLE_PAYLOAD_DEVICE_UID_LEN + 1);
+               memset(dst_payload->bt_mac, 0, UAM_BT_MAC_ADDRESS_STRING_LEN);
                if (src_payload->device_uid)
                        memcpy(dst_payload->device_uid,
                        src_payload->device_uid, UAM_BLE_PAYLOAD_DEVICE_UID_LEN);
@@ -4072,6 +4083,7 @@ int _uam_core_add_payload(uam_ble_payload_s *payload,
        retv_if(UAM_TECH_TYPE_MAX <= tech_type, UAM_ERROR_INVALID_PARAMETER);
 
        // <TO-DO> check if payload already exist
+       __print_payload(payload);
 
        tech_info = __uam_core_get_dev_tech_info(device_id, tech_type);
        retv_if(NULL == tech_info, UAM_ERROR_INVALID_PARAMETER);