summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLokesh <l.kasana@samsung.com>2019-11-06 15:52:05 +0530
committersaerome.kim <saerome.kim@samsung.com>2019-11-15 18:44:16 +0900
commitd852f1a58e83cd48eeacdfbc1afca44f1e67a2e0 (patch)
treed6c0cd826201c446f4cea7edfa4bff280b0cf244
parent2574d285965190830ef697d5410c48fbd0b9c218 (diff)
downloaduser-awareness-d852f1a58e83cd48eeacdfbc1afca44f1e67a2e0.tar.gz
user-awareness-d852f1a58e83cd48eeacdfbc1afca44f1e67a2e0.tar.bz2
user-awareness-d852f1a58e83cd48eeacdfbc1afca44f1e67a2e0.zip
Detection stopped event updated with detection cycle mid/end
Clean user_state only when it is end of detection cycle. Change-Id: Iadd958c6048b8cf5935c8c85217709ada4942c51 Signed-off-by: Lokesh <l.kasana@samsung.com>
-rw-r--r--include/user-awareness-private.h5
-rw-r--r--src/user-awareness-event-handler.c7
-rw-r--r--src/user-awareness-monitors.c33
3 files changed, 31 insertions, 14 deletions
diff --git a/include/user-awareness-private.h b/include/user-awareness-private.h
index a436cdc..f4b77f0 100644
--- a/include/user-awareness-private.h
+++ b/include/user-awareness-private.h
@@ -364,11 +364,14 @@ void _ua_monitor_handle_user_presence_detected(uam_sensor_info_s *sensor_info,
* @brief Stops monitoring detection.
* @since_tizen 5.5
*
+ * @param[in] svc_name Service name.
+ * @param[in] cycle_state Detection cycle in mid or end.
+ *
* @exception
* @pre
* @post
*/
-void _ua_monitor_handle_detection_stopped(void);
+void _ua_monitor_handle_detection_stopped(char *svc_name, uam_cycle_state_e cycle_state);
/**
* @brief Changes sensor state.
diff --git a/src/user-awareness-event-handler.c b/src/user-awareness-event-handler.c
index 9a29348..e591c84 100644
--- a/src/user-awareness-event-handler.c
+++ b/src/user-awareness-event-handler.c
@@ -141,7 +141,12 @@ static void __ua_event_handler(int event, uam_event_data_s *event_param,
break;
}
case UAM_EVENT_DETECTION_STOPPED: {
- _ua_monitor_handle_detection_stopped();
+ uam_detection_stopped_event_data_s *event_data = event_param->data;
+ ret_if(NULL == event_data);
+ ret_if(NULL == event_data->service);
+
+ _ua_monitor_handle_detection_stopped(event_data->service,
+ event_data->cycle_state);
break;
}
case UAM_EVENT_SENSOR_STATE_READY: {
diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c
index 6123708..2c6fc44 100644
--- a/src/user-awareness-monitors.c
+++ b/src/user-awareness-monitors.c
@@ -154,7 +154,7 @@ static void __ua_free_user_state_info_t(gpointer data)
FUNC_EXIT;
}
-static void __ua_user_state_clean()
+static void __ua_user_state_clean(char *svc_name)
{
FUNC_ENTRY;
GSList *l;
@@ -162,10 +162,12 @@ static void __ua_user_state_clean()
for (l = ua_monitor_list; NULL != l; l = g_slist_next(l)) {
ua_monitor_s *monitor = l->data;
- if (!monitor)
+ if (!monitor || g_strcmp0(monitor->service, svc_name))
continue;
g_slist_free_full(monitor->user_state, __ua_free_user_state_info_t);
+ monitor->presence_detected_bitmask = 0;
+ monitor->absence_detected_bitmask = 0;
monitor->user_state = NULL;
monitor->env_user_cb_sent = FALSE;
}
@@ -389,7 +391,7 @@ static void __ua_monitor_send_env_user_presence_cb(ua_monitor_s *monitor)
return;
}
-static void __ua_send_presence_detection()
+static void __ua_send_presence_detection(char *svc_name)
{
FUNC_ENTRY;
GSList *l;
@@ -398,7 +400,7 @@ static void __ua_send_presence_detection()
for (l = ua_monitor_list; NULL != l; l = g_slist_next(l)) {
ua_monitor_s *monitor = l->data;
- if (!monitor)
+ if (!monitor || g_strcmp0(monitor->service, svc_name))
continue;
if (monitor->presence_mode != UA_DETECT_MODE_ANY_SENSOR) {
@@ -423,7 +425,9 @@ static void __ua_send_presence_detection()
}
}
- monitor->presence_detected_bitmask = 0;
+ /* Only reset environmental sensors presence data */
+ monitor->presence_detected_bitmask &=
+ ~(UA_SENSOR_MOTION | UA_SENSOR_LIGHT);
}
FUNC_EXIT;
@@ -639,7 +643,7 @@ static void __ua_monitor_send_user_absence_cb(ua_monitor_s *monitor,
return;
}
-static void __ua_send_absence_detection()
+static void __ua_send_absence_detection(char *svc_name)
{
FUNC_ENTRY;
GSList *l;
@@ -648,7 +652,7 @@ static void __ua_send_absence_detection()
for (l = ua_monitor_list; NULL != l; l = g_slist_next(l)) {
ua_monitor_s *monitor = l->data;
- if (!monitor)
+ if (!monitor || g_strcmp0(monitor->service, svc_name))
continue;
UA_INFO("monitor->sensor_bitmask: 0x%8.8X, monitor->absence_detected_bitmask: 0x%8.8X",
@@ -686,7 +690,9 @@ static void __ua_send_absence_detection()
}
}
- monitor->absence_detected_bitmask = 0;
+ /* Only reset environmental sensors presence data */
+ monitor->absence_detected_bitmask &=
+ ~(UA_SENSOR_MOTION | UA_SENSOR_LIGHT);
}
FUNC_EXIT;
@@ -886,13 +892,16 @@ void _ua_monitor_handle_user_absence_detected(uam_sensor_info_s *info,
FUNC_EXIT;
}
-void _ua_monitor_handle_detection_stopped()
+void _ua_monitor_handle_detection_stopped(char *svc_name,
+ uam_cycle_state_e cycle_state)
{
FUNC_ENTRY;
- __ua_send_presence_detection();
- __ua_send_absence_detection();
- __ua_user_state_clean();
+ __ua_send_presence_detection(svc_name);
+ __ua_send_absence_detection(svc_name);
+
+ if (cycle_state == UAM_DETECTION_CYCLE_END)
+ __ua_user_state_clean(svc_name);
FUNC_EXIT;
}