summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt7
-rw-r--r--include/bt-util.h14
-rw-r--r--packaging/org.tizen.bluetooth.spec12
-rw-r--r--src/bt-handler.c5
-rw-r--r--src/bt-main-view.c174
-rw-r--r--src/bt-profile-view.c54
-rw-r--r--src/bt-util.c36
7 files changed, 157 insertions, 145 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ec3ae7b..1955968 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,14 +7,8 @@ SET(SRCS
src/bt-handler.c
src/bt-popup.c
src/bt-util.c
- )
-
-IF (TELEPHONY_DISABLED)
-ELSE ()
-LIST(APPEND SRCS
src/bt-profile-view.c
)
-ENDIF (TELEPHONY_DISABLED)
SET(VENDOR "samsung")
SET(PACKAGE ${PROJECT_NAME})
@@ -58,6 +52,7 @@ pkg_check_modules(pkgs REQUIRED
dbus-glib-1
deviced
capi-ui-efl-util
+ capi-system-info
)
FIND_LIBRARY(LIB_M m)
diff --git a/include/bt-util.h b/include/bt-util.h
index 9d3f463..d297589 100644
--- a/include/bt-util.h
+++ b/include/bt-util.h
@@ -91,9 +91,7 @@ void _bt_util_get_lcd_status(int *val);
gboolean _bt_util_is_battery_low(void);
-#ifndef TELEPHONY_DISABLED
gboolean _bt_util_is_flight_mode(void);
-#endif
void _bt_util_addr_type_to_addr_string(char *address,
unsigned char *addr);
@@ -129,6 +127,18 @@ void _bt_util_change_discoverable_mode(bt_app_data_t *ad, gboolean discoverable)
void _bt_insert_log(const char *feature);
+typedef enum {
+ TIZEN_PROFILE_UNKNOWN = 0,
+ TIZEN_PROFILE_MOBILE = 0x1,
+ TIZEN_PROFILE_WEARABLE = 0x2,
+ TIZEN_PROFILE_TV = 0x4,
+ TIZEN_PROFILE_IVI = 0x8,
+ TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+extern tizen_profile_t _get_tizen_profile();
+
+#define TELEPHONY_DISABLED (_get_tizen_profile() == TIZEN_PROFILE_WEARABLE)
+
#ifdef __cplusplus
}
#endif
diff --git a/packaging/org.tizen.bluetooth.spec b/packaging/org.tizen.bluetooth.spec
index a2de8cb..f910916 100644
--- a/packaging/org.tizen.bluetooth.spec
+++ b/packaging/org.tizen.bluetooth.spec
@@ -8,10 +8,6 @@ Source: %{name}-%{version}.tar.gz
License: Flora-1.1
Group: TO_BE/FILLED_IN
-%if "%{?profile}" != "wearable"
-ExcludeArch: %{arm} %ix86 x86_64
-%endif
-
BuildRequires: cmake
BuildRequires: gettext-tools
BuildRequires: pkgconfig(embryo)
@@ -29,6 +25,7 @@ BuildRequires: pkgconfig(capi-ui-efl-util)
BuildRequires: pkgconfig(dbus-glib-1)
BuildRequires: pkgconfig(deviced)
BuildRequires: pkgconfig(edje)
+BuildRequires: pkgconfig(capi-system-info)
BuildRequires: edje-bin, embryo-bin
@@ -47,14 +44,7 @@ export CFLAGS+=" -DTIZEN_ENGINEER_MODE"
export CXXFLAGS+=" -DTIZEN_ENGINEER_MODE"
export FFLAGS+=" -DTIZEN_ENGINEER_MODE"
-%if "%{?profile}" == "wearable"
-export CFLAGS+=" -DTELEPHONY_DISABLED"
-export CXXFLAGS+=" -DTELEPHONY_DISABLED"
-export FFLAGS+=" -DTELEPHONY_DISABLED"
-%endif
-
%cmake \
- -DTELEPHONY_DISABLED=NO \
LDFLAGS+="-Wl,--rpath=%{PREFIX}/lib -Wl,--as-needed -Wl,--hash-style=both"; export LDFLAGS
cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX}
diff --git a/src/bt-handler.c b/src/bt-handler.c
index 5228568..aeb2c79 100644
--- a/src/bt-handler.c
+++ b/src/bt-handler.c
@@ -349,13 +349,12 @@ static void __bt_cb_new_device_found(bt_adapter_device_discovery_info_s *info,
return;
}
-#ifdef TELEPHONY_DISABLED
- if (ad->launch_mode == BT_LAUNCH_SETTING &&
+ if (TELEPHONY_DISABLED &&
+ ad->launch_mode == BT_LAUNCH_SETTING &&
!(info->bt_class.major_service_class_mask & BT_COD_SC_RENDERING)) {
DBG("A2DP is not supported. Do not add");
return;
}
-#endif
if (info->is_bonded == TRUE) {
DBG("Bonded device");
diff --git a/src/bt-main-view.c b/src/bt-main-view.c
index 85f8439..684cf48 100644
--- a/src/bt-main-view.c
+++ b/src/bt-main-view.c
@@ -1361,14 +1361,14 @@ static bool __bt_cb_adapter_bonded_device(bt_device_info_s *device_info,
return true;
}
-#ifdef TELEPHONY_DISABLED
- if (ad->launch_mode == BT_LAUNCH_SETTING &&
- !(service_class & BT_COD_SC_RENDERING)) {
- DBG("A2DP is not supported");
- free(dev);
- return true;
+ if (TELEPHONY_DISABLED) {
+ if (ad->launch_mode == BT_LAUNCH_SETTING &&
+ !(service_class & BT_COD_SC_RENDERING)) {
+ DBG("A2DP is not supported");
+ free(dev);
+ return true;
+ }
}
-#endif
if (dev->service_list & BT_SC_HFP_SERVICE_MASK ||
dev->service_list & BT_SC_HSP_SERVICE_MASK ||
@@ -1432,14 +1432,14 @@ static bool __bt_cb_adapter_create_paired_device_list
return true;
}
-#ifdef TELEPHONY_DISABLED
- if (ad->launch_mode == BT_LAUNCH_SETTING &&
- !(service_class & BT_COD_SC_RENDERING)) {
- DBG("A2DP is not supported");
- free(dev);
- return true;
+ if (TELEPHONY_DISABLED) {
+ if (ad->launch_mode == BT_LAUNCH_SETTING &&
+ !(service_class & BT_COD_SC_RENDERING)) {
+ DBG("A2DP is not supported");
+ free(dev);
+ return true;
+ }
}
-#endif
if (dev->service_list & BT_SC_HFP_SERVICE_MASK ||
dev->service_list & BT_SC_HSP_SERVICE_MASK ||
@@ -1693,7 +1693,6 @@ static void __bt_searched_item_sel_cb(void *data, Evas_Object *obj,
FN_END;
}
-#ifndef TELEPHONY_DISABLED
static bool __bt_is_profile_connected(bt_app_data_t *ad,
bt_audio_profile_type_e profile)
{
@@ -1719,7 +1718,6 @@ static bool __bt_is_profile_connected(bt_app_data_t *ad,
return FALSE;
}
-#endif
void _bt_connect_device(bt_app_data_t *ad, bt_dev_t *dev)
{
@@ -1730,81 +1728,82 @@ void _bt_connect_device(bt_app_data_t *ad, bt_dev_t *dev)
INFO("Request connection");
-#ifndef TELEPHONY_DISABLED
- int headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
- if ((dev->service_list & BT_SC_HFP_SERVICE_MASK) ||
- (dev->service_list & BT_SC_HSP_SERVICE_MASK)) {
- /* Connect the Headset */
- if (dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
- if (ad->launch_mode == BT_LAUNCH_CONNECT_HEADSET) {
- if (__bt_is_profile_connected(ad, BT_AUDIO_PROFILE_TYPE_HSP_HFP)) {
- INFO("HFP is already connected, connect A2DP only!");
- headset_type = BT_AUDIO_PROFILE_TYPE_A2DP;
+ if (!TELEPHONY_DISABLED) {
+ int headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
+ if ((dev->service_list & BT_SC_HFP_SERVICE_MASK) ||
+ (dev->service_list & BT_SC_HSP_SERVICE_MASK)) {
+ /* Connect the Headset */
+ if (dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
+ if (ad->launch_mode == BT_LAUNCH_CONNECT_HEADSET) {
+ if (__bt_is_profile_connected(ad, BT_AUDIO_PROFILE_TYPE_HSP_HFP)) {
+ INFO("HFP is already connected, connect A2DP only!");
+ headset_type = BT_AUDIO_PROFILE_TYPE_A2DP;
+ } else {
+ INFO("Connect ALL profiles!");
+ headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
+ }
+ } else if (ad->launch_mode == BT_LAUNCH_CALL) {
+ if (__bt_is_profile_connected(ad, BT_AUDIO_PROFILE_TYPE_A2DP)) {
+ INFO("A2DP is already connected, connect HFP only!");
+ headset_type = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
+ } else {
+ INFO("Connect ALL profiles!");
+ headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
+ }
} else {
- INFO("Connect ALL profiles!");
- headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
- }
- } else if (ad->launch_mode == BT_LAUNCH_CALL) {
- if (__bt_is_profile_connected(ad, BT_AUDIO_PROFILE_TYPE_A2DP)) {
- INFO("A2DP is already connected, connect HFP only!");
- headset_type = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
- } else {
- INFO("Connect ALL profiles!");
- headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
+ if (!(dev->connected_mask & BT_HEADSET_CONNECTED) &&
+ !(dev->connected_mask & BT_STEREO_HEADSET_CONNECTED))
+ headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
+ else if (dev->connected_mask & BT_HEADSET_CONNECTED)
+ headset_type = BT_AUDIO_PROFILE_TYPE_A2DP;
+ else
+ headset_type = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
}
+ } else
+ headset_type = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
+
+ INFO("Connection type = %d", headset_type);
+ INFO("HFP connection status: %d", dev->connected_mask & BT_HEADSET_CONNECTED ? 1 : 0);
+ INFO("A2DP connection status: %d", dev->connected_mask & BT_STEREO_HEADSET_CONNECTED ? 1 : 0);
+
+ if (bt_audio_connect(dev->addr_str,
+ headset_type) == BT_ERROR_NONE) {
+ ad->connect_req = TRUE;
+ dev->status = BT_CONNECTING;
+ ad->connect_req_item = dev;
+ _bt_util_disable_genlist_items(ad, EINA_TRUE);
+ if (ad->scan_btn)
+ elm_object_disabled_set(ad->scan_btn, EINA_TRUE);
} else {
- if (!(dev->connected_mask & BT_HEADSET_CONNECTED) &&
- !(dev->connected_mask & BT_STEREO_HEADSET_CONNECTED))
- headset_type = BT_AUDIO_PROFILE_TYPE_ALL;
- else if (dev->connected_mask & BT_HEADSET_CONNECTED)
- headset_type = BT_AUDIO_PROFILE_TYPE_A2DP;
- else
- headset_type = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
+ ERR("Fail to connect Headset device");
+ }
+ } else if (dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
+ if (bt_audio_connect(dev->addr_str,
+ BT_AUDIO_PROFILE_TYPE_A2DP) ==
+ BT_ERROR_NONE) {
+ ad->connect_req = TRUE;
+ dev->status = BT_CONNECTING;
+ ad->connect_req_item = dev;
+ _bt_util_disable_genlist_items(ad, EINA_TRUE);
+ } else {
+ ERR("Fail to connect Headset device");
}
- } else
- headset_type = BT_AUDIO_PROFILE_TYPE_HSP_HFP;
-
- INFO("Connection type = %d", headset_type);
- INFO("HFP connection status: %d", dev->connected_mask & BT_HEADSET_CONNECTED ? 1 : 0);
- INFO("A2DP connection status: %d", dev->connected_mask & BT_STEREO_HEADSET_CONNECTED ? 1 : 0);
-
- if (bt_audio_connect(dev->addr_str,
- headset_type) == BT_ERROR_NONE) {
- ad->connect_req = TRUE;
- dev->status = BT_CONNECTING;
- ad->connect_req_item = dev;
- _bt_util_disable_genlist_items(ad, EINA_TRUE);
- if (ad->scan_btn)
- elm_object_disabled_set(ad->scan_btn, EINA_TRUE);
- } else {
- ERR("Fail to connect Headset device");
- }
- } else if (dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
- if (bt_audio_connect(dev->addr_str,
- BT_AUDIO_PROFILE_TYPE_A2DP) ==
- BT_ERROR_NONE) {
- ad->connect_req = TRUE;
- dev->status = BT_CONNECTING;
- ad->connect_req_item = dev;
- _bt_util_disable_genlist_items(ad, EINA_TRUE);
- } else {
- ERR("Fail to connect Headset device");
}
- }
-#else
- if (dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
- if (bt_audio_connect(dev->addr_str,
- BT_AUDIO_PROFILE_TYPE_A2DP) ==
- BT_ERROR_NONE) {
- ad->connect_req = TRUE;
- dev->status = BT_CONNECTING;
- ad->connect_req_item = dev;
- _bt_util_disable_genlist_items(ad, EINA_TRUE);
- } else {
- ERR("Fail to connect Headset device");
+ } else {
+ if (dev->service_list & BT_SC_A2DP_SERVICE_MASK) {
+ if (bt_audio_connect(dev->addr_str,
+ BT_AUDIO_PROFILE_TYPE_A2DP) ==
+ BT_ERROR_NONE) {
+ ad->connect_req = TRUE;
+ dev->status = BT_CONNECTING;
+ ad->connect_req_item = dev;
+ _bt_util_disable_genlist_items(ad, EINA_TRUE);
+ } else {
+ ERR("Fail to connect Headset device");
+ }
}
}
-#endif
+
if (dev->genlist_item)
_bt_update_genlist_item((Elm_Object_Item *) dev->genlist_item);
@@ -1818,8 +1817,7 @@ void _bt_disconnect_device(bt_app_data_t *ad, bt_dev_t *dev)
ret_if(ad == NULL);
ret_if(dev == NULL);
-#ifndef TELEPHONY_DISABLED
- if (_bt_util_is_profile_connected(BT_HEADSET_CONNECTED,
+ if (!TELEPHONY_DISABLED && _bt_util_is_profile_connected(BT_HEADSET_CONNECTED,
dev->bd_addr) == TRUE) {
DBG("Disconnecting AG service");
if (bt_audio_disconnect(dev->addr_str,
@@ -1832,10 +1830,6 @@ void _bt_disconnect_device(bt_app_data_t *ad, bt_dev_t *dev)
}
} else if (_bt_util_is_profile_connected(BT_STEREO_HEADSET_CONNECTED,
dev->bd_addr) == TRUE) {
-#else
- if (_bt_util_is_profile_connected(BT_STEREO_HEADSET_CONNECTED,
- dev->bd_addr) == TRUE) {
-#endif
DBG("Disconnecting AV service");
if (bt_audio_disconnect(dev->addr_str,
BT_AUDIO_PROFILE_TYPE_A2DP) ==
diff --git a/src/bt-profile-view.c b/src/bt-profile-view.c
index 5a31ade..ce9937b 100644
--- a/src/bt-profile-view.c
+++ b/src/bt-profile-view.c
@@ -63,7 +63,6 @@ static int __bt_profile_connect_option(bt_app_data_t *ad, bt_dev_t *dev,
return 0;
}
-#ifndef TELEPHONY_DISABLED
static void __bt_profile_call_option_check_sel(void *data,
Evas_Object *obj, void *event_info)
{
@@ -113,7 +112,6 @@ static void __bt_profile_call_option_check_sel(void *data,
FN_END;
}
-#endif
static void __bt_profile_media_option_check_sel(void *data,
Evas_Object *obj, void *event_info)
@@ -250,7 +248,6 @@ static char *__bt_profile_group_idx_label_get(void *data, Evas_Object *obj,
return strdup(buf);
}
-#ifndef TELEPHONY_DISABLED
static char *__bt_profile_call_option_label_get(void *data, Evas_Object *obj,
const char *part)
{
@@ -275,7 +272,6 @@ static char *__bt_profile_call_option_label_get(void *data, Evas_Object *obj,
FN_END;
return strdup(buf);
}
-#endif
static char *__bt_profile_media_option_label_get(void *data, Evas_Object *obj,
const char *part)
@@ -302,7 +298,6 @@ static char *__bt_profile_media_option_label_get(void *data, Evas_Object *obj,
return strdup(buf);
}
-#ifndef TELEPHONY_DISABLED
static Evas_Object *__bt_profile_call_option_icon_get(void *data, Evas_Object *obj,
const char *part)
{
@@ -341,7 +336,6 @@ static Evas_Object *__bt_profile_call_option_icon_get(void *data, Evas_Object *o
return check;
}
-#endif
static Evas_Object *__bt_profile_media_option_icon_get(void *data, Evas_Object *obj,
const char *part)
@@ -381,7 +375,6 @@ static Evas_Object *__bt_profile_media_option_icon_get(void *data, Evas_Object *
return check;
}
-#ifndef TELEPHONY_DISABLED
static void __bt_profile_call_option_item_sel(void *data, Evas_Object *obj,
void *event_info)
{
@@ -398,7 +391,6 @@ static void __bt_profile_call_option_item_sel(void *data, Evas_Object *obj,
FN_END;
}
-#endif
static void __bt_profile_media_option_item_sel(void *data, Evas_Object *obj,
void *event_info)
@@ -490,16 +482,17 @@ static Evas_Object *__bt_profile_draw_genlist(bt_app_data_t *ad, bt_dev_t *dev_i
vd->group_idx_itc->func.state_get = NULL;
vd->group_idx_itc->func.del = NULL;
-#ifndef TELEPHONY_DISABLED
- vd->call_itc = elm_genlist_item_class_new();
- retv_if(vd->call_itc == NULL, NULL);
+ if (!TELEPHONY_DISABLED) {
+ vd->call_itc = elm_genlist_item_class_new();
+ retv_if(vd->call_itc == NULL, NULL);
+
+ vd->call_itc->item_style = "1text.1icon.1";
+ vd->call_itc->func.text_get = __bt_profile_call_option_label_get;
+ vd->call_itc->func.content_get = __bt_profile_call_option_icon_get;
+ vd->call_itc->func.state_get = NULL;
+ vd->call_itc->func.del = NULL;
+ }
- vd->call_itc->item_style = "1text.1icon.1";
- vd->call_itc->func.text_get = __bt_profile_call_option_label_get;
- vd->call_itc->func.content_get = __bt_profile_call_option_icon_get;
- vd->call_itc->func.state_get = NULL;
- vd->call_itc->func.del = NULL;
-#endif
vd->media_itc = elm_genlist_item_class_new();
retv_if(vd->media_itc == NULL, NULL);
@@ -520,18 +513,19 @@ static Evas_Object *__bt_profile_draw_genlist(bt_app_data_t *ad, bt_dev_t *dev_i
vd->title_item = git;
DBG("service list = %x", dev_info->service_list);
-#ifndef TELEPHONY_DISABLED
- if ((dev_info->service_list & BT_SC_HFP_SERVICE_MASK) ||
- (dev_info->service_list & BT_SC_HSP_SERVICE_MASK)) {
- /* Call audio */
- git = elm_genlist_item_append(genlist, vd->call_itc,
- dev_info, NULL,
- ELM_GENLIST_ITEM_NONE,
- __bt_profile_call_option_item_sel,
- dev_info);
- vd->call_item = git;
+
+ if (!TELEPHONY_DISABLED) {
+ if ((dev_info->service_list & BT_SC_HFP_SERVICE_MASK) ||
+ (dev_info->service_list & BT_SC_HSP_SERVICE_MASK)) {
+ /* Call audio */
+ git = elm_genlist_item_append(genlist, vd->call_itc,
+ dev_info, NULL,
+ ELM_GENLIST_ITEM_NONE,
+ __bt_profile_call_option_item_sel,
+ dev_info);
+ vd->call_item = git;
+ }
}
-#endif
if (dev_info->service_list & BT_SC_A2DP_SERVICE_MASK) {
/* Media audio */
@@ -589,12 +583,10 @@ static void __bt_clean_profile_view(void *data)
vd->title_itc = NULL;
}
-#ifndef TELEPHONY_DISABLED
- if (vd->call_itc) {
+ if (!TELEPHONY_DISABLED && vd->call_itc) {
elm_genlist_item_class_free(vd->call_itc);
vd->call_itc = NULL;
}
-#endif
if (vd->media_itc) {
elm_genlist_item_class_free(vd->media_itc);
diff --git a/src/bt-util.c b/src/bt-util.c
index 356a34a..34153a1 100644
--- a/src/bt-util.c
+++ b/src/bt-util.c
@@ -20,6 +20,8 @@
#include <vconf.h>
#include <dd-display.h>
#include <bundle.h>
+#include <stdlib.h>
+#include <system_info.h>
#include "bt-main.h"
#include "bt-main-view.h"
@@ -495,7 +497,6 @@ gboolean _bt_util_is_battery_low(void)
return FALSE;
}
-#ifndef TELEPHONY_DISABLED
gboolean _bt_util_is_flight_mode(void)
{
FN_START;
@@ -512,7 +513,6 @@ gboolean _bt_util_is_flight_mode(void)
FN_END;
return mode ? TRUE : FALSE;
}
-#endif
void _bt_util_addr_type_to_addr_string(char *address,
unsigned char *addr)
@@ -839,3 +839,35 @@ void _bt_util_change_discoverable_mode(bt_app_data_t *ad, gboolean discoverable)
FN_END;
}
+tizen_profile_t _get_tizen_profile()
+{
+ static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+ if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+ return profile;
+
+ char *profileName;
+ system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+ switch (*profileName) {
+ case 'm':
+ case 'M':
+ profile = TIZEN_PROFILE_MOBILE;
+ break;
+ case 'w':
+ case 'W':
+ profile = TIZEN_PROFILE_WEARABLE;
+ break;
+ case 't':
+ case 'T':
+ profile = TIZEN_PROFILE_TV;
+ break;
+ case 'i':
+ case 'I':
+ profile = TIZEN_PROFILE_IVI;
+ break;
+ default: // common or unknown ==> ALL ARE COMMON.
+ profile = TIZEN_PROFILE_COMMON;
+ }
+ free(profileName);
+
+ return profile;
+}