diff options
author | saerome.kim <saerome.kim@samsung.com> | 2019-10-17 18:26:52 +0900 |
---|---|---|
committer | saerome.kim <saerome.kim@samsung.com> | 2019-10-17 19:18:35 +0900 |
commit | 1a1d16753a8e4c8cfbb2336c99375ca500c3a71d (patch) | |
tree | e1a8f5b7cdd4f348a85f54a630143d9eda775e0c | |
parent | 3ed49c0bd89543f69144e464db8d51cfbd6b3226 (diff) | |
download | user-awareness-1a1d16753a8e4c8cfbb2336c99375ca500c3a71d.tar.gz user-awareness-1a1d16753a8e4c8cfbb2336c99375ca500c3a71d.tar.bz2 user-awareness-1a1d16753a8e4c8cfbb2336c99375ca500c3a71d.zip |
Add new API to set low power modetizen_5.5.m2_releasesubmit/tizen_5.5_mobile_hotfix/20201026.185102submit/tizen_5.5/20191031.000002submit/tizen/20191018.005538accepted/tizen/unified/20191018.052938accepted/tizen/5.5/unified/mobile/hotfix/20201027.065752accepted/tizen/5.5/unified/20191031.031318tizen_5.5_mobile_hotfixaccepted/tizen_5.5_unified_mobile_hotfix
- Problem: it is needed that new API that can set low power mode
- Cause: without adding new API, build break occurs.
- Solution: add new API to set low power mode.
Change-Id: I2e9269003238973f29424a017c0b9f56c18b4b6d
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
-rw-r--r-- | include/user-awareness-internal.h | 18 | ||||
-rw-r--r-- | include/user-awareness.h | 15 | ||||
-rw-r--r-- | src/user-awareness-monitors.c | 36 | ||||
-rw-r--r-- | test/uat-detections.c | 74 |
4 files changed, 98 insertions, 45 deletions
diff --git a/include/user-awareness-internal.h b/include/user-awareness-internal.h index 3af7f57..9510379 100644 --- a/include/user-awareness-internal.h +++ b/include/user-awareness-internal.h @@ -58,7 +58,7 @@ int ua_monitor_set_brightness_threshold(ua_monitor_h handle, * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful */ -int ua_enable_low_power_mode(unsigned int sensors); +int ua_enable_low_power_mode(void); /** * @internal @@ -69,7 +69,21 @@ int ua_enable_low_power_mode(unsigned int sensors); * @return 0 on success, otherwise a negative error value * @retval #UA_ERROR_NONE Successful */ -int ua_disable_low_power_mode(unsigned int sensors); +int ua_disable_low_power_mode(void); + +/** + * @internal + * @ingroup CAPI_NETWORK_UA_MODULE + * @brief Sets low power mode for each sensor. + * @since_tizen 5.5 + * + * @param[in] bitmask The sensor bitmask + * @param[in] on_off Low power mode enable or not + * + * @return 0 on success, otherwise a negative error value + * @retval #UA_ERROR_NONE Successful + */ +int ua_set_low_power_mode(unsigned int bitmask, bool on_off); /** * @internal diff --git a/include/user-awareness.h b/include/user-awareness.h index a71dd6e..8ee579a 100644 --- a/include/user-awareness.h +++ b/include/user-awareness.h @@ -166,13 +166,14 @@ typedef enum { * @since_tizen 5.5 */ typedef enum { - UA_SENSOR_BT = 0x0001, /**< BT Sensor */ - UA_SENSOR_BLE = 0x0002, /**< BLE Sensor */ - UA_SENSOR_WIFI = 0x0004, /**< Wi-Fi Sensor */ - UA_SENSOR_MOTION = 0x0008, /**< Motion Sensor */ - UA_SENSOR_LIGHT = 0x0010, /**< Light Sensor */ - UA_SENSOR_AUDIO = 0x0020, /**< Audio Sensor */ - UA_SENSOR_MAX /**< Sensor Max. */ + UA_SENSOR_BT = 0x00000001, /**< BT Sensor */ + UA_SENSOR_BLE = 0x00000002, /**< BLE Sensor */ + UA_SENSOR_WIFI = 0x00000004, /**< Wi-Fi Sensor */ + UA_SENSOR_MOTION = 0x00000008, /**< Motion Sensor */ + UA_SENSOR_LIGHT = 0x00000010, /**< Light Sensor */ + UA_SENSOR_AUDIO = 0x00000020, /**< Audio Sensor */ + UA_SENSOR_MAX, /**< Sensor Max. */ + UA_SENSOR_ALL = 0xFFFFFFFF /**< All sensors */ } ua_sensor_e; /** diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c index f707cdb..debbc0b 100644 --- a/src/user-awareness-monitors.c +++ b/src/user-awareness-monitors.c @@ -21,6 +21,7 @@ #include <user-awareness.h> #include <user-awareness-log.h> #include <user-awareness-private.h> +#include <user-awareness-internal.h> #include <user-awareness-util.h> #define UA_MONITORING_TIME 60 /* Default: 60 seconds for scanning for device */ @@ -128,6 +129,9 @@ static unsigned int __ua_sensor_type_to_bitmask(ua_sensor_e sensor_type) case UA_SENSOR_AUDIO: bitmask = UAM_SENSOR_BITMASK_AUDIO; break; + case UA_SENSOR_ALL: + bitmask = UAM_SENSOR_ALL; + break; default: UA_WARN("Unsupported sensor [%d]", sensor_type); bitmask = 0x00; @@ -1761,31 +1765,51 @@ int ua_monitor_set_brightness_threshold(ua_monitor_h handle, return UA_ERROR_NONE; } -int ua_enable_low_power_mode(unsigned int sensors) +int ua_enable_low_power_mode(void) { FUNC_ENTRY; int ret; - ret = _ua_get_error_code(_uam_enable_low_power_mode(sensors)); + ret = _ua_get_error_code(_uam_set_low_power_mode(UA_SENSOR_ALL, true)); if (UA_ERROR_NONE != ret) { - UA_ERR("_uam_enable_low_power_mode failed"); + /* LCOV_EXCL_START */ + UA_ERR("_uam_set_low_power_mode failed"); return ret; + /* LCOV_EXCL_STOP */ } FUNC_EXIT; return UA_ERROR_NONE; } +int ua_disable_low_power_mode(void) +{ + FUNC_ENTRY; + int ret; + + ret = _ua_get_error_code(_uam_set_low_power_mode(UA_SENSOR_ALL, false)); + if (UA_ERROR_NONE != ret) { + /* LCOV_EXCL_START */ + UA_ERR("_uam_set_low_power_mode failed"); + return ret; + /* LCOV_EXCL_STOP */ + } + + FUNC_EXIT; + return UA_ERROR_NONE; +} -int ua_disable_low_power_mode(unsigned int sensors) +int ua_set_low_power_mode(unsigned int bitmask, bool on_off) { FUNC_ENTRY; int ret; - ret = _ua_get_error_code(_uam_disable_low_power_mode(sensors)); + ret = _ua_get_error_code(_uam_set_low_power_mode(bitmask, on_off)); if (UA_ERROR_NONE != ret) { - UA_ERR("_uam_disable_low_power_mode failed"); + /* LCOV_EXCL_START */ + UA_ERR("_uam_set_low_power_mode failed"); return ret; + /* LCOV_EXCL_STOP */ } FUNC_EXIT; diff --git a/test/uat-detections.c b/test/uat-detections.c index 4ee49b8..ce0476c 100644 --- a/test/uat-detections.c +++ b/test/uat-detections.c @@ -43,13 +43,14 @@ static char g_presence_conjunction_op[MENU_DATA_SIZE + 1] = {"1",}; /**< logical 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_lpm_enable_sensors[MENU_DATA_SIZE + 1] = {"30",}; /**< Low Power Mode enable sensors */ -static char g_lpm_disable_sensors[MENU_DATA_SIZE + 1] = {"30",}; /**< Low Power Mode disable sensors */ 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_scan_time_multiplier[MENU_DATA_SIZE + 1] = {0,}; /**< 10ms * what number */ +static char g_lpm_sensor[MENU_DATA_SIZE + 1] = "2"; /**< Sensor to set LPM */ +static char g_lpm_onoff[MENU_DATA_SIZE + 1] = "1"; /**< LPM mode on/off */ + static void __sensor_presence_detected_device(ua_device_h device_handle) { int ret; @@ -577,13 +578,10 @@ static int run_ua_enable_low_power_mode( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; - unsigned int lpm_enable_sensors = 0; - if (strlen(g_lpm_enable_sensors)) - lpm_enable_sensors = (unsigned int)strtol(g_lpm_enable_sensors, NULL, 10); msg("ua_enable_low_power_mode"); - ret = ua_enable_low_power_mode(lpm_enable_sensors); + ret = ua_enable_low_power_mode(); msg(" - ua_enable_low_power_mode() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); @@ -595,20 +593,40 @@ static int run_ua_disable_low_power_mode( MManager *mm, struct menu_data *menu) { int ret = UA_ERROR_NONE; - unsigned int lpm_disable_sensors = 0; - - if (strlen(g_lpm_disable_sensors)) - lpm_disable_sensors = (unsigned int)strtol(g_lpm_disable_sensors, NULL, 10); msg("ua_disable_low_power_mode"); - ret = ua_disable_low_power_mode(lpm_disable_sensors); + ret = ua_disable_low_power_mode(); msg(" - ua_disable_low_power_mode() ret: [0x%X] [%s]", ret, uat_get_error_str(ret)); return RET_SUCCESS; } + +static int run_ua_set_low_power_mode( + MManager *mm, struct menu_data *menu) +{ + int ret = UA_ERROR_NONE; + ua_sensor_e sensor = UA_SENSOR_ALL; + int onoff = 0; + + if (strlen(g_lpm_sensor)) + sensor = (unsigned char)strtol((g_lpm_sensor), NULL, 10); + + if (strlen(g_lpm_onoff)) + onoff = (unsigned char)strtol((g_lpm_onoff), NULL, 10); + + msg("run_ua_set_low_power_mode bitmask [%x]", sensor); + + ret =ua_set_low_power_mode(sensor, onoff == 1 ? true : false); + + msg(" - run_ua_set_low_power_mode() ret: [0x%X] [%s]", + ret, uat_get_error_str(ret)); + + return RET_SUCCESS; +} + #ifdef SUSPEND_RESUME_TEST static int run_device_power_request_poweroff( MManager *mm, struct menu_data *menu) @@ -669,22 +687,6 @@ static struct menu_data menu_ua_set_detection_window[] = { { NULL, NULL, }, }; -static struct menu_data menu_ua_enable_low_power_mode[] = { - { "1", "Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", - NULL, NULL, g_lpm_enable_sensors }, - { "2", "run", NULL, - run_ua_enable_low_power_mode, NULL }, - { NULL, NULL, }, -}; - -static struct menu_data menu_ua_disable_low_power_mode[] = { - { "1", "Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", - NULL, NULL, g_lpm_disable_sensors }, - { "2", "run", NULL, - run_ua_disable_low_power_mode, NULL }, - { NULL, NULL, }, -}; - static struct menu_data menu_ua_set_presence_condition[] = { { "1", "AND Bitmask (1:BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", NULL, NULL, g_presence_and_cond }, @@ -763,6 +765,16 @@ static struct menu_data menu_start_absence_presence[] = { { NULL, NULL, }, }; +static struct menu_data menu_set_low_power_mode[] = { + { "1", "(1 BT 2:BLE 4:Wi-Fi 8:Motion 16:Light 32:Audio)", + NULL, NULL, g_lpm_sensor }, + { "2", "(0:OFF 1:ON)", + NULL, NULL, g_lpm_onoff }, + { "3", "ua_set_low_power_mode", + NULL, run_ua_set_low_power_mode, NULL }, + { NULL, NULL, }, +}; + struct menu_data menu_ua_detections[] = { { "1", "ua_set_detection_cycle", menu_ua_set_detection_cycle, NULL, NULL}, @@ -791,11 +803,13 @@ struct menu_data menu_ua_detections[] = { NULL, run_ua_monitor_cancel_scan_devices, NULL }, { "12", "ua_enable_low_power_mode", - menu_ua_enable_low_power_mode, NULL, NULL }, + NULL, run_ua_enable_low_power_mode, NULL }, { "13", "ua_disable_low_power_mode", - menu_ua_disable_low_power_mode, NULL, NULL }, + NULL, run_ua_disable_low_power_mode, NULL }, + { "14", "ua_set_low_power_mode", + menu_set_low_power_mode, NULL, NULL }, #ifdef SUSPEND_RESUME_TEST - { "14", "request_power_off", + { "15", "request_power_off", NULL, run_device_power_request_poweroff, NULL }, #endif { NULL, NULL, }, |