Reduce the predefined logic (PredefinedPreprocessor)
[platform/core/connectivity/bluetooth-frwk.git] / bt-core / bt-core-adapter.c
index 10ea862..7c2ea5c 100644 (file)
@@ -21,9 +21,7 @@
 #include <bundle.h>
 #include <eventsystem.h>
 #include <stdio.h>
-#ifdef TIZEN_FEATURE_ACTD
 #include <actd/unit_control.h>
-#endif
 
 #include "bt-core-main.h"
 #include "bt-core-adapter.h"
@@ -121,7 +119,6 @@ gboolean _bt_core_is_flight_mode_enabled(void)
        }
 }
 
-#ifdef TIZEN_FEATURE_ACTD
 static int __bt_call_systemact_service(const char *service_name)
 {
        int ret;
@@ -138,35 +135,6 @@ static int __bt_call_systemact_service(const char *service_name)
 
        return 0;
 }
-#else
-static int __bt_call_systemact_service(const char *file_path)
-{
-       BT_DBG("+");
-       FILE *fp;
-
-       if (!file_path) {
-               BT_ERR("service file path is NULL");
-               return -1;
-       }
-
-       if (!access(file_path, F_OK)) {
-               remove(file_path);
-               usleep(100);
-       }
-
-       fp = fopen(file_path, "w");
-       if (!fp) {
-               BT_ERR("Failed to fopen service file");
-               return -1;
-       }
-
-
-       fclose(fp);
-       BT_DBG("-");
-       return 0;
-
-}
-#endif
 
 static int __execute_command(const char *cmd, char *const arg_list[])
 {
@@ -241,9 +209,7 @@ int _bt_enable_adapter(void)
 {
        int ret;
        bt_status_t status;
-#if 0
-       bt_le_status_t le_status;
-#endif
+
        BT_INFO("");
 
        status = _bt_core_get_status();
@@ -253,17 +219,21 @@ int _bt_enable_adapter(void)
                return -1;
        }
 
-#if 0 /* only the concept of private */
+/* only the concept of private
+#if 0
+       bt_le_status_t le_status;
+
        le_status = _bt_core_get_le_status();
        if (le_status == BT_LE_ACTIVATED) {
-               /* Turn on PSCAN, (ISCAN if needed) */
-               /* Return with 0 for the Enabled response. */
+               // Turn on PSCAN, (ISCAN if needed)
+               // Return with 0 for the Enabled response.
                __bt_core_set_status(BT_ACTIVATED);
                BT_INFO("BR/EDR is enabled.");
                g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
                return 0;
        }
 #endif
+*/
 
        __bt_core_set_status(BT_ACTIVATING);
        if (TIZEN_FEATURE_BT_USB_DONGLE) {
@@ -297,24 +267,25 @@ int _bt_enable_adapter(void)
 int _bt_disable_adapter(void)
 {
        bt_status_t status;
-#if 0
-       bt_le_status_t le_status;
-#endif
 
        BT_INFO_C("Disable adapter");
 
-#if 0 /* only the concept of private */
+/* only the concept of private
+#if 0
+       bt_le_status_t le_status;
+
        le_status = _bt_core_get_le_status();
        BT_DBG("le_status : %d", le_status);
        if (le_status == BT_LE_ACTIVATED) {
-               /* Turn off PSCAN, (ISCAN if needed) */
-               /* Return with 0 for the Disabled response. */
+               // Turn off PSCAN, (ISCAN if needed)
+               // Return with 0 for the Disabled response.
                __bt_core_set_status(BT_DEACTIVATED);
                BT_INFO("BR/EDR is disabled. now LE only mode");
                g_timeout_add(BT_CORE_IDLE_TERM_TIME, __bt_core_idle_terminate, NULL);
                return 0;
        }
 #endif
+*/
 
        status = _bt_core_get_status();
        if (status == BT_ACTIVATING) {
@@ -323,7 +294,6 @@ int _bt_disable_adapter(void)
                        if (__bt_call_systemact_service(BT_SYSTEMACT_HCI_DOWN) < 0)
                                BT_ERR("Failed to call systemact service");
                } else {
-#ifdef TIZEN_FEATURE_RADIO
                        int radio_status = VCONFKEY_RADIO_STATUS_OFF;
 
                        /* Check if radio status on or off */
@@ -339,10 +309,6 @@ int _bt_disable_adapter(void)
                                if (__bt_call_systemact_service(BT_SYSTEMACT_STACK_DOWN) < 0)
                                        BT_ERR("running script failed");
                        }
-#else
-                       if (__bt_call_systemact_service(BT_SYSTEMACT_STACK_DOWN) < 0)
-                               BT_ERR("running script failed");
-#endif
                }
                _bt_core_terminate();
                return 0;
@@ -360,7 +326,6 @@ int _bt_disable_adapter(void)
                }
                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;
 
                /* Check if radio status on or off */
@@ -382,13 +347,6 @@ int _bt_disable_adapter(void)
                                return -1;
                        }
                }
