From: jinwang.an Date: Mon, 3 Jun 2019 05:53:35 +0000 (+0900) Subject: [ACR-1409] Add SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED X-Git-Tag: submit/tizen/20191001.074704^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10dea44150f20a252d02663da0e560f574629da7;p=platform%2Fcore%2Fapi%2Fsystem-settings.git [ACR-1409] Add SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED Change-Id: I12615065585129f8a7b17c2cc66f4412df7dbe29 Signed-off-by: jinwang.an --- diff --git a/doc/system_settings_doc.h b/doc/system_settings_doc.h index 77d62b3..01f273b 100644 --- a/doc/system_settings_doc.h +++ b/doc/system_settings_doc.h @@ -69,5 +69,6 @@ * #SYSTEM_SETTINGS_KEY_AUTOMATIC_TIME_UPDATE * http://tizen.org/feature/accessibility.grayscale #SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE * http://tizen.org/feature/accessibility.negative #SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR +* http://tizen.org/feature/input.rotating_bezel #SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED * */ diff --git a/include/system_settings.h b/include/system_settings.h index c2ecb5f..1552817 100644 --- a/include/system_settings.h +++ b/include/system_settings.h @@ -94,6 +94,7 @@ typedef enum { SYSTEM_SETTINGS_KEY_DEVELOPER_OPTION_STATE, /**< (bool) Indicates whether developer option state is enabled on the device. (Since 5.0) */ SYSTEM_SETTINGS_KEY_ACCESSIBILITY_GRAYSCALE, /**< (bool) Indicates whether accessibility grayscale is enabled on the device. (Since 5.5) */ SYSTEM_SETTINGS_KEY_ACCESSIBILITY_NEGATIVE_COLOR, /**< (bool) Indicates whether accessibility negative color is enabled on the device. (Since 5.5) */ + SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, /**< (bool) Indicates whether rotary event is enabled on the device. (Since 5.5) */ SYSTEM_SETTINGS_KEY_MAX, } system_settings_key_e; diff --git a/include/system_settings_private.h b/include/system_settings_private.h index 5d68c48..2fd0a77 100644 --- a/include/system_settings_private.h +++ b/include/system_settings_private.h @@ -82,6 +82,7 @@ extern "C" #define SETTING_TELEPHONY_PATH "tizen.org/feature/network.telephony" #define SETTING_ACCESSIBILITY_GRAYSCALE_PATH "tizen.org/feature/accessibility.grayscale" #define SETTING_ACCESSIBILITY_NEGATIVE_PATH "tizen.org/feature/accessibility.negative" +#define SETTING_INPUT_ROTATING_BEZEL_PATH "tizen.org/feature/input.rotating_bezel" /** * @internal @@ -1699,6 +1700,46 @@ int system_setting_set_changed_callback_accessibility_negative_color(system_sett */ int system_setting_unset_changed_callback_accessibility_negative_color(system_settings_key_e key); +/** + * @internal + * @since_tizen 5.5 + * @return 0 on success, otherwise a negative error value + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + * @retval #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error + */ +int system_setting_get_rotary_event_enabled(system_settings_key_e key, void **value); + +/** + * @internal + * @since_tizen 5.5 + * @return 0 on success, otherwise a negative error value + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + * @retval #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error + */ +int system_setting_set_rotary_event_enabled(system_settings_key_e key, void *value); + +/** + * @internal + * @since_tizen 5.5 + * @return 0 on success, otherwise a negative error value + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + * @retval #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error + */ +int system_setting_set_changed_callback_rotary_event_enabled(system_settings_key_e key, system_settings_changed_cb callback, void *user_data); + +/** + * @internal + * @since_tizen 5.5 + * @return 0 on success, otherwise a negative error value + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + * @retval #SYSTEM_SETTINGS_ERROR_PERMISSION_DENIED Permission violation error + */ +int system_setting_unset_changed_callback_rotary_event_enabled(system_settings_key_e key); + /** * @internal * @since_tizen 3.0 @@ -1799,6 +1840,16 @@ int system_setting_feature_check_accessibility_grayscale(void *value); */ int system_setting_feature_check_accessibility_negative(void *value); +/** + * @internal + * @since_tizen 5.5 + * @return 0 on success, otherwise a negative error value + * @retval #SYSTEM_SETTINGS_ERROR_NONE Successful + * @retval #SYSTEM_SETTINGS_ERROR_IO_ERROR Internal I/O error + * @retval #SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED Not support system-settings API + */ +int system_setting_feature_check_wearable_profile(void *value); + /*// */ #ifdef __cplusplus diff --git a/src/system_setting_platform.c b/src/system_setting_platform.c index b7e76e2..f546270 100644 --- a/src/system_setting_platform.c +++ b/src/system_setting_platform.c @@ -2147,14 +2147,14 @@ int system_setting_unset_changed_callback_ads_id(system_settings_key_e key) int system_settings_feature_check_bool(char *path) { - bool profile_data = false; - int ret = system_info_get_platform_bool(path, &profile_data); + bool feature_data = false; + int ret = system_info_get_platform_bool(path, &feature_data); if (ret != SYSTEM_INFO_ERROR_NONE) { - SETTING_TRACE("Setting - reading profile string failed, %d", ret); + SETTING_TRACE("Setting - reading feature data failed, %d", ret); return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; } - ret = (profile_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + ret = (feature_data == true) ? SYSTEM_SETTINGS_ERROR_NONE : SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; return ret; @@ -2278,6 +2278,36 @@ int system_setting_feature_check_accessibility_negative(void *value) return ret; } +int system_setting_feature_check_wearable_profile(void *value) +{ + static bool first_query = true; + static int ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + + if (first_query == true) { + char *profile_data = NULL; + int rotary_feature = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + ret = system_info_get_platform_string(SETTING_PROFILE_PATH, &profile_data); + if (ret != SYSTEM_INFO_ERROR_NONE) { + SETTING_TRACE("Setting - reading profile string failed, %d", ret); + return SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + } + + rotary_feature = system_settings_feature_check_bool(SETTING_INPUT_ROTATING_BEZEL_PATH); + + if ((rotary_feature == SYSTEM_SETTINGS_ERROR_NONE) && profile_data && !strcmp(profile_data, "wearable")) + ret = SYSTEM_SETTINGS_ERROR_NONE; + else + ret = SYSTEM_SETTINGS_ERROR_NOT_SUPPORTED; + + if (profile_data) + free(profile_data); + + first_query = false; + } + + return ret; +} + /* LCOV_EXCL_START */ int system_setting_get_uds_state(system_settings_key_e key, void **value) { @@ -2605,3 +2635,49 @@ int system_setting_unset_changed_callback_accessibility_negative_color(system_se return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, 2); } +/* SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED */ +/* LCOV_EXCL_START */ +int system_setting_get_rotary_event_enabled(system_settings_key_e key, void **value) +{ + SETTING_TRACE_BEGIN; + bool vconf_value; + + if (system_setting_vconf_get_value_bool(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, &vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + *value = (void *)vconf_value; + + return SYSTEM_SETTINGS_ERROR_NONE; +} +/* LCOV_EXCL_STOP */ + +/* LCOV_EXCL_START */ +int system_setting_set_rotary_event_enabled(system_settings_key_e key, void *value) +{ + SETTING_TRACE_BEGIN; + bool *vconf_value; + vconf_value = (bool *)value; + if (system_setting_vconf_set_value_bool(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, *vconf_value)) { + return SYSTEM_SETTINGS_ERROR_IO_ERROR; + } + + return SYSTEM_SETTINGS_ERROR_NONE; +} +/* LCOV_EXCL_STOP */ + +/* LCOV_EXCL_START */ +int system_setting_set_changed_callback_rotary_event_enabled(system_settings_key_e key, system_settings_changed_cb callback, void *user_data) +{ + SETTING_TRACE_BEGIN; + return system_setting_vconf_set_changed_cb(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, 3, user_data); +} +/* LCOV_EXCL_STOP */ + +/* LCOV_EXCL_START */ +int system_setting_unset_changed_callback_rotary_event_enabled(system_settings_key_e key) +{ + SETTING_TRACE_BEGIN; + return system_setting_vconf_unset_changed_cb(VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, 3); +} +/* LCOV_EXCL_STOP */ + diff --git a/src/system_settings.c b/src/system_settings.c index 5515fab..491d061 100644 --- a/src/system_settings.c +++ b/src/system_settings.c @@ -596,6 +596,21 @@ system_setting_s system_setting_table[] = { { NULL, 0 }, /* changed callabck list */ NULL, /* user data */ }, + { + SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, + SYSTEM_SETTING_DATA_TYPE_BOOL, + system_setting_get_rotary_event_enabled, + system_setting_set_rotary_event_enabled, + system_setting_set_changed_callback_rotary_event_enabled, + system_setting_unset_changed_callback_rotary_event_enabled, + NULL, + NULL, /* ADD */ + NULL, /* DEL */ + NULL, /* LIST */ + system_setting_feature_check_wearable_profile, /* feature check */ + { NULL, 0 }, /* changed callabck list */ + NULL, /* user data */ + }, { SYSTEM_SETTINGS_MAX, -1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, { NULL, 0 }, NULL } diff --git a/src/system_settings_vconf.c b/src/system_settings_vconf.c index 7187977..03639e7 100644 --- a/src/system_settings_vconf.c +++ b/src/system_settings_vconf.c @@ -69,6 +69,7 @@ static char *_system_settings_vconf_table[] = { VCONFKEY_SETAPPL_DEVELOPER_OPTION_STATE, VCONFKEY_SETAPPL_ACCESSIBILITY_GREYSCALE, VCONFKEY_SETAPPL_ACCESSIBILITY_HIGH_CONTRAST, + VCONFKEY_SETAPPL_ROTARY_EVENT_ENABLED_BOOL, "MAX" }; diff --git a/unit_test/src/unit_test.c b/unit_test/src/unit_test.c index 8c8eeee..7785fdc 100644 --- a/unit_test/src/unit_test.c +++ b/unit_test/src/unit_test.c @@ -679,6 +679,21 @@ RETTYPE utc_system_settings_get_value_bool_p13(void) RETURN(0); } +/** + * @testcase utc_system_settings_get_value_bool_p14 + * @since_tizen 5.5 + * @description check if SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED is able to get the property + */ +RETTYPE utc_system_settings_get_value_bool_p14(void) +{ + bool value = false; + + int retcode = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, &value); + my_assert_ret(retcode); + + RETURN(0); +} + /** * @testcase utc_system_settings_set_changed_cb_p1 @@ -2371,6 +2386,37 @@ RETTYPE utc_system_settings_set_value_bool_p11(void) RETURN(0); } +/** + * @testcase utc_system_settings_set_value_bool_p12 + * @since_tizen 5.5 + * @description check if SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED is able to set the property. + * check if SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED is able to get the property. + */ +RETTYPE utc_system_settings_set_value_bool_p12(void) +{ + int ret; + + /* get current state */ + bool cur_state = false; + bool ret_state = false; + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, &cur_state); + my_assert_ret(ret); + + bool state = !cur_state; + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, state); + my_assert_ret(ret); + + /* check current state */ + ret = system_settings_get_value_bool(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, &ret_state); + my_assert_ret_eq_bool(ret, state, ret_state); + + /* roll back */ + ret = system_settings_set_value_bool(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, cur_state); + my_assert_ret(ret); + + RETURN(0); +} + /** * @testcase utc_system_settings_set_value_int_p2 * @since_tizen 2.3 @@ -2979,6 +3025,40 @@ RETTYPE utc_system_settings_unset_changed_cb_p40(void) RETURN(0); } +/** + * @testcase utc_system_settings_set_changed_cb_p43 + * @since_tizen 5.5 + * @description check if SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED is able to set the callback for change-notification. + */ +RETTYPE utc_system_settings_set_changed_cb_p43(void) +{ + system_settings_changed_cb callback = get_system_settings_test_callback(); + int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, + callback, NULL); + my_assert_ret(retcode); + + RETURN(0); +} + + +/** + * @testcase utc_system_settings_unset_changed_cb_p42 + * @since_tizen 5.5 + * @description check if SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED is able to set the callback for change-notification. + * check if SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED is able to unset the callback for change-notification. + */ +RETTYPE utc_system_settings_unset_changed_cb_p42(void) +{ + system_settings_changed_cb callback = get_system_settings_test_callback(); + int retcode = system_settings_set_changed_cb(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED, + callback, NULL); + + retcode = system_settings_unset_changed_cb(SYSTEM_SETTINGS_KEY_ROTARY_EVENT_ENABLED); + my_assert_ret(retcode); + + RETURN(0); +} + void unittest_api() { /* hook up your test functions */ @@ -3011,6 +3091,7 @@ void unittest_api() add_test_func("/utc_system_settings_get_value_bool_p11", utc_system_settings_get_value_bool_p11); add_test_func("/utc_system_settings_get_value_bool_p12", utc_system_settings_get_value_bool_p12); add_test_func("/utc_system_settings_get_value_bool_p13", utc_system_settings_get_value_bool_p13); + add_test_func("/utc_system_settings_get_value_bool_p14", utc_system_settings_get_value_bool_p14); add_test_func("/utc_system_settings_get_value_bool_n", utc_system_settings_get_value_bool_n); add_test_func("/utc_system_settings_get_value_int_p1", utc_system_settings_get_value_int_p1); add_test_func("/utc_system_settings_get_value_int_p2", utc_system_settings_get_value_int_p2); @@ -3089,6 +3170,8 @@ void unittest_api() g_test_add_func("/utc_system_settings_unset_changed_cb_p38", utc_system_settings_unset_changed_cb_p38); g_test_add_func("/utc_system_settings_set_changed_cb_p41", utc_system_settings_set_changed_cb_p41); g_test_add_func("/utc_system_settings_unset_changed_cb_p40", utc_system_settings_unset_changed_cb_p40); + g_test_add_func("/utc_system_settings_set_changed_cb_p43", utc_system_settings_set_changed_cb_p43); + g_test_add_func("/utc_system_settings_unset_changed_cb_p42", utc_system_settings_unset_changed_cb_p42); g_test_add_func("/utc_system_settings_add_ringtone_list_p1", utc_system_settings_add_ringtone_list_p1); g_test_add_func("/utc_system_settings_delete_ringtone_list_p1", utc_system_settings_delete_ringtone_list_p1); add_test_func("/utc_system_settings_set_value_string_p1", utc_system_settings_set_value_string_p1); @@ -3113,6 +3196,7 @@ void unittest_api() add_test_func("/utc_system_settings_set_value_bool_p9", utc_system_settings_set_value_bool_p9); add_test_func("/utc_system_settings_set_value_bool_p10", utc_system_settings_set_value_bool_p10); add_test_func("/utc_system_settings_set_value_bool_p11", utc_system_settings_set_value_bool_p11); + add_test_func("/utc_system_settings_set_value_bool_p12", utc_system_settings_set_value_bool_p12); add_test_func("/utc_system_settings_set_value_int_p2", utc_system_settings_set_value_int_p2); add_test_func("/utc_system_settings_set_value_string_n6", utc_system_settings_set_value_string_n6); g_test_add_func("/utc_system_settings_unset_changed_cb_n", utc_system_settings_unset_changed_cb_n);