From: saerome.kim Date: Wed, 4 Sep 2019 01:33:13 +0000 (+0900) Subject: Combined bitmask conditions menu and detection menu into one. X-Git-Tag: submit/tizen/20190916.120818~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=30e33df93d86f9e56f3ec2fdb6c9ab286f2214b9;p=platform%2Fcore%2Fapi%2Fuser-awareness.git Combined bitmask conditions menu and detection menu into one. Change-Id: Ibf8b870dfdaff8d4952966e0ecd8523313f7c3f5 Signed-off-by: saerome.kim --- diff --git a/packaging/capi-network-ua.spec b/packaging/capi-network-ua.spec index 8317716..077649f 100644 --- a/packaging/capi-network-ua.spec +++ b/packaging/capi-network-ua.spec @@ -1,6 +1,6 @@ Name: capi-network-ua Summary: User Awareness Framework CAPI -Version: 0.8.3 +Version: 0.8.4 Release: 1 License: Apache-2.0 Source0: %{name}-%{version}.tar.gz diff --git a/test/uat-detections.c b/test/uat-detections.c index 6e3898d..264b5c2 100644 --- a/test/uat-detections.c +++ b/test/uat-detections.c @@ -37,14 +37,15 @@ extern char g_service_str[MENU_DATA_SIZE + 1]; /**< Service string */ static char cycle_time[MENU_DATA_SIZE + 1] = {"900", }; /**< cycle time */ static char window[MENU_DATA_SIZE + 1] = {"60", }; /**< Detection window */ -static char g_presence_and_cond[MENU_DATA_SIZE + 1] = {0,}; /**< PRESENCE AND condition */ -static char g_presence_or_cond[MENU_DATA_SIZE + 1] = {0,}; /**< PRESENCE OR condition */ -static char g_absence_and_cond[MENU_DATA_SIZE + 1] = {0,}; /**< ABSENCE AND condition */ -static char g_absence_or_cond[MENU_DATA_SIZE + 1] = {0,}; /**< ABSENCE OR condition */ -static char g_conjunction_op[MENU_DATA_SIZE + 1] = {"1",}; /**< logical conjunction operation */ - -static char g_presence_type[MENU_DATA_SIZE + 1] = "2"; /**< Selected PRESENCE type */ -static char g_absence_type[MENU_DATA_SIZE + 1] = "2"; /**< Selected ABSENCE type */ +static char g_presence_and_cond[MENU_DATA_SIZE + 1] = {"16",}; /**< PRESENCE AND condition */ +static char g_presence_or_cond[MENU_DATA_SIZE + 1] = {"6",}; /**< PRESENCE OR condition */ +static char g_presence_conjunction_op[MENU_DATA_SIZE + 1] = {"1",}; /**< logical conjunction operation */ +static char g_absence_and_cond[MENU_DATA_SIZE + 1] = {"6",}; /**< ABSENCE AND condition */ +static char g_absence_or_cond[MENU_DATA_SIZE + 1] = {"16",}; /**< ABSENCE OR condition */ +static char g_absence_conjunction_op[MENU_DATA_SIZE + 1] = {"0",}; /**< logical conjunction operation */ + +static char g_presence_type[MENU_DATA_SIZE + 1] = "1"; /**< Selected PRESENCE type */ +static char g_absence_type[MENU_DATA_SIZE + 1] = "1"; /**< Selected ABSENCE type */ static char g_scan_time_multiplier[MENU_DATA_SIZE + 1] = {0,}; /**< 10ms * what number */ static void __device_presence_detected_cb(int result, ua_monitor_h monitor, @@ -227,15 +228,16 @@ static int run_ua_monitor_set_user_presence_condition( bitmask_and = (unsigned int)strtol(g_presence_and_cond, NULL, 10); if (strlen(g_presence_or_cond)) bitmask_or = (unsigned int)strtol(g_presence_or_cond, NULL, 10); - if (strlen(g_conjunction_op)) - op_value = (unsigned int)strtol(g_conjunction_op, NULL, 10); + if (strlen(g_presence_conjunction_op)) + op_value = (unsigned int)strtol(g_presence_conjunction_op, NULL, 10); conjunction_op = op_value ? UA_AND_OPERATION : UA_OR_OPERATION; msgb("AND [%u] [%s] OR [%u]", bitmask_and, op_value ? "and" : "or", bitmask_or); - ret = ua_monitor_set_user_presence_condition(g_ua_mon_h, bitmask_and, bitmask_or, conjunction_op); + ret = ua_monitor_set_user_presence_condition(g_ua_mon_h, + bitmask_and, bitmask_or, conjunction_op); msg(" - ua_monitor_set_user_presence_condition() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); @@ -258,8 +260,8 @@ static int run_ua_monitor_set_user_absence_condition( bitmask_and = (unsigned int)strtol(g_absence_and_cond, NULL, 10); if (strlen(g_absence_or_cond)) bitmask_or = (unsigned int)strtol(g_absence_or_cond, NULL, 10); - if (strlen(g_conjunction_op)) - op_value = (unsigned int)strtol(g_conjunction_op, NULL, 10); + if (strlen(g_absence_conjunction_op)) + op_value = (unsigned int)strtol(g_absence_conjunction_op, NULL, 10); conjunction_op = op_value ? UA_AND_OPERATION : UA_OR_OPERATION; @@ -278,6 +280,10 @@ static int run_ua_monitor_start_presence_detection( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; + unsigned int bitmask_and = 0; + unsigned int bitmask_or = 0; + unsigned int op_value = 1; + ua_condition_conjunction_e conjunction_op = UA_AND_OPERATION; msg("ua_monitor_start_presence_detection"); @@ -285,6 +291,21 @@ static int run_ua_monitor_start_presence_detection( check_if(NULL == g_ua_mon_h); + if (strlen(g_presence_and_cond)) + bitmask_and = (unsigned int)strtol(g_presence_and_cond, NULL, 10); + if (strlen(g_presence_or_cond)) + bitmask_or = (unsigned int)strtol(g_presence_or_cond, NULL, 10); + if (strlen(g_presence_conjunction_op)) + op_value = (unsigned int)strtol(g_presence_conjunction_op, NULL, 10); + + conjunction_op = op_value ? UA_AND_OPERATION : UA_OR_OPERATION; + + msgb("AND [%u] [%s] OR [%u]", bitmask_and, op_value ? "and" : "or", + bitmask_or); + + ret = ua_monitor_set_user_presence_condition(g_ua_mon_h, + bitmask_and, bitmask_or, conjunction_op); + if (strlen(g_presence_type)) detection_mode = (unsigned char)strtol(g_presence_type, NULL, 10); @@ -320,12 +341,32 @@ static int run_ua_monitor_start_absence_detection( { int ret = UA_ERROR_NONE; - msg("ua_monitor_start_absence_detection"); + unsigned int bitmask_and = 0; + unsigned int bitmask_or = 0; + unsigned int op_value = 1; + ua_condition_conjunction_e conjunction_op = UA_AND_OPERATION; - ua_detection_mode_e detection_mode = UA_DETECT_MODE_INVALID; + msg("ua_monitor_start_absence_detection"); check_if(NULL == g_ua_mon_h); + if (strlen(g_absence_and_cond)) + bitmask_and = (unsigned int)strtol(g_absence_and_cond, NULL, 10); + if (strlen(g_absence_or_cond)) + bitmask_or = (unsigned int)strtol(g_absence_or_cond, NULL, 10); + if (strlen(g_absence_conjunction_op)) + op_value = (unsigned int)strtol(g_absence_conjunction_op, NULL, 10); + + conjunction_op = op_value ? UA_AND_OPERATION : UA_OR_OPERATION; + + msgb("AND [%u] [%s] OR [%u]", bitmask_and, op_value ? "and" : "or", + bitmask_or); + + ret = ua_monitor_set_user_absence_condition(g_ua_mon_h, + bitmask_and, bitmask_or, conjunction_op); + + ua_detection_mode_e detection_mode = UA_DETECT_MODE_INVALID; + if (strlen(g_absence_type)) detection_mode = (unsigned char)strtol((g_absence_type), NULL, 10); @@ -494,7 +535,7 @@ static int run_device_power_request_poweroff( msgr("Fail to request power off"); return false; } -#if 0 + ret = device_power_set_wakeup_reason(POWER_WAKEUP_REASON_REMOTE_CONTROLLER); if(POWER_ERROR_NONE != device_power_set_wakeup_reason(POWER_WAKEUP_REASON_REMOTE_CONTROLLER)) { @@ -506,7 +547,7 @@ static int run_device_power_request_poweroff( msgr("Failed to request TV to STANDBY!"); return RET_SUCCESS; } -#endif + msg(" - run_device_power_request_poweroff() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); @@ -546,7 +587,7 @@ static struct menu_data menu_ua_set_presence_condition[] = { { "2", "OR Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", NULL, NULL, g_presence_or_cond }, { "3", "logical conjunction operation(0:OR, 1:AND)", - NULL, NULL, g_conjunction_op }, + NULL, NULL, g_presence_conjunction_op }, { "4", "run", NULL, run_ua_monitor_set_user_presence_condition, NULL }, { NULL, NULL, }, @@ -558,7 +599,7 @@ static struct menu_data menu_ua_set_absence_condition[] = { { "2", "OR Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", NULL, NULL, g_absence_or_cond }, { "3", "logical conjunction operation(0:OR, 1:AND)", - NULL, NULL, g_conjunction_op }, + NULL, NULL, g_absence_conjunction_op }, { "4", "run", NULL, run_ua_monitor_set_user_absence_condition, NULL }, { NULL, NULL, }, @@ -571,24 +612,46 @@ static struct menu_data menu_start_device_scan[] = { }; static struct menu_data menu_ua_start_presence[] = { - { "1", "type (1:ALL 2:ANY)", NULL, NULL, g_presence_type }, - { "2", "service(empty for default, else selected service)", NULL, NULL, g_service_str}, - { "3", "run", NULL, run_ua_monitor_start_presence_detection, NULL }, + { "1", "AND (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", + NULL, NULL, g_presence_and_cond }, + { "2", "OR (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", + NULL, NULL, g_presence_or_cond }, + { "3", "[1] cond. [2] (0:OR, 1:AND)", + NULL, NULL, g_presence_conjunction_op }, + { "4", "type (1:ALL 2:ANY)", + NULL, NULL, g_presence_type }, + { "5", "service(empty for default, else selected service)", + NULL, NULL, g_service_str}, + { "6", "run", + NULL, run_ua_monitor_start_presence_detection, NULL }, { NULL, NULL, }, }; static struct menu_data menu_ua_start_absence[] = { - { "1", "type (1:ALL 2:ANY)", NULL, NULL, g_absence_type }, - { "2", "service(empty for default, else selected service)", NULL, NULL, g_service_str}, - { "3", "run", NULL, run_ua_monitor_start_absence_detection, NULL }, + { "1", "AND (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", + NULL, NULL, g_absence_and_cond }, + { "2", "OR (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", + NULL, NULL, g_absence_or_cond }, + { "3", "[1] cond. [2] ( 0:OR, 1:AND)", + NULL, NULL, g_absence_conjunction_op }, + { "4", "type (1:ALL 2:ANY)", + NULL, NULL, g_absence_type }, + { "5", "service(empty for default, else selected service)", + NULL, NULL, g_service_str}, + { "6", "run", + NULL, run_ua_monitor_start_absence_detection, NULL }, { NULL, NULL, }, }; static struct menu_data menu_start_absence_presence[] = { - { "1", "ABSENCE detection type (1:ALL 2:ANY)", NULL, NULL, g_absence_type }, - { "2", "PRESENCE detection type (1:ALL 2:ANY)", NULL, NULL, g_presence_type }, - { "3", "start", NULL, run_ua_monitor_start_absence_presence, NULL }, - { "4", "stop", NULL, run_ua_monitor_stop_absence_presence, NULL }, + { "1", "ABSENCE detection type (1:ALL 2:ANY)", + NULL, NULL, g_absence_type }, + { "2", "PRESENCE detection type (1:ALL 2:ANY)", + NULL, NULL, g_presence_type }, + { "3", "start", + NULL, run_ua_monitor_start_absence_presence, NULL }, + { "4", "stop", + NULL, run_ua_monitor_stop_absence_presence, NULL }, { NULL, NULL, }, };