Remove Profile Build Dependenceis: do it at runtime 58/100158/4
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 25 Nov 2016 07:19:12 +0000 (16:19 +0900)
committerMyungJoo Ham <myungjoo.ham@samsung.com>
Mon, 5 Dec 2016 03:53:16 +0000 (12:53 +0900)
- This is for Tizen 4.0.

  : Tizen 4.0 Configurability and Build Blocks require
  to remove all profile-depending build options in spec files.
  (No More profile macros)

- It is recommended to distinguish features/profiles at runtime.
 unless it incurs too much overhead, which requires you to
 create multiple binaries and subpackages.
  However, because there are different service files per profile,

- Please create JIRA-TRE issue when you SR this commit:

  - Add bluetooth-frwk-profile_common for common profile if common has bluetooth-frwk
  - Add bluetooth-frwk-profile_mobile for mobile profile if mobile has bluetooth-frwk
  - Add bluetooth-frwk-profile_wearable for wearable profile if wearable has bluetooth-frwk
  - Add bluetooth-frwk-profile_tv for tv profile if tv has bluetooth-frwk
  - Add bluetooth-frwk-profile_ivi for ivi profile if ivi has bluetooth-frwk

Conflicts:
bt-api/CMakeLists.txt
bt-core/CMakeLists.txt
bt-service/bt-service-adapter.c
packaging/bluetooth-frwk.spec

Change-Id: I813f9f9351571bfad6c437e073da92117fdc80eb
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
24 files changed:
bt-api/CMakeLists.txt
bt-api/bt-adapter-le.c
bt-api/bt-adapter.c
bt-api/bt-telephony.c
bt-core/CMakeLists.txt
bt-core/bt-core-adapter.c
bt-core/bt-core-main.c
bt-core/bt-core-noti-handler.c
bt-service-emul/CMakeLists.txt
bt-service-emul/bt-service-adapter.c
bt-service-emul/bt-service-main.c
bt-service-emul/include/bt-service-common.h
bt-service/CMakeLists.txt
bt-service/bt-service-adapter.c
bt-service/bt-service-agent.c
bt-service/bt-service-audio.c
bt-service/bt-service-device.c
bt-service/bt-service-event-receiver.c
bt-service/bt-service-main.c
bt-service/include/bt-service-agent.h
bt-service/include/bt-service-common.h
include/bt-internal-types.c [new file with mode: 0644]
include/bt-internal-types.h
packaging/bluetooth-frwk.spec

index d2805d0..17a23ef 100644 (file)
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(bt-service-api C)
 
 SET(SRCS
+../include/bt-internal-types.c
 bt-common.c
 bt-adapter.c
 bt-adapter-le.c
@@ -59,6 +60,7 @@ SET(PKG_MODULES
        glib-2.0
        gio-2.0
        gio-unix-2.0
+       capi-system-info
 )
 
 INCLUDE(FindPkgConfig)
index 8cbb29d..018db76 100644 (file)
@@ -243,7 +243,6 @@ BT_EXPORT_API int bluetooth_unregister_all_scan_filters(void)
        return result;
 }
 
-#ifdef TIZEN_PROFILE_WEARABLE
 gboolean __bluetooth_is_privileged_process(void)
 {
        FILE *fp = NULL;
@@ -265,7 +264,6 @@ gboolean __bluetooth_is_privileged_process(void)
        fclose(fp);
        return FALSE;
 }
-#endif
 
 BT_EXPORT_API int bluetooth_set_advertising(int handle, gboolean enable)
 {
@@ -274,9 +272,8 @@ BT_EXPORT_API int bluetooth_set_advertising(int handle, gboolean enable)
 
        BT_CHECK_ENABLED_ANY(return);
 
-#ifdef TIZEN_PROFILE_WEARABLE
-       use_reserved_slot = __bluetooth_is_privileged_process();
-#endif
+       if (TIZEN_PROFILE_WEARABLE)
+               use_reserved_slot = __bluetooth_is_privileged_process();
 
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
@@ -301,9 +298,8 @@ BT_EXPORT_API int bluetooth_set_custom_advertising(int handle, gboolean enable,
 
        BT_CHECK_ENABLED_ANY(return);
 
-#ifdef TIZEN_PROFILE_WEARABLE
+       if (TIZEN_PROFILE_WEARABLE)
        use_reserved_slot = __bluetooth_is_privileged_process();
-#endif
 
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
@@ -360,9 +356,8 @@ BT_EXPORT_API int bluetooth_set_advertising_data(int handle, const bluetooth_adv
        if (length > BLUETOOTH_ADVERTISING_DATA_LENGTH_MAX - 3)
                return BLUETOOTH_ERROR_INVALID_PARAM;
 
-#ifdef TIZEN_PROFILE_WEARABLE
-       use_reserved_slot = __bluetooth_is_privileged_process();
-#endif
+       if (TIZEN_PROFILE_WEARABLE)
+               use_reserved_slot = __bluetooth_is_privileged_process();
 
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
@@ -420,9 +415,8 @@ BT_EXPORT_API int bluetooth_set_scan_response_data(int handle,
        if (length > BLUETOOTH_SCAN_RESP_DATA_LENGTH_MAX)
                return BLUETOOTH_ERROR_INVALID_PARAM;
 
-#ifdef TIZEN_PROFILE_WEARABLE
-       use_reserved_slot = __bluetooth_is_privileged_process();
-#endif
+       if (TIZEN_PROFILE_WEARABLE)
+               use_reserved_slot = __bluetooth_is_privileged_process();
 
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
index 02ac8a3..f26b7e8 100644 (file)
@@ -277,25 +277,25 @@ BT_EXPORT_API int bluetooth_get_discoverable_mode(bluetooth_discoverable_mode_t
 
        BT_CHECK_PARAMETER(discoverable_mode_ptr, return);
 
-#ifndef TIZEN_PROFILE_WEARABLE
-       int timeout = 0;
-       /* Requirement in OSP */
-       if (bluetooth_check_adapter() == BLUETOOTH_ADAPTER_DISABLED) {
-               if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0) {
-                       BT_ERR("Fail to get the timeout value");
-                       return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
-               }
+       if (!TIZEN_PROFILE_WEARABLE) {
+               int timeout = 0;
+               /* Requirement in OSP */
+               if (bluetooth_check_adapter() == BLUETOOTH_ADAPTER_DISABLED) {
+                       if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0) {
+                               BT_ERR("Fail to get the timeout value");
+                               return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
+                       }
 
-               if (timeout == -1)
-                       *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE;
-               else
-                       *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
+                       if (timeout == -1)
+                               *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE;
+                       else
+                               *discoverable_mode_ptr = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
 
-               return BLUETOOTH_ERROR_NONE;
+                       return BLUETOOTH_ERROR_NONE;
+               }
+       } else {
+               BT_CHECK_ENABLED(return);
        }
-#else
-       BT_CHECK_ENABLED(return);
-#endif
 
        BT_INIT_PARAMS();
        BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param);
index 493e339..ababe28 100644 (file)
@@ -25,6 +25,7 @@
 #include "bt-common.h"
 #include "bluetooth-telephony-api.h"
 #include "marshal.h"
+#include "bt-internal-types.h"
 
 #define BT_SCO_TIMEOUT 3000
 
@@ -307,11 +308,11 @@ static GVariant *__bluetooth_telephony_dbus_method_send(const char *path,
                const char *interface, const char *method,
                GError **err, GVariant *parameters)
 {
-#if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI)
-       int timeout = 4000;
-#else
        int timeout = -1;
-#endif
+
+       if (TIZEN_PROFILE_WEARABLE || TIZEN_PROFILE_IVI)
+               timeout = 4000;
+
        GVariant *reply;
        GDBusProxy *proxy;
        GDBusConnection *conn;
@@ -799,7 +800,6 @@ static  int __bluetooth_telephony_unregister(void)
        return BLUETOOTH_TELEPHONY_ERROR_NONE;
 }
 
-#if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI)
 static void __bluetooth_telephony_init_headset_state(void)
 {
        GVariant *reply;
@@ -839,7 +839,6 @@ static void __bluetooth_telephony_init_headset_state(void)
 
        FN_END;
 }
-#endif
 
 static gboolean __bluetooth_telephony_is_headset(uint32_t device_class)
 {
@@ -1405,9 +1404,8 @@ BT_EXPORT_API int bluetooth_telephony_init(bt_telephony_func_ptr cb,
                goto fail;
        }
 
-#if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI)
-       __bluetooth_telephony_init_headset_state();
-#endif
+       if (TIZEN_PROFILE_WEARABLE || TIZEN_PROFILE_IVI)
+               __bluetooth_telephony_init_headset_state();
 
        FN_END;
        return ret;
@@ -1487,10 +1485,9 @@ BT_EXPORT_API gboolean bluetooth_telephony_is_sco_connected(void)
        g_variant_get(reply, "(b)", &status);
        g_variant_unref(reply);
 
-#if defined(TIZEN_PROFILE_WEARABLE) || defined(TIZEN_PROFILE_IVI)
-       if (status == TRUE && telephony_info.headset_state != BLUETOOTH_STATE_PLAYING)
-               telephony_info.headset_state = BLUETOOTH_STATE_PLAYING;
-#endif
+       if (TIZEN_PROFILE_WEARABLE || TIZEN_PROFILE_IVI)
+               if (status == TRUE && telephony_info.headset_state != BLUETOOTH_STATE_PLAYING)
+                       telephony_info.headset_state = BLUETOOTH_STATE_PLAYING;
 
        BT_INFO("SCO Connected Status = [%d]", status);
        return status;
index bbcd17e..1bbf1cc 100644 (file)
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(bt-core C)
 
 SET(SRCS
+../include/bt-internal-types.c
 bt-core-main.c
 bt-core-adapter.c
 bt-core-dbus-handler.c
@@ -22,7 +23,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED dlog vconf gio-2.0 gio-unix-2.0 eventsystem)
+pkg_check_modules(pkgs REQUIRED dlog vconf gio-2.0 gio-unix-2.0 eventsystem capi-system-info)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 00b9c5c..1860931 100644 (file)
@@ -96,18 +96,18 @@ static gboolean __bt_core_idle_terminate(gpointer data)
 
 gboolean _bt_core_is_flight_mode_enabled(void)
 {
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
        int isFlightMode = 0;
        int ret = -1;
 
-       ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &isFlightMode);
-       if (ret != 0)
-               BT_ERR("vconf_get_bool failed");
+       if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
+               ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &isFlightMode);
+               if (ret != 0)
+                       BT_ERR("vconf_get_bool failed");
 
-       return isFlightMode;
-#else
-       return FALSE;
-#endif
+               return isFlightMode;
+       } else {
+               return FALSE;
+       }
 }
 
 static int __execute_command(const char *cmd, char *const arg_list[])
@@ -173,20 +173,20 @@ int _bt_enable_adapter(void)
 #endif
 
        __bt_core_set_status(BT_ACTIVATING);
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-       char *argv_up[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "up", NULL};
-       ret = __execute_command("/usr/bin/hciconfig", argv_up);
-#else
-       ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
-#endif
+       if (TIZEN_FEATURE_BT_USB_DONGLE) {
+               char *argv_up[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "up", NULL};
+               ret = __execute_command("/usr/bin/hciconfig", argv_up);
+       } else {
+               ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
+       }
        if (ret < 0) {
                BT_ERR("running script failed");
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-               char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
-               ret = __execute_command("/usr/bin/hciconfig", argv_down);
-#else
-               ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh", NULL);
-#endif
+               if (TIZEN_FEATURE_BT_USB_DONGLE) {
+                       char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
+                       ret = __execute_command("/usr/bin/hciconfig", argv_down);
+               } else {
+                       ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh", NULL);
+               }
                __bt_core_set_status(BT_DEACTIVATED);
                return -1;
        }
@@ -219,33 +219,33 @@ int _bt_disable_adapter(void)
        status = _bt_core_get_status();
        if (status == BT_ACTIVATING) {
                /* Forcely terminate */
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-               char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
-               if (__execute_command("/usr/bin/hciconfig", argv_down) < 0)
-                       BT_ERR("running script failed");
-#else
+               if (TIZEN_FEATURE_BT_USB_DONGLE) {
+                       char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
+                       if (__execute_command("/usr/bin/hciconfig", argv_down) < 0)
+                               BT_ERR("running script failed");
+               } else {
 
 #ifdef TIZEN_FEATURE_RADIO
-               int radio_status = VCONFKEY_RADIO_STATUS_OFF;
+                       int radio_status = VCONFKEY_RADIO_STATUS_OFF;
 
-               /* Check if radio status on or off */
-               if (vconf_get_int(VCONFKEY_RADIO_STATUS, &radio_status) < 0)
-                       BT_ERR("Fail to get radio status");
+                       /* Check if radio status on or off */
+                       if (vconf_get_int(VCONFKEY_RADIO_STATUS, &radio_status) < 0)
+                               BT_ERR("Fail to get radio status");
 
-               BT_DBG("Radio status: %d", radio_status);
+                       BT_DBG("Radio status: %d", radio_status);
 
-               if (radio_status == VCONFKEY_RADIO_STATUS_ON) {
-                       if (__execute_command("/usr/etc/bluetooth/bt-stack-down-with-radio.sh", NULL) < 0)
-                               BT_ERR("running script failed");
-               } else {
+                       if (radio_status == VCONFKEY_RADIO_STATUS_ON) {
+                               if (__execute_command("/usr/etc/bluetooth/bt-stack-down-with-radio.sh", NULL) < 0)
+                                       BT_ERR("running script failed");
+                       } else {
+                               if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0)
+                                       BT_ERR("running script failed");
+                       }
+#else
                        if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0)
                                BT_ERR("running script failed");
-               }
-#else
-               if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0)
-                       BT_ERR("running script failed");
-#endif
 #endif
