diff options
-rwxr-xr-x | data/org.tizen.w-home.xml.in | 2 | ||||
-rwxr-xr-x | inc/moments/moments_view_edje_conf.h | 4 | ||||
-rwxr-xr-x | src/moments/moments_control_view.c | 82 | ||||
-rwxr-xr-x | test/feature_test/group_feature_moments_control_button_status_behavior.c | 119 | ||||
-rwxr-xr-x | test/test_function.h | 1 |
5 files changed, 196 insertions, 12 deletions
diff --git a/data/org.tizen.w-home.xml.in b/data/org.tizen.w-home.xml.in index c56380f..2ddc4c8 100755 --- a/data/org.tizen.w-home.xml.in +++ b/data/org.tizen.w-home.xml.in @@ -19,6 +19,7 @@ <privilege>http://tizen.org/privilege/contact.read</privilege> <privilege>http://tizen.org/privilege/appmanager.launch</privilege> <privilege>http://tizen.org/privilege/appmanager.kill</privilege> + <privilege>http://tizen.org/privilege/appmanager.kill.bgapp</privilege> <privilege>http://tizen.org/privilege/widget.viewer</privilege> <privilege>http://tizen.org/privilege/packagemanager.admin</privilege> <privilege>http://tizen.org/privilege/packagemanager.info</privilege> @@ -26,5 +27,6 @@ <privilege>http://tizen.org/privilege/telephony</privilege> <privilege>http://tizen.org/privilege/network.get</privilege> <privilege>http://tizen.org/privilege/systemsettings.admin</privilege> + <privilege>http://tizen.org/privilege/volume.set</privilege> </privileges> </manifest> diff --git a/inc/moments/moments_view_edje_conf.h b/inc/moments/moments_view_edje_conf.h index 69cf3fc..ec5fed5 100755 --- a/inc/moments/moments_view_edje_conf.h +++ b/inc/moments/moments_view_edje_conf.h @@ -44,8 +44,8 @@ #define CONTROLS_GROUP_ICON_AND_TEXT "controls_group_icon_and_text" #define CONTROLS_GROUP_ICON_AND_BAR "controls_group_icon_and_bar" #define CONTROLS_ICON "controls_icon" -#define CONTROLS_TEXT "controls_TEXT" -#define CONTROLS_BAR "controls_BAR" +#define CONTROLS_TEXT "controls_text" +#define CONTROLS_BAR "controls_bar" #define SIGNAL_SOURCE "signal_source" #define SIGNAL_MOMENTS_FREEZE_TOUCH "signal_moments_freeze_touch" diff --git a/src/moments/moments_control_view.c b/src/moments/moments_control_view.c index d033c69..2ed4b43 100755 --- a/src/moments/moments_control_view.c +++ b/src/moments/moments_control_view.c @@ -18,6 +18,7 @@ #include <Elementary.h> #include <efl_extension.h> #include <vconf.h> +#include <sound_manager.h> #include "log.h" #include "util.h" @@ -29,6 +30,7 @@ #include "moments/moments_control_view.h" #define CONTROL_BUTTON_LAYOUT_EDJE EDJE_DIR"/circle/moments_control_button_layout.edj" +#define SETTING_PKG_NAME "org.tizen.watch-setting" static struct __control_view_s { Evas_Object *base_win; @@ -60,6 +62,10 @@ static bool __is_with_phone(void); static bool __is_with_bt_device(void); static void __do_not_disturb_pressed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); static void __flight_mode_pressed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void __volume_pressed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void __do_not_disturb_status_changed_cb(keynode_t *node, void *user_data); +static void __flight_mode_status_changed_cb(keynode_t *node, void *user_data); +static void __volume_status_changed_cb(sound_type_e type, unsigned int volume, void *data); const char *controls_btn_group_name[MOMENTS_CONTROLS_BTN_TYPE_MAX] = { CONTROLS_GROUP_ICON_ONLY, @@ -69,8 +75,8 @@ const char *controls_btn_group_name[MOMENTS_CONTROLS_BTN_TYPE_MAX] = { control_info_t control_button_list[MOMENTS_CONTROLS_MAX] = { {MOMENTS_CONTROLS_DO_NOT_DISTURB, MOMENTS_CONTROLS_BTN_TYPE_ICON_AND_BAR, "do not disturb", "donotdisturb.png", 0, "", 0, __do_not_disturb_pressed_cb, NULL}, - {MOMENTS_CONTROLS_VOLUME, MOMENTS_CONTROLS_BTN_TYPE_ICON_AND_TEXT, "volume", "multimedia.png", 0, "10", 0, NULL, NULL}, - {MOMENTS_CONTROLS_FLIGHT_MODE, MOMENTS_CONTROLS_BTN_TYPE_ICON_AND_BAR, "flight mode", "flight_mode.png", 0, "", 0, __flight_mode_pressed_cb, NULL}, + {MOMENTS_CONTROLS_VOLUME, MOMENTS_CONTROLS_BTN_TYPE_ICON_AND_TEXT, "volume", "multimedia.png", 0, "10", 0, __volume_pressed_cb, NULL}, + {MOMENTS_CONTROLS_FLIGHT_MODE, MOMENTS_CONTROLS_BTN_TYPE_ICON_AND_BAR, "flight mode", "flight_mode.png", 0, "", 0, __flight_mode_pressed_cb, NULL}, {MOMENTS_CONTROLS_BRIGHTNESS, MOMENTS_CONTROLS_BTN_TYPE_ICON_AND_TEXT, "brightness", "brightness.png", 0, "7", 0, NULL, NULL}, {MOMENTS_CONTROLS_MUSIC_PLAYER, MOMENTS_CONTROLS_BTN_TYPE_ICON_ONLY, "music player", "music.png", 0, "7", 0, NULL, NULL}, {MOMENTS_CONTROLS_CALL_FORWARDING, MOMENTS_CONTROLS_BTN_TYPE_ICON_ONLY, "call forwarding", "call_forwarding.png", 0, "7", 0, NULL, NULL}, @@ -113,6 +119,9 @@ void moments_control_init(void) { __update_control_state(); __update_control_view(); + __do_not_disturb_status_changed_cb(NULL, NULL); + __flight_mode_status_changed_cb(NULL, NULL); + __volume_status_changed_cb(0, NULL, NULL); } void moments_control_fini(void) @@ -167,7 +176,7 @@ __fail: return NULL; } -static void __change_do_not_disturb_button_cb(keynode_t *node, void *user_data) +static void __do_not_disturb_status_changed_cb(keynode_t *node, void *user_data) { int is_do_not_disturb = false; @@ -179,7 +188,7 @@ static void __change_do_not_disturb_button_cb(keynode_t *node, void *user_data) } } -static void __change_flight_mode_button_cb(keynode_t *node, void *user_data) +static void __flight_mode_status_changed_cb(keynode_t *node, void *user_data) { int is_flight_mode = false; @@ -191,6 +200,37 @@ static void __change_flight_mode_button_cb(keynode_t *node, void *user_data) } } +static int __get_current_device_volume_level() +{ + int level = 0; + + if(moments_check_is_3g_device()) { + sound_manager_get_volume(SOUND_TYPE_RINGTONE, &level); + _D("ringtone volume value: %d", level); + } else { + sound_manager_get_volume(SOUND_TYPE_MEDIA, &level); + _D("media volume value: %d", level); + } + + return level; +} + +static void __volume_status_changed_cb(sound_type_e type, unsigned int volume, void *data) +{ + Evas_Object *icon = elm_object_part_content_get(control_button_list[MOMENTS_CONTROLS_VOLUME].button_layout, CONTROLS_ICON); + elm_object_part_content_unset(control_button_list[MOMENTS_CONTROLS_VOLUME].button_layout, CONTROLS_ICON); + + int level = __get_current_device_volume_level(); + if (level == 0) elm_image_file_set(icon, IMAGEDIR"/multimedia_off.png", NULL); + else elm_image_file_set(icon, IMAGEDIR"/multimedia.png", NULL); + + elm_object_part_content_set(control_button_list[MOMENTS_CONTROLS_VOLUME].button_layout, CONTROLS_ICON, icon); + + char volume_text[3]; + snprintf(volume_text, sizeof(volume_text), "%d", level); + elm_object_part_text_set(control_button_list[MOMENTS_CONTROLS_VOLUME].button_layout, CONTROLS_TEXT, volume_text); +} + control_info_t *moments_control_create_button(Evas_Object *base_layout, int button_id) { control_info_t *button = (control_info_t *)malloc(sizeof(control_info_t)); @@ -209,13 +249,18 @@ control_info_t *moments_control_create_button(Evas_Object *base_layout, int butt switch (button_id) { case MOMENTS_CONTROLS_DO_NOT_DISTURB: - if (vconf_notify_key_changed(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, __change_do_not_disturb_button_cb, NULL) < 0) { - _E("Failed to register the changed_apps_order callback"); + if (vconf_notify_key_changed(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, __do_not_disturb_status_changed_cb, NULL) < 0) { + _E("Failed to register the __do_not_disturb_status_changed_cb callback"); + } + break; + case MOMENTS_CONTROLS_VOLUME: + if (sound_manager_set_volume_changed_cb(__volume_status_changed_cb, NULL) != SOUND_MANAGER_ERROR_NONE) { + _E("Failed to register the __volume_status_changed_cb callback"); } break; case MOMENTS_CONTROLS_FLIGHT_MODE: - if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, __change_flight_mode_button_cb, NULL) < 0) { - _E("Failed to register the changed_apps_order callback"); + if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, __flight_mode_status_changed_cb, NULL) < 0) { + _E("Failed to register the __flight_mode_status_changed_cb callback"); } break; default: @@ -235,10 +280,13 @@ void moments_control_destroy_button(control_info_t *button_info) switch (button_info->index) { case MOMENTS_CONTROLS_DO_NOT_DISTURB: - vconf_ignore_key_changed(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, __change_do_not_disturb_button_cb); + vconf_ignore_key_changed(VCONFKEY_SETAPPL_BLOCKMODE_WEARABLE_BOOL, __do_not_disturb_status_changed_cb); + break; + case MOMENTS_CONTROLS_VOLUME: + sound_manager_unset_volume_changed_cb(); break; case MOMENTS_CONTROLS_FLIGHT_MODE: - vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, __change_flight_mode_button_cb); + vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, __flight_mode_status_changed_cb); break; default: break; @@ -582,6 +630,12 @@ static void __flight_mode_pressed_cb(void *data, Evas *e, Evas_Object *obj, void } } +static void __volume_pressed_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + moments_hide(); + util_launch_app(SETTING_PKG_NAME, "launch-type", "volume"); +} + #include "test.h" #if TEST_MODE Eina_List *__t__get_moments_control_button_list(void) @@ -650,5 +704,13 @@ void __t__flight_mode_popup_ok_cb(void *data, Evas_Object *obj, void *event_info { __flight_mode_popup_ok_cb(data, obj, event_info); } +void __t__set_volume_level(int level) +{ + if(moments_check_is_3g_device()) { + sound_manager_set_volume(SOUND_TYPE_RINGTONE, level); + } else { + sound_manager_set_volume(SOUND_TYPE_MEDIA, level); + } +} #endif diff --git a/test/feature_test/group_feature_moments_control_button_status_behavior.c b/test/feature_test/group_feature_moments_control_button_status_behavior.c index 5f6df97..608ee89 100755 --- a/test/feature_test/group_feature_moments_control_button_status_behavior.c +++ b/test/feature_test/group_feature_moments_control_button_status_behavior.c @@ -12,6 +12,7 @@ #include <Elementary.h> #include <app.h> +#include <app_manager.h> static struct { unit_group_t * group; @@ -29,6 +30,7 @@ static void __group_set_up(void) __t__update_control_view(); __t__set_do_not_disturb_state(false); __t__set_flight_mode_state(false); + __t__set_volume_level(5); TEST_GROUP_SET_UP_DONE(0.0, s_info.group); } @@ -346,6 +348,118 @@ unit_case_func_t __continue_check_ok_button_clicked_on_flight_mode_popup(void * TEST_CASE_DONE(s_info.group); } +unit_case_func_t __continue_check_volume(void * data); +unit_case_func_t __case_check_volume(void * data) +{ + Eina_List *button_list = __t__get_moments_control_button_list(); + TEST_ASSERT_TRUE_UPGRADE(button_list != NULL); + + Eina_List *l; + control_info_t *button = NULL; + + EINA_LIST_FOREACH(button_list, l, button) { + if (button->index == MOMENTS_CONTROLS_VOLUME) { + break; + } + } + + TEST_ASSERT_TRUE_UPGRADE(button != NULL); + s_info.current_button = button; + + const char *volume_text = elm_object_part_text_get(button->button_layout, CONTROLS_TEXT); + TEST_ASSERT_EQUAL_STRING_UPGRADE("5", volume_text); + + Evas_Object *icon = elm_object_part_content_get(button->button_layout, CONTROLS_ICON); + const char *icon_image = NULL; + elm_image_file_get(icon, &icon_image, NULL); + + TEST_ASSERT_TRUE_UPGRADE(icon_image != NULL); + TEST_ASSERT_EQUAL_STRING_UPGRADE(IMAGEDIR"/multimedia.png", icon_image); + + TEST_ASSERT_TRUE_UPGRADE(button->pressed != NULL); + + button->pressed(NULL, NULL, NULL, NULL); + + TEST_CASE_CONTINUE(0.3, __continue_check_volume, NULL); +} + +unit_case_func_t __continue_check_volume(void * data) +{ + TEST_ASSERT_TRUE_UPGRADE(moments_get_visible() == false); + + app_context_h setting_app_context = NULL; + int ret = APP_MANAGER_ERROR_NONE; + + ret = app_manager_get_app_context("org.tizen.watch-setting", &setting_app_context); + TEST_ASSERT_EQUAL_INT_UPGRADE(APP_MANAGER_ERROR_NONE, ret); + + app_state_e setting_app_state = APP_STATE_UNDEFINED; + ret = app_context_get_app_state(setting_app_context , &setting_app_state); + TEST_ASSERT_EQUAL_INT_UPGRADE(APP_MANAGER_ERROR_NONE, ret); + + TEST_ASSERT_EQUAL_INT_UPGRADE(APP_STATE_FOREGROUND, setting_app_state); + + app_context_h home_app_context = NULL; + ret = app_manager_get_app_context(PACKAGE, &home_app_context); + TEST_ASSERT_EQUAL_INT_UPGRADE(APP_MANAGER_ERROR_NONE, ret); + + ret = app_manager_resume_app(home_app_context); + TEST_ASSERT_EQUAL_INT_UPGRADE(APP_MANAGER_ERROR_NONE, ret); + + ret = app_manager_request_terminate_bg_app(setting_app_context); + TEST_ASSERT_EQUAL_INT_UPGRADE(APP_MANAGER_ERROR_NONE, ret); + + ret = app_context_destroy(home_app_context); + TEST_ASSERT_EQUAL_INT_UPGRADE(APP_MANAGER_ERROR_NONE, ret); + + ret = app_context_destroy(setting_app_context); + TEST_ASSERT_EQUAL_INT_UPGRADE(APP_MANAGER_ERROR_NONE, ret); + + TEST_CASE_DONE(s_info.group); +} + +unit_case_func_t __case_check_volume_sound(void * data) +{ + const char *volume_text = elm_object_part_text_get(s_info.current_button->button_layout, CONTROLS_TEXT); + + if (strcmp(volume_text, "2") != 0) { + __t__set_volume_level(2); + TEST_CASE_CONTINUE(0.3, __case_check_volume_sound, NULL); + } + + TEST_ASSERT_EQUAL_STRING_UPGRADE("2", volume_text); + + Evas_Object *icon = elm_object_part_content_get(s_info.current_button->button_layout, CONTROLS_ICON); + const char *icon_image = NULL; + elm_image_file_get(icon, &icon_image, NULL); + + TEST_ASSERT_TRUE_UPGRADE(icon_image != NULL); + TEST_ASSERT_EQUAL_STRING_UPGRADE(IMAGEDIR"/multimedia.png", icon_image); + + TEST_CASE_DONE(s_info.group); +} + +unit_case_func_t __case_check_volume_mute(void * data) +{ + const char *volume_text = elm_object_part_text_get(s_info.current_button->button_layout, CONTROLS_TEXT); + + if (strcmp(volume_text, "0") != 0) { + __t__set_volume_level(0); + TEST_CASE_CONTINUE(0.3, __case_check_volume_mute, NULL); + } + + TEST_ASSERT_EQUAL_STRING_UPGRADE("0", volume_text); + + Evas_Object *icon = elm_object_part_content_get(s_info.current_button->button_layout, CONTROLS_ICON); + const char *icon_image = NULL; + elm_image_file_get(icon, &icon_image, NULL); + + TEST_ASSERT_TRUE_UPGRADE(icon_image != NULL); + TEST_ASSERT_EQUAL_STRING_UPGRADE(IMAGEDIR"/multimedia_off.png", icon_image); + + TEST_CASE_DONE(s_info.group); +} + void group_feature_moments_control_button_status_behavior(unit_group_t * group) { s_info.group = group; @@ -353,6 +467,7 @@ void group_feature_moments_control_button_status_behavior(unit_group_t * group) s_info.group->tear_down = __tear_down; TEST_GROUP_SET_UP(s_info.group, __group_set_up); + TEST_CASE_ADD(s_info.group, __case_check_do_not_disturb, NULL); TEST_CASE_ADD(s_info.group, __case_check_cancel_button_clicked_on_do_not_disturb_popup, NULL); TEST_CASE_ADD(s_info.group, __case_check_ok_button_clicked_on_do_not_disturb_popup, NULL); @@ -361,6 +476,10 @@ void group_feature_moments_control_button_status_behavior(unit_group_t * group) TEST_CASE_ADD(s_info.group, __case_check_cancel_button_clicked_on_flight_mode_popup, NULL); TEST_CASE_ADD(s_info.group, __case_check_ok_button_clicked_on_flight_mode_popup, NULL); + TEST_CASE_ADD(s_info.group, __case_check_volume, NULL); + TEST_CASE_ADD(s_info.group, __case_check_volume_sound, NULL); + TEST_CASE_ADD(s_info.group, __case_check_volume_mute, NULL); + TEST_GROUP_TEAR_DOWN(s_info.group, __group_tear_down); TEST_GROUP_RUN(s_info.group); diff --git a/test/test_function.h b/test/test_function.h index ea63c82..05a40bf 100755 --- a/test/test_function.h +++ b/test/test_function.h @@ -69,6 +69,7 @@ extern void __t__set_flight_mode_state(bool state); extern void __t__flight_mode_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info); extern void __t__flight_mode_popup_ok_cb(void *data, Evas_Object *obj, void *event_info); +extern void __t__set_volume_level(int level); #endif #endif |