X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bt-core%2Fbt-core-adapter.c;h=975a5d2372a4296594a1ae88728668f418f37edf;hb=0bffd0dc57188e9d53863475c1112711b8e73367;hp=2def3c47e23f3a7c58083c34edeaa36ff08e17b6;hpb=dc6e2e147b9661e0318b51ae6e9c47f84887f5fc;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git diff --git a/bt-core/bt-core-adapter.c b/bt-core/bt-core-adapter.c index 2def3c4..975a5d2 100644 --- a/bt-core/bt-core-adapter.c +++ b/bt-core/bt-core-adapter.c @@ -21,6 +21,9 @@ #include #include #include +#ifdef TIZEN_FEATURE_ACTD +#include +#endif #include "bt-core-main.h" #include "bt-core-adapter.h" @@ -28,6 +31,8 @@ #include "bt-core-dbus-handler.h" #include "bt-core-noti-handler.h" +#include "bt-internal-types.h" + #define BT_CORE_IDLE_TERM_TIME 200 /* 200ms */ #define BT_CORE_CHECK_ADAPTER_OBJECT_PATH_MAX 50 @@ -116,6 +121,24 @@ gboolean _bt_core_is_flight_mode_enabled(void) } } +#ifdef TIZEN_FEATURE_ACTD +static int __bt_call_systemact_service(const char *service_name) +{ + int ret; + + BT_DBG("Use System Activated : %s", service_name); + + ret = actd_start_unit(UNIT_CONTROL_BUS_TYPE_SYSTEM, service_name, 5000); + + if (ret != UNIT_CONTROL_OK) { + BT_ERR("Failed to activate the %s: %d", service_name, ret); + /* Return Success even if the activating result is fail */ + return 0; + } + + return 0; +} +#else static int __bt_call_systemact_service(const char *file_path) { BT_DBG("+"); @@ -143,6 +166,7 @@ static int __bt_call_systemact_service(const char *file_path) return 0; } +#endif static int __execute_command(const char *cmd, char *const arg_list[]) { @@ -162,7 +186,12 @@ static int __execute_command(const char *cmd, char *const arg_list[]) if (pid2 == -1) { BT_ERR("fork failed"); } else if (pid2 == 0) { - execv(cmd, arg_list); + if (arg_list != NULL) { + execv(cmd, arg_list); + } else { + char *argv[] = { NULL }; + execv(cmd, argv); + } exit(256); } exit(0); @@ -189,24 +218,6 @@ static int __bt_stack_up(void) return -1; } - /* We need to insert BT driver module by using 'insmod' in case of ARTIK530, - * and 'insmod' should be executed by systemd not bt-core. */ - ret = __bt_call_systemact_service(BT_SYSTEMACT_BT_DRIVER_INSMOD); - if (ret < 0) { - BT_ERR("Failed to call systemact service"); - return -1; - } else { - /* Insmod should run before bt-stack-up.sh command */ - usleep(1000 * 200); /* 200ms */ - } - - ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL); - if (ret < 0) { - BT_ERR("Failed to run script"); - __bt_call_systemact_service(BT_SYSTEMACT_HCI_LOGGER_STOP); - return -1; - } - /* activate Bluez */ ret = __bt_call_systemact_service(BT_SYSTEMACT_BLUEZ_START); if (ret < 0) { @@ -215,17 +226,15 @@ static int __bt_stack_up(void) } /* activate bluetooth-share */ - ret = __bt_call_systemact_service(BT_SYSTEMACT_BLUETOOTH_SHARE_START); - if (ret < 0) { - BT_ERR("Failed to call systemact service"); - return -1; + if (!TIZEN_PROFILE_WEARABLE) { + ret = __bt_call_systemact_service(BT_SYSTEMACT_BLUETOOTH_SHARE_START); + if (ret < 0) { + BT_ERR("Failed to call systemact service"); + return -1; + } } - return 0; - - - } int _bt_enable_adapter(void) @@ -344,6 +353,7 @@ int _bt_disable_adapter(void) __bt_core_set_status(BT_ACTIVATED); return -1; } + g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL); } else { #ifdef TIZEN_FEATURE_RADIO int radio_status = VCONFKEY_RADIO_STATUS_OFF; @@ -387,6 +397,7 @@ int _bt_enable_adapter_le(void) bt_status_t status; bt_le_status_t le_status; le_status = _bt_core_get_le_status(); + retv_if(le_status == BT_LE_ACTIVATED, 0); retv_if(le_status != BT_LE_DEACTIVATED, -1); status = _bt_core_get_status(); @@ -398,7 +409,7 @@ int _bt_enable_adapter_le(void) if (ret < 0) BT_ERR("Failed to call systemact service"); } else { - ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL); + ret = __bt_stack_up(); } if (ret < 0) { BT_ERR("running script failed"); @@ -786,12 +797,22 @@ gboolean _bt_core_set_transfer_value(gboolean value) gboolean _bt_core_factory_test_mode(const char *type, const char *arg) { + BT_DBG("Test item : %s", type); +#ifdef TIZEN_FEATURE_ACTD + if (g_strcmp0(type, "Enable_RF_Test") == 0) { + __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_ON); + } else if (g_strcmp0(type, "Disable_RF_Test") == 0) { + __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_OFF); + } else { + BT_DBG("Terminate bt-core process"); + g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL); + return FALSE; + } +#else char *cmd = NULL; char *arg_list[3] = { NULL, NULL, NULL }; - BT_DBG("Test item : %s", type); - if (g_strcmp0(type, "Enable_RF_Test") == 0) { cmd = "/usr/etc/bluetooth/bt-edutm-on.sh"; arg_list[0] = "bt-edutm-on.sh"; @@ -819,6 +840,7 @@ gboolean _bt_core_factory_test_mode(const char *type, const char *arg) BT_DBG("Run %s", cmd); if (__execute_command(cmd, arg_list) < 0) BT_ERR("running script failed"); +#endif return TRUE; } @@ -826,14 +848,11 @@ gboolean _bt_core_factory_test_mode(const char *type, const char *arg) static gboolean __bt_core_recovery_cb(gpointer data) { int ret = 0; -#ifdef TIZEN_FEATURE_BUSACT gboolean is_request_failed = FALSE; static gboolean is_first_failure = TRUE; -#endif BT_DBG("+"); -#ifdef TIZEN_FEATURE_BUSACT if (_bt_core_get_bt_status(BT_RECOVERY_MODE) == 1) { ret = _bt_core_service_request_adapter(BT_ENABLE_ADAPTER); if (ret < 0) @@ -858,7 +877,6 @@ static gboolean __bt_core_recovery_cb(gpointer data) } } else is_first_failure = TRUE; -#endif if (_bt_core_get_bt_status(BT_RECOVERY_MODE) == 1) { _bt_core_set_bt_status(BT_RECOVERY_MODE, 0);