From 19ae9570e78fc6f37cddb2baaa6b47bc9b6fc6ef Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Fri, 29 Mar 2013 14:15:33 +0900 Subject: [PATCH] Fix the problem to revert the device name [Issue] N_SE-30654 [Problem] Bluetooth device name is restored to "Redwood" every time you enter the native setting menu. [Cause] The logic was wrong [Solution] Correct the logic Change-Id: I346301d9cbc27f83e03d409e233a0c1f2d1b5e5e --- include/bt-callback.h | 2 ++ src/libraries/bt-callback.c | 17 +++++++++++++++++ src/ui/bt-main-ug.c | 4 ++++ src/ui/bt-main-view.c | 21 +++++++-------------- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/include/bt-callback.h b/include/bt-callback.h index 872a7fa..7f95316 100644 --- a/include/bt-callback.h +++ b/include/bt-callback.h @@ -50,6 +50,8 @@ void _bt_cb_audio_state_changed(int result, bool connected, bt_audio_profile_type_e type, void *user_data); +void _bt_cb_adapter_name_changed(char *device_name, void *user_data); + #ifdef __cplusplus } #endif diff --git a/src/libraries/bt-callback.c b/src/libraries/bt-callback.c index 2c42220..cefcb1a 100644 --- a/src/libraries/bt-callback.c +++ b/src/libraries/bt-callback.c @@ -694,3 +694,20 @@ void _bt_cb_audio_state_changed(int result, bool connected, FN_END; } +void _bt_cb_adapter_name_changed(char *device_name, void *user_data) +{ + FN_START; + + bt_ug_data *ugd; + + BT_DBG("Name: [%s]", device_name); + + ret_if(user_data == NULL); + + ugd = (bt_ug_data *)user_data; + + elm_genlist_item_update((Elm_Object_Item *)ugd->status_item); + + FN_END; +} + diff --git a/src/ui/bt-main-ug.c b/src/ui/bt-main-ug.c index a82504f..2a208e4 100644 --- a/src/ui/bt-main-ug.c +++ b/src/ui/bt-main-ug.c @@ -398,6 +398,10 @@ static void __on_destroy(ui_gadget_h ug, service_h service, void *priv) if (err != BT_ERROR_NONE) BT_DBG("unset audio connection state cb failed: %d", err); + err = bt_adapter_unset_name_changed_cb(); + if (err != BT_ERROR_NONE) + BT_DBG("unset name change cb failed: %d", err); + err = bt_hid_host_deinitialize(); if (err != BT_ERROR_NONE) BT_DBG("bt_hid_host_deinitialize failed: %d", err); diff --git a/src/ui/bt-main-view.c b/src/ui/bt-main-view.c index 1b69aae..70be90b 100644 --- a/src/ui/bt-main-view.c +++ b/src/ui/bt-main-view.c @@ -3621,8 +3621,6 @@ void _bt_main_init_status(bt_ug_data *ugd, void *data) service_h service = NULL; int remain_time = 0; int ret; - char *dev_name = NULL; - char phone_name[BT_DEVICE_NAME_LENGTH_MAX + 1]; bool status = false; bt_adapter_state_e bt_state = BT_ADAPTER_DISABLED; bt_adapter_visibility_mode_e mode = @@ -3663,18 +3661,6 @@ void _bt_main_init_status(bt_ug_data *ugd, void *data) bt_adapter_stop_device_discovery(); ugd->op_status = BT_ACTIVATED; - - /* Get adapter name from bluez */ - bt_adapter_get_name(&dev_name); - - /* Get phone name from vconf */ - _bt_util_get_phone_name(phone_name, BT_DEVICE_NAME_LENGTH_MAX); - - if (g_strcmp0(dev_name, phone_name) != 0) { - _bt_util_set_phone_name(); - } - - g_free(dev_name); } if(bt_adapter_get_visibility(&mode, &remain_time) != BT_ERROR_NONE) @@ -3743,10 +3729,17 @@ void _bt_main_init_status(bt_ug_data *ugd, void *data) if (ret != BT_ERROR_NONE) BT_DBG("bt_device_set_service_searched_cb failed"); + ret = bt_adapter_set_name_changed_cb( + _bt_cb_adapter_name_changed, + (void *)ugd); + if (ret != BT_ERROR_NONE) + BT_DBG("bt_adapter_set_name_changed_cb failed"); + ret = bt_hid_host_initialize(_bt_cb_hid_state_changed, (void *)ugd); if (ret != BT_ERROR_NONE) BT_DBG("bt_hid_host_initialize failed"); + FN_END; } -- 2.7.4