Added condition for connection status 61/135861/1
authorjin0.kim <jin0.kim@samsung.com>
Tue, 27 Jun 2017 05:56:11 +0000 (14:26 +0830)
committerjin0.kim <jin0.kim@samsung.com>
Tue, 27 Jun 2017 05:56:11 +0000 (14:26 +0830)
Change-Id: Ie627eb56645b192b2013ced866db7d10075eca0c

inc/moments/moments.h
src/moments/moments_control_view.c
src/moments/moments_manager.c
src/moments/moments_view.c
test/feature_test/group_feature_moments_center_layout_show.c
test/feature_test/group_feature_moments_controls_state.c
test/test_function.h

index ae52d60f161915920e772f44f84fc965fcb6153b..2e3d253dd03ce7e30f4a1b2ec60790a626a4d632 100755 (executable)
 bool moments_get_visible(void);
 bool moments_get_is_on_initialization(void);
 bool moments_check_is_3g_device(void);
+bool moments_check_is_bt_device(void);
+bool moments_check_is_connected_remotely(void);
+bool moments_check_is_with_phone_via_bluetooth(void);
+bool moments_check_is_call_fwd_enable(void);
+bool moments_check_is_music_enable(void);
 
 void moments_init(Evas_Object *win, Evas_Object *bg_scroller);
 void moments_fini(void);
index 4d8f3d78fc495675ecf7537c05d3ae4917b2a8d4..d4c4f5a21adcb4e667213247948c732f37b3ae7d 100755 (executable)
@@ -43,9 +43,7 @@ static void __update_control_view(void);
 static void __set_state_stand_alone(void);
 static void __set_state_3g_with_phone_connection(void);
 static void __set_state_bt_with_phone_connection(void);
-static bool __is_stand_alone(void);
-static bool __is_with_phone(void);
-static bool __is_with_bt_device(void);
+static void __bluetooth_state_changed_cb(keynode_t *node, void *user_data);
 
 
 const char *controls_btn_group_name[MOMENTS_CONTROLS_BTN_TYPE_MAX] = {
@@ -83,11 +81,13 @@ Evas_Object *moments_control_view_create(Evas_Object *base_layout)
 
        s_info.control_layout = control_layout;
 
+       vconf_notify_key_changed(VCONFKEY_WMS_WMANAGER_CONNECTED, __bluetooth_state_changed_cb, NULL);
        return control_layout;
 }
 
 void moments_control_view_destroy(void)
 {
+       vconf_ignore_key_changed(VCONFKEY_WMS_WMANAGER_CONNECTED, __bluetooth_state_changed_cb);
        if (s_info.control_layout) {
                /*FIXME : unset*/
                evas_object_del(s_info.control_layout);
@@ -109,11 +109,17 @@ void moments_control_fini(void)
 
 }
 
+static void __bluetooth_state_changed_cb(keynode_t *node, void *user_data)
+{
+
+       moments_control_init();
+       moments_view_update();
+}
 static void __update_control_state(void)
 {
-       if (__is_with_bt_device()) __set_state_bt_with_phone_connection();
-       else if (__is_with_phone()) __set_state_3g_with_phone_connection();
-       else if (__is_stand_alone()) __set_state_stand_alone();
+       if (moments_check_is_bt_device()) __set_state_bt_with_phone_connection();
+       else if (moments_check_is_with_phone_via_bluetooth()) __set_state_3g_with_phone_connection();
+       else __set_state_stand_alone();
 }
 
 static int move_count = 0;
@@ -133,7 +139,7 @@ static void __control_button_up_cb(void *data, Evas *e, Evas_Object *obj, void *
 
        if (move_count < 10) {
                control_info_t *btn_info = (control_info_t *)data;
-               if (btn_info != NULL) btn_info->pressed(NULL, NULL, NULL, NULL);
+               if (btn_info != NULL && btn_info->pressed != NULL) btn_info->pressed(NULL, NULL, NULL, NULL);
        }
 
        move_count = 0;
@@ -357,11 +363,15 @@ static void __set_state_3g_with_phone_connection(void)
        control_info_t *flight_mode_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_FLIGHT_MODE);
        moments_control_push_to_button_list(flight_mode_button);
 
-       control_info_t *call_forwarding_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_CALL_FORWARDING);
-       moments_control_push_to_button_list(call_forwarding_button);
+       if (moments_check_is_call_fwd_enable()) {
+               control_info_t *call_forwarding_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_CALL_FORWARDING);
+               moments_control_push_to_button_list(call_forwarding_button);
+       }
 
-       control_info_t *music_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_MUSIC_PLAYER);
-       moments_control_push_to_button_list(music_button);
+       if (moments_check_is_music_enable()) {
+               control_info_t *music_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_MUSIC_PLAYER);
+               moments_control_push_to_button_list(music_button);
+       }
 }
 
 static void __set_state_bt_with_phone_connection(void)
