Fix device search for multiple apps 19/274119/1
authorAbhay Agarwal <ay.agarwal@samsung.com>
Thu, 21 Apr 2022 12:13:09 +0000 (17:43 +0530)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Thu, 21 Apr 2022 12:37:51 +0000 (18:07 +0530)
Change-Id: I3d8856902dc87bf8d5b0d54a1980b414a859a3ce
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
ua-daemon/src/ua-manager-core.c

index c0d3e22..e259c52 100755 (executable)
@@ -2483,7 +2483,8 @@ int _uam_core_service_remove_user(const char *svc_name, const char *account, con
        return UAM_ERROR_NONE;
 }
 
-static uam_db_tech_info_t *__uam_core_get_dev_tech_info(const char *device_id, int tech_type)
+static uam_db_tech_info_t *__uam_core_get_dev_tech_info(
+       const char *device_id, int tech_type, int app_num)
 {
        FUNC_ENTRY;
        uam_db_device_info_t *device;
@@ -2493,7 +2494,17 @@ static uam_db_tech_info_t *__uam_core_get_dev_tech_info(const char *device_id, i
        retv_if(UAM_TECH_TYPE_NONE >= tech_type, NULL);
        retv_if(UAM_TECH_TYPE_MAX <= tech_type, NULL);
 
-       l = g_slist_find_custom(devices, device_id, __compare_device_id);
+       uam_device_info_s *temp_dev_info;
+
+       temp_dev_info = g_new0(uam_device_info_s, 1);
+       g_strlcpy(temp_dev_info->device_id, device_id,
+                               UAM_DEVICE_ID_MAX_STRING_LEN);
+       temp_dev_info->type = tech_type;
+       temp_dev_info->app_num = app_num;
+
+       l = g_slist_find_custom(devices, temp_dev_info, __compare_device_id_and_appnum);
+       g_free(temp_dev_info);
+
        if (NULL == l) {
                UAM_DBG("DeviceId [%s] is not in the list", device_id);
                return NULL;
@@ -2519,7 +2530,8 @@ static uam_db_tech_info_t *__uam_core_get_dev_tech_info(const char *device_id, i
                }
        }
 
-       UAM_DBG("DeviceId [%s], Device type [0x%2.2X] not found", device_id, tech_type);
+       UAM_DBG("DeviceId [%s], Device type [0x%2.2X] for app [%d] not found",
+                                               device_id, tech_type, app_num);
        FUNC_EXIT;
        return NULL;
 }
@@ -2540,7 +2552,7 @@ int _uam_core_service_add_device(const char *svc_name, const char *device_id,
        retv_if(UAM_TECH_TYPE_NONE >= tech_type, UAM_ERROR_INVALID_PARAMETER);
        retv_if(UAM_TECH_TYPE_MAX <= tech_type, UAM_ERROR_INVALID_PARAMETER);
 
-       tech_info = __uam_core_get_dev_tech_info(device_id, tech_type);
+       tech_info = __uam_core_get_dev_tech_info(device_id, tech_type, app_num);
        retv_if(NULL == tech_info, UAM_ERROR_INVALID_PARAMETER);
 
        l = __search_service(tech_info->svc_list, svc_name, app_num);
@@ -2596,7 +2608,7 @@ int _uam_core_service_remove_device(const char *svc_name,
        l = __search_service(services, svc_name, app_num);
        retv_if(NULL == l, UAM_ERROR_INVALID_PARAMETER);
 
-       tech_info = __uam_core_get_dev_tech_info(device_id, tech_type);
+       tech_info = __uam_core_get_dev_tech_info(device_id, tech_type, app_num);
        retv_if(NULL == tech_info, UAM_ERROR_INVALID_PARAMETER);
 
        l = __search_service(tech_info->svc_list, svc_name, app_num);
@@ -2632,7 +2644,7 @@ int _uam_core_service_set_device_discriminant(const char *svc_name,
        retv_if(UAM_TECH_TYPE_NONE >= tech_type, UAM_ERROR_INVALID_PARAMETER);
        retv_if(UAM_TECH_TYPE_MAX <= tech_type, UAM_ERROR_INVALID_PARAMETER);
 
-       tech_info = __uam_core_get_dev_tech_info(device_id, tech_type);
+       tech_info = __uam_core_get_dev_tech_info(device_id, tech_type, app_num);
        retv_if(NULL == tech_info, UAM_ERROR_INVALID_PARAMETER);
 
        /* Retrieve service from list */
@@ -5072,7 +5084,7 @@ int _uam_core_add_payload(uam_ble_payload_s *payload,
        /* <TO-DO> check if payload already exist */
        __print_payload(payload);
 
-       tech_info = __uam_core_get_dev_tech_info(device_id, tech_type);
+       tech_info = __uam_core_get_dev_tech_info(device_id, tech_type, app_num);
        retv_if(NULL == tech_info, UAM_ERROR_INVALID_PARAMETER);
        mac = __get_mac_addr(tech_info);