if (connected_device->type & BT_AUDIO_A2DP_SOURCE)
connected_device->type &= ~(BT_AUDIO_A2DP_SOURCE);
break;
+ case BT_AUDIO_AG:
+ if (connected_device->type & BT_AUDIO_AG)
+ connected_device->type &= ~(BT_AUDIO_AG);
+ break;
default:
break;
}
return result;
}
+
+void _bt_audio_handle_incoming_authorization(char *address, int service_id)
+{
+ char connected_address[BT_ADDRESS_STRING_SIZE + 1];
+ gboolean connected = FALSE;
+ bluetooth_device_address_t device_address;
+ oal_status_t res = OAL_STATUS_SUCCESS;
+
+ _bt_convert_addr_string_to_type(device_address.addr, address);
+
+ switch (service_id) {
+ case HSP_SERVICE_ID:
+ case HFP_SERVICE_ID:
+ connected = _bt_is_headset_type_connected(BT_AUDIO_HSP, connected_address);
+ BT_DBG("Connected [0x%x]", connected);
+ break;
+ case HSP_HS_SERVICE_ID:
+ case HFP_HS_SERVICE_ID:
+ connected = _bt_is_headset_type_connected(BT_AUDIO_AG, connected_address);
+ BT_DBG("Connected [0x%x]", connected);
+ break;
+ default:
+ BT_ERR("Invalid HFP device ID.. [%d]", service_id);
+ return;
+ }
+
+ if (connected) {
+ BT_INFO("[%d] device is already connected..check which device..", service_id);
+ if (g_strcmp0(connected_address, address) != 0) {
+ BT_INFO("Different device is connected[%s] reject current [%s] device authorization request",
+ connected_address, address);
+ res = device_reply_auth_request((bt_address_t*)&device_address, service_id, FALSE, FALSE);
+ if (res != OAL_STATUS_SUCCESS)
+ BT_ERR("authorize_response: %d", res);
+ return;
+ }
+ }
+
+ res = device_reply_auth_request((bt_address_t*)&device_address, service_id, TRUE, FALSE);
+ if (res != OAL_STATUS_SUCCESS)
+ BT_ERR("authorize_response: %d", res);
+}
#include "oal-hf-client.h"
#include "bt-service-common.h"
+#include <bt-service-audio-common.h>
#include <bt-service-hf-client.h>
#include <bt-service-event.h>
-
-
-
static void __bt_reply_hf_client_disconnection_pending_request(bt_address_t *address)
{
- BT_DBG("+");
char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
bluetooth_device_address_t device_address;
GArray *out_param;
memcpy(device_address.addr, address->addr, BLUETOOTH_ADDRESS_LENGTH);
_bt_convert_addr_type_to_string(addr, address->addr);
- BT_INFO("HF Client Disconnection remote device [%s]", addr);
+ BT_DBG("HF Client Disconnection remote device [%s]", addr);
/* Find Async request information*/
req_info = _bt_get_request_info_data(BT_HF_DISCONNECT, addr);
__bt_hf_client_connect_cb) which will internally trigger HF DISCONNECTED event */
req_info = _bt_get_request_info_data(BT_HF_CONNECT, addr);
if (NULL == req_info) {
- BT_INFO("HF Connect request not found..");
+ BT_DBG("HF Connect request not found..");
return;
} else {
- BT_INFO("HF Connect request found..reply this request");
+ BT_DBG("HF Connect request found..reply this request");
}
} else {
- BT_INFO("HF DisConnect request found..reply this request");
+ BT_DBG("HF DisConnect request found..reply this request");
}
/* In any of the above cases, reply DBUS context */
_bt_service_method_return(req_info->context, out_param, result);
g_array_free(out_param, TRUE);
_bt_free_info_from_invocation_list(req_info);
-
- BT_DBG("-");
}
static void __bt_reply_hf_client_connection_pending_request(bt_address_t *address)
{
- BT_DBG("+");
char addr[BT_ADDRESS_STRING_SIZE] = { 0 };
bluetooth_device_address_t device_address;
GArray *out_param;
memcpy(device_address.addr, address->addr, BLUETOOTH_ADDRESS_LENGTH);
_bt_convert_addr_type_to_string(addr, address->addr);
- BT_INFO("HF Client Connection remote device [%s]", addr);
+ BT_DBG("HF Client Connection remote device [%s]", addr);
/* Find Async request information*/
req_info = _bt_get_request_info_data(BT_HF_CONNECT, addr);
if (NULL == req_info) {
- BT_INFO("HF Connect request not found or possibly already replied..");
+ BT_DBG("HF Connect request not found or possibly already replied..");
return;
} else {
- BT_INFO("HF Connect request found..");
+ BT_DBG("HF Connect request found..");
}
/* In any of the above cases, reply DBUS context */
g_array_free(out_param, TRUE);
_bt_free_info_from_invocation_list(req_info);
- BT_DBG("-");
}
/* This event handler process events for HF Client role */
void _bt_hf_client_event_handler(int oal_event, gpointer event_data)
{
- BT_INFO("+");
bt_address_t *bt_addr = event_data;
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
switch (oal_event) {
case OAL_EVENT_HF_CLIENT_DISCONNECTED:
BT_INFO("HF client Profile disconnected, reply pending DBUS request and check waiting device");
__bt_reply_hf_client_disconnection_pending_request(bt_addr);
BT_PERMANENT_LOG("Disconnected HF");
+
+ _bt_convert_addr_type_to_string(address, bt_addr->addr);
+ _bt_remove_headset_from_list(BT_AUDIO_AG, address);
break;
case OAL_EVENT_HF_CLIENT_CONNECTED:
BT_INFO("HF Client Profile connected, Event & DBUS context will be handled at finalizing SCO connect..");
__bt_reply_hf_client_connection_pending_request(bt_addr);
BT_PERMANENT_LOG("Connected HF");
+
+ _bt_convert_addr_type_to_string(address, bt_addr->addr);
+ _bt_add_headset_to_list(BT_AUDIO_AG, BT_STATE_CONNECTED, address);
break;
case OAL_EVENT_HF_CLIENT_CONNECTING:
BT_INFO("HF Client Profile connection successful, wait for Audio connect..");
int result = BLUETOOTH_ERROR_NONE;
gboolean is_connected = FALSE;
- BT_INFO("+");
-
is_connected = device_get_svc_conn_state((bt_address_t*)device_address, HFP_SERVICE_ID);
if (is_connected == TRUE) {
BT_ERR("HF Client is already connected");
{
oal_status_t status = OAL_STATUS_SUCCESS;
int result = BLUETOOTH_ERROR_NONE;
- BT_INFO("+");
status = hf_client_disconnect((bt_address_t *)device_address);
if (status != OAL_STATUS_SUCCESS) {
static void __bt_device_authorization_request_callback(event_dev_authorize_req_t* auth_event)
{
- oal_service_t service_d = auth_event->service_id;
+ oal_service_t service_id = auth_event->service_id;
gchar address[BT_ADDRESS_STR_LEN];
int res;
_bt_convert_addr_type_to_string(address, auth_event->address.addr);
- BT_DBG("service_d: %d", service_d);
+ BT_DBG("service_d: %d", service_id);
- switch (service_d) {
+ switch (service_id) {
case HID_SERVICE_ID:
BT_DBG("Incoming HID Profile conn Req from device addr [%s]", address);
break;
case A2DP_SERVICE_ID:
BT_DBG("Incoming A2DP(Remote Sink) profile conn Req from device addr [%s]", address);
- _bt_a2dp_src_handle_incoming_authorization(address, service_d);
+ _bt_a2dp_src_handle_incoming_authorization(address, service_id);
return;
case A2DP_SRC_SERVICE_ID:
BT_DBG("Incoming A2DP(Remote Source) Profile conn Req from device addr [%s]", address);
- _bt_a2dp_sink_handle_incoming_authorization(address, service_d);
+ _bt_a2dp_sink_handle_incoming_authorization(address, service_id);
break;
case AVRCP_SERVICE_ID:
BT_DBG("Incoming AVRCP (Remote) Profile conn Req from device addr [%s]", address);
}
#endif
case HSP_SERVICE_ID:
- BT_DBG("Incoming HSP_SERVICE_ID conn Req from device addr [%s]", address);
- break;
case HFP_SERVICE_ID:
BT_DBG("Incoming HFP_SERVICE_ID conn Req from device addr [%s]", address);
- break;
+ _bt_audio_handle_incoming_authorization(address, service_id);
+ return;
case SAP_SERVICE_ID:
BT_DBG("Incoming SAP_SERVICE_ID conn Req from device addr [%s]", address);
break;
case HSP_HS_SERVICE_ID:
- BT_DBG("Incoming HSP_HS_SERVICE_ID conn Req from device addr [%s]", address);
- break;
case HFP_HS_SERVICE_ID:
BT_DBG("Incoming HFP_HS_SERVICE_ID conn Req from device addr [%s]", address);
- break;
+ _bt_audio_handle_incoming_authorization(address, service_id);
+ return;
#ifdef TIZEN_BT_HAL
case IOTIVITY_SERVICE_ID:
BT_DBG("Incoming IOTIVITY_SERVICE_ID conn Req from device addr [%s]", address);
#endif
default:
/* For now, reject authorization for any service apart from above switch cases */
- BT_DBG("Incoming Profile conn req with service ID [%d] from device addr [%s]", service_d, address);
- res = device_reply_auth_request((bt_address_t*)&auth_event->address, service_d, FALSE, FALSE);
+ BT_DBG("Incoming Profile conn req with service ID [%d] from device addr [%s]", service_id, address);
+ res = device_reply_auth_request((bt_address_t*)&auth_event->address, service_id, FALSE, FALSE);
if (res != OAL_STATUS_SUCCESS)
BT_ERR("authorize_response: %d", res);
return;
/* Auto accept authorization request for HID, A2DP and AVRCP profiles */
BT_INFO("Auto Accept authorization");
- res = device_reply_auth_request((bt_address_t*)&auth_event->address, service_d, TRUE, FALSE);
+ res = device_reply_auth_request((bt_address_t*)&auth_event->address, service_id, TRUE, FALSE);
if (res != OAL_STATUS_SUCCESS)
BT_ERR("authorize_response: %d", res);
}
typedef enum {
BT_AUDIO_HSP = 0x01, /* HSP Connection */
BT_AUDIO_A2DP = 0x02, /* A2DP Source Connection, remote device is A2DP Sink */
- BT_AUDIO_ALL = 0x03, /* HSP and A2DP Source Connection (BT_AUDIO_HSP and BT_AUDIO_A2DP) */
+ BT_AUDIO_ALL = (0x01 | 0x02), /* HSP and A2DP Source Connection (BT_AUDIO_HSP and BT_AUDIO_A2DP) */
BT_AVRCP_TARGET = 0x04, /* AVRCP Target Connection to remote AVRCP controller */
BT_AVRCP = 0x08, /* AVRCP ctrl Connection to remote AVRCP target */
BT_AUDIO_A2DP_SOURCE = 0x10, /* A2DP Sink Connection, remote device is A2DP Source */
- BT_AUDIO_HFP_SOURCE = 0x11, /* HSP and A2DP Sink Connection (BT_AUDIO_HSP and BT_AUDIO_A2DP_SOURCE)*/
- BT_AUDIO_AG = 0x12 /* BT_HF_CONNECT local device HF Client and remote device AG */
+ BT_AUDIO_AG = 0x20, /* BT_HF_CONNECT local device HF Client and remote device AG */
+ BT_AUDIO_HFP_SOURCE = (0x10 | 0x20) /* HSP and A2DP Sink Connection (BT_AUDIO_HSP and BT_AUDIO_A2DP_SOURCE)*/
} bt_audio_type_t;
typedef enum {
void _bt_audio_set_current_role(bluetooth_audio_role_t role);
+void _bt_audio_handle_incoming_authorization(char *address, int service_id);
+
#ifdef TIZEN_FEATURE_BT_AVC_TARGET
typedef enum {
BT_AVC_OFF = 0x00,