+               }
                _bt_core_terminate();
                return 0;
        } else if (status != BT_ACTIVATED) {
@@ -254,44 +254,44 @@ int _bt_disable_adapter(void)
        }
 
        __bt_core_set_status(BT_DEACTIVATING);
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-       char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
-       if (__execute_command("/usr/bin/hciconfig", argv_down) < 0) {
-               BT_ERR("running script failed");
-               __bt_core_set_status(BT_ACTIVATED);
-               return -1;
-       }
-#else
-#ifdef TIZEN_FEATURE_RADIO
-       int radio_status = VCONFKEY_RADIO_STATUS_OFF;
-
-       /* Check if radio status on or off */
-       if (vconf_get_int(VCONFKEY_RADIO_STATUS, &radio_status) < 0)
-               BT_ERR("Fail to get radio status");
-
-       BT_DBG("Radio status: %d", radio_status);
-
-       if (radio_status == VCONFKEY_RADIO_STATUS_ON) {
-               if (__execute_command("/usr/etc/bluetooth/bt-stack-down-with-radio.sh", NULL) < 0) {
+       if (TIZEN_FEATURE_BT_USB_DONGLE) {
+               char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
+               if (__execute_command("/usr/bin/hciconfig", argv_down) < 0) {
                        BT_ERR("running script failed");
                        __bt_core_set_status(BT_ACTIVATED);
                        return -1;
                }
        } else {
-               if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
-                       BT_ERR("running script failed");
-                       __bt_core_set_status(BT_ACTIVATED);
-                       return -1;
+#ifdef TIZEN_FEATURE_RADIO
+               int radio_status = VCONFKEY_RADIO_STATUS_OFF;
+
+               /* Check if radio status on or off */
+               if (vconf_get_int(VCONFKEY_RADIO_STATUS, &radio_status) < 0)
+                       BT_ERR("Fail to get radio status");
+
+               BT_DBG("Radio status: %d", radio_status);
+
+               if (radio_status == VCONFKEY_RADIO_STATUS_ON) {
+                       if (__execute_command("/usr/etc/bluetooth/bt-stack-down-with-radio.sh", NULL) < 0) {
+                               BT_ERR("running script failed");
+                               __bt_core_set_status(BT_ACTIVATED);
+                               return -1;
+                       }
+               } else {
+                       if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
+                               BT_ERR("running script failed");
+                               __bt_core_set_status(BT_ACTIVATED);
+                               return -1;
+                       }
                }
-       }
 #else
-       if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
-                       BT_ERR("running script failed");
-                       __bt_core_set_status(BT_ACTIVATED);
-                       return -1;
-       }
-#endif
+               if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
+                               BT_ERR("running script failed");
+                               __bt_core_set_status(BT_ACTIVATED);
+                               return -1;
+               }
 #endif
+       }
 
        return 0;
 }
@@ -310,20 +310,20 @@ int _bt_enable_adapter_le(void)
        if (status == BT_DEACTIVATED) {
                __bt_core_set_le_status(BT_LE_ACTIVATING);
                BT_DBG("Activate BT");
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-               char *argv_up[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "up", NULL};
-               ret = __execute_command("/usr/bin/hciconfig", argv_up);
-#else
-               ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
-#endif
+               if (TIZEN_FEATURE_BT_USB_DONGLE) {
+                       char *argv_up[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "up", NULL};
+                       ret = __execute_command("/usr/bin/hciconfig", argv_up);
+               } else {
+                       ret = __execute_command("/usr/etc/bluetooth/bt-stack-up.sh", NULL);
+               }
                if (ret < 0) {
                        BT_ERR("running script failed");
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-                       char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
-                       ret = __execute_command("/usr/bin/hciconfig", argv_down);
-#else
-                       ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh &", NULL);
-#endif
+                       if (TIZEN_FEATURE_BT_USB_DONGLE) {
+                               char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
+                               ret = __execute_command("/usr/bin/hciconfig", argv_down);
+                       } else {
+                               ret = __execute_command("/usr/etc/bluetooth/bt-dev-end.sh &", NULL);
+                       }
                        __bt_core_set_status(BT_DEACTIVATED);
                        __bt_core_set_le_status(BT_LE_DEACTIVATED);
                        return -1;
@@ -361,12 +361,14 @@ int _bt_disable_adapter_le(void)
 
        if (status == BT_DEACTIVATED) {
                __bt_core_set_le_status(BT_LE_DEACTIVATING);
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-               char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
-               if (__execute_command("/usr/bin/hciconfig", argv_down) < 0) {
-#else
-               if (__execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL) < 0) {
-#endif
+               int ret;
+               if (TIZEN_FEATURE_BT_USB_DONGLE) {
+                       char *argv_down[] = {"/usr/bin/hciconfig", "/usr/bin/hciconfig", "hci0", "down", NULL};
+                       ret = __execute_command("/usr/bin/hciconfig", argv_down);
+               } else {
+                       ret = __execute_command("/usr/etc/bluetooth/bt-stack-down.sh", NULL);
+               }
+               if (ret < 0) {
                        BT_ERR("running script failed");
                        __bt_core_set_le_status(BT_LE_ACTIVATED);
                        return -1;
index e5e7197..04612e3 100755 (executable)
@@ -108,9 +108,8 @@ static gboolean __bt_check_bt_core(void *data)
 
                /* Enable the BT */
                _bt_core_service_request_adapter(BT_ENABLE_ADAPTER);
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-               _bt_enable_adapter();
-#endif
+               if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                       _bt_enable_adapter();
        } else if (bt_status == VCONFKEY_BT_STATUS_OFF &&
                        (flight_mode_deactivation == 1 || ps_mode_deactivation > 0)) {
                _bt_core_handle_flight_mode_noti();
@@ -125,9 +124,8 @@ static gboolean __bt_check_bt_core(void *data)
 
                /* Enable the BT LE */
                _bt_core_service_request_adapter(BT_ENABLE_ADAPTER_LE);
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-               _bt_enable_adapter_le();
-#endif
+               if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                       _bt_enable_adapter_le();
        } else {
                status = _bt_core_get_status();
                le_status = _bt_core_get_le_status();
index 9860f5d..7615e5d 100644 (file)
@@ -87,9 +87,8 @@ static void __bt_core_handle_adapter_with_flight_mode(gboolean flight_mode)
 #ifdef TIZEN_FEATURE_BUSACT
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
 #endif
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-                       _bt_disable_adapter();
-#endif
+                       if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                               _bt_disable_adapter();
                }
 
                if (adapter_status_le == BT_LE_ACTIVATED) {
@@ -101,9 +100,8 @@ static void __bt_core_handle_adapter_with_flight_mode(gboolean flight_mode)
 #ifdef TIZEN_FEATURE_BUSACT
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
 #endif
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-                       _bt_disable_adapter_le();
-#endif
+                       if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                               _bt_disable_adapter_le();
                }
        } else {
                int flight_mode_value = 0;
@@ -135,18 +133,16 @@ static void __bt_core_handle_adapter_with_flight_mode(gboolean flight_mode)
                    _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 TIZEN_FEATURE_BT_USB_DONGLE
-                       _bt_enable_adapter();
-#endif
+                       if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                               _bt_enable_adapter();
                }
 
                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 TIZEN_FEATURE_BT_USB_DONGLE
-                       _bt_enable_adapter_le();
-#endif
+                       if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                               _bt_enable_adapter_le();
                }
        }
 }
@@ -172,9 +168,8 @@ static void __bt_core_handle_adapter_with_power_saving_mode(int power_saving_mod
 #ifdef TIZEN_FEATURE_BUSACT
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER);
 #endif
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-                       _bt_disable_adapter();
-#endif
+                       if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                               _bt_disable_adapter();
                }
                if (adapter_status_le == BT_LE_ACTIVATED) {
                        int bt_le_status_before_mode = 0;
@@ -186,9 +181,8 @@ static void __bt_core_handle_adapter_with_power_saving_mode(int power_saving_mod
                        /* Disable the BT LE */
                        _bt_core_service_request_adapter(BT_DISABLE_ADAPTER_LE);
 #endif
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-                       _bt_disable_adapter_le();
-#endif
+                       if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                               _bt_disable_adapter_le();
                }
        } else {
                int ps_mode_value = 0;
@@ -211,22 +205,20 @@ static void __bt_core_handle_adapter_with_power_saving_mode(int power_saving_mod
                if (adapter_status == BT_DEACTIVATED && (_bt_core_get_bt_status(BT_POWER_SAVING_MODE) != 0)) {
                        _bt_core_set_bt_status(BT_POWER_SAVING_MODE, 0);
                        _bt_core_service_request_adapter(BT_ENABLE_ADAPTER);
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-                       _bt_enable_adapter();
-#endif
+                       if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                               _bt_enable_adapter();
                }
                BT_DBG("BT LE status before Emergency mode() :%d", _bt_core_get_bt_le_status(BT_POWER_SAVING_MODE));
                if (adapter_status_le == BT_LE_DEACTIVATED &&  _bt_core_get_bt_le_status(BT_POWER_SAVING_MODE) != 0) {
                        _bt_core_set_bt_le_status(BT_POWER_SAVING_MODE, 0);
                        /* Enable the BT LE */
                        _bt_core_service_request_adapter(BT_ENABLE_ADAPTER_LE);
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-                       _bt_enable_adapter_le();
-#endif
+                       if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                               _bt_enable_adapter_le();
                }
        }
 }
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
+
 static void __bt_core_flight_mode_cb(keynode_t *node, void *data)
 {
        gboolean flight_mode = FALSE;
@@ -244,9 +236,7 @@ static void __bt_core_flight_mode_cb(keynode_t *node, void *data)
 
        __bt_core_handle_adapter_with_flight_mode(flight_mode);
 }
