2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <vconf-keys.h>
20 #include <vconf-internal-radio-keys.h>
22 #include <eventsystem.h>
24 #include "bt-core-main.h"
25 #include "bt-core-adapter.h"
26 #include "bt-core-common.h"
27 #include "bt-core-dbus-handler.h"
28 #include "bt-core-noti-handler.h"
30 #define BT_CORE_IDLE_TERM_TIME 200 /* 200ms */
31 #define BT_CORE_CHECK_ADAPTER_OBJECT_PATH_MAX 50
34 static bt_status_t adapter_status = BT_DEACTIVATED;
35 static bt_le_status_t adapter_le_status = BT_LE_DEACTIVATED;
36 static gboolean is_recovery_mode = FALSE;
38 static int bt_status_before[BT_MODE_MAX] = { VCONFKEY_BT_STATUS_OFF, };
39 static int bt_le_status_before[BT_MODE_MAX] = { VCONFKEY_BT_LE_STATUS_OFF, };
41 static void __bt_core_set_status(bt_status_t status)
43 adapter_status = status;
46 bt_status_t _bt_core_get_status(void)
48 return adapter_status;
51 static void __bt_core_set_le_status(bt_le_status_t status)
53 adapter_le_status = status;
56 bt_le_status_t _bt_core_get_le_status(void)
58 return adapter_le_status;
61 int _bt_core_get_bt_status(bt_mode_e mode)
63 return bt_status_before[mode];
66 int _bt_core_get_bt_le_status(bt_mode_e mode)
68 return bt_le_status_before[mode];
71 void _bt_core_set_bt_status(bt_mode_e mode, int status)
73 bt_status_before[mode] = status;
76 void _bt_core_set_bt_le_status(bt_mode_e mode, int status)
78 bt_le_status_before[mode] = status;
81 gboolean _bt_core_is_recovery_mode(void)
83 return is_recovery_mode;
86 static gboolean __bt_core_idle_terminate(gpointer data)
93 gboolean _bt_core_is_flight_mode_enabled(void)
95 #ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
99 ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &isFlightMode);
101 BT_ERR("vconf_get_bool failed");
109 static int __execute_command(const char *cmd, char *const arg_list[])
119 BT_ERR("fork failed");
125 BT_ERR("fork failed");
126 } else if (pid2 == 0) {
127 execv(cmd, arg_list);
134 BT_DBG("parent : forked[%d]", pid);
135 waitpid(pid, &status, 0);
136 BT_DBG("child is terminated : %d", status);
143 int _bt_enable_adapter(void)
148 bt_le_status_t le_status;
152 status = _bt_core_get_status();
153 if (status != BT_DEACTIVATED) {
154 BT_ERR("Invalid state %d", status);
155 g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
159 #if 0 /* only the concept of private */
160 le_status = _bt_core_get_le_status();
161 if (le_status == BT_LE_ACTIVATED) {
162 /* Turn on PSCAN, (ISCAN if needed) */
163 /* Return with 0 for the Enabled response. */
164 __bt_core_set_status(BT_ACTIVATED);
165 BT_INFO("BR/EDR is enabled.");
166 g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
171 __bt_core_set_status(BT_ACTIVATING);
173 char *argv_up[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "up", NULL};
174 ret = __execute_command("/usr/bin/hciconfig", argv_up);
176 ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
179 BT_ERR("running script failed");
181 char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
182 ret = __execute_command("/usr/bin/hciconfig", argv_down);
184 ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh", NULL);
186 __bt_core_set_status(BT_DEACTIVATED);
193 int _bt_disable_adapter(void)
197 bt_le_status_t le_status;
200 BT_INFO_C("Disable adapter");
202 #if 0 /* only the concept of private */
203 le_status = _bt_core_get_le_status();
204 BT_DBG("le_status : %d", le_status);
205 if (le_status == BT_LE_ACTIVATED) {
206 /* Turn off PSCAN, (ISCAN if needed) */
207 /* Return with 0 for the Disabled response. */
208 __bt_core_set_status(BT_DEACTIVATED);
209 BT_INFO("BR/EDR is disabled. now LE only mode");
210 g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
215 status = _bt_core_get_status();
216 if (status == BT_ACTIVATING) {
217 /* Forcely terminate */
219 char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
220 if (__execute_command("/usr/bin/hciconfig", argv_down) < 0)
221 BT_ERR("running script failed");
224 #ifdef TIZEN_FEATURE_RADIO
225 int radio_status = VCONFKEY_RADIO_STATUS_OFF;
227 /* Check if radio status on or off */
228 if (vconf_get_int(VCONFKEY_RADIO_STATUS, &radio_status) < 0)
229 BT_ERR("Fail to get radio status");
231 BT_DBG("Radio status: %d", radio_status);
233 if (radio_status == VCONFKEY_RADIO_STATUS_ON) {
234 if (__execute_command("/usr/etc/bluetooth/bt-stack-down-with-radio.sh", NULL) < 0)
235 BT_ERR("running script failed");
237 if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0)
238 BT_ERR("running script failed");
241 if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0)
242 BT_ERR("running script failed");
245 _bt_core_terminate();
247 } else if (status != BT_ACTIVATED) {
248 BT_ERR("Invalid state %d", status);
249 g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
252 __bt_core_set_status(BT_DEACTIVATING);
254 char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
255 if (__execute_command("/usr/bin/hciconfig", argv_down) < 0) {
256 BT_ERR("running script failed");
257 __bt_core_set_status(BT_ACTIVATED);
261 #ifdef TIZEN_FEATURE_RADIO
262 int radio_status = VCONFKEY_RADIO_STATUS_OFF;
264 /* Check if radio status on or off */
265 if (vconf_get_int(VCONFKEY_RADIO_STATUS, &radio_status) < 0)
266 BT_ERR("Fail to get radio status");
268 BT_DBG("Radio status: %d", radio_status);
270 if (radio_status == VCONFKEY_RADIO_STATUS_ON) {
271 if (__execute_command("/usr/etc/bluetooth/bt-stack-down-with-radio.sh", NULL) < 0) {
272 BT_ERR("running script failed");
273 __bt_core_set_status(BT_ACTIVATED);
277 if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
278 BT_ERR("running script failed");
279 __bt_core_set_status(BT_ACTIVATED);
284 if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
285 BT_ERR("running script failed");
286 __bt_core_set_status(BT_ACTIVATED);
295 int _bt_enable_adapter_le(void)
301 bt_le_status_t le_status;
302 le_status = _bt_core_get_le_status();
303 retv_if(le_status != BT_LE_DEACTIVATED, -1);
305 status = _bt_core_get_status();
306 if (status == BT_DEACTIVATED) {
307 __bt_core_set_le_status(BT_LE_ACTIVATING);
308 BT_DBG("Activate BT");
310 char *argv_up[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "up", NULL};
311 ret = __execute_command("/usr/bin/hciconfig", argv_up);
313 ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
316 BT_ERR("running script failed");
318 char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
319 ret = __execute_command("/usr/bin/hciconfig", argv_down);
321 ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh &", NULL);
323 __bt_core_set_status(BT_DEACTIVATED);
324 __bt_core_set_le_status(BT_LE_DEACTIVATED);
328 __bt_core_set_le_status(BT_LE_ACTIVATED);
329 g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
332 ret = _bt_core_start_httpproxy();
334 BT_ERR("_bt_core_start_httpproxy() failed");
341 int _bt_disable_adapter_le(void)
346 bt_le_status_t le_status;
348 le_status = _bt_core_get_le_status();
349 retv_if(le_status == BT_LE_DEACTIVATED, 0);
350 retv_if(le_status == BT_LE_DEACTIVATING, -1);
353 _bt_core_stop_httpproxy();
356 status = _bt_core_get_status();
357 BT_DBG("status : %d", status);
359 if (status == BT_DEACTIVATED) {
360 __bt_core_set_le_status(BT_LE_DEACTIVATING);
362 char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
363 if (__execute_command("/usr/bin/hciconfig", argv_down) < 0) {
365 if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
367 BT_ERR("running script failed");
368 __bt_core_set_le_status(BT_LE_ACTIVATED);
372 g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
375 __bt_core_set_le_status(BT_LE_DEACTIVATED);
381 int _bt_core_service_request_adapter(int service_function)
385 GArray *in_param1 = NULL;
386 GArray *in_param2 = NULL;
387 GArray *in_param3 = NULL;
388 GArray *in_param4 = NULL;
389 GArray *out_param = NULL;
391 BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
393 ret = _bt_core_service_request(BT_CORE_SERVICE, service_function,
394 in_param1, in_param2, in_param3, in_param4, &out_param);
396 BT_ERR("_bt_core_service_request_adapter() failed");
398 BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
403 static gboolean __bt_core_check_the_adapter_path(GDBusConnection *conn)
406 GDBusProxy *manager_proxy = NULL;
407 GVariant *result = NULL;
408 char *adapter_path = NULL;
413 manager_proxy = g_dbus_proxy_new_sync(conn,
414 G_DBUS_PROXY_FLAGS_NONE, NULL,
417 "org.freedesktop.DBus.ObjectManager",
420 if (!manager_proxy) {
422 BT_ERR("Unable to create proxy: %s", err->message);
425 BT_ERR("Fail to create proxy");
430 result = g_dbus_proxy_call_sync(manager_proxy, "DefaultAdapter", NULL,
431 G_DBUS_CALL_FLAGS_NONE, -1, NULL, &err);
434 BT_ERR("Fail to get DefaultAdapter (Error: %s)", err->message);
437 BT_ERR("Fail to get DefaultAdapter");
442 if (g_strcmp0(g_variant_get_type_string(result), "(o)")) {
443 BT_ERR("Incorrect result\n");
447 g_variant_get(result, "(&o)", &adapter_path);
449 if (adapter_path == NULL ||
450 strlen(adapter_path) >= BT_CORE_CHECK_ADAPTER_OBJECT_PATH_MAX) {
451 BT_ERR("Adapter path is inproper\n");
455 g_variant_unref(result);
456 g_object_unref(manager_proxy);
462 g_variant_unref(result);
465 g_object_unref(manager_proxy);
470 void _bt_core_update_status(void)
472 int bt_status = VCONFKEY_BT_STATUS_OFF;
473 int bt_le_status = VCONFKEY_BT_LE_STATUS_OFF;
474 gboolean ret = FALSE;
476 ret = __bt_core_check_the_adapter_path(_bt_core_get_gdbus_connection());
477 BT_INFO("check the real status of bt_adapter");
480 __bt_core_set_status(BT_DEACTIVATED);
481 __bt_core_set_le_status(BT_DEACTIVATED);
483 if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
484 BT_ERR("no bluetooth device info, so BT was disabled at previous session");
485 if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status) < 0)
486 BT_ERR("no bluetooth le info, so BT LE was disabled at previous session");
488 BT_INFO("bt_status = %d, bt_le_status = %d", bt_status, bt_le_status);
490 if (bt_status & VCONFKEY_BT_STATUS_ON)
491 __bt_core_set_status(BT_ACTIVATED);
492 if (bt_le_status & VCONFKEY_BT_LE_STATUS_ON)
493 __bt_core_set_le_status(BT_ACTIVATED);
497 gboolean _bt_core_enable_adapter(void)
501 _bt_set_flightmode_request(FALSE);
502 if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
503 BT_ERR("Set vconf failed");
505 ret = _bt_enable_adapter();
512 gboolean _bt_core_disable_adapter(void)
516 _bt_set_flightmode_request(FALSE);
517 if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
518 BT_ERR("Set vconf failed");
520 ret = _bt_disable_adapter();
527 gboolean _bt_core_recover_adapter(void)
532 BT_INFO_C("Recover bt adapter");
534 _bt_set_flightmode_request(FALSE);
535 if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
536 BT_ERR("Set vconf failed");
538 is_recovery_mode = TRUE;
540 _bt_core_update_status();
542 if (_bt_core_get_status() == BT_ACTIVATED) {
543 _bt_core_set_bt_status(BT_RECOVERY_MODE, 1);
544 _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
546 if (_bt_core_get_le_status() == BT_LE_ACTIVATED) {
547 _bt_core_set_bt_le_status(BT_RECOVERY_MODE, 1);
548 _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
551 ret = _bt_disable_adapter();
553 BT_ERR("_bt_disable_adapter() failed");
554 ret_le = _bt_disable_adapter_le();
556 BT_ERR("_bt_disable_adapter_le() failed");
561 gboolean _bt_core_enable_adapter_le(void)
565 ret = _bt_enable_adapter_le();
572 gboolean _bt_core_disable_adapter_le(void)
578 ret = _bt_disable_adapter_le();
585 gboolean __bt_core_reset_adapter(void)
587 /* Forcely terminate */
588 if (__execute_command("/usr/etc/bluetooth/bt-reset-env.sh", NULL) < 0) {
589 BT_ERR("running script failed");
591 _bt_core_terminate();
596 static gboolean __bt_core_enable_core_timeout_cb(gpointer data)
600 _bt_core_init_vconf_value();
605 gboolean _bt_core_enable_core(void)
609 _bt_core_update_status();
611 g_timeout_add(200, (GSourceFunc)__bt_core_enable_core_timeout_cb, NULL);
617 gboolean _bt_core_factory_test_mode(const char *type, const char *arg)
621 char *arg_list[3] = { NULL, NULL, NULL };
623 BT_DBG("Test item : %s", type);
625 if (g_strcmp0(type, "Enable_RF_Test") == 0) {
626 cmd = "/usr/etc/bluetooth/bt-edutm-on.sh";
627 arg_list[0] = "bt-edutm-on.sh";
628 } else if (g_strcmp0(type, "Disable_RF_Test") == 0) {
629 cmd = "/usr/etc/bluetooth/bt-edutm-off.sh";
630 arg_list[0] = "bt-edutm-off.sh";
631 } else if (g_strcmp0(type, "Slave_Mode") == 0) {
632 cmd = "/usr/etc/bluetooth/bt-mode-slave.sh";
633 arg_list[0] = "bt-mode-slave.sh";
634 } else if (g_strcmp0(type, "Master_Mode") == 0) {
635 cmd = "/usr/etc/bluetooth/bt-mode-master.sh";
636 arg_list[0] = "bt-mode-master.sh";
637 } else if (g_strcmp0(type, "SSP_Debug_Mode") == 0) {
638 cmd = "/usr/etc/bluetooth/bt-set-ssp-debug-mode.sh";
639 arg_list[0] = "bt-set-ssp-debug-mode.sh";
640 arg_list[1] = (char *)arg;
641 } else if (g_strcmp0(type, "RF_Channel") == 0) {
642 cmd = "/usr/etc/bluetooth/bt-enable-rf-channel.sh";
643 arg_list[0] = "bt-enable-rf-channel.sh";
644 arg_list[1] = (char *)arg;
646 _bt_core_terminate();
650 BT_DBG("Run %s", cmd);
651 if (__execute_command(cmd, arg_list) < 0) {
652 BT_ERR("running script failed");
655 _bt_core_terminate();
659 static gboolean __bt_core_recovery_cb(gpointer data)
662 gboolean is_request_failed = FALSE;
663 static gboolean is_first_failure = TRUE;
667 if (_bt_core_get_bt_status(BT_RECOVERY_MODE) == 1) {
668 ret = _bt_core_service_request_adapter(BT_ENABLE_ADAPTER);
670 is_request_failed = TRUE;
673 if (_bt_core_get_bt_le_status(BT_RECOVERY_MODE) == 1) {
674 ret = _bt_core_service_request_adapter(BT_ENABLE_ADAPTER_LE);
676 is_request_failed = TRUE;
679 if (is_request_failed == TRUE) {
680 BT_ERR("Recovery is failed.");
681 if (is_first_failure == TRUE) {
682 g_timeout_add(2000, (GSourceFunc)__bt_core_recovery_cb, NULL);
683 is_first_failure = FALSE;
686 is_first_failure = TRUE;
690 is_first_failure = TRUE;
692 if (_bt_core_get_bt_status(BT_RECOVERY_MODE) == 1) {
693 _bt_core_set_bt_status(BT_RECOVERY_MODE, 0);
694 ret = _bt_enable_adapter();
696 BT_ERR("_bt_enable_adapter() failed");
698 if (_bt_core_get_bt_le_status(BT_RECOVERY_MODE) == 1) {
699 _bt_core_set_bt_le_status(BT_RECOVERY_MODE, 0);
700 ret = _bt_enable_adapter_le();
702 BT_ERR("_bt_enable_adapter_le() failed");
705 is_recovery_mode = FALSE;
712 static gboolean __bt_core_enable_timeout_cb(gpointer data)
714 bt_status_t adapter_status;
715 bt_le_status_t adapter_status_le;
719 if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
720 BT_ERR("Set vconf failed");
722 adapter_status = _bt_core_get_status();
723 adapter_status_le = _bt_core_get_le_status();
725 if (adapter_status == BT_DEACTIVATED &&
726 _bt_core_get_bt_status(BT_FLIGHT_MODE) != 0) {
727 _bt_core_set_bt_status(BT_FLIGHT_MODE, 0);
728 _bt_core_service_request_adapter(BT_ENABLE_ADAPTER);
729 _bt_enable_adapter();
732 if (adapter_status_le == BT_LE_DEACTIVATED &&
733 _bt_core_get_bt_le_status(BT_FLIGHT_MODE) != 0) {
734 _bt_core_set_bt_le_status(BT_FLIGHT_MODE, 0);
735 _bt_core_service_request_adapter(BT_ENABLE_ADAPTER_LE);
736 _bt_enable_adapter_le();
742 static gboolean __bt_core_disable_timeout_cb(gpointer data)
744 bt_status_t adapter_status;
745 bt_le_status_t adapter_status_le;
749 if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 1) != 0)
750 BT_ERR("Set vconf failed");
752 adapter_status = _bt_core_get_status();
753 adapter_status_le = _bt_core_get_le_status();
755 if (adapter_status == BT_ACTIVATED) {
756 int bt_status_before_mode = 0;
758 if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status_before_mode) == 0)
759 _bt_core_set_bt_status(BT_FLIGHT_MODE, bt_status_before_mode);
761 _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
762 _bt_disable_adapter();
765 if (adapter_status_le == BT_LE_ACTIVATED) {
766 int bt_le_status_before_mode = 0;
768 if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
769 _bt_core_set_bt_le_status(BT_FLIGHT_MODE, bt_le_status_before_mode);
771 _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
772 _bt_disable_adapter_le();
778 static int __bt_eventsystem_set_value(const char *event, const char *key, const char *value)
785 bundle_add_str(b, key, value);
787 ret = eventsystem_send_system_event(event, b);
789 BT_DBG("eventsystem_send_system_event result: %d", ret);
796 void _bt_core_adapter_added_cb(void)
799 bt_le_status_t le_status;
800 gboolean flight_mode_status;
804 status = _bt_core_get_status();
805 BT_DBG("status : %d", status);
806 le_status = _bt_core_get_le_status();
807 BT_DBG("le_status : %d", le_status);
809 if (status == BT_ACTIVATING)
810 __bt_core_set_status(BT_ACTIVATED);
811 if (le_status == BT_LE_ACTIVATING)
812 __bt_core_set_le_status(BT_LE_ACTIVATED);
814 flight_mode_status = _bt_core_is_flight_mode_enabled();
816 if (flight_mode_status == TRUE && _bt_is_flightmode_request() == TRUE) {
817 _bt_set_flightmode_request(FALSE);
818 g_timeout_add(2000, (GSourceFunc)__bt_core_disable_timeout_cb, NULL);
821 _bt_set_flightmode_request(FALSE);
822 _bt_core_terminate();
825 void _bt_core_adapter_removed_cb(void)
827 int flight_mode_value = 0;
828 int power_saving_mode = 0;
829 gboolean flight_mode_status;
830 static int timer_id = -1;
834 __bt_core_set_status(BT_DEACTIVATED);
835 __bt_core_set_le_status(BT_LE_DEACTIVATED);
836 if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
837 BT_ERR("Set vconf failed");
838 if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_OFF) != 0)
839 BT_ERR("Set vconf failed");
841 if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
842 EVT_VAL_BT_OFF) != ES_R_OK)
843 BT_ERR("Fail to set value");
845 if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
846 EVT_VAL_BT_LE_OFF) != ES_R_OK)
847 BT_ERR("Fail to set value");
849 if (is_recovery_mode == TRUE) {
851 timer_id = g_timeout_add(2000, (GSourceFunc)__bt_core_recovery_cb, NULL);
855 if (vconf_get_int(BT_OFF_DUE_TO_FLIGHT_MODE, &flight_mode_value) != 0)
856 BT_ERR("Fail to get the flight_mode_deactivated value");
858 if (vconf_get_int(BT_OFF_DUE_TO_POWER_SAVING_MODE, &power_saving_mode) != 0)
859 BT_ERR("Fail to get the ps_mode_deactivated value");
861 flight_mode_status = _bt_core_is_flight_mode_enabled();
863 if (flight_mode_status == FALSE && _bt_is_flightmode_request() == TRUE) {
864 _bt_set_flightmode_request(FALSE);
866 timer_id = g_timeout_add(2000, (GSourceFunc)__bt_core_enable_timeout_cb, NULL);
869 _bt_set_flightmode_request(FALSE);
871 if (flight_mode_value == 1 || power_saving_mode == 1) {
872 BT_DBG("Bt Core not terminated");
876 _bt_core_terminate();