Reset detected bitmask when STOP command received
authorsaerome.kim <saerome.kim@samsung.com>
Tue, 3 Dec 2019 08:34:06 +0000 (17:34 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Tue, 3 Dec 2019 10:01:29 +0000 (19:01 +0900)
- Problem: PRESENCE is not detected after start -> stop -> start
  PRESENCE detection.
- Cause: When receiving the stop PRESENCE detection command,
  the previously detected sensor bitmask is not initialized.
- Solution: When the STOP PRESENCE command is received, initialize the detectedi
  bitmask.

Change-Id: I8893563e0d9f1379b19ac9a0680c9f17d25ecd71
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
packaging/capi-network-ua.spec
src/user-awareness-monitors.c

index 7b1b4654fca990aba13591288e52d1336ad10869..6ead266aeec888059fadc32edd3f0b2664dd5c58 100644 (file)
@@ -1,6 +1,6 @@
 Name: capi-network-ua
 Summary: User Awareness Framework CAPI
-Version: 0.13.3
+Version: 0.13.4
 Release: 1
 License: Apache-2.0
 Source0: %{name}-%{version}.tar.gz
index e70e44d4f17a3ea9018cd0079de85a6798187867..735642b15c3fb52adadd77c4e5db8ace02524450 100644 (file)
@@ -455,6 +455,9 @@ static void __ua_monitor_send_sensor_presence_cb(ua_monitor_s *monitor,
                 * send presence detection callback to application. This will make sure that each sensor is
                 * detected at least one device from registered devices list.
                 */
+               UA_INFO("UA_DETECT_MODE_ALL_SENSOR [%d][%d]",
+                       bitmask, monitor->presence_detected_bitmask);
+
                if (((bitmask == UA_SENSOR_BLE) && (monitor->sensor_bitmask & UA_SENSOR_WIFI))
                                || ((bitmask == UA_SENSOR_WIFI) && (monitor->sensor_bitmask & UA_SENSOR_BLE)))
                        monitor->presence_detected_bitmask |= (UA_SENSOR_BLE | UA_SENSOR_WIFI);
@@ -467,6 +470,9 @@ static void __ua_monitor_send_sensor_presence_cb(ua_monitor_s *monitor,
                break;
 
        case UA_DETECT_MODE_ANY_SENSOR:
+               UA_INFO("UA_DETECT_MODE_ANY_SENSOR [%d][%d]",
+                       bitmask, monitor->presence_detected_bitmask);
+
                if ((monitor->presence_detected_bitmask & bitmask) == 0)
                        if (monitor->presence_cb)
                                monitor->presence_cb(UA_ERROR_NONE, monitor,
@@ -906,89 +912,6 @@ void _ua_monitor_handle_detection_stopped(char *svc_name,
        FUNC_EXIT;
 }
 
-#if 0
-static void __ua_remove_sensor(ua_monitor_s *monitor, ua_sensor_e sensor_type)
-{
-       FUNC_ENTRY;
-       int ret;
-       int is_presence = 0;
-       int is_absence = 0;
-       void *presence_callback = NULL;
-       void *presence_user_data = NULL;
-       void *absence_callback = NULL;
-       void *absence_user_data = NULL;
-       ua_detection_mode_e mode_presence;
-       ua_detection_mode_e mode_absence;
-
-       if (monitor->presence_detection_started) {
-               /* Stop detection first */
-               if (monitor->presence_cb) {
-                       /* Presence detection ongoing */
-                       presence_callback = monitor->presence_cb;
-                       presence_user_data = monitor->user_data;
-                       mode_presence = monitor->presence_mode;
-
-                       ret = ua_monitor_stop_presence_detection(monitor);
-                       UA_INFO("ua_monitor_stop_presence_detection returned %s",
-                                       _ua_get_error_string(ret));
-
-                       is_presence = 1;
-               } else {
-                       UA_WARN("Unexpected, detection started but cbs are NULL");
-               }
-       }
-
-       if (monitor->absence_detection_started) {
-               /* Stop detection first */
-               if (monitor->absence_cb) {
-                       /* absence detection ongoing */
-                       absence_callback = monitor->absence_cb;
-                       absence_user_data = monitor->user_data;
-                       mode_absence = monitor->absence_mode;
-
-                       ret = ua_monitor_stop_presence_detection(monitor);
-                       UA_INFO("ua_monitor_stop_presence_detection returned %s",
-                                       _ua_get_error_string(ret));
-
-                       is_absence = 1;
-               } else {
-                       UA_WARN("Unexpected, detection started but cbs are NULL");
-               }
-       }
-
-       if (is_presence || is_absence) {
-               ret = ua_monitor_remove_sensor(monitor, sensor_type);
-               UA_INFO("ua_monitor_remove_sensor returned %s",
-                               _ua_get_error_string(ret));
-       }
-
-       if (0 != monitor->sensor_bitmask) {
-               if (is_presence) {
-                       ret = ua_monitor_start_presence_detection(
-                                       monitor, monitor->service, mode_presence, presence_callback, presence_user_data);
-                       UA_INFO("ua_monitor_start_presence_detection returned %s",
-                                       _ua_get_error_string(ret));
-               }
-
-               if (is_absence) {
-                       ret = ua_monitor_start_absence_detection(
-                                       monitor, monitor->service, mode_absence, absence_callback, absence_user_data);
-                       UA_INFO("ua_monitor_start_absence_detection returned %s",
-                                       _ua_get_error_string(ret));
-               }
-       }
-
-       if (!is_presence && !is_absence) {
-               /* Monitoring is already stopped, just remove sensor from monitor */
-               ret = ua_monitor_remove_sensor(monitor, sensor_type);
-               UA_INFO("ua_monitor_remove_sensor returned %s",
-                               _ua_get_error_string(ret));
-       }
-
-       FUNC_EXIT;
-}
-#endif
-
 void _ua_monitor_handle_sensor_state(unsigned int bitmask, gboolean ready)
 {
        FUNC_ENTRY;
@@ -1790,6 +1713,7 @@ int ua_monitor_stop_presence_detection(ua_monitor_h handle)
        monitor->presence_cb = NULL;
        monitor->user_data = NULL;
        monitor->presence_detection_started = FALSE;
+       monitor->presence_detected_bitmask = 0;
        g_slist_free_full(monitor->user_state, __ua_free_user_state_info_t);
        monitor->user_state = NULL;
        monitor->env_user_cb_sent = FALSE;
@@ -1839,7 +1763,7 @@ int ua_monitor_stop_absence_detection(ua_monitor_h handle)
        monitor->absence_cb = NULL;
        monitor->user_data = NULL;
        monitor->absence_detection_started = FALSE;
-
+       monitor->absence_detected_bitmask = 0;
        if (!monitor->presence_detection_started) {
                g_free(monitor->service);
                monitor->service = NULL;