-#endif
 
-#ifndef TIZEN_PROFILE_WEARABLE
 #ifdef ENABLE_TIZEN_2_4
 static void __bt_core_power_saving_mode_cb(keynode_t *node, void *data)
 {
@@ -266,7 +256,6 @@ static void __bt_core_power_saving_mode_cb(keynode_t *node, void *data)
        __bt_core_handle_adapter_with_power_saving_mode(power_saving_mode);
 }
 #endif
-#endif
 
 void _bt_core_init_vconf_value(void)
 {
@@ -282,12 +271,12 @@ void _bt_core_init_vconf_value(void)
 
        flight_mode = _bt_core_is_flight_mode_enabled();
 
-#ifndef TIZEN_PROFILE_WEARABLE
 #ifndef ENABLE_TIZEN_2_4
-       if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &power_saving_mode) != 0)
-               BT_ERR("Fail to get the power_saving_mode status value");
-       BT_DBG("flight_mode = %d, power_saving_mode = %d", flight_mode, power_saving_mode);
-#endif
+       if (!TIZEN_PROFILE_WEARABLE) {
+               if (vconf_get_int(VCONFKEY_SETAPPL_PSMODE, &power_saving_mode) != 0)
+                       BT_ERR("Fail to get the power_saving_mode status value");
+               BT_DBG("flight_mode = %d, power_saving_mode = %d", flight_mode, power_saving_mode);
+       }
 #endif
        BT_DBG("flight_mode = %d, power_saving_mode = %d", flight_mode, power_saving_mode);
 
@@ -311,25 +300,27 @@ void _bt_core_init_vconf_value(void)
 
 void _bt_core_handle_flight_mode_noti(void)
 {
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
        int ret;
 
-       BT_DBG("+");
+       if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
+               BT_DBG("+");
 
-       ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-                       (vconf_callback_fn)__bt_core_flight_mode_cb, NULL);
-       if (ret < 0)
-               BT_ERR("Unable to register key handler");
-#else
-       BT_DBG("Telephony is disabled");
-#endif
+               ret = vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+                               (vconf_callback_fn)__bt_core_flight_mode_cb, NULL);
+               if (ret < 0)
+                       BT_ERR("Unable to register key handler");
+       } else {
+               BT_DBG("Telephony is disabled");
+       }
 }
 
 void _bt_core_handle_power_saving_mode_noti(void)
 {
-#ifndef TIZEN_PROFILE_WEARABLE
        int ret = 0;
 
+       if (TIZEN_PROFILE_WEARABLE)
+               return;
+
        BT_DBG("+");
 #ifdef ENABLE_TIZEN_2_4
        ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
@@ -337,21 +328,20 @@ void _bt_core_handle_power_saving_mode_noti(void)
 #endif
        if (ret < 0)
                BT_ERR("Unable to register key handler");
-#endif
 }
 
 void _bt_core_unregister_vconf_handler(void)
 {
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
-       vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-                       (vconf_callback_fn)__bt_core_flight_mode_cb);
-#endif
+       if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
+               vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+                               (vconf_callback_fn)__bt_core_flight_mode_cb);
+       }
 
-#ifndef TIZEN_PROFILE_WEARABLE
 #ifdef ENABLE_TIZEN_2_4
-       vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
-                       (vconf_callback_fn)__bt_core_power_saving_mode_cb);
-#endif
+       if (!TIZEN_PROFILE_WEARABLE) {
+               vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
+                               (vconf_callback_fn)__bt_core_power_saving_mode_cb);
+       }
 #endif
 
        return;
index e4f7299..f61ba23 100644 (file)
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(bt-service C)
 
 SET(SRCS
+../include/bt-internal-types.c
 marshal.c
 bt-service-main.c
 bt-service-event-sender.c
@@ -42,6 +43,7 @@ SET(PKG_MODULES
        cynara-client
        cynara-creds-gdbus
        eventsystem
+       capi-system-info
 )
 
 INCLUDE(FindPkgConfig)
@@ -88,11 +90,8 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/auto-pair-blacklist DESTINATION /opt/v
 # install booting script
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf)
 
-IF (TIZEN_PROFILE_WEARABLE)
-       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/wearable/stack_info DESTINATION /usr/etc/bluetooth/)
-ELSE ()
-       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mobile/stack_info DESTINATION /usr/etc/bluetooth/)
-ENDIF (TIZEN_PROFILE_WEARABLE)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/wearable/stack_info DESTINATION /usr/etc/bluetooth/wearable)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mobile/stack_info DESTINATION /usr/etc/bluetooth/)
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf DESTINATION /etc/dbus-1/system.d)
 
index 85653e8..8d4cee7 100644 (file)
@@ -79,10 +79,10 @@ static gboolean __bt_timeout_handler(gpointer user_data)
                visible_timer.event_id = 0;
                visible_timer.timeout = 0;
 
-#ifndef TIZEN_PROFILE_WEARABLE
-               if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
-                       BT_ERR("Set vconf failed\n");
-#endif
+               if (!TIZEN_PROFILE_WEARABLE) {
+                       if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+                               BT_ERR("Set vconf failed\n");
+               }
                return FALSE;
        }
 
@@ -107,10 +107,10 @@ static int __bt_visibility_alarm_cb(alarm_id_t alarm_id, void* user_param)
                visible_timer.event_id = 0;
                visible_timer.timeout = 0;
 
-#ifndef TIZEN_PROFILE_WEARABLE
-               if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
-                       BT_ERR("Set vconf failed\n");
-#endif
+               if (!TIZEN_PROFILE_WEARABLE) {
+                       if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+                               BT_ERR("Set vconf failed\n");
+               }
        }
        /* Switch Off visibility in Bluez */
        _bt_set_discoverable_mode(BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0);
@@ -154,10 +154,10 @@ int __bt_set_visible_time(int timeout)
 
        visible_timer.timeout = timeout;
 
-#ifndef TIZEN_PROFILE_WEARABLE
-       if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0)
-               BT_ERR("Set vconf failed");
-#endif
+       if (!TIZEN_PROFILE_WEARABLE) {
+               if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0)
+                       BT_ERR("Set vconf failed");
+       }
 
        if (timeout <= 0)
                return BLUETOOTH_ERROR_NONE;
@@ -242,7 +242,6 @@ static void __bt_phone_name_changed_cb(keynode_t *node, void *data)
        }
 }
 
-#ifdef TIZEN_PROFILE_MOBILE
 static void __bt_set_visible_mode(void)
 {
        int timeout = 0;
@@ -265,7 +264,6 @@ static void __bt_set_visible_mode(void)
                }
        }
 }
-#endif
 
 static void __bt_set_local_name(void)
 {
@@ -291,15 +289,13 @@ static int __bt_set_enabled(void)
        BT_DBG("+");
        int result = BLUETOOTH_ERROR_NONE;
 
-#ifdef TIZEN_PROFILE_MOBILE
-       __bt_set_visible_mode();
-#else
-#ifdef TIZEN_PROFILE_TV
-       if (_bt_set_discoverable_mode(
-               BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0) != BLUETOOTH_ERROR_NONE)
-                       BT_ERR("Fail to set discoverable mode");
-#endif
-#endif
+       if (TIZEN_PROFILE_MOBILE) {
+               __bt_set_visible_mode();
+       } else if (TIZEN_PROFILE_TV) {
+               if (_bt_set_discoverable_mode(
+                       BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0) != BLUETOOTH_ERROR_NONE)
+                               BT_ERR("Fail to set discoverable mode");
+       }
        __bt_set_local_name();
 
        /* Update Bluetooth Status to notify other modules */
@@ -427,7 +423,6 @@ void _bt_set_le_disabled(int result)
                        g_variant_new_int32(result));
 }
 
-#if defined(TIZEN_FEATURE_FLIGHTMODE_ENABLED) || (!defined(TIZEN_PROFILE_WEARABLE) && defined(ENABLE_TIZEN_2_4))
 static void __bt_service_flight_ps_mode_cb(keynode_t *node, void *data)
 {
        gboolean flight_mode = FALSE;
@@ -453,43 +448,39 @@ static void __bt_service_flight_ps_mode_cb(keynode_t *node, void *data)
                return;
        }
 }
