Fix location detection events 98/260598/3
authorAbhay Agarwal <ay.agarwal@samsung.com>
Fri, 4 Jun 2021 09:07:13 +0000 (14:37 +0530)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Thu, 1 Jul 2021 10:51:16 +0000 (16:21 +0530)
This patch handles following
- Update to handle 'LOCATION' detection type
- Update to send location detection event continously

Change-Id: I4c8f97a158977b85834abaefdb464faae531a6cb
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
src/wifi-location-plugin.c

index 5ae5077..2ab9327 100755 (executable)
@@ -293,7 +293,8 @@ static int start_detection(unsigned int detection_type, int scan_mode)
 
 done:
        wifi_location_detection_type |= detection_type;
-       UA_WIFI_LOCATION_INFO_C("wifi_location_detection_type = 0x%8.8X", wifi_location_detection_type);
+       UA_WIFI_LOCATION_INFO_C("wifi_location_detection_type = 0x%8.8X",
+                                               wifi_location_detection_type);
 
        FUNC_EXIT;
        return ret;
@@ -427,9 +428,6 @@ static void __wifi_location_nofity_device_detected(
        if (!wifi_location_info)
                return;
 
-       if (wifi_location_info->presence_reported)
-               return;
-
        dev_info = _wifi_location_plugin_util_get_dev_info_from_wifi_location_info(
                                                                wifi_location_info);
        if (!dev_info) {
@@ -441,8 +439,14 @@ static void __wifi_location_nofity_device_detected(
        dev_info->last_seen = _wifi_location_plugin_util_get_curr_time();
 
        if (uas_cbs && uas_cbs->device_detected_cb) {
-               uas_cbs->device_detected_cb(PLUGIN_ID, UAS_PRESENCE, dev_info);
-               wifi_location_info->presence_reported = TRUE;
+               /*Report location */
+               uas_cbs->device_detected_cb(PLUGIN_ID, UAS_LOCATION, dev_info);
+
+               /*Report presence */
+               if (!(wifi_location_info->presence_reported)) {
+                       uas_cbs->device_detected_cb(PLUGIN_ID, UAS_PRESENCE, dev_info);
+                       wifi_location_info->presence_reported = TRUE;
+               }
        } else {
                UA_WIFI_LOCATION_ERR("uas_cbs not ready");
        }
@@ -456,7 +460,7 @@ void _wifi_location_plugin_handle_device_found(const char *address, int distance
 
        GSList *l;
 
-       ret_if(!(UAS_PRESENCE & wifi_location_detection_type));
+       ret_if(!((UAS_PRESENCE | UAS_LOCATION) & wifi_location_detection_type));
 
        for (l = dev_list; NULL != l; l = g_slist_next(l)) {
                uas_wifi_location_info_t *wifi_location_info = l->data;