@@ -380,26 +390,12 @@ static void __set_state_bt_with_phone_connection(void)
        control_info_t *flight_mode_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_FLIGHT_MODE);
        moments_control_push_to_button_list(flight_mode_button);
 
-       control_info_t *music_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_MUSIC_PLAYER);
-       moments_control_push_to_button_list(music_button);
-}
-
-static bool __is_stand_alone(void)
-{
-       return !__is_with_phone();
-}
-
-static bool __is_with_phone(void)
-{
-       return false;
-}
-
-static bool __is_with_bt_device(void)
-{
-       return !moments_check_is_3g_device();
+       if (moments_check_is_music_enable()) {
+               control_info_t *music_button = moments_control_create_button(s_info.control_layout, MOMENTS_CONTROLS_MUSIC_PLAYER);
+               moments_control_push_to_button_list(music_button);
+       }
 }
 
-
 #include "test.h"
 #if TEST_MODE
 Eina_List *__t__get_moments_control_button_list(void)
index dc04deb19610bd80381d5bf521b2bf5ac0324e94..97d183adb78ba1cc534dc565f95ddc258a3db9bd 100755 (executable)
@@ -22,6 +22,7 @@
 #include <net_connection.h>
 #include <runtime_info.h>
 #include <vconf.h>
+#include <package_manager.h>
 
 #include "log.h"
 #include "moments/moments.h"
@@ -31,6 +32,7 @@
 #include "scroller.h"
 #include "key.h"
 #include "common_conf.h"
+#include "app_log.h"
 
 static struct __manager_s {
        Evas_Object *win;
@@ -47,6 +49,7 @@ static struct __manager_s {
 };
 
 static telephony_handle_list_s handle_list;
+#define MUSIC_PKG_NAME "org.tizen.w-music-player"
 
 static key_cb_ret_e __back_key_cb(void *data);
 static void __initialize_status_view(void);
@@ -91,6 +94,66 @@ bool moments_check_is_3g_device(void)
        return is_3g;
 }
 
+bool moments_check_is_bt_device(void)
+{
+       return !moments_check_is_3g_device();
+}
+
+bool moments_check_is_connected_remotely(void)
+{
+       return false; /* FIXME - Not supported */
+}
+
+bool moments_check_is_with_phone_via_bluetooth(void)
+{
+       int is_bt_enable = 0;
+
+       if (vconf_get_int(VCONFKEY_BT_STATUS, &is_bt_enable) != 0) {
+               _E("Failed to get vconfkey : %s", VCONFKEY_BT_STATUS);
+               return false;
+       }
+
+       if (is_bt_enable) {
+               int sap_connected = 0;
+               if (vconf_get_int(VCONFKEY_WMS_WMANAGER_CONNECTED, &sap_connected) < 0) {
+                       _E("Failed to get vconfkey : %s", VCONFKEY_WMS_WMANAGER_CONNECTED);
+                       return false;
+               }
+
+               if (sap_connected) {
+                       return true;
+               }
+       }
+
+       return false;
+}
+
+bool moments_check_is_call_fwd_enable(void)
+{
+       return true;
+       int status = 0;
+       if (vconf_get_int(VCONFKEY_TELEPHONY_CALL_FORWARD_STATE, &status) < 0) {
+               _E("Failed to get vconfkey : %s", VCONFKEY_TELEPHONY_CALL_FORWARD_STATE);
+               return false;
+       }
+       return status;
+}
+
+bool moments_check_is_music_enable(void)
+{
+       return true;
+       package_info_h package_info = NULL;
+
+       if (package_info_create(MUSIC_PKG_NAME, &package_info) != PACKAGE_MANAGER_ERROR_NONE) {
+               _E("Failed to get music-player info");
+               return false;
+       }
+
+       package_info_destroy(package_info);
+
+       return true;
+}
+
 bool moments_get_is_on_initialization(void)
 {
        return s_info.on_initialization;
index ff74f3c1c6de663e86785df5174d34647496064d..ab994e550d9e577cc31ad4bde069a77ec6087026 100755 (executable)
@@ -84,7 +84,7 @@ static Evas_Object *__create_base_layout(Evas_Object *parent);
 static Evas_Object *__create_base_size_setter(Evas_Object *base_layout);
 static Evas_Object *__create_center_layout(Evas_Object *base_layout);
 static void __adjust_content_alpha(void *data, Evas *e, Evas_Object *obj, void *event_info);
-static void __set_center_contents(void);
+static void __set_center_contents(moments_connection_status_e status);
 
 static void __put_down(void);
 static void __freeze_touch_event(void);
@@ -232,11 +232,6 @@ void moments_view_move(int from_y, int to_y)
 }
 
 
