Stop scan on sensor when no monitoring application 52/225152/1 accepted/tizen_5.5_unified accepted/tizen_5.5_unified_wearable_hotfix tizen_5.5 tizen_5.5_wearable_hotfix accepted/tizen/5.5/unified/20200220.050514 accepted/tizen/5.5/unified/wearable/hotfix/20201027.115057 submit/tizen_5.5/20200218.012516 submit/tizen_5.5_wearable_hotfix/20201026.184303
authorAbhay Agarwal <ay.agarwal@samsung.com>
Mon, 17 Feb 2020 08:43:39 +0000 (14:13 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 18 Feb 2020 00:35:57 +0000 (09:35 +0900)
Issue: Presence/absence scanning on BLE/wifi plugin was not able to
stop in case only presence or only absence was started by application.

Reason: Even if only presence or only absence is started by application
ua-manager simultaneoulsy starts both presence and absence to keep their
detection cycle in sync.

Solution: Stop both presence and absence detection when stop detection
is called, if no application is monitioring on this sensor.

Change-Id: I8a49e9c558e352dc54530dc03478f7bf69fbbcbc
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
packaging/ua-manager.spec
ua-daemon/src/pm/ua-plugin-manager.c
ua-daemon/src/ua-manager-core.c

index a06bec7..de9539e 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ua-manager
 Summary:    User awareness manager
-Version:    0.13.20
+Version:    0.13.21
 Release:    1
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index fcc1b92..73e23fd 100644 (file)
@@ -31,9 +31,6 @@ extern const uas_callbacks_t wifi_cbs;
 extern const uas_callbacks_t light_cbs;
 extern const uas_callbacks_t motion_cbs;
 
-static int ble_detection_type = 0;
-static int wifi_detection_type = 0;
-
 typedef struct {
        void *handle;
        uas_module_t *module;
@@ -544,25 +541,13 @@ int _uam_pm_start_detection(unsigned int detection_mode, unsigned int bitmask)
                if (!plugin || !plugin->api)
                        continue;
 
-               /*
-                * For User/device detection capable plugins, need to start both, PRESENCE
-                * as well as ABSENCE detection, to keep UA database updated.
-                */
-               if (UAS_PLUGIN_ID_BLE == id || UAS_PLUGIN_ID_WIFI == id)
-                       status = plugin->api->start_detection(UAS_PRESENCE | UAS_ABSENCE);
-               else
-                       status = plugin->api->start_detection(type);
+               status = plugin->api->start_detection(type);
 
                if (UAS_STATUS_SUCCESS != status && UAS_STATUS_ALREADY_DONE != status) {
                        UAM_ERR("plugin->start_detection(%d) failed for %d", type, id);
                        continue;
                }
 
-               if (UAS_PLUGIN_ID_BLE == id)
-                       ble_detection_type |= type;
-               if (UAS_PLUGIN_ID_WIFI == id)
-                       wifi_detection_type |= type;
-
                /* Result success if detection started for atleast 1 of the sensor */
                ret = UAM_ERROR_NONE;
        }
@@ -600,24 +585,7 @@ int _uam_pm_stop_detection(unsigned int detection_mode, unsigned int bitmask)
                if (!plugin || !plugin->api)
                        continue;
 
-               if (UAS_PLUGIN_ID_BLE == id) {
-                       ble_detection_type &= ~type;
-                       ret = UAM_ERROR_NONE;
-                       if (0 != ble_detection_type)
-                               continue;
-               }
-
-               if (UAS_PLUGIN_ID_WIFI == id) {
-                       wifi_detection_type &= ~type;
-                       ret = UAM_ERROR_NONE;
-                       if (0 != wifi_detection_type)
-                               continue;
-               }
-
-               if (UAS_PLUGIN_ID_BLE == id || UAS_PLUGIN_ID_WIFI == id)
-                       status = plugin->api->stop_detection(UAS_PRESENCE | UAS_ABSENCE);
-               else
-                       status = plugin->api->stop_detection(type);
+               status = plugin->api->stop_detection(type);
 
                if (UAS_STATUS_SUCCESS != status && UAS_STATUS_ALREADY_DONE != status) {
                        UAM_ERR("plugin->stop_detection(%d) failed for %d", type, id);
index 2a3587c..9772ff8 100644 (file)
@@ -2108,7 +2108,8 @@ static int __uam_core_stop_detection(int detection_type,
        retv_if(0 != g_strcmp0(service->name, svc_name), UAM_ERROR_NOT_IN_OPERATION);
 
        /* Find sensors which are already monitoring */
-       active_sensors = _uam_core_get_active_sensors(detection_type);
+       active_sensors = _uam_core_get_active_sensors(UAM_DETECT_PRESENCE) |
+                               _uam_core_get_active_sensors(UAM_DETECT_ABSENCE);
        UAM_DBG("sensors: 0x%8.8X, Active sensors: 0x%8.8X",
                        sensors, active_sensors);
 
@@ -2135,17 +2136,18 @@ static int __uam_core_stop_detection(int detection_type,
        }
 
        /* Find sensors which are already monitoring */
-       remaining_sensors = _uam_core_get_active_sensors(detection_type);
+       remaining_sensors = _uam_core_get_active_sensors(UAM_DETECT_PRESENCE) |
+                               _uam_core_get_active_sensors(UAM_DETECT_ABSENCE);
        UAM_DBG("Remaining sensors: 0x%8.8X", remaining_sensors);
 
        if (active_sensors == remaining_sensors) {
-               UAM_INFO("NO need to stop monitoring");
+               UAM_INFO("No need to stop monitoring");
                return UAM_ERROR_NONE;
        }
 
        /* Stop monitoring only for sensors which aren't required anymore */
        sensors = (active_sensors & ~remaining_sensors);
-       ret = _uam_pm_stop_detection(detection_type, sensors);
+       ret = _uam_pm_stop_detection(UAM_DETECT_PRESENCE | UAM_DETECT_ABSENCE, sensors);
        if (UAM_ERROR_NONE != ret)
                UAM_ERR("Failed with error: %s (0x%4.4X)",
                                _uam_manager_error_to_str(ret), ret);