-static void __bt_core_handle_adapter_with_flight_mode(gboolean flight_mode)
-{
- bt_status_t adapter_status;
- bt_le_status_t adapter_status_le;
-
- adapter_status = _bt_core_get_status();
- adapter_status_le = _bt_core_get_le_status();
-
- BT_INFO("bt status %d, le status %d", adapter_status, adapter_status_le);
- if (flight_mode == TRUE) {
- BT_INFO_C("Flight mode on. Turn off BT");
-
- if (adapter_status == BT_ACTIVATING || adapter_status_le == BT_LE_ACTIVATING) {
- BT_INFO("BT adapter is activating. Turn off BT after activation");
- _bt_set_flightmode_request(TRUE);
- return;
- }
- if (adapter_status != BT_ACTIVATED && adapter_status_le != BT_LE_ACTIVATED) {
- BT_INFO("No need to control bt status");
- return;
- }
-
- if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 1) != 0)
- BT_ERR("Set vconf failed");
-
- if (adapter_status == BT_ACTIVATED) {
- int bt_status_before_mode = 0;
-
- if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status_before_mode) == 0)
- _bt_core_set_bt_status(BT_FLIGHT_MODE, bt_status_before_mode);
-
- _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
-#ifndef USB_BLUETOOTH
- _bt_disable_adapter();
-#endif
- }
-
- if (adapter_status_le == BT_LE_ACTIVATED) {
- int bt_le_status_before_mode = 0;
-
- if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status_before_mode) == 0)
- _bt_core_set_bt_le_status(BT_FLIGHT_MODE, bt_le_status_before_mode);
-
- _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
-#ifndef USB_BLUETOOTH
- _bt_disable_adapter_le();
-#endif
- }
- } else {
- int flight_mode_value = 0;
-
- BT_INFO_C("Flight mode off. Turn on BT");
-
- if (adapter_status == BT_DEACTIVATING || adapter_status_le == BT_LE_DEACTIVATING) {
- BT_INFO("BT adapter is activating. Turn off BT after activation");
- _bt_set_flightmode_request(TRUE);
- return;
- }
- if (adapter_status != BT_DEACTIVATED && adapter_status_le != BT_LE_DEACTIVATED) {
- BT_INFO("No need to control bt status");
- return;
- }
-
- if (vconf_get_int(BT_OFF_DUE_TO_FLIGHT_MODE, &flight_mode_value))
- BT_ERR("Fail get flight mode value");
-
- if (flight_mode_value == 0)
- return;
-
- if (vconf_set_int(BT_OFF_DUE_TO_FLIGHT_MODE, 0) != 0)
- BT_ERR("Set vconf failed");
-
- ret_if(__bt_off_cause_conflict_check());
-
- if (adapter_status == BT_DEACTIVATED &&
- _bt_core_get_bt_status(BT_FLIGHT_MODE) != 0) {
- _bt_core_set_bt_status(BT_FLIGHT_MODE, 0);
- _bt_core_service_request_adapter(BT_ENABLE_ADAPTER);
-#ifndef USB_BLUETOOTH
- _bt_enable_adapter();
-#endif
- }
-
- if (adapter_status_le == BT_LE_DEACTIVATED &&
- _bt_core_get_bt_le_status(BT_FLIGHT_MODE) != 0) {
- _bt_core_set_bt_le_status(BT_FLIGHT_MODE, 0);
- _bt_core_service_request_adapter(BT_ENABLE_ADAPTER_LE);
-#ifndef USB_BLUETOOTH
- _bt_enable_adapter_le();
-#endif
- }
- }
-}
-