-#else
-               if (__bt_call_systemact_service(BT_SYSTEMACT_STACK_DOWN) < 0) {
-                               BT_ERR("running script failed");
-                               __bt_core_set_status(BT_ACTIVATED);
-                               return -1;
-               }
-#endif
        }
 
        return 0;
@@ -674,9 +632,7 @@ gboolean _bt_core_disable_adapter(void)
 gboolean _bt_core_recover_adapter(void)
 {
        int ret;
-#if 0
-       int ret_le;
-#endif
+
        BT_INFO_C("Recover bt adapter");
 
        _bt_set_flightmode_request(FALSE);
@@ -689,27 +645,26 @@ gboolean _bt_core_recover_adapter(void)
 
        if (_bt_core_get_status() == BT_ACTIVATED) {
                _bt_core_set_bt_status(BT_RECOVERY_MODE, 1);
-#ifdef TIZEN_FEATURE_BUSACT
                _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
-#endif
        }
        if (_bt_core_get_le_status() == BT_LE_ACTIVATED) {
                _bt_core_set_bt_le_status(BT_RECOVERY_MODE, 1);
-#ifdef TIZEN_FEATURE_BUSACT
                _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
-#endif
        }
 
        ret = _bt_disable_adapter();
        if (ret < 0)
                BT_ERR("_bt_disable_adapter() failed");
 
-/* In platform, don't seperate BR/EDR and LE status */
+/* In platform, don't seperate BR/EDR and LE status
 #if 0
+       int ret_le;
+
        ret_le = _bt_disable_adapter_le();
        if (ret_le < 0)
                BT_ERR("_bt_disable_adapter_le() failed");
 #endif
+*/
        return TRUE;
 }
 
@@ -803,7 +758,6 @@ gboolean _bt_core_factory_test_mode(const char *type, const char *arg)
        int ret;
        BT_DBG("Test item : %s", type);
 
-#ifdef TIZEN_FEATURE_ACTD
        if (g_strcmp0(type, "Enable_RF_Test") == 0) {
                ret = __bt_call_systemact_service(BT_SYSTEMACT_EDUTM_ON);
                if (ret < 0)
@@ -817,38 +771,6 @@ gboolean _bt_core_factory_test_mode(const char *type, const char *arg)
                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 };
-
-       if (g_strcmp0(type, "Enable_RF_Test") == 0) {
-               cmd = "/usr/etc/bluetooth/bt-edutm-on.sh";
-               arg_list[0] = "bt-edutm-on.sh";
-       } else if (g_strcmp0(type, "Disable_RF_Test") == 0) {
-               cmd = "/usr/etc/bluetooth/bt-edutm-off.sh";
-               arg_list[0] = "bt-edutm-off.sh";
-       } else if (g_strcmp0(type, "Slave_Mode") == 0) {
-               cmd = "/usr/etc/bluetooth/bt-mode-slave.sh";
-               arg_list[0] = "bt-mode-slave.sh";
-       } else if (g_strcmp0(type, "Master_Mode") == 0) {
-               cmd = "/usr/etc/bluetooth/bt-mode-master.sh";
-               arg_list[0] = "bt-mode-master.sh";
-       } else if (g_strcmp0(type, "SSP_Debug_Mode") == 0) {
-               cmd = "/usr/etc/bluetooth/bt-set-ssp-debug-mode.sh";
-               arg_list[0] = "bt-set-ssp-debug-mode.sh";
-               arg_list[1] = (char *)arg;
-       } else if (g_strcmp0(type, "RF_Channel") == 0) {
-               cmd = "/usr/etc/bluetooth/bt-enable-rf-channel.sh";
-               arg_list[0] = "bt-enable-rf-channel.sh";
-               arg_list[1] = (char *)arg;
-       } else {
-               return FALSE;
-       }
-
-       BT_DBG("Run %s", cmd);
-       if (__execute_command(cmd, arg_list) < 0)
-               BT_ERR("running script failed");
-#endif
 
        return TRUE;
 }
@@ -893,14 +815,6 @@ static gboolean __bt_core_recovery_cb(gpointer data)
                        BT_ERR("_bt_enable_adapter() failed");
        }
 
-#if 0
-       if (_bt_core_get_bt_le_status(BT_RECOVERY_MODE) == 1) {
-               _bt_core_set_bt_le_status(BT_RECOVERY_MODE, 0);
-               ret = _bt_enable_adapter_le();
-               if (ret < 0)
-                       BT_ERR("_bt_enable_adapter_le() failed");
-       }
-#endif
        is_recovery_mode = FALSE;
 
        BT_DBG("-");
@@ -957,9 +871,7 @@ static gboolean __bt_core_disable_timeout_cb(gpointer data)
                if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status_before_mode) == 0)
                        _bt_core_set_bt_status(BT_FLIGHT_MODE, bt_status_before_mode);
 
-#ifdef TIZEN_FEATURE_BUSACT
                _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
-#endif
                _bt_disable_adapter();
        }
 
@@ -969,9 +881,7 @@ static gboolean __bt_core_disable_timeout_cb(gpointer data)
                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);
 
-#ifdef TIZEN_FEATURE_BUSACT
                _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
-#endif
                _bt_disable_adapter_le();
        }