-#endif
 
 void _bt_service_register_vconf_handler(void)
 {
        BT_DBG("+");
 
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
-       if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
-               BT_ERR("Unable to register key handler");
-#else
-       BT_DBG("Telephony is disabled");
-#endif
+       if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
+               if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+                               (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
+                       BT_ERR("Unable to register key handler");
+       } else {
+               BT_DBG("Telephony is disabled");
+       }
 
-#ifndef TIZEN_PROFILE_WEARABLE
 #ifdef ENABLE_TIZEN_2_4
-       if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
+       if (!TIZEN_PROFILE_WEARABLE && vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
                        (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
                BT_ERR("Unable to register key handler");
 #endif
-#endif
 }
 
 void _bt_service_unregister_vconf_handler(void)
 {
        BT_DBG("+");
 
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
-       vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
-#endif
+       if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
+               vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+                               (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
+       }
 
-#ifndef TIZEN_PROFILE_WEARABLE
 #ifdef ENABLE_TIZEN_2_4
-       vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
-                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
-#endif
+       if (!TIZEN_PROFILE_WEARABLE)
+               vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
+                               (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
 #endif
 }
 
index bc1ed82..40d66ab 100644 (file)
@@ -129,18 +129,17 @@ static gboolean __bt_check_bt_service(void *data)
 {
        bt_status_t status = BT_DEACTIVATED;
        bt_le_status_t le_status = BT_LE_DEACTIVATED;
-#ifndef TIZEN_PROFILE_TV
        int bt_status = VCONFKEY_BT_STATUS_OFF;
        int bt_le_status = VCONFKEY_BT_LE_STATUS_OFF;
-#endif
 
        status = _bt_adapter_get_status();
        le_status = _bt_adapter_get_le_status();
        BT_DBG("State: %d, LE State: %d", status, le_status);
 
-#ifdef TIZEN_PROFILE_TV
-       _bt_enable_adapter();
-#else
+       if (TIZEN_PROFILE_TV) {
+               _bt_enable_adapter();
+               return FALSE;
+       }
        if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
                BT_DBG("no bluetooth device info, so BT was disabled at previous session");
 
@@ -170,7 +169,6 @@ static gboolean __bt_check_bt_service(void *data)
                        _bt_terminate_service(NULL);
                }
        }
-#endif
        return FALSE;
 }
 
index 4cc3b73..0bc594d 100644 (file)
@@ -97,11 +97,8 @@ extern "C" {
 #define BT_AGENT_NEW_LINE "\r\n"
 
 #define BT_MAX_DBUS_TIMEOUT 45000
-#ifndef TIZEN_PROFILE_TV
-#define BT_ENABLE_TIMEOUT 20000 /* 20 seconds */
-#else
-#define BT_ENABLE_TIMEOUT 5000 /* 5 seconds */
-#endif
+
+#define BT_ENABLE_TIMEOUT ((TIZEN_PROFILE_TV)?5000:20000) /* 5(TV) / 20(others) seconds */
 #define BT_DISCOVERY_FINISHED_DELAY 200
 
 #define MANAGER_EVENT_MATCH_RULE \
index c0f0abc..1d33d18 100644 (file)
@@ -2,6 +2,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(bt-service C)
 
 SET(SRCS
+../include/bt-internal-types.c
 marshal.c
 bt-service-main.c
 bt-service-event-sender.c
@@ -65,13 +66,9 @@ SET(PKG_MODULES
        cynara-creds-gdbus
        eventsystem
        storage
-)
-
-IF("$ENV{CFLAGS}" MATCHES "-DTIZEN_FEATURE_NETWORK_TETHERING_ENABLE")
-SET(PKG_MODULES ${PKG_MODULES}
        capi-network-tethering
+       capi-system-info
 )
-ENDIF()
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(service_pkgs REQUIRED ${PKG_MODULES})
@@ -118,11 +115,8 @@ INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/auto-pair-blacklist DESTINATION /opt/v
 # install booting script
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf.in ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf)
 
-IF (TIZEN_PROFILE_WEARABLE)
-       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/wearable/stack_info DESTINATION /usr/etc/bluetooth/)
-ELSE ()
-       INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mobile/stack_info DESTINATION /usr/etc/bluetooth/)
-ENDIF (TIZEN_PROFILE_WEARABLE)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/wearable/stack_info DESTINATION /usr/etc/bluetooth/wearable/)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mobile/stack_info DESTINATION /usr/etc/bluetooth/)
 
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf DESTINATION /etc/dbus-1/system.d)
 
index 33bc5d0..7efb4f6 100644 (file)
@@ -23,6 +23,8 @@
 #include <vconf.h>
 #include <syspopup_caller.h>
 #include <aul.h>
+#include <dbus/dbus-glib.h>
+#include <dbus/dbus.h>
 #include <bundle.h>
 #include <eventsystem.h>
 #include <bundle_internal.h>
@@ -155,10 +157,10 @@ static gboolean __bt_timeout_handler(gpointer user_data)
                visible_timer.event_id = 0;
                visible_timer.timeout = 0;
 
-#ifndef TIZEN_PROFILE_WEARABLE
-               if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
-                       BT_ERR("Set vconf failed\n");
-#endif
+               if (!TIZEN_PROFILE_WEARABLE) {
+                       if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+                               BT_ERR("Set vconf failed\n");
+               }
                return FALSE;
        }
 
@@ -182,10 +184,10 @@ static int __bt_visibility_alarm_cb(alarm_id_t alarm_id, void* user_param)
                visible_timer.event_id = 0;
                visible_timer.timeout = 0;
 
-#ifndef TIZEN_PROFILE_WEARABLE
-               if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
-                       BT_ERR("Set vconf failed\n");
-#endif
+               if (!TIZEN_PROFILE_WEARABLE) {
+                       if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
+                               BT_ERR("Set vconf failed\n");
+               }
        }
        /* Switch Off visibility in Bluez */
        _bt_set_discoverable_mode(BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0);
@@ -210,27 +212,25 @@ int __bt_set_visible_time(int timeout)
 {
        int result;
        alarm_id_t alarm_id;
-#ifndef TIZEN_PROFILE_WEARABLE
 #ifdef TIZEN_FEATURE_BT_DPM
        int discoverable_state = DPM_BT_ERROR;
 #endif
-#endif
 
        __bt_visibility_alarm_remove();
 
        visible_timer.timeout = timeout;
 
-#ifndef TIZEN_PROFILE_WEARABLE
+       if (!TIZEN_PROFILE_WEARABLE) {
 #ifdef TIZEN_FEATURE_BT_DPM
-       _bt_dpm_get_bluetooth_limited_discoverable_state(&discoverable_state);
-       if(discoverable_state != DPM_RESTRICTED) {
+               _bt_dpm_get_bluetooth_limited_discoverable_state(&discoverable_state);
+               if(discoverable_state != DPM_RESTRICTED) {
 #endif
-       if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0)
-               BT_ERR("Set vconf failed");
+               if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0)
+                       BT_ERR("Set vconf failed");
 #ifdef TIZEN_FEATURE_BT_DPM
-       }
-#endif
+               }
 #endif
+       }
 
 
        if (timeout <= 0)
@@ -515,18 +515,16 @@ static int __bt_set_enabled(void)
                return BLUETOOTH_ERROR_INTERNAL;
        }
 
-#if defined(TIZEN_PROFILE_MOBILE) || defined(TIZEN_PROFILE_IVI)
-       /* BT setting UI will control Mobile's visible mode. So in the FRWK...set the visible mode as off: */
-       if (_bt_set_discoverable_mode(
-               BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0) != BLUETOOTH_ERROR_NONE)
-                       BT_ERR("Set connectable mode failed");
-#else
-#ifdef TIZEN_PROFILE_TV
-       if (_bt_set_discoverable_mode(
-               BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0) != BLUETOOTH_ERROR_NONE)
-                       BT_ERR("Fail to set discoverable mode");
-#endif
-#endif
+       if (TIZEN_PROFILE_MOBILE || TIZEN_PROFILE_IVI) {
+               /* BT setting UI will control Mobile's visible mode. So in the FRWK...set the visible mode as off: */
+               if (_bt_set_discoverable_mode(
+                       BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0) != BLUETOOTH_ERROR_NONE)
+                               BT_ERR("Set connectable mode failed");
+       } else if (TIZEN_PROFILE_TV) {
+               if (_bt_set_discoverable_mode(
+                       BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0) != BLUETOOTH_ERROR_NONE)
+                               BT_ERR("Fail to set discoverable mode");
+       }
 
        /* Update Bluetooth Status to notify other modules */
        if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_ON) != 0)
@@ -591,15 +589,12 @@ void _bt_set_disabled(int result)
        _bt_adapter_set_status(BT_DEACTIVATED);
        _bt_set_discovery_status(FALSE);
 
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-       if (_bt_adapter_get_le_status() != BT_LE_DEACTIVATED) {
-#endif
+       if (TIZEN_FEATURE_BT_USB_DONGLE ||
+           _bt_adapter_get_le_status() != BT_LE_DEACTIVATED) {
                /* Send disabled event */
                _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
                                g_variant_new("(i)", result));
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
        }
-#endif
 
        BT_INFO("Adapter disabled");
 }
@@ -703,7 +698,6 @@ int _bt_enable_core(void)
        return BLUETOOTH_ERROR_NONE;
 }
 
-#if defined(TIZEN_FEATURE_FLIGHTMODE_ENABLED) || (!defined(TIZEN_PROFILE_WEARABLE))
 static void __bt_service_flight_ps_mode_cb(keynode_t *node, void *data)
 {
        gboolean flight_mode = FALSE;
@@ -731,40 +725,39 @@ static void __bt_service_flight_ps_mode_cb(keynode_t *node, void *data)
 
        _bt_enable_core();
 }
-#endif
 
 void _bt_service_register_vconf_handler(void)
 {
        BT_DBG("+");
 
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
-       if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
-               BT_ERR("Unable to register key handler");
-#else
-       BT_DBG("Telephony is disabled");
-#endif
+       if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
+               if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+                               (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
+                       BT_ERR("Unable to register key handler");
+       } else {
+               BT_DBG("Telephony is disabled");
+       }
 
-#ifndef TIZEN_PROFILE_WEARABLE
-       if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
-                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
-               BT_ERR("Unable to register key handler");
-#endif
+       if (!TIZEN_PROFILE_WEARABLE) {
+               if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
+                               (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
+                       BT_ERR("Unable to register key handler");
+       }
 }
 
 void _bt_service_unregister_vconf_handler(void)
 {
        BT_DBG("+");
 
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
-       vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
-                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
-#endif
+       if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
+               vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
+                               (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
+       }
 
-#ifndef TIZEN_PROFILE_WEARABLE
-       vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
-                       (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
-#endif
+       if (!TIZEN_PROFILE_WEARABLE) {
+               vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
+                               (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
+       }
 }
 
 static void __bt_state_event_handler(const char *event_name, bundle *data, void *user_data)
@@ -799,21 +792,21 @@ void _bt_handle_adapter_added(void)
        BT_DBG("status : %d", status);
        BT_DBG("le_status : %d", le_status);
 
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-       adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
-       if (!adapter_agent) {
-               BT_ERR("Fail to register agent");
-               return;
-       }
-#else
-       if (adapter_agent == NULL) {
+       if (!TIZEN_FEATURE_BT_USB_DONGLE) {
                adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
                if (!adapter_agent) {
                        BT_ERR("Fail to register agent");
                        return;
                }
+       } else {
+               if (adapter_agent == NULL) {
+                       adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
+                       if (!adapter_agent) {
+                               BT_ERR("Fail to register agent");
+                               return;
+                       }
+               }
        }
-#endif
 
        if (_bt_register_media_player() != BLUETOOTH_ERROR_NONE)
                BT_ERR("Fail to register media player");
@@ -874,23 +867,23 @@ void _bt_handle_adapter_removed(void)
        if (0 != ret)
                ERR("vconf_ignore_key_changed failed\n");
 
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-       _bt_destroy_agent(adapter_agent);
-       adapter_agent = NULL;
+       if (!TIZEN_FEATURE_BT_USB_DONGLE) {
+               _bt_destroy_agent(adapter_agent);
+               adapter_agent = NULL;
 
-       if (is_recovery_mode == TRUE) {
-               /* Send disabled event */
-               _bt_set_disabled(BLUETOOTH_ERROR_NONE);
+               if (is_recovery_mode == TRUE) {
+                       /* Send disabled event */
+                       _bt_set_disabled(BLUETOOTH_ERROR_NONE);
 
-               /* Will recover BT by bt-core, so set the mode as activating */
-               _bt_adapter_set_status(BT_ACTIVATING);
-               is_recovery_mode = FALSE;
+                       /* Will recover BT by bt-core, so set the mode as activating */
+                       _bt_adapter_set_status(BT_ACTIVATING);
+                       is_recovery_mode = FALSE;
+               } else {
+                       _bt_reliable_terminate_service(NULL);
+               }
        } else {
-               _bt_reliable_terminate_service(NULL);
+               _bt_set_disabled(BLUETOOTH_ERROR_NONE);
        }
-#else
-       _bt_set_disabled(BLUETOOTH_ERROR_NONE);
-#endif
 
        if (eventsystem_unregister_event(status_reg_id) != ES_R_OK)
                BT_ERR("Fail to unregister system event");
@@ -934,9 +927,8 @@ static gboolean __bt_enable_timeout_cb(gpointer user_data)
        g_variant_unref(result);
        _bt_set_disabled(BLUETOOTH_ERROR_TIMEOUT);
 
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
-       _bt_terminate_service(NULL);
-#endif
+       if (!TIZEN_FEATURE_BT_USB_DONGLE)
+               _bt_terminate_service(NULL);
 
        return FALSE;
 }
@@ -1012,7 +1004,6 @@ void _bt_adapter_start_enable_timer(void)
        return;
 }
 
-#ifdef TIZEN_PROFILE_TV
 static gboolean __bt_adapter_enabled_cb(gpointer user_data)
 {
        BT_DBG("+");
@@ -1022,7 +1013,6 @@ static gboolean __bt_adapter_enabled_cb(gpointer user_data)
 
        return FALSE;
 }
-#endif
 
 int _bt_enable_adapter_check_status(void)
 {
@@ -1077,7 +1067,7 @@ int _bt_enable_adapter(void)
 
        _bt_adapter_set_status(BT_ACTIVATING);
 
-#ifdef TIZEN_PROFILE_TV
+if (TIZEN_PROFILE_TV)
 {
        int adapter_status = BT_ADAPTER_DISABLED;
 
@@ -1091,7 +1081,6 @@ int _bt_enable_adapter(void)
                return BLUETOOTH_ERROR_NONE;
        }
 }
-#endif
 
        proxy = __bt_get_core_proxy();
        if (!proxy)
@@ -1128,10 +1117,9 @@ int _bt_enable_adapter(void)
                                g_clear_error(&error);
                }
                g_variant_unref(result);
-#ifndef TIZEN_FEATURE_BT_USB_DONGLE
                /* Terminate myself */
-               g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
-#endif
+               if (!TIZEN_FEATURE_BT_USB_DONGLE)
+                       g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
                return BLUETOOTH_ERROR_INTERNAL;
        }
        g_variant_unref(result);
@@ -1423,10 +1411,9 @@ int _bt_reset_adapter(void)
        return BLUETOOTH_ERROR_NONE;
 }
 
