X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=bt-api%2Fbt-audio.c;h=0bca5f217f2f301c6c920a73df96080920451944;hb=62a00d2e3430ed504bc220bcfe67387dd0507e22;hp=dd7eef7c5718230899bba4f4020f98bb0f822f47;hpb=f3bb85ce124d84934179652a3da4b445ce136523;p=platform%2Fcore%2Fconnectivity%2Fbluetooth-frwk.git diff --git a/bt-api/bt-audio.c b/bt-api/bt-audio.c index dd7eef7..0bca5f2 100644 --- a/bt-api/bt-audio.c +++ b/bt-api/bt-audio.c @@ -24,9 +24,7 @@ #include "bt-common.h" #include "bt-request-sender.h" #include "bt-event-handler.h" -#ifdef TIZEN_FEATURE_BT_DPM #include "bt-dpm.h" -#endif BT_EXPORT_API int bluetooth_audio_init(bt_audio_func_ptr cb, void *user_data) { @@ -88,7 +86,6 @@ BT_EXPORT_API int bluetooth_audio_connect(bluetooth_device_address_t *remote_add return BLUETOOTH_ERROR_PERMISSION_DEINED; } -#ifdef TIZEN_FEATURE_BT_DPM if (_bt_check_dpm(BT_DPM_ADDRESS, (void *)remote_address) == BT_DPM_RESTRICTED) { BT_ERR("Blacklist device"); return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION; @@ -118,7 +115,6 @@ BT_EXPORT_API int bluetooth_audio_connect(bluetooth_device_address_t *remote_add return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION; } } -#endif user_info = _bt_get_user_data(BT_AUDIO); retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL); @@ -137,6 +133,7 @@ BT_EXPORT_API int bluetooth_audio_connect(bluetooth_device_address_t *remote_add in_param1, in_param2, in_param3, in_param4, user_info->cb, user_info->user_data); else /* default case - with or without DPM enabled */ + result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AUDIO_CONNECT, in_param1, in_param2, in_param3, in_param4, user_info->cb, user_info->user_data); @@ -191,7 +188,6 @@ BT_EXPORT_API int bluetooth_ag_connect(bluetooth_device_address_t *remote_addres return BLUETOOTH_ERROR_PERMISSION_DEINED; } -#ifdef TIZEN_FEATURE_BT_DPM if (_bt_check_dpm(BT_DPM_ADDRESS, (void *)remote_address) == BT_DPM_RESTRICTED) { BT_ERR("Blacklist device"); return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION; @@ -214,7 +210,6 @@ BT_EXPORT_API int bluetooth_ag_connect(bluetooth_device_address_t *remote_addres return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION; } } -#endif user_info = _bt_get_user_data(BT_AUDIO); retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL); @@ -256,6 +251,7 @@ BT_EXPORT_API int bluetooth_ag_disconnect(bluetooth_device_address_t *remote_add g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t)); + BT_INFO_C("### Disconnect AG"); result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AG_DISCONNECT, in_param1, in_param2, in_param3, in_param4, user_info->cb, user_info->user_data); @@ -279,7 +275,6 @@ BT_EXPORT_API int bluetooth_av_connect(bluetooth_device_address_t *remote_addres return BLUETOOTH_ERROR_PERMISSION_DEINED; } -#ifdef TIZEN_FEATURE_BT_DPM if (_bt_check_dpm(BT_DPM_ADDRESS, (void *)remote_address) == BT_DPM_RESTRICTED) { BT_ERR("Blacklist device"); return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION; @@ -302,7 +297,6 @@ BT_EXPORT_API int bluetooth_av_connect(bluetooth_device_address_t *remote_addres return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION; } } -#endif user_info = _bt_get_user_data(BT_AUDIO); retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL); @@ -312,6 +306,7 @@ BT_EXPORT_API int bluetooth_av_connect(bluetooth_device_address_t *remote_addres g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t)); + BT_INFO_C("### Connect AV"); result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AV_CONNECT, in_param1, in_param2, in_param3, in_param4, user_info->cb, user_info->user_data); @@ -335,7 +330,6 @@ BT_EXPORT_API int bluetooth_av_source_connect(bluetooth_device_address_t *remote return BLUETOOTH_ERROR_PERMISSION_DEINED; } -#ifdef TIZEN_FEATURE_BT_DPM if (_bt_check_dpm(BT_DPM_ADDRESS, (void *)remote_address) == BT_DPM_RESTRICTED) { BT_ERR("Blacklist device"); return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION; @@ -345,7 +339,6 @@ BT_EXPORT_API int bluetooth_av_source_connect(bluetooth_device_address_t *remote BT_ERR("Not allow to use A2DP profile"); return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION; } -#endif user_info = _bt_get_user_data(BT_AUDIO); retv_if(user_info->cb == NULL, BLUETOOTH_ERROR_INTERNAL); @@ -355,6 +348,7 @@ BT_EXPORT_API int bluetooth_av_source_connect(bluetooth_device_address_t *remote g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t)); + BT_INFO_C("### Connect AV Source"); result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AV_SOURCE_CONNECT, in_param1, in_param2, in_param3, in_param4, user_info->cb, user_info->user_data); @@ -386,6 +380,7 @@ BT_EXPORT_API int bluetooth_av_disconnect(bluetooth_device_address_t *remote_add g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t)); + BT_INFO_C("### Disconnect AV"); result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AV_DISCONNECT, in_param1, in_param2, in_param3, in_param4, user_info->cb, user_info->user_data); @@ -417,6 +412,7 @@ BT_EXPORT_API int bluetooth_av_source_disconnect(bluetooth_device_address_t *rem g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t)); + BT_INFO_C("### Disconnect AV Source"); result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_AV_SOURCE_DISCONNECT, in_param1, in_param2, in_param3, in_param4, user_info->cb, user_info->user_data); @@ -444,6 +440,75 @@ BT_EXPORT_API int bluetooth_audio_select_role(bluetooth_audio_role_t role) return result; } +BT_EXPORT_API int bluetooth_audio_set_absolute_volume(unsigned int volume) +{ + int result; + + BT_CHECK_ENABLED(return); + + BT_INIT_PARAMS(); + BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); + + g_array_append_vals(in_param1, &volume, sizeof(unsigned int)); + + result = _bt_send_request(BT_BLUEZ_SERVICE, BT_AUDIO_SET_ABSOLUTE_VOLUME, + in_param1, in_param2, in_param3, in_param4, &out_param); + + BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); + return result; +} + +BT_EXPORT_API int bluetooth_audio_get_absolute_volume(unsigned int *volume) +{ + int result; + + BT_CHECK_PARAMETER(volume, return); + BT_CHECK_ENABLED(return); + + BT_INIT_PARAMS(); + BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); + + result = _bt_send_request(BT_BLUEZ_SERVICE, BT_AUDIO_GET_ABSOLUTE_VOLUME, + in_param1, in_param2, in_param3, in_param4, &out_param); + + if (result == BLUETOOTH_ERROR_NONE) { + *volume = g_array_index(out_param, + unsigned int, 0); + } + + BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); + + return result; +} + +BT_EXPORT_API int bluetooth_audio_is_avc_activated(bool *activated) +{ + int result; + + BT_CHECK_PARAMETER(activated, return); + + if (bluetooth_check_adapter() == BLUETOOTH_ADAPTER_DISABLED) { + BT_DBG("BT is not enabled. So activated value is false"); + *activated = false; + return BLUETOOTH_ERROR_NONE; + } + + BT_INIT_PARAMS(); + BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); + + result = _bt_send_request(BT_BLUEZ_SERVICE, BT_AUDIO_IS_AVC_ACTIVATED, + in_param1, in_param2, in_param3, in_param4, &out_param); + + if (result == BLUETOOTH_ERROR_NONE) { + *activated = g_array_index(out_param, + bool, 0); + } + + BT_FREE_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); + + return result; +} + BT_EXPORT_API int bluetooth_ag_get_headset_volume(unsigned int *speaker_gain) { int result; @@ -473,12 +538,10 @@ BT_EXPORT_API int bluetooth_ag_set_speaker_gain(unsigned int speaker_gain) BT_CHECK_ENABLED(return); -#ifdef TIZEN_FEATURE_BT_DPM if (_bt_check_dpm(BT_DPM_HSP, NULL) == BT_DPM_RESTRICTED) { BT_ERR("Not allow to use HSP profile"); return BLUETOOTH_ERROR_DEVICE_POLICY_RESTRICTION; } -#endif BT_INIT_PARAMS(); BT_ALLOC_PARAMS(in_param1, in_param2, in_param3, in_param4, out_param); @@ -505,10 +568,10 @@ static GVariant* __bt_hf_agent_dbus_send(const char *path, const char *interface GDBusProxy *proxy = NULL; GDBusConnection *conn = NULL; - conn = _bt_gdbus_get_system_gconn(); + conn = _bt_get_system_common_conn(); retv_if(conn == NULL, NULL); - proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE, + proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES, NULL, BT_HF_SERVICE_NAME, path, interface, NULL, err); if (proxy == NULL) { BT_ERR("Unable to allocate new proxy"); @@ -558,6 +621,8 @@ static int __bt_hf_agent_read_call_list(GVariant *reply, (*call_list)->list = g_list_append((*call_list)->list, (gpointer)call_info); } + + g_variant_unref(var_temp); BT_DBG("-"); return BLUETOOTH_ERROR_NONE; } @@ -674,6 +739,7 @@ BT_EXPORT_API int bluetooth_hf_disconnect(bluetooth_device_address_t *remote_add g_array_append_vals(in_param1, remote_address, sizeof(bluetooth_device_address_t)); + BT_INFO_C("### Disconnect HF"); result = _bt_send_request_async(BT_BLUEZ_SERVICE, BT_HF_DISCONNECT, in_param1, in_param2, in_param3, in_param4, user_info->cb, user_info->user_data); @@ -1081,6 +1147,33 @@ BT_EXPORT_API int bluetooth_hf_request_call_list( return BLUETOOTH_ERROR_NONE; } +BT_EXPORT_API int bluetooth_hf_request_call_list_async(void) +{ + GVariant *reply = NULL; + GError *err = NULL; + int ret = BLUETOOTH_ERROR_INTERNAL; + + BT_CHECK_ENABLED(return); + + reply = __bt_hf_agent_dbus_send(BT_HF_OBJECT_PATH, BT_HF_INTERFACE, + "RequestCallListAsync", &err, NULL); + if (!reply) { + BT_ERR("Error returned in method call\n"); + if (err) { + BT_ERR("Error = %s", err->message); + if (strstr(err->message, "No data")) + ret = BLUETOOTH_ERROR_NO_DATA; + else if (strstr(err->message, "NotConnected")) + ret = BLUETOOTH_ERROR_NOT_CONNECTED; + g_clear_error(&err); + } + return ret; + } + + g_variant_unref(reply); + return BLUETOOTH_ERROR_NONE; +} + BT_EXPORT_API int bluetooth_hf_get_codec(unsigned int *codec_id) { GVariant *reply = NULL;