-void moments_view_update()
-{
-       __set_center_contents();
-}
-
 void moments_view_put_down(void)
 {
        _D("%s", __func__);
@@ -244,6 +239,15 @@ void moments_view_put_down(void)
        __put_down();
 }
 
+
+void moments_view_update(void)
+{
+       if (moments_check_is_with_phone_via_bluetooth()) __set_center_contents(MOMENTS_CONNECTION_STATUS_CONNECTED_BLUETOOTH);
+       else if (moments_check_is_connected_remotely()) __set_center_contents(MOMENTS_CONNECTION_STATUS_CONNECTED_REMOTELY);
+       else __set_center_contents(MOMENTS_CONNECTION_STATUS_STANDALONE);
+
+}
+
 Evas_Object *moments_view_get_base_window(void)
 {
        return s_info.win;
@@ -312,9 +316,10 @@ __fail:
 }
 
 
-static void __set_center_contents()
+void __set_center_contents(moments_connection_status_e status)
 {
-       elm_layout_file_set(s_info.center_layout, util_get_res_file_path(CENTER_LAYOUT_EDJE), center_layout_group_name[connection_status]);
+       connection_status = status;
+       elm_layout_file_set(s_info.center_layout, util_get_res_file_path(CENTER_LAYOUT_EDJE), center_layout_group_name[status]);
 
        //elm_object_part_text_set(center_layout, CENTER_STATUS_TEXT, "Connected<br/>via Bluetooth");
        //elm_object_part_text_set(center_layout, CENTER_PLMN_TEXT, "PLMN/SPN");
@@ -604,7 +609,12 @@ int __t__get_center_layout_alpha(int layout_bottom)
 
 void __t__set_connection_status(int status)
 {
-       connection_status = status;
+       __set_center_contents(status);
+}
+
+int __t__get_connection_status(void)
+{
+       return connection_status;
 }
 
 void __t__pull_down_complete_cb(void)
index 3366a1205ce9f83c0615c328326ee9d91506e47d..838d9e2838771297883a399beec82586244fe4b5 100755 (executable)
 
 static struct {
        unit_group_t * group;
+       moments_connection_status_e current_connection_status;
 } s_info = {
        .group = NULL,
+       .current_connection_status = MOMENTS_CONNECTION_STATUS_STANDALONE,
 };
 
 extern const char *center_layout_group_name[MOMENTS_CONNECTION_STATUS_MAX];
@@ -46,15 +48,14 @@ static void __group_set_up(void)
                TEST_GROUP_SET_UP_DONE(0.6, s_info.group);
        }
 
+       s_info.current_connection_status = __t__get_connection_status();
        __t__pull_down_complete_cb();
        TEST_GROUP_SET_UP_DONE(0.05, s_info.group);
 }
 
 static void __group_tear_down(void)
 {
-       __t__set_connection_status(MOMENTS_CONNECTION_STATUS_STANDALONE);
-
-       moments_view_update();
+       __t__set_connection_status(s_info.current_connection_status);
 
        if (moments_get_visible()) {
                moments_hide();
@@ -81,7 +82,6 @@ static unit_case_func_t __case_check_center_layout(void *data)
        int connection_status = (int)data;
        __t__set_connection_status((int)connection_status);
 
-       moments_view_update();
 
        TEST_CASE_CONTINUE(0.6, __continue_check_center_layout, data);
 }
index 17ff3dea3a2e6c3c772bc4f9abff6b3529436ff8..e392cbc72f9b756a161a74ded7eed5cdffdf56f0 100755 (executable)
@@ -123,6 +123,11 @@ unit_case_func_t __continue_check_state(void * data)
        for (i = 0; i < total; i++) {
                button = eina_list_nth(button_list, i);
 
+               if ((!moments_check_is_call_fwd_enable() && button->index == MOMENTS_CONTROLS_CALL_FORWARDING) ||
+                       (!moments_check_is_music_enable() && button->index == MOMENTS_CONTROLS_MUSIC_PLAYER)) {
+                       continue;
+               }
+
                TEST_ASSERT_TRUE(button != NULL);
                TEST_ASSERT_TRUE(evas_object_visible_get(button->button_layout));
 
index bce2d8dcb4fda8dfdb5a5b4052939079d4329100..b19edbf6d842a898cdc90432748e750e237e8b35 100755 (executable)
@@ -42,6 +42,7 @@ extern void __t__get_draw_down_view_y(int from_y, int to_y, int * dest_y);
 extern int __t__get_control_layout_alpha(int layout_bottom);
 extern int __t__get_center_layout_alpha(int layout_bottom);
 extern void __t__set_connection_status(int status);
+extern int __t__get_connection_status(void);
 extern Eina_List *__t__get_moments_control_button_list(void);
 extern void __t__update_control_state(void);
 extern void __t__update_control_view(void);