-#ifndef TIZEN_PROFILE_TV
 int _bt_check_adapter(int *status)
 {
-
+if (!TIZEN_PROFILE_TV) {
        char *adapter_path = NULL;
 
        BT_CHECK_PARAMETER(status, return);
@@ -1441,10 +1428,7 @@ int _bt_check_adapter(int *status)
 
        g_free(adapter_path);
        return BLUETOOTH_ERROR_NONE;
-}
-#else
-int _bt_check_adapter(int *status)
-{
+} else {
        GDBusProxy *proxy;
        GError *error = NULL;
        GVariant *result;
@@ -1487,7 +1471,7 @@ int _bt_check_adapter(int *status)
        g_variant_unref(temp);
        return BLUETOOTH_ERROR_NONE;
 }
-#endif
+}
 
 int _bt_enable_adapter_le(void)
 {
@@ -3059,9 +3043,7 @@ int _bt_adapter_request_delayed(int function)
        return BLUETOOTH_ERROR_NONE;
 }
 
-#ifdef TIZEN_PROFILE_TV
 int _bt_get_enable_timer_id(void)
 {
        return timer_id;
 }
-#endif
index c7f181b..05957d1 100644 (file)
@@ -24,9 +24,7 @@
 #include <vconf.h>
 #include <bundle_internal.h>
 
-#ifdef TIZEN_FEATURE_NETWORK_TETHERING_ENABLE
 #include <tethering.h>
-#endif
 
 #include "bt-internal-types.h"
 #include "bt-service-common.h"
@@ -591,12 +589,10 @@ static gboolean __authorize_request(GapAgentPrivate *agent, GDBusProxy *device,
        GVariant *reply = NULL;
        GVariant *reply_temp = NULL;
        GVariant *tmp_value;
-#ifdef TIZEN_FEATURE_NETWORK_TETHERING_ENABLE
        bool enabled;
-       tethering_h tethering = NULL;
-#endif
        int result = BLUETOOTH_ERROR_NONE;
        int request_type = BT_AGENT_EVENT_AUTHORIZE_REQUEST;
+       tethering_h tethering = NULL;
 
        BT_DBG("+");
 
@@ -638,43 +634,41 @@ static gboolean __authorize_request(GapAgentPrivate *agent, GDBusProxy *device,
              !strcasecmp(uuid, BNEP_UUID)) {
 
                BT_DBG("Network connection request: %s", uuid);
-#ifdef TIZEN_FEATURE_NETWORK_TETHERING_ENABLE
-               if (nap_connected_device_count >=
-                                       BT_PAN_MAX_CONNECTION) {
-                       BT_ERR("Max connection exceeded");
-                       goto fail;
-               }
-               int ret;
-               ret = tethering_create(&tethering);
+               if (TIZEN_FEATURE_NETWORK_TETHERING_ENABLE) {
+                       if (nap_connected_device_count >=
+                                               BT_PAN_MAX_CONNECTION) {
+                               BT_ERR("Max connection exceeded");
+                               goto fail;
+                       }
+                       int ret;
+                       ret = tethering_create(&tethering);
 
-               if (ret != TETHERING_ERROR_NONE) {
-                       BT_ERR("Fail to create tethering: %d", ret);
-                       goto fail;
-               }
+                       if (ret != TETHERING_ERROR_NONE) {
+                               BT_ERR("Fail to create tethering: %d", ret);
+                               goto fail;
+                       }
 
-               enabled = tethering_is_enabled(tethering, TETHERING_TYPE_BT);
+                       enabled = tethering_is_enabled(tethering, TETHERING_TYPE_BT);
 
-               ret = tethering_destroy(tethering);
+                       ret = tethering_destroy(tethering);
 
-               if (ret != TETHERING_ERROR_NONE)
-                       BT_ERR("Fail to create tethering: %d", ret);
+                       if (ret != TETHERING_ERROR_NONE)
+                               BT_ERR("Fail to create tethering: %d", ret);
 
-               if (enabled != true) {
-                       BT_ERR("BT tethering is not enabled");
-                       goto fail;
+                       if (enabled != true) {
+                               BT_ERR("BT tethering is not enabled");
+                               goto fail;
+                       }
                }
-#endif
 
                gap_agent_reply_authorize(agent, GAP_AGENT_ACCEPT,
                                              NULL);
                goto done;
-#ifdef TIZEN_FEATURE_NETWORK_TETHERING_ENABLE
 fail:
                gap_agent_reply_authorize(agent, GAP_AGENT_REJECT,
                      NULL);
 
                goto done;
-#endif
        }
 
        reply_temp = __bt_service_getall(device, BT_DEVICE_INTERFACE);
index 8030bb4..524a5d2 100644 (file)
 #include "bt-service-headset-connection.h"
 
 #ifdef TIZEN_SUPPORT_DUAL_HF
-#ifdef TIZEN_PROFILE_WEARABLE
 #define VCONF_KEY_BT_HOST_BT_MAC_ADDR "db/wms/host_bt_mac"
 #endif
-#endif
 
 typedef struct {
        unsigned int type;
@@ -334,27 +332,27 @@ gboolean _bt_is_headset_type_connected(int type, char *address)
 #ifdef TIZEN_SUPPORT_DUAL_HF
 gboolean __bt_is_companion_device(const char *addr)
 {
-#ifdef TIZEN_PROFILE_WEARABLE
-       char *host_device_address = NULL;
-       host_device_address = vconf_get_str(VCONF_KEY_BT_HOST_BT_MAC_ADDR);
+       if (TIZEN_PROFILE_WEARABLE) {
+               char *host_device_address = NULL;
+               host_device_address = vconf_get_str(VCONF_KEY_BT_HOST_BT_MAC_ADDR);
 
-       if (!host_device_address) {
-               BT_INFO("Failed to get a companion device address");
-               return FALSE;
-       }
+               if (!host_device_address) {
+                       BT_INFO("Failed to get a companion device address");
+                       return FALSE;
+               }
+
+               if (g_strcmp0(host_device_address, addr) == 0) {
+                       BT_INFO("Found companion device");
+                       free(host_device_address);
+                       return TRUE;
+               }
 
-       if (g_strcmp0(host_device_address, addr) == 0) {
-               BT_INFO("Found companion device");
                free(host_device_address);
-               return TRUE;
+               return FALSE;
+       } else {
+               /* TODO : Need to add companion device check condition for Phone models */
+               return FALSE;
        }
-
-       free(host_device_address);
-       return FALSE;
-#else
-       /* TODO : Need to add companion device check condition for Phone models */
-       return FALSE;
-#endif
 }
 #endif
 
index 9f480bf..dcc02a3 100644 (file)
@@ -192,7 +192,6 @@ done:
        BT_DBG("-");
 } */
 
-#ifdef TIZEN_PROFILE_WEARABLE
 static gboolean __bt_syspopup_timer_cb(gpointer user_data)
 {
        int ret;
@@ -247,7 +246,6 @@ static gboolean __bt_launch_unable_to_pairing_syspopup(int result)
        BT_DBG("-");
        return TRUE;
 }
-#endif
 
 gboolean _bt_is_device_creating(void)
 {
@@ -794,17 +792,17 @@ static void __bt_bond_device_cb(GDBusProxy *proxy, GAsyncResult *res,
                        result == BLUETOOTH_ERROR_AUTHENTICATION_FAILED ||
                        result == BLUETOOTH_ERROR_TIMEOUT ||
                        result == BLUETOOTH_ERROR_HOST_DOWN) {
-#ifdef TIZEN_PROFILE_WEARABLE
-               int is_sw_running = 0;
+               if (TIZEN_PROFILE_WEARABLE) {
+                       int is_sw_running = 0;
 
-               if (vconf_get_int(VCONFKEY_SETUP_WIZARD_STATE, &is_sw_running))
-                       BT_ERR("vconf_get_int for setup wizard state failed");
+                       if (vconf_get_int(VCONFKEY_SETUP_WIZARD_STATE, &is_sw_running))
+                               BT_ERR("vconf_get_int for setup wizard state failed");
 
-               if (!is_sw_running)
-                       __bt_launch_unable_to_pairing_syspopup(result);
-               else
-                       BT_ERR("Unable to pair");
-#endif
+                       if (!is_sw_running)
+                               __bt_launch_unable_to_pairing_syspopup(result);
+                       else
+                               BT_ERR("Unable to pair");
+               }
                bonding_info->result = result;
        }
 
index 1824a25..067a4e9 100644 (file)
@@ -433,18 +433,18 @@ static void __bt_device_remote_connected_properties(
 
 gboolean __bt_handle_is_flight_mode_enabled(void)
 {
-#ifdef TIZEN_FEATURE_FLIGHTMODE_ENABLED
        int is_flight_mode = 0;
        int ret = -1;
 
-       ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &is_flight_mode);
-       if (ret != 0)
-               BT_ERR("vconf_get_bool failed");
+       if (TIZEN_FEATURE_FLIGHTMODE_ENABLED) {
+               ret = vconf_get_bool(VCONFKEY_TELEPHONY_FLIGHT_MODE, &is_flight_mode);
+               if (ret != 0)
+                       BT_ERR("vconf_get_bool failed");
 
-       return (is_flight_mode == 0) ? FALSE : TRUE;
-#else
-       return FALSE;
-#endif
+               return (is_flight_mode == 0) ? FALSE : TRUE;
+       } else {
+               return FALSE;
+       }
 }
 
 void _bt_handle_adapter_event(GVariant *msg, const char *member)
@@ -784,25 +784,24 @@ static void __bt_adapter_property_changed_event(GVariant *msg, const char *path)
                        g_variant_get(val, "b", &powered);
                        BT_DBG("Powered = %d", powered);
                        if (powered == FALSE) {
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-                               _bt_handle_adapter_removed();
-#else
-                               if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_state) == 0 &&
-                               bt_state != VCONFKEY_BT_STATUS_OFF) {
-                                       if (__bt_handle_is_flight_mode_enabled() == FALSE)
-                                               _bt_disable_adapter();
-                                       else
-                                               _bt_handle_adapter_removed();
+                               if (TIZEN_FEATURE_BT_USB_DONGLE) {
+                                       _bt_handle_adapter_removed();
+                               } else {
+                                       if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_state) == 0 &&
+                                       bt_state != VCONFKEY_BT_STATUS_OFF) {
+                                               if (__bt_handle_is_flight_mode_enabled() == FALSE)
+                                                       _bt_disable_adapter();
+                                               else
+                                                       _bt_handle_adapter_removed();
+                                       }
                                }
-#endif
                                if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_state) == 0 &&
                                        bt_state != VCONFKEY_BT_LE_STATUS_OFF) {
                                        _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
                                }
                        } else {
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-                               _bt_handle_adapter_added();
-#endif
+                               if (TIZEN_FEATURE_BT_USB_DONGLE)
+                                       _bt_handle_adapter_added();
                        }
                } else if (strcasecmp(property, "Connectable") == 0) {
                        gboolean connectable = FALSE;
@@ -2660,12 +2659,12 @@ static  void __bt_manager_event_filter(GDBusConnection *connection,
                g_variant_get(parameters, "(&o@a{sa{sv}})", &obj_path, &value);
 
                if (strcasecmp(obj_path, BT_BLUEZ_HCI_PATH) == 0) {
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-                       BT_DBG("Enable Adapter");
-                       _bt_enable_adapter();
-#else
-                       _bt_handle_adapter_added();
-#endif
+                       if (TIZEN_FEATURE_BT_USB_DONGLE) {
+                               BT_DBG("Enable Adapter");
+                               _bt_enable_adapter();
+                       } else {
+                               _bt_handle_adapter_added();
+                       }
                } else {
                        bt_event = __bt_parse_event(value);
                        if (bt_event == BT_DEVICE_EVENT) {
@@ -2759,10 +2758,10 @@ static  void __bt_manager_event_filter(GDBusConnection *connection,
                }
                g_variant_unref(value);
        } else if (strcasecmp(signal_name, "InterfacesRemoved") == 0) {
-#ifdef TIZEN_FEATURE_BT_USB_DONGLE
-               BT_DBG("InterfacesRemoved");
-               _bt_handle_adapter_removed();
-#endif
+               if (TIZEN_FEATURE_BT_USB_DONGLE) {
+                       BT_DBG("InterfacesRemoved");
+                       _bt_handle_adapter_removed();
+               }
                if (g_strcmp0(interface_name, BT_MEDIATRANSPORT_INTERFACE) == 0)
                        bt_event = BT_MEDIA_TRANSFER_EVENT;
                else if (g_strcmp0(interface_name, BT_DEVICE_INTERFACE) == 0)
@@ -3583,26 +3582,26 @@ fail:
 static int __bt_init_obexd_receiver(void)
 {
        BT_DBG("+");
-#ifndef TIZEN_PROFILE_TV /* TODO: obexd doesn't work in TV profile. It should be resolved later. */
-       GError *error = NULL;
+       if (!TIZEN_PROFILE_TV) { /* TODO: obexd doesn't work in TV profile. It should be resolved later. */
+               GError *error = NULL;
 
-       if (obexd_conn == NULL) {
-               obexd_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
-               if (error != NULL) {
-                       BT_ERR("ERROR: Can't get on session bus [%s]", error->message);
-                       g_clear_error(&error);
+               if (obexd_conn == NULL) {
+                       obexd_conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
+                       if (error != NULL) {
+                               BT_ERR("ERROR: Can't get on session bus [%s]", error->message);
+                               g_clear_error(&error);
+                       }
+                       retv_if(obexd_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
                }
-               retv_if(obexd_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
-       }
 
-       if (_bt_register_service_event(obexd_conn,
-                               BT_OPP_SERVER_EVENT) != BLUETOOTH_ERROR_NONE) {
-               BT_ERR("Error while registering service event");
-               g_object_unref(obexd_conn);
-               obexd_conn = NULL;
-               return BLUETOOTH_ERROR_INTERNAL;
+               if (_bt_register_service_event(obexd_conn,
+                                       BT_OPP_SERVER_EVENT) != BLUETOOTH_ERROR_NONE) {
+                       BT_ERR("Error while registering service event");
+                       g_object_unref(obexd_conn);
+                       obexd_conn = NULL;
+                       return BLUETOOTH_ERROR_INTERNAL;
+               }
        }
-#endif
        BT_DBG("-");
 
        return BLUETOOTH_ERROR_NONE;
index 9a622da..a626be6 100644 (file)
@@ -70,12 +70,12 @@ static void __bt_sigterm_handler(int signo, siginfo_t *info, void *data)
 {
        BT_INFO("signal [%d] is sent by [%d]", signo, info->si_pid);
 
-#ifndef TIZEN_PROFILE_TV
-       int ret;
-       ret = _bt_recover_adapter();
-       if (ret != BLUETOOTH_ERROR_NONE)
-               BT_ERR("_bt_recover_adapter is failed : %d", ret);
-#endif
+       if (!TIZEN_PROFILE_TV) {
+               int ret;
+               ret = _bt_recover_adapter();
+               if (ret != BLUETOOTH_ERROR_NONE)
+                       BT_ERR("_bt_recover_adapter is failed : %d", ret);
+       }
        return;
 }
 
@@ -125,12 +125,10 @@ static gboolean __bt_check_bt_service(void *data)
 {
        bt_status_t status = BT_DEACTIVATED;
        bt_le_status_t le_status = BT_LE_DEACTIVATED;
-#ifndef TIZEN_PROFILE_TV
        int bt_status = VCONFKEY_BT_STATUS_OFF;
        int bt_le_status = VCONFKEY_BT_LE_STATUS_OFF;
        int flight_mode_deactivation = 0;
        int bt_off_due_to_timeout = 0;
-#endif
 #if 0
        int ps_mode_deactivation = 0;
 #endif
@@ -139,53 +137,54 @@ static gboolean __bt_check_bt_service(void *data)
        le_status = _bt_adapter_get_le_status();
        BT_DBG("State: %d, LE State: %d", status, le_status);
 
-#ifdef TIZEN_PROFILE_TV
-       if (_bt_get_enable_timer_id() == 0)
-               _bt_enable_adapter();
-#else
-       if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
-               BT_DBG("no bluetooth device info, so BT was disabled at previous session");
+       if (TIZEN_PROFILE_TV) {
+               if (_bt_get_enable_timer_id() == 0)
+                       _bt_enable_adapter();
+       } else {
+               if (vconf_get_int(VCONFKEY_BT_STATUS, &bt_status) < 0)
+                       BT_DBG("no bluetooth device info, so BT was disabled at previous session");
 
-       if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status) < 0)
-               BT_ERR("no bluetooth le info, so BT LE was disabled at previous session");
+               if (vconf_get_int(VCONFKEY_BT_LE_STATUS, &bt_le_status) < 0)
+                       BT_ERR("no bluetooth le info, so BT LE was disabled at previous session");
 
-       if (vconf_get_int(BT_OFF_DUE_TO_FLIGHT_MODE, &flight_mode_deactivation) != 0)
-               BT_ERR("Fail to get the flight_mode_deactivation value");
+               if (vconf_get_int(BT_OFF_DUE_TO_FLIGHT_MODE, &flight_mode_deactivation) != 0)
+                       BT_ERR("Fail to get the flight_mode_deactivation value");
 
 #if 0
        if (vconf_get_int(BT_OFF_DUE_TO_POWER_SAVING_MODE, &ps_mode_deactivation) != 0)
                BT_ERR("Fail to get the ps_mode_deactivation value");
+       }
 #endif
 
-       if (vconf_get_int(BT_OFF_DUE_TO_TIMEOUT, &bt_off_due_to_timeout) != 0)
-               BT_ERR("Fail to get BT_OFF_DUE_TO_TIMEOUT");
+               if (vconf_get_int(BT_OFF_DUE_TO_TIMEOUT, &bt_off_due_to_timeout) != 0)
+                       BT_ERR("Fail to get BT_OFF_DUE_TO_TIMEOUT");
 
-       if ((bt_status != VCONFKEY_BT_STATUS_OFF || bt_off_due_to_timeout) &&
-               (status == BT_DEACTIVATED)) {
-               BT_DBG("Previous session was enabled.");
+               if ((bt_status != VCONFKEY_BT_STATUS_OFF || bt_off_due_to_timeout) &&
+                       (status == BT_DEACTIVATED)) {
+                       BT_DBG("Previous session was enabled.");
 
-               /* Enable the BT */
-               _bt_enable_adapter();
-       } else if (bt_status == VCONFKEY_BT_STATUS_OFF && flight_mode_deactivation == 1) {
-               _bt_enable_core();
-       }
+                       /* Enable the BT */
+                       _bt_enable_adapter();
+               } else if (bt_status == VCONFKEY_BT_STATUS_OFF && flight_mode_deactivation == 1) {
+                       _bt_enable_core();
+               }
 
-       if ((bt_le_status == VCONFKEY_BT_LE_STATUS_ON) && (le_status == BT_LE_DEACTIVATED)) {
-               BT_DBG("Previous session was le enabled. Turn BT LE on automatically.");
+               if ((bt_le_status == VCONFKEY_BT_LE_STATUS_ON) && (le_status == BT_LE_DEACTIVATED)) {
+                       BT_DBG("Previous session was le enabled. Turn BT LE on automatically.");
 
-               /* Enable the BT LE */
-               _bt_enable_adapter_le();
-       } else {
-               status = _bt_adapter_get_status();
-               le_status = _bt_adapter_get_le_status();
-               BT_DBG("State: %d, LE State: %d", status, le_status);
+                       /* Enable the BT LE */
+                       _bt_enable_adapter_le();
+               } else {
+                       status = _bt_adapter_get_status();
+                       le_status = _bt_adapter_get_le_status();
+                       BT_DBG("State: %d, LE State: %d", status, le_status);
 
-               if ((status != BT_ACTIVATING && status != BT_ACTIVATED) &&
-                               (le_status != BT_LE_ACTIVATING && le_status != BT_LE_ACTIVATED)) {
-                       _bt_terminate_service(NULL);
+                       if ((status != BT_ACTIVATING && status != BT_ACTIVATED) &&
+                                       (le_status != BT_LE_ACTIVATING && le_status != BT_LE_ACTIVATED)) {
+                               _bt_terminate_service(NULL);
+                       }
                }
        }
-#endif
        return FALSE;
 }
 
index 54716d2..c69ab6a 100644 (file)
@@ -30,9 +30,7 @@
 
 #define BT_MAX_EVENT_STR_LENGTH        50
 
-#ifndef TIZEN_PROFILE_WEARABLE
 #define BT_FILE_VISIBLE_TIME "file/private/libug-setting-bluetooth-efl/visibility_time"
-#endif
 
 typedef enum {
        HS_PROFILE_UUID = ((unsigned short)0x1108),             /**<HS*/
index a9d063a..a85ef2a 100644 (file)
@@ -25,6 +25,7 @@
 #include <gio/gio.h>
 
 #include "bluetooth-api.h"
+#include "bt-internal-types.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -49,21 +50,12 @@ extern "C" {
 #define LOG_COLOR_PURPLE   "\033[35m"
 
 
-#ifndef TIZEN_PROFILE_TV
 #define BT_DBG(fmt, args...) \
-       SLOGD(fmt, ##args)
+       ((TIZEN_PROFILE_TV) ? (LOGI(fmt, ##args)) : (SLOGD(fmt, ##args)))
 #define BT_INFO(fmt, args...) \
-       SLOGI(fmt, ##args)
+       ((TIZEN_PROFILE_TV) ? (LOGI(fmt, ##args)) : (SLOGI(fmt, ##args)))
 #define BT_ERR(fmt, args...) \
-       SLOGE(fmt, ##args)
-#else
-#define BT_DBG(fmt, args...) \
-       LOGI(fmt, ##args)
-#define BT_INFO(fmt, args...) \
-       LOGI(fmt, ##args)
-#define BT_ERR(fmt, args...) \
-       LOGE(fmt, ##args)
-#endif
+       ((TIZEN_PROFILE_TV) ? (LOGE(fmt, ##args)) : (SLOGE(fmt, ##args)))
 
 #define BT_INFO_C(fmt, arg...) \
        SLOGI_IF(TRUE,  LOG_COLOR_GREEN" "fmt" "LOG_COLOR_RESET, ##arg)
@@ -108,11 +100,7 @@ extern "C" {
 #define BT_AGENT_NEW_LINE "\r\n"
 
 #define BT_MAX_DBUS_TIMEOUT 45000
-#ifndef TIZEN_PROFILE_TV
-#define BT_ENABLE_TIMEOUT 20000 /* 20 seconds */
-#else
-#define BT_ENABLE_TIMEOUT 5000 /* 5 seconds */
-#endif
+#define BT_ENABLE_TIMEOUT ((TIZEN_PROFILE_TV) ? 5000 : 20000) /* 5(TV),20(others) seconds */
 #define BT_DISCOVERY_FINISHED_DELAY 200
 
 #define BT_SESSION_BUS_GET_TIMEOUT 200 /* 200 ms */
diff --git a/include/bt-internal-types.c b/include/bt-internal-types.c
new file mode 100644 (file)
index 0000000..cdbfb66
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *             http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/* This is infrastructral, shared functino for all bt-* / *.c files. */
+
+#include "bt-internal-types.h"
+
+tizen_profile_t profile = _PROFILE_UNKNOWN;
index 8ff4c66..f4e0435 100644 (file)
@@ -381,9 +381,7 @@ typedef struct {
 #define BT_DPM_SYSPOPUP "dpm-syspopup"
 #endif
 
-#ifndef TIZEN_PROFILE_WEARABLE
 #define BT_FILE_VISIBLE_TIME "file/private/libug-setting-bluetooth-efl/visibility_time"
-#endif
 
 #define BT_OFF_DUE_TO_FLIGHT_MODE "file/private/bt-core/flight_mode_deactivated"
 #define BT_OFF_DUE_TO_POWER_SAVING_MODE "file/private/bt-core/powersaving_mode_deactivated"
@@ -525,6 +523,68 @@ typedef struct {
 #define BT_LE_DATA_LENGTH_CHANGED "LEDataLengthChanged"
 #define BT_PXP_PROPERTY_CHANGED "PxpValueChanged"
 
+typedef enum {
+       _PROFILE_UNKNOWN = 0,
+       _PROFILE_MOBILE = 0x1,
+       _PROFILE_WEARABLE = 0x2,
+       _PROFILE_TV = 0x4,
+       _PROFILE_IVI = 0x8,
+       _PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+
+/* For optimization, make this extern and define in a shared C file */
+extern tizen_profile_t profile;
+
+/* Accessing system info */
+int system_info_get_platform_string(const char *key, char **value);
+
+static inline tizen_profile_t get_tizen_profile()
+{
+       char *profileName = NULL;
+
+       if (__builtin_expect(profile != _PROFILE_UNKNOWN, 1))
+               return profile;
+
+       system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+
+       /* To pass the checking of g_ir */
+       if (!profileName)
+               return _PROFILE_UNKNOWN;
+
+       switch (*profileName) {
+               case 'm':
+               case 'M':
+                       profile = _PROFILE_MOBILE;
+                       break;
+               case 'w':
+               case 'W':
+                       profile = _PROFILE_WEARABLE;
+                       break;
+               case 't':
+               case 'T':
+                       profile = _PROFILE_TV;
+                       break;
+               case 'i':
+               case 'I':
+                       profile = _PROFILE_IVI;
+                       break;
+               default: // common or unknown ==> ALL ARE COMMON.
+                       profile = _PROFILE_COMMON;
+       }
+       free(profileName);
+
+       return profile;
+}
+#define TIZEN_PROFILE_WEARABLE (get_tizen_profile() == _PROFILE_WEARABLE)
+#define TIZEN_PROFILE_IVI (get_tizen_profile() == _PROFILE_IVI)
+#define TIZEN_PROFILE_TV (get_tizen_profile() == _PROFILE_TV)
+#define TIZEN_PROFILE_MOBILE (get_tizen_profile() == _PROFILE_MOBILE)
+
+#define TIZEN_FEATURE_NETWORK_TETHERING_ENABLE (get_tizen_profile() & (_PROFILE_MOBILE))
+#define TIZEN_FEATURE_TELEPHONY_ENABLED (get_tizen_profile() & (_PROFILE_MOBILE))
+#define TIZEN_FEATURE_FLIGHTMODE_ENABLED (get_tizen_profile() & (_PROFILE_MOBILE | _PROFILE_WEARABLE))
+#define TIZEN_FEATURE_BT_USB_DONGLE (get_tizen_profile() & (_PROFILE_TV))
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index c3f9924..ebf123c 100644 (file)
@@ -4,7 +4,7 @@
 
 Name:       bluetooth-frwk
 Summary:    Bluetooth framework for BlueZ and Obexd. This package is Bluetooth framework based on BlueZ and Obexd stack.
-Version:    0.2.156
+Version:    0.2.157
 Release:    1
 Group:      Network & Connectivity/Bluetooth
 License:    Apache-2.0
@@ -31,24 +31,74 @@ BuildRequires:  pkgconfig(pkgmgr)
 #BuildRequires:  pkgconfig(journal)
 BuildRequires:  pkgconfig(eventsystem)
 BuildRequires: pkgconfig(libsoup-2.4)
-%if "%{?profile}" == "mobile"
 BuildRequires:  pkgconfig(capi-network-tethering)
-%endif
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(cynara-client)
 BuildRequires:  pkgconfig(cynara-creds-gdbus)
 BuildRequires:  pkgconfig(libtzplatform-config)
 BuildRequires:  pkgconfig(storage)
+BuildRequires:  pkgconfig(capi-system-info)
 
 Requires(post): /usr/bin/vconftool
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 Requires: psmisc
+Requires:   %{name}-servicescript = %{version}-%{release}
+Recommends: %{name}-profile_common = %{version}-%{release}
 
 %description
 Bluetooth framework for BlueZ and Obexd. This package is Bluetooth framework based on BlueZ and Obexd stack.
  This package contains API set for BT GAP, BT SDP, and BT RFCOMM.
 
+%package profile_common
+Summary:    bluetooth-frwk service and conf files for common profile
+Provides:   %{name}-servicescript = %{version}-%{release}
+Conflicts:  %{name}-profile_mobile
+Conflicts:  %{name}-profile_wearable
+Conflicts:  %{name}-profile_tv
+Conflicts:  %{name}-profile_ivi
+%description profile_common
+Bluetooth framework configuration and service files for Tizen common profile
+
+%package profile_mobile
+Summary:    bluetooth-frwk service and conf files for mobile profile
+Provides:   %{name}-servicescript = %{version}-%{release}
+Conflicts:  %{name}-profile_common
+Conflicts:  %{name}-profile_wearable
+Conflicts:  %{name}-profile_tv
+Conflicts:  %{name}-profile_ivi
+%description profile_mobile
+Bluetooth framework configuration and service files for Tizen mobile profile
+
+%package profile_wearable
+Summary:    bluetooth-frwk service and conf files for wearable profile
+Provides:   %{name}-servicescript = %{version}-%{release}
+Conflicts:  %{name}-profile_mobile
+Conflicts:  %{name}-profile_common
+Conflicts:  %{name}-profile_tv
+Conflicts:  %{name}-profile_ivi
+%description profile_wearable
+Bluetooth framework configuration and service files for Tizen wearable profile
+
+%package profile_tv
+Summary:    bluetooth-frwk service and conf files for tv profile
+Provides:   %{name}-servicescript = %{version}-%{release}
+Conflicts:  %{name}-profile_mobile
+Conflicts:  %{name}-profile_wearable
+Conflicts:  %{name}-profile_common
+Conflicts:  %{name}-profile_ivi
+%description profile_tv
+Bluetooth framework configuration and service files for Tizen tv profile
+
+%package profile_ivi
+Summary:    bluetooth-frwk service and conf files for ivi profile
+Provides:   %{name}-servicescript = %{version}-%{release}
+Conflicts:  %{name}-profile_mobile
+Conflicts:  %{name}-profile_wearable
+Conflicts:  %{name}-profile_tv
+Conflicts:  %{name}-profile_common
+%description profile_ivi
+Bluetooth framework configuration and service files for Tizen ivi profile
 
 %package devel
 Summary:    Bluetooth framework for BlueZ and Obexd
@@ -101,37 +151,6 @@ export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
 export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
 export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
 
-%define _servicefile packaging/bluetooth-frwk-common.service
-%define _servicedir starter.target.wants
-
-%if "%{?profile}" == "mobile"
-export CFLAGS="$CFLAGS -DTIZEN_FEATURE_NETWORK_TETHERING_ENABLE -DTIZEN_FEATURE_FLIGHTMODE_ENABLED -DTIZEN_PROFILE_MOBILE -DTIZEN_FEATURE_TELEPHONY_ENABLED"
-%if "%{?tizen_target_name}" == "TM1"
-%define _servicefile packaging/bluetooth-frwk-mobile-sprd.service
-%else
-%define _servicefile packaging/bluetooth-frwk-mobile.service
-%endif
-%define _servicedir multi-user.target.wants
-%endif
-
-%if "%{?profile}" == "wearable"
-export CFLAGS="$CFLAGS -DTIZEN_PROFILE_WEARABLE -DTIZEN_FEATURE_FLIGHTMODE_ENABLED"
-%define _servicefile packaging/bluetooth-frwk-wearable.service
-%define _servicedir multi-user.target.wants
-%endif
-
-%if "%{?profile}" == "tv"
-export CFLAGS="$CFLAGS -DTIZEN_FEATURE_BT_USB_DONGLE -DTIZEN_PROFILE_TV"
-%define _servicefile packaging/bluetooth-frwk-tv.service
-%define _servicedir multi-user.target.wants
-%endif
-
-%if "%{?profile}" == "ivi"
-export CFLAGS="$CFLAGS -DTIZEN_PROFILE_IVI"
-%define _servicefile packaging/bluetooth-frwk-wearable.service
-%define _servicedir multi-user.target.wants
-%endif
-
 %ifarch x86_64
 export CFLAGS="$CFLAGS -Wall -g -fvisibility=hidden -fPIC"
 %else
@@ -170,15 +189,7 @@ cmake . -DCMAKE_INSTALL_PREFIX=/usr \
        -DLIBNOTIFICATION_SUPPORT=Off
 make
 
-%cmake \
-%if "%{?profile}" == "wearable"
-       -DTIZEN_PROFILE_WEARABLE=YES \
-%else
-       -DTIZEN_PROFILE_WEARABLE=NO \
-%endif
-%if "%{?profile}" == "common"
-        -DTIZEN_PROFILE_WEARABLE=NO \
-%endif
+%cmake
 
 %install
 rm -rf %{buildroot}
@@ -189,44 +200,31 @@ install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/bluetooth-frwk-servic
 install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/bluetooth-frwk-httpproxy
 install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/bluetooth-frwk-devel
 
-#mkdir -p %{buildroot}%{_libdir}/systemd/user
-#install -m 0644 packaging/bluetooth-frwk-tv.service %{buildroot}%{_libdir}/systemd/user
-mkdir -p %{buildroot}%{_unitdir}/%{_servicedir}
-install -m 0644 %{_servicefile} %{buildroot}%{_unitdir}/bluetooth-frwk.service
-ln -s ../bluetooth-frwk.service %{buildroot}%{_unitdir}/%{_servicedir}/bluetooth-frwk.service
+mkdir -p %{buildroot}%{_unitdir}/starter.target.wants
+mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants
 
-# On IVI bt-service needs to be run as 'app' even if there is a 'guest' user.
-%if "%{profile}"=="ivi"
-sed -i 's/%TZ_SYS_DEFAULT_USER/app/' %{buildroot}%{_datadir}/dbus-1/system-services/org.projectx.bt.service
+# Rename the postfix (.mobile, .tv, ..) at post script
+# mobile
+%if "%{?tizen_target_name}" == "TM1"
+install -m 0644 packaging/bluetooth-frwk-mobile-sprd.service %{buildroot}%{_unitdir}/bluetooth-frwk.service.mobile
+%else
+install -m 0644 packaging/bluetooth-frwk-mobile.service %{buildroot}%{_unitdir}/bluetooth-frwk.service.mobile
 %endif
 
+# wearable / ivi
+install -m 0644 packaging/bluetooth-frwk-wearable.service %{buildroot}%{_unitdir}/bluetooth-frwk.service.wearable
+# On IVI bt-service needs to be run as 'app' even if there is a 'guest' user.
+cp %{buildroot}%{_datadir}/dbus-1/system-services/org.projectx.bt.service %{buildroot}%{_datadir}/dbus-1/system-services/org.projectx.bt.service.ivi
+sed -i 's/%TZ_SYS_DEFAULT_USER/app/' %{buildroot}%{_datadir}/dbus-1/system-services/org.projectx.bt.service.ivi
+
+# tv
+install -m 0644 packaging/bluetooth-frwk-tv.service %{buildroot}%{_unitdir}/bluetooth-frwk.service.tv
+
+# common
+install -m 0644 packaging/bluetooth-frwk-common.service %{buildroot}%{_unitdir}/bluetooth-frwk.service.common
 
-#%post
-#/sbin/ldconfig
-#%if "%{?profile}" == "wearable"
-#vconftool set -f -t int db/bluetooth/status "1" -g 6520
-#%endif
-#%if "%{?profile}" == "mobile"
-#vconftool set -f -t int db/bluetooth/status "0" -g 6520
-#%endif
-#%if "%{?profile}" == "common"
-#vconftool set -f -t int db/bluetooth/status "0" -g 6520
-#%endif
-
-#vconftool set -f -t int db/bluetooth/status "0" -s User
-#vconftool set -f -t int db/bluetooth/lestatus "0" -s User
-#vconftool set -f -t int file/private/bt-core/flight_mode_deactivated "0" -s User
-#vconftool set -f -t int file/private/bt-core/powersaving_mode_deactivated "0" -s User
-#vconftool set -f -t int file/private/bt-service/bt_off_due_to_timeout "0" -s User
-#vconftool set -f -t string memory/bluetooth/sco_headset_name "" -g 6520 -i
-#vconftool set -f -t int memory/bluetooth/device "0" -g 6520 -i
-#vconftool set -f -t bool memory/bluetooth/btsco "0" -g 6520 -i
-#vconftool set -f -t bool memory/bluetooth/dutmode "0" -g 6520 -i
-
-
-#%post service
-#mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
-#ln -sf %{_libdir}/systemd/user/bluetooth-frwk.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+ln -s ../bluetooth-frwk.service %{buildroot}%{_unitdir}/multi-user.target.wants/bluetooth-frwk.service
+ln -s ../bluetooth-frwk.service %{buildroot}%{_unitdir}/starter.target.wants/bluetooth-frwk.service
 
 %postun -p /sbin/ldconfig
 
@@ -235,8 +233,6 @@ sed -i 's/%TZ_SYS_DEFAULT_USER/app/' %{buildroot}%{_datadir}/dbus-1/system-servi
 %defattr(-, root, root)
 %{_libdir}/libbluetooth-api.so.*
 %{_datadir}/license/bluetooth-frwk
-%{_unitdir}/%{_servicedir}/bluetooth-frwk.service
-%{_unitdir}/bluetooth-frwk.service
 
 %files devel
 %defattr(-, root, root)
@@ -254,19 +250,11 @@ sed -i 's/%TZ_SYS_DEFAULT_USER/app/' %{buildroot}%{_datadir}/dbus-1/system-servi
 %files service
 %manifest %{name}.manifest
 %defattr(-, root, root)
-%{_datadir}/dbus-1/system-services/org.projectx.bt.service
 %{_bindir}/bt-service
-#%{_libdir}/systemd/user/bluetooth-frwk-tv.service
-%{_unitdir}/%{_servicedir}/bluetooth-frwk.service
 %{_sysconfdir}/dbus-1/system.d/bluetooth-frwk-service.conf
 %{_bindir}/bluetooth-frwk-test
-#%{_bindir}/bluetooth-gatt-test
-#%{_bindir}/bluetooth-advertising-test
 %{_varlibdir}/bluetooth
 %{_prefix}/etc/bluetooth
-#%attr(0666,-,-) %{_varlibdir}/bluetooth/auto-pair-blacklist
-#%attr(0666,-,-) %{_prefix}/etc/bluetooth/stack_info
-#%{_dumpdir}/bluetooth_log_dump.sh
 %{_datadir}/license/bluetooth-frwk-service
 
 %files httpproxy
@@ -288,5 +276,81 @@ sed -i 's/%TZ_SYS_DEFAULT_USER/app/' %{buildroot}%{_datadir}/dbus-1/system-servi
 %manifest %{name}.manifest
 %defattr(-, root, root)
 %{_bindir}/bluetooth-frwk-test
-#%{_bindir}/bluetooth-gatt-test
-#%{_bindir}/bluetooth-advertising-test
+#{_bindir}/bluetooth-gatt-test
+#{_bindir}/bluetooth-advertising-test
+
+%post profile_common
+pushd %{_unitdir}
+mv bluetooth-frwk.service.common bluetooth-frwk.service
+popd
+%preun profile_common
+pushd %{_unitdir}
+mv bluetooth-frwk.service bluetooth-frwk.service.common
+popd
+%files profile_common
+%{_unitdir}/starter.target.wants/bluetooth-frwk.service
+%{_unitdir}/bluetooth-frwk.service.common
+%{_datadir}/dbus-1/system-services/org.projectx.bt.service
+
+%post profile_mobile
+pushd %{_unitdir}
+mv bluetooth-frwk.service.mobile bluetooth-frwk.service
+popd
+%preun profile_mobile
+pushd %{_unitdir}
+mv bluetooth-frwk.service bluetooth-frwk.service.mobile
+popd
+%files profile_mobile
+%{_unitdir}/multi-user.target.wants/bluetooth-frwk.service
+%{_unitdir}/bluetooth-frwk.service.mobile
+%{_datadir}/dbus-1/system-services/org.projectx.bt.service
+
+%post profile_wearable
+pushd %{_unitdir}
+mv bluetooth-frwk.service.wearable bluetooth-frwk.service
+popd
+%preun profile_wearable
+pushd %{_unitdir}
+mv bluetooth-frwk.service bluetooth-frwk.service.wearable
+popd
+%files profile_wearable
+%{_unitdir}/multi-user.target.wants/bluetooth-frwk.service
+%{_unitdir}/bluetooth-frwk.service.wearable
+%{_datadir}/dbus-1/system-services/org.projectx.bt.service
+
+%post profile_tv
+pushd %{_unitdir}
+mv bluetooth-frwk.service.tv bluetooth-frwk.service
+popd
+%preun profile_tv
+pushd %{_unitdir}
+mv bluetooth-frwk.service bluetooth-frwk.service.tv
+popd
+%files profile_tv
+%{_unitdir}/multi-user.target.wants/bluetooth-frwk.service
+%{_unitdir}/bluetooth-frwk.service.tv
+%{_datadir}/dbus-1/system-services/org.projectx.bt.service
+
+# Note: ivi reuses bluetooth-frwk.service.wearable
+%post profile_ivi
+pushd %{_unitdir}
+mv bluetooth-frwk.service.wearable bluetooth-frwk.service
+popd
+pushd %{_datadir}/dbus-1/system-services
+mv org.projectx.bt.service.ivi org.projectx.bt.service
+popd
+%preun profile_ivi
+pushd %{_unitdir}
+mv bluetooth-frwk.service bluetooth-frwk.service.wearable
+popd
+pushd %{_datadir}/dbus-1/system-services
+mv org.projectx.bt.service org.projectx.bt.service.ivi
+popd
+%files profile_ivi
+%{_unitdir}/multi-user.target.wants/bluetooth-frwk.service
+%{_unitdir}/bluetooth-frwk.service.wearable
+%{_datadir}/dbus-1/system-services/org.projectx.bt.service.ivi
+
+### added /usr/etc/bluetooth/wearable/stack_info (others: /usr/etc/bluetooth/stack_info))
+# (for PROFILE WEARABLE)
+