diff options
author | junkyu han <junkyu.han@samsung.com> | 2017-05-25 09:11:00 +0900 |
---|---|---|
committer | junkyu han <junkyu.han@samsung.com> | 2017-05-25 11:29:44 +0900 |
commit | bf5a34782798e97c87292e5cb96fcd1cff2a9550 (patch) | |
tree | 4c9a4bb86c41b333791b7b8a03a86644d6b21e05 | |
parent | 2f57eb6fd8652709e3625f41a88c44cc0266fbdf (diff) | |
download | w3-home-bf5a34782798e97c87292e5cb96fcd1cff2a9550.tar.gz w3-home-bf5a34782798e97c87292e5cb96fcd1cff2a9550.tar.bz2 w3-home-bf5a34782798e97c87292e5cb96fcd1cff2a9550.zip |
Check 'is_3g' to avoid crash occured in telephony
Change-Id: I44e76240298674a21b96f9940b04ce0afef336e7
-rwxr-xr-x | src/moments/moments_manager.c | 68 | ||||
-rw-r--r-- | src/moments/moments_status_view.c | 5 | ||||
-rwxr-xr-x | test/feature_test/group_feature_moments_status_behavior.c | 28 | ||||
-rwxr-xr-x | test/feature_test/group_feature_moments_status_view_ui.c | 20 |
4 files changed, 87 insertions, 34 deletions
diff --git a/src/moments/moments_manager.c b/src/moments/moments_manager.c index 5ef84a9..849dbd4 100755 --- a/src/moments/moments_manager.c +++ b/src/moments/moments_manager.c @@ -168,7 +168,12 @@ static void __moments_initialize_status_util(void) s_info.on_initialization = true; __moments_status_battery_state_changed_cb(-1, NULL, NULL); - __moments_status_call_network_service_state_changed_cb(NULL, 0, NULL, NULL); + if (moments_check_is_3g_device()) { + _D("This device is 3G DEVICE"); + moments_status_callsignal_icon_show(); + moments_status_network_icon_show(); + __moments_status_call_network_service_state_changed_cb(NULL, 0, NULL, NULL); + } s_info.on_initialization = false; } @@ -179,6 +184,7 @@ static void __moments_register_status_util_callback(void) device_add_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, __moments_status_battery_state_changed_cb, NULL); device_add_callback(DEVICE_CALLBACK_BATTERY_CHARGING, __moments_status_battery_state_changed_cb, NULL); + if (moments_check_is_3g_device()) { int ret = TELEPHONY_ERROR_NONE; ret = telephony_init(&handle_list); if (ret != TELEPHONY_ERROR_NONE) { @@ -211,10 +217,12 @@ static void __moments_register_status_util_callback(void) } vconf_notify_key_changed(VCONFKEY_DNET_STATE, __moments_status_util_network_type_changed_cb, NULL); - vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, __moments_status_util_flight_mode_changed_cb, NULL); - vconf_notify_key_changed(VCONFKEY_WIFI_STATE, __moments_status_util_wifi_state_changed_cb, NULL); - vconf_notify_key_changed(VCONFKEY_WIFI_TRANSFER_STATE, __moments_status_util_wifi_state_changed_cb, NULL); - vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH, __moments_status_util_wifi_state_changed_cb, NULL); + } + + vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, __moments_status_util_flight_mode_changed_cb, NULL); + vconf_notify_key_changed(VCONFKEY_WIFI_STATE, __moments_status_util_wifi_state_changed_cb, NULL); + vconf_notify_key_changed(VCONFKEY_WIFI_TRANSFER_STATE, __moments_status_util_wifi_state_changed_cb, NULL); + vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH, __moments_status_util_wifi_state_changed_cb, NULL); } static void __moments_unregister_status_util_callback(void) @@ -223,35 +231,37 @@ static void __moments_unregister_status_util_callback(void) device_remove_callback(DEVICE_CALLBACK_BATTERY_CAPACITY, __moments_status_battery_state_changed_cb); device_remove_callback(DEVICE_CALLBACK_BATTERY_CHARGING, __moments_status_battery_state_changed_cb); - /* Call Signal */ - int ret = TELEPHONY_ERROR_NONE; + if (moments_check_is_3g_device()) { + /* Call Signal */ + int ret = TELEPHONY_ERROR_NONE; - ret = telephony_unset_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_PS_TYPE); - if (ret != TELEPHONY_ERROR_NONE) { - _E("Failed to unregister service state"); - } + ret = telephony_unset_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_PS_TYPE); + if (ret != TELEPHONY_ERROR_NONE) { + _E("Failed to unregister service state"); + } - ret = telephony_unset_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_ROAMING_STATUS); - if (ret != TELEPHONY_ERROR_NONE) { - _E("Failed to unregister roaming status"); - } + ret = telephony_unset_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_ROAMING_STATUS); + if (ret != TELEPHONY_ERROR_NONE) { + _E("Failed to unregister roaming status"); + } - ret = telephony_unset_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL); - if (ret != TELEPHONY_ERROR_NONE) { - _E("Failed to unregister signal strength"); - } + ret = telephony_unset_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_SIGNALSTRENGTH_LEVEL); + if (ret != TELEPHONY_ERROR_NONE) { + _E("Failed to unregister signal strength"); + } - ret = telephony_unset_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_SERVICE_STATE); - if (ret != TELEPHONY_ERROR_NONE) { - _E("Failed to unregister service state"); - } + ret = telephony_unset_noti_cb(handle_list.handle[0], TELEPHONY_NOTI_NETWORK_SERVICE_STATE); + if (ret != TELEPHONY_ERROR_NONE) { + _E("Failed to unregister service state"); + } - ret = telephony_deinit(&handle_list); - if (ret != TELEPHONY_ERROR_NONE) { - _E("Failed to deinitialize telephony"); - } + ret = telephony_deinit(&handle_list); + if (ret != TELEPHONY_ERROR_NONE) { + _E("Failed to deinitialize telephony"); + } - vconf_ignore_key_changed(VCONFKEY_DNET_STATE, __moments_status_util_network_type_changed_cb); + vconf_ignore_key_changed(VCONFKEY_DNET_STATE, __moments_status_util_network_type_changed_cb); + } vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE, __moments_status_util_flight_mode_changed_cb); vconf_ignore_key_changed(VCONFKEY_WIFI_STATE, __moments_status_util_wifi_state_changed_cb); vconf_ignore_key_changed(VCONFKEY_WIFI_TRANSFER_STATE, __moments_status_util_wifi_state_changed_cb); @@ -312,6 +322,8 @@ static void __moments_manager_update_status_view(int is_flight, int _service_sta } moments_status_callsignal_update(callsignal_strength, is_roaming); moments_status_network_update(wifi_state == VCONFKEY_WIFI_CONNECTED ? (int)network_type + MOMENT_STATUS_SIGNAL_WIFI_INDEX : (int)network_type, (int)network_type == 0 ? (int)network_type : (int)packet_type+15); + + moments_status_update_util_icon_list(); } static void __moments_status_call_network_service_state_changed_cb(telephony_h handle, telephony_noti_e noti_id, void *data, void *user_data) diff --git a/src/moments/moments_status_view.c b/src/moments/moments_status_view.c index c86bc53..4aa5274 100644 --- a/src/moments/moments_status_view.c +++ b/src/moments/moments_status_view.c @@ -184,6 +184,9 @@ void moments_destroy_status_ui(void) if (moments_check_is_3g_device()) { if (s_info.status_callsignal) evas_object_del(s_info.status_callsignal); s_info.status_callsignal = NULL; + + if (s_info.status_network) evas_object_del(s_info.status_network); + s_info.status_network = NULL; } if (s_info.status_battery) evas_object_del(s_info.status_battery); @@ -279,7 +282,7 @@ static status_util_icon_type_e __status_get_prev_type_by_priority(status_util_ic status_util_icon_type_e cur_type = -1; if (moments_check_is_3g_device()) { cur_type = __status_util_icon_priority_3g[i]; - } else { + } else if (!moments_check_is_3g_device() && i < STATUS_UTIL_ICON_MAX_COUNT_BT) { cur_type = __status_util_icon_priority_bt[i]; } diff --git a/test/feature_test/group_feature_moments_status_behavior.c b/test/feature_test/group_feature_moments_status_behavior.c index ac97042..f3d62ed 100755 --- a/test/feature_test/group_feature_moments_status_behavior.c +++ b/test/feature_test/group_feature_moments_status_behavior.c @@ -20,6 +20,7 @@ extern Evas_Object *__t__get_moments_status_battery(void); extern Evas_Object *__t__get_moments_status_callsignal(void); extern Evas_Object *__t__get_moments_status_network(void); +static void __t__moments_status_restore_icons(void); extern void __t__moments_restore_status_battery(void); extern void __t__moments_restore_status_call_network_service_state(void); extern void __t__layout_mouse_down(Evas_Object *layout, int down_x, int down_y); @@ -88,6 +89,8 @@ static void __tear_down(void) static void __group_tear_down(void *data) { + __t__moments_status_restore_icons(); + if (moments_get_visible()) { main_s * info = main_get_info(); __t__layout_mouse_up(info->layout, 180, 50); @@ -98,6 +101,8 @@ static void __group_tear_down(void *data) TEST_GROUP_TEAR_DOWN_DONE(0.0, s_info.group); } +static bool call_is_for_test = false; +static bool network_is_for_test = false; static unit_case_func_t __continue_check_status_flight_on(void *data); static unit_case_func_t __case_check_status_flight_on(void *data) { @@ -114,6 +119,7 @@ static unit_case_func_t __case_check_status_flight_on(void *data) if (!callsignal) { moments_status_callsignal_icon_show(); moments_status_update_util_icon_list(); + call_is_for_test = true; TEST_CASE_CONTINUE(0.1, __case_check_status_flight_on, NULL); } TEST_ASSERT_TRUE_UPGRADE(evas_object_visible_get(callsignal)); @@ -122,6 +128,7 @@ static unit_case_func_t __case_check_status_flight_on(void *data) if (!network) { moments_status_network_icon_show(); moments_status_update_util_icon_list(); + network_is_for_test = true; TEST_CASE_CONTINUE(0.1, __case_check_status_flight_on, NULL); } TEST_ASSERT_TRUE_UPGRADE(evas_object_visible_get(network)); @@ -219,8 +226,6 @@ static unit_case_func_t __continue_check_status_flightoff_serviceon_wifion(void TEST_ASSERT_EQUAL_STRING_UPGRADE(__t__network_type[network_type+10], edje_object_part_state_get(elm_layout_edje_get(network), "type_icon_image", &val)); TEST_ASSERT_EQUAL_STRING_UPGRADE(__t__network_type[packet_type+15], edje_object_part_state_get(elm_layout_edje_get(network), "inout_icon_image", &val)); - __t__moments_restore_status_call_network_service_state(); - TEST_CASE_DONE(s_info.group); } @@ -232,11 +237,26 @@ void group_feature_moments_status_behavior(unit_group_t * group) TEST_CASE_ADD(s_info.group, __case_check_status_flight_on, NULL); TEST_CASE_ADD(s_info.group, __case_check_status_flightoff_serviceoff_wifioff, NULL); - TEST_CASE_ADD(s_info.group, __case_check_status_flightoff_serviceon_wifioff, NULL); - TEST_CASE_ADD(s_info.group, __case_check_status_flightoff_serviceon_wifion, NULL); + if (moments_check_is_3g_device()) { + TEST_CASE_ADD(s_info.group, __case_check_status_flightoff_serviceon_wifioff, NULL); + TEST_CASE_ADD(s_info.group, __case_check_status_flightoff_serviceon_wifion, NULL); + } TEST_GROUP_TEAR_DOWN(s_info.group, __group_tear_down); TEST_GROUP_RUN(s_info.group); } +static void __t__moments_status_restore_icons(void) +{ + if (call_is_for_test) { + moments_status_callsignal_icon_hide(); + } + if (network_is_for_test) { + moments_status_network_icon_hide(); + } + if (!call_is_for_test && !network_is_for_test) { + __t__moments_restore_status_call_network_service_state(); + } +} + #endif diff --git a/test/feature_test/group_feature_moments_status_view_ui.c b/test/feature_test/group_feature_moments_status_view_ui.c index 8322e3f..0966d8c 100755 --- a/test/feature_test/group_feature_moments_status_view_ui.c +++ b/test/feature_test/group_feature_moments_status_view_ui.c @@ -22,6 +22,7 @@ extern Evas_Object *__t__get_moments_status_battery(void); extern Evas_Object *__t__get_moments_status_callsignal(void); extern Evas_Object *__t__get_moments_status_callsignal(void); extern Evas_Object *__t__get_moments_status_network(void); +static void __t__moments_status_restore_icons(void); extern void __t__moments_restore_status_battery(void); extern void __t__moments_restore_status_call_network_service_state(void); extern void __t__layout_mouse_down(Evas_Object *layout, int down_x, int down_y); @@ -203,6 +204,7 @@ static unit_case_func_t __continue_check_status_battery_icon_change(void *data) static bool is_roaming = false; static int call_strength = -1; static int call_signal_index = 0; +static bool call_is_for_test = false; static unit_case_func_t __continue_check_status_callsignal_icon_change(void *data); static unit_case_func_t __case_check_status_view_callsignal(void *data) @@ -211,6 +213,7 @@ static unit_case_func_t __case_check_status_view_callsignal(void *data) if (!callsignal) { moments_status_callsignal_icon_show(); moments_status_update_util_icon_list(); + call_is_for_test = true; TEST_CASE_CONTINUE(0.1, __case_check_status_view_callsignal, NULL); } @@ -269,12 +272,14 @@ static network_state_t network_state = { .network_type = 0, .packet_type = -1 }; +static int network_is_for_test = false; static unit_case_func_t __case_check_status_view_network(void *data) { Evas_Object *network = __t__get_moments_status_network(); if (!network) { moments_status_network_icon_show(); moments_status_update_util_icon_list(); + network_is_for_test = true; TEST_CASE_CONTINUE(0.1, __case_check_status_view_network, NULL); } @@ -306,7 +311,7 @@ static unit_case_func_t __continue_check_status_network_icon_change(void *data) if (network_state->network_type == 14 && network_state->packet_type == 18) { main_s *info = main_get_info(); - __t__moments_restore_status_call_network_service_state(); + __t__moments_status_restore_icons(); __t__layout_mouse_up(info->layout, 0, 0); TEST_CASE_DONE(s_info.group); } @@ -341,5 +346,18 @@ void group_feature_moments_status_view_ui(unit_group_t * group) TEST_GROUP_RUN(s_info.group); } +static void __t__moments_status_restore_icons(void) +{ + if (call_is_for_test) { + moments_status_callsignal_icon_hide(); + } + if (network_is_for_test) { + moments_status_network_icon_hide(); + } + if (!call_is_for_test && !network_is_for_test) { + __t__moments_restore_status_call_network_service_state(); + } +} + #endif |