From: Liu, Guoqiang Date: Tue, 2 Apr 2013 10:34:49 +0000 (+0800) Subject: Tethering: Power on Wi-Fi before enable Wi-Fi tethering X-Git-Tag: submit/tizen/20151117.101206~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=10bba1f56a59c9034110271724395aeaaa16ec5b;p=apps%2Fnative%2Fug-mobile-ap.git Tethering: Power on Wi-Fi before enable Wi-Fi tethering Change-Id: Ie06fcf172a08cc0188777a094d4da94dc0bd6289 Signed-off-by: Liu, Guoqiang --- diff --git a/include/mh_func_onoff.h b/include/mh_func_onoff.h index d755b20..5056845 100644 --- a/include/mh_func_onoff.h +++ b/include/mh_func_onoff.h @@ -38,7 +38,7 @@ int _handle_wifi_onoff_change(mh_appdata_t *ad); int _handle_bt_onoff_change(mh_appdata_t *ad); int _handle_usb_onoff_change(mh_appdata_t *ad); int _turn_off_wifi(mh_appdata_t *ad); -int _turn_on_wifi(void); +int _turn_on_wifi(mh_appdata_t *ad); bool _is_wifi_direct_on(void); int _turn_off_wifi_direct(mh_appdata_t *ad); diff --git a/src/mh_common_utility.c b/src/mh_common_utility.c index cd409ea..b0a399b 100644 --- a/src/mh_common_utility.c +++ b/src/mh_common_utility.c @@ -104,9 +104,15 @@ static void __popup_resp_yes(void *data, Evas_Object *obj, void *event_info) switch (popup_type) { case MH_POP_WIFI_ON_CONF: wifi_is_activated(&wifi_state); - if (wifi_state == true) { - if (_turn_off_wifi(ad) != 0) { - ERR("_turn_off_wifi is failed\n"); + DBG("wifi_state : %d\n", wifi_state); + if (wifi_state == false) { + ret = vconf_set_int(VCONFKEY_MOBILE_HOTSPOT_WIFI_STATE, + VCONFKEY_MOBILE_HOTSPOT_WIFI_PENDING_ON); + if (ret < 0) + ERR("vconf_set_int() is failed : %d\n", ret); + + if (_turn_on_wifi(ad) != 0) { + ERR("_turn_on_wifi is failed\n"); _update_wifi_item(ad, MH_STATE_NONE); } } else if (_is_wifi_direct_on() == true) { @@ -124,6 +130,11 @@ static void __popup_resp_yes(void *data, Evas_Object *obj, void *event_info) break; case MH_POP_WIFI_OFF_CONF: + ret = vconf_set_int(VCONFKEY_MOBILE_HOTSPOT_WIFI_STATE, + VCONFKEY_MOBILE_HOTSPOT_WIFI_PENDING_OFF); + if (ret < 0) + ERR("vconf_set_int() is failed : %d\n", ret); + ret = tethering_disable(ad->handle, TETHERING_TYPE_WIFI); if (ret != TETHERING_ERROR_NONE) { ERR("wifi tethering off is failed : %d\n", ret); @@ -728,4 +739,4 @@ Evas_Object *_create_slide_title(Evas_Object *parent, const char *text) elm_access_object_unregister(label); return label; -} \ No newline at end of file +} diff --git a/src/mh_func_onoff.c b/src/mh_func_onoff.c index 71ef960..4f84f27 100644 --- a/src/mh_func_onoff.c +++ b/src/mh_func_onoff.c @@ -236,23 +236,6 @@ static void __disable_tethering_by_ind(mh_appdata_t *ad, tethering_disabled_caus return; } -static void __recover_wifi_station_mode(void) -{ - DBG("+\n"); - - if (__get_vconf_prev_wifi_state() == false) { - DBG("No need to recover wifi station mode\n"); - return; - } - - if (_turn_on_wifi() != 0) - ERR("_turn_on_wifi is failed\n"); - if (vconf_set_bool(VCONF_MOBILE_AP_PREV_WIFI_STATUS, 0) < 0) - ERR("vconf_set_bool failed\n"); - - return; -} - /* Wi-Fi Direct callback */ static void _wifi_direct_state_cb(int error_code, wifi_direct_device_state_e state, void *user_data) { @@ -297,8 +280,29 @@ static void __wifi_activated_cb(wifi_error_e result, void *user_data) { __MOBILE_AP_FUNC_ENTER__; + if (user_data == NULL) { + ERR("The param is NULL\n"); + return; + } + + mh_appdata_t *ad = (mh_appdata_t *)user_data; + int ret = 0; + + if (result != WIFI_ERROR_NONE) { + ERR("__wifi_activated_cb error : %d\n", result); + _update_main_view(ad); + return; + } + DBG("Wi-Fi on is done\n"); + ret = tethering_enable(ad->handle, TETHERING_TYPE_WIFI); + if (ret != TETHERING_ERROR_NONE) { + ERR("wifi tethering on is failed : %d\n", ret); + return; + } + _update_main_view(ad); + __MOBILE_AP_FUNC_EXIT__; return; } @@ -346,6 +350,14 @@ void _enabled_cb(tethering_error_e result, tethering_type_e type, bool is_reques return; } + if (result == TETHERING_ERROR_NONE) { + int ret = vconf_set_int( + VCONFKEY_MOBILE_HOTSPOT_WIFI_STATE, + VCONFKEY_MOBILE_HOTSPOT_WIFI_ON); + if (ret < 0) + ERR("vconf_set_int() is failed : %d\n", ret); + } + mh_appdata_t *ad = (mh_appdata_t *)user_data; ad->main.need_recover_wifi_tethering = false; @@ -378,6 +390,14 @@ void _disabled_cb(tethering_error_e result, tethering_type_e type, tethering_dis return; } + if (result == TETHERING_ERROR_NONE) { + int ret = vconf_set_int( + VCONFKEY_MOBILE_HOTSPOT_WIFI_STATE, + VCONFKEY_MOBILE_HOTSPOT_WIFI_OFF); + if (ret < 0) + ERR("vconf_set_int() is failed : %d\n", ret); + } + mh_appdata_t *ad = (mh_appdata_t *)user_data; if (ad->main.need_recover_wifi_tethering == true) { @@ -405,9 +425,6 @@ void _disabled_cb(tethering_error_e result, tethering_type_e type, tethering_dis } DBG("Tethering [%d] is disabled by reqeust\n", type); - if (type == TETHERING_TYPE_WIFI) { - __recover_wifi_station_mode(); - } _update_main_view(ad); @@ -474,6 +491,12 @@ int _handle_wifi_onoff_change(mh_appdata_t *ad) _("IDS_MOBILEAP_POP_DISABLING_TETHERING_WILL_PREVENT_LINKED_DEVICES_FROM_ACCESSING_THE_INTERNET_CONTINUE_Q")); _create_popup(ad); } else { + ret = vconf_set_int( + VCONFKEY_MOBILE_HOTSPOT_WIFI_STATE, + VCONFKEY_MOBILE_HOTSPOT_WIFI_PENDING_OFF); + if (ret < 0) + ERR("vconf_set_int() is failed : %d\n", ret); + ret = tethering_disable(ad->handle, TETHERING_TYPE_WIFI); if (ret != TETHERING_ERROR_NONE) { ERR("wifi tethering off is failed : %d\n", ret); @@ -578,11 +601,11 @@ int _turn_off_wifi(mh_appdata_t *ad) return 0; } -int _turn_on_wifi(void) +int _turn_on_wifi(mh_appdata_t *ad) { int ret; - ret = wifi_activate(__wifi_activated_cb, NULL); + ret = wifi_activate(__wifi_activated_cb, (void *)ad); if (ret != WIFI_ERROR_NONE) { ERR("wifi_activate() is failed : %d\n", ret); return -1;