From: Lokesh Date: Wed, 6 Nov 2019 10:22:05 +0000 (+0530) Subject: Detection stopped event updated with detection cycle mid/end X-Git-Tag: submit/tizen/20191115.102151~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d852f1a58e83cd48eeacdfbc1afca44f1e67a2e0;p=platform%2Fcore%2Fapi%2Fuser-awareness.git 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 --- 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; }