2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 #if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
23 #include <syspopup_caller.h>
26 #include "bluetooth-api.h"
27 #include "bt-internal-types.h"
29 #include "bt-service-audio.h"
30 #include "bt-service-adapter.h"
31 #include "bt-service-common.h"
32 #include "bt-service-device.h"
33 #include "bt-service-event.h"
34 #include "bt-service-util.h"
36 #include "bt-service-headset-connection.h"
38 #ifdef TIZEN_SUPPORT_DUAL_HF
40 #define VCONF_KEY_BT_HOST_BT_MAC_ADDR "db/wms/host_bt_mac"
47 char device_address[BT_ADDRESS_STRING_SIZE + 1];
48 } bt_connected_headset_data_t;
50 static GList *g_connected_list;
52 static bt_headset_wait_t *g_wait_data;
54 static bt_audio_function_data_t *pdata;
56 static void __bt_remove_device_from_wait_list();
58 static void __bt_free_wait_data();
60 static gboolean __bt_device_support_uuid(char *remote_address,
61 bt_audio_type_t type);
63 static void __bt_hf_request_cb(GDBusProxy *proxy, GAsyncResult *res,
66 GError *g_error = NULL;
67 GVariant *out_param1 = NULL;
68 GVariant *reply = NULL;
69 int result = BLUETOOTH_ERROR_NONE;
70 bt_function_data_t *func_data;
71 request_info_t *req_info;
73 reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
74 g_object_unref(proxy);
76 func_data = user_data;
78 if (func_data == NULL) {
80 BT_ERR("func_data == NULL");
84 req_info = _bt_get_request_info(func_data->req_id);
85 if (req_info == NULL) {
86 BT_ERR("req_info == NULL");
91 BT_ERR("HF Connect Dbus Call Error");
93 BT_ERR("Error: %s\n", g_error->message);
94 g_clear_error(&g_error);
96 result = BLUETOOTH_ERROR_INTERNAL;
98 g_variant_unref(reply);
101 if (req_info->context == NULL)
104 out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
105 func_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
107 g_dbus_method_invocation_return_value(req_info->context,
108 g_variant_new("(iv)", result, out_param1));
110 _bt_delete_request_list(req_info->req_id);
114 g_free(func_data->address);
119 void _bt_audio_check_pending_connect()
122 bluetooth_device_address_t device_address;
127 if (pdata->pending == BT_PENDING_CONNECT) {
129 _bt_convert_addr_string_to_type(device_address.addr,
131 _bt_audio_connect(pdata->req_id,
136 g_free(pdata->address);
145 static void __bt_audio_request_cb(GDBusProxy *proxy, GAsyncResult *res,
148 GError *g_error = NULL;
149 GVariant *out_param1 = NULL;
150 GVariant *reply = NULL;
151 int result = BLUETOOTH_ERROR_NONE;
152 bt_audio_function_data_t *func_data;
153 request_info_t *req_info;
155 reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
156 g_object_unref(proxy);
157 g_variant_unref(reply);
159 func_data = user_data;
161 if (func_data == NULL) {
163 BT_ERR("func_data == NULL");
167 if (func_data->pending != BT_PENDING_NONE && g_error == NULL) {
169 bluetooth_device_address_t device_address;
170 _bt_convert_addr_string_to_type(device_address.addr,
173 if (func_data->pending == BT_PENDING_CONNECT) {
175 if (__bt_device_support_uuid(func_data->address,
178 pdata = g_new0(bt_audio_function_data_t, 1);
179 pdata->req_id = func_data->req_id;
180 pdata->out_param = func_data->out_param;
181 pdata->address = strdup(func_data->address);
182 pdata->pending = func_data->pending;
188 if (_bt_is_service_connected(func_data->address
190 _bt_audio_disconnect(func_data->req_id,
193 func_data->out_param);
202 req_info = _bt_get_request_info(func_data->req_id);
203 if (req_info == NULL) {
204 BT_ERR("req_info == NULL");
211 BT_ERR("Audio Connect/Disconnect Dbus Call Error: %s\n", g_error->message);
213 result = BLUETOOTH_ERROR_INTERNAL;
215 /* Remove the device from the list */
216 _bt_remove_headset_from_list(func_data->type, func_data->address);
218 /* Error, check if any waiting device is there */
219 if (g_wait_data == NULL)
222 if (g_strcmp0(g_wait_data->address, func_data->address) != 0) {
223 bluetooth_device_address_t device_address;
224 _bt_convert_addr_string_to_type(device_address.addr,
225 g_wait_data->address);
226 _bt_audio_connect(g_wait_data->req_id, g_wait_data->type,
227 &device_address, g_wait_data->out_param1);
230 /* Event will be sent by the event reciever */
232 if (req_info->context == NULL) {
233 BT_DBG("req_info->context is NULL");
237 out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
238 func_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
240 g_dbus_method_invocation_return_value(req_info->context,
241 g_variant_new("(iv)", result, out_param1));
243 _bt_delete_request_list(req_info->req_id);
245 g_clear_error(&g_error);
248 g_free(func_data->address);
253 static void __bt_free_wait_data()
255 if (g_wait_data != NULL) {
256 g_free(g_wait_data->address);
262 static void __bt_remove_device_from_wait_list()
264 /* Before deleting the request update the UI */
265 GVariant *out_param_1 = NULL;
266 int result = BLUETOOTH_ERROR_INTERNAL;
267 request_info_t *req_info;
269 req_info = _bt_get_request_info(g_wait_data->req_id);
270 if (req_info == NULL) {
271 BT_ERR("req_info == NULL");
275 out_param_1 = g_variant_new_from_data((const GVariantType *)"ay",
276 g_wait_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
278 g_dbus_method_invocation_return_value(req_info->context,
279 g_variant_new("(iv)", result, out_param_1));
281 _bt_delete_request_list(g_wait_data->req_id);
284 static void __bt_set_headset_disconnection_type(const char *address)
286 bt_connected_headset_data_t *connected_device;
289 node = g_list_first(g_connected_list);
290 while (node != NULL) {
291 connected_device = node->data;
292 if (g_strcmp0(connected_device->device_address, address) == 0) {
293 g_wait_data->disconnection_type = connected_device->type;
296 node = g_list_next(node);
300 gboolean _bt_is_headset_type_connected(int type, char *address)
304 node = g_list_first(g_connected_list);
305 while (node != NULL) {
306 bt_connected_headset_data_t *connected_device = node->data;
308 if (connected_device->type & type) {
310 g_strlcpy(address, connected_device->device_address,
311 BT_ADDRESS_STRING_SIZE + 1);
315 node = g_list_next(node);
320 #ifdef TIZEN_SUPPORT_DUAL_HF
321 gboolean __bt_is_companion_device(const char *addr)
323 #ifdef TIZEN_WEARABLE
324 char *host_device_address = NULL;
325 host_device_address = vconf_get_str(VCONF_KEY_BT_HOST_BT_MAC_ADDR);
327 if (!host_device_address) {
328 BT_INFO("Failed to get a companion device address");
332 if (g_strcmp0(host_device_address, addr) == 0) {
333 BT_INFO("addr[%s] is companion device", addr);
339 /* TODO : Need to add companion device check condition for Phone models */
345 static int __bt_is_headset_connected(int type, int req_id,
346 const char *address, GArray **out_param1)
348 gboolean connected = FALSE;
349 char connected_address[BT_ADDRESS_STRING_SIZE + 1];
350 bluetooth_device_address_t device_address;
351 bt_connected_headset_data_t *connected_device = NULL;
352 #ifdef TIZEN_SUPPORT_DUAL_HF
353 gboolean is_companion_device = FALSE;
356 /* Check if any other headset is connected */
359 node = g_list_first(g_connected_list);
360 while (node != NULL) {
361 connected_device = node->data;
362 if ((connected_device->type & type) == type) {
363 g_strlcpy(connected_address, connected_device->device_address,
364 BT_ADDRESS_STRING_SIZE + 1);
365 #ifdef TIZEN_SUPPORT_DUAL_HF
366 is_companion_device = __bt_is_companion_device(connected_address);
367 BT_INFO(" is_companion_device[%d]", is_companion_device);
369 if (!is_companion_device) {
378 node = g_list_next(node);
382 return BLUETOOTH_ERROR_NOT_CONNECTED;
384 BT_DBG("connected headset %s", connected_address);
386 if (g_strcmp0(connected_address, address) == 0)
387 return BLUETOOTH_ERROR_ALREADY_CONNECT;
388 #ifdef TIZEN_SUPPORT_DUAL_HF
389 else if (TRUE == __bt_is_companion_device(address))
390 return BLUETOOTH_ERROR_NOT_CONNECTED;
393 /* If already one device is waiting, remove current waiting device and add new */
394 if (g_wait_data != NULL) {
395 if (g_strcmp0(g_wait_data->address, address) != 0) {
396 __bt_remove_device_from_wait_list();
397 __bt_free_wait_data();
401 if (g_wait_data == NULL) {
402 g_wait_data = g_malloc0(sizeof(bt_headset_wait_t));
403 g_wait_data->address = g_strdup(address);
404 g_wait_data->req_id = req_id;
405 g_wait_data->type = type;
406 g_wait_data->ag_flag = FALSE;
407 g_wait_data->out_param1 = out_param1;
409 /* Set disconnection type */
410 __bt_set_headset_disconnection_type(connected_address);
413 /* Convert BD adress from string type */
414 _bt_convert_addr_string_to_type(device_address.addr, connected_address);
415 _bt_audio_disconnect(0, connected_device->type & type, &device_address, NULL);
416 return BLUETOOTH_ERROR_NONE;
419 void _bt_set_audio_wait_data_flag(gboolean flag)
421 BT_DBG("_bt_set_audio_wait_data_flag \n");
422 g_wait_data->ag_flag = flag;
425 bt_headset_wait_t *_bt_get_audio_wait_data(void)
427 BT_DBG("_bt_get_audio_wait_data \n");
431 void _bt_rel_wait_data(void)
433 BT_DBG("_bt_rel_wait_data \n");
434 __bt_free_wait_data();
437 void _bt_add_headset_to_list(int type, int status, const char *address)
439 bt_connected_headset_data_t *connected_device;
440 bt_connected_headset_data_t *device;
443 BT_DBG("_bt_add_headset_to_list \n");
445 node = g_list_first(g_connected_list);
446 while (node != NULL) {
447 device = (bt_connected_headset_data_t *)node->data;
449 if (g_strcmp0(device->device_address, address) == 0) {
450 BT_DBG("Address match, update connection type \n");
451 if (status == BT_STATE_CONNECTED)
452 device->type |= type;
453 device->device_state = status;
456 node = g_list_next(node);
459 connected_device = g_malloc0(sizeof(bt_connected_headset_data_t));
460 /* Fix : NULL_RETURNS */
461 if (connected_device == NULL) {
462 BT_ERR("No memory allocated");
466 connected_device->device_state = status;
467 if ((status == BT_STATE_CONNECTED) || (status == BT_STATE_CONNECTING))
468 connected_device->type |= type;
469 g_strlcpy(connected_device->device_address, address,
470 sizeof(connected_device->device_address));
471 g_connected_list = g_list_append(g_connected_list, connected_device);
474 int _bt_get_device_state_from_list(int type, const char *address)
477 bt_connected_headset_data_t *device;
480 node = g_list_first(g_connected_list);
481 while (node != NULL) {
482 device = (bt_connected_headset_data_t *)node->data;
483 if (g_strcmp0(device->device_address, address) == 0) {
484 BT_DBG("Device found");
485 return device->device_state;
487 node = g_list_next(node);
490 BT_DBG("Device not found");
491 return BLUETOOTH_ERROR_INTERNAL;
494 void _bt_remove_headset_from_list(int type, const char *address)
498 BT_DBG("_bt_remove_headset_from_list \n");
500 node = g_list_first(g_connected_list);
501 while (node != NULL) {
502 bt_connected_headset_data_t *connected_device = node->data;
504 if (g_strcmp0(connected_device->device_address, address) != 0) {
505 node = g_list_next(node);
509 BT_DBG("Address match \n");
511 BT_DBG("Connection type = %x\n", connected_device->type);
515 if (connected_device->type & BT_AUDIO_A2DP)
516 connected_device->type &= ~(BT_AUDIO_A2DP);
519 if (connected_device->type & BT_AUDIO_HSP)
520 connected_device->type &= ~(BT_AUDIO_HSP);
523 if (connected_device->type & BT_AUDIO_ALL)
524 connected_device->type &= ~(BT_AUDIO_ALL);
527 if (connected_device->type & BT_AVRCP)
528 connected_device->type &= ~(BT_AVRCP);
532 BT_DBG("Connection type = %x\n", connected_device->type);
534 if (connected_device->type == 0x00) {
535 g_connected_list = g_list_remove(g_connected_list, connected_device);
536 g_free(connected_device);
539 node = g_list_next(node);
543 static gboolean __bt_device_support_uuid(char *remote_address,
544 bt_audio_type_t type)
546 GArray *dev_list = NULL;
548 bluetooth_device_info_t info;
549 char bond_address[BT_ADDRESS_STRING_SIZE] = { 0 };
550 gboolean ret = FALSE;
554 dev_list = g_array_new (FALSE, FALSE, sizeof(gchar));
556 _bt_get_bonded_devices(&dev_list);
557 size = (dev_list->len) / sizeof(bluetooth_device_info_t);
559 for (i=0; i < size; i++) {
560 info = g_array_index(dev_list, bluetooth_device_info_t, i);
561 _bt_convert_addr_type_to_string(bond_address,
562 info.device_address.addr);
563 if (strcmp(bond_address, remote_address) != 0)
566 BT_INFO("Device address Matched");
568 while (j != info.service_index) {
569 if (type == BT_AUDIO_HSP) {
570 if (strcmp(info.uuids[j], HFP_HS_UUID) == 0) {
571 BT_INFO("HFP HS UUID exists");
575 } else if (type == BT_AUDIO_A2DP) {
576 if (strcmp(info.uuids[j], A2DP_SINK_UUID) == 0) {
577 BT_INFO("A2DP SINK UUID exists");
586 g_array_free(dev_list, TRUE);
591 gboolean _bt_is_service_connected(char* address, int type)
595 node = g_list_first(g_connected_list);
596 while (node != NULL) {
597 bt_connected_headset_data_t *conn_device = node->data;
599 if ((g_strcmp0(conn_device->device_address, address) == 0) &&
600 (conn_device->type & type)) {
601 BT_INFO("Service connected");
605 node = g_list_next(node);
607 BT_INFO("Service not connected");
611 int _bt_audio_connect(int request_id, int type,
612 bluetooth_device_address_t *device_address,
615 int result = BLUETOOTH_ERROR_NONE;
616 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
617 GDBusProxy *adapter_proxy;
618 GDBusConnection *g_conn;
621 int value = BLUETOOTH_ERROR_NONE;
622 bt_audio_function_data_t *func_data;
624 BT_CHECK_PARAMETER(device_address, return);
626 adapter_proxy = _bt_get_adapter_proxy();
627 retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
629 g_conn = _bt_get_system_gconn();
630 retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
632 _bt_convert_addr_type_to_string(address, device_address->addr);
634 func_data = g_malloc0(sizeof(bt_audio_function_data_t));
635 /* Fix : NULL_RETURNS */
636 if (func_data == NULL) {
637 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
641 func_data->address = g_strdup(address);
642 func_data->req_id = request_id;
643 func_data->type = type;
644 func_data->pending = BT_PENDING_NONE;
645 func_data->out_param = out_param1;
652 uuid = A2DP_SINK_UUID;
655 uuid = AVRCP_TARGET_UUID;
657 case BT_AUDIO_A2DP_SOURCE:
658 uuid = A2DP_SOURCE_UUID;
661 if (__bt_device_support_uuid(address, BT_AUDIO_HSP)) {
663 func_data->pending = BT_PENDING_CONNECT;
665 } else if (__bt_device_support_uuid(address, BT_AUDIO_A2DP)) {
666 uuid = A2DP_SINK_UUID;
667 type = BT_AUDIO_A2DP;
669 BT_ERR("No audio role supported");
670 result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
675 BT_ERR("Unknown role");
676 result = BLUETOOTH_ERROR_INTERNAL;
679 BT_INFO("Connecting to service %s", uuid);
681 value = __bt_is_headset_connected(type, request_id, address, out_param1);
683 if (value == BLUETOOTH_ERROR_ALREADY_CONNECT) {
684 return BLUETOOTH_ERROR_ALREADY_CONNECT;
685 } else if (value == BLUETOOTH_ERROR_NOT_CONNECTED) {
686 _bt_headset_set_local_connection(TRUE);
687 ret = _bt_connect_profile(address, uuid,
688 __bt_audio_request_cb, func_data);
690 if (ret != BLUETOOTH_ERROR_NONE) {
691 BT_ERR("_bt_connect_profile Error");
692 _bt_headset_set_local_connection(FALSE);
693 g_free(func_data->address);
698 /* Add data to the connected list */
699 _bt_add_headset_to_list(type, BT_STATE_CONNECTING, address);
702 return BLUETOOTH_ERROR_NONE;
704 g_array_append_vals(*out_param1, address,
710 int _bt_audio_disconnect(int request_id, int type,
711 bluetooth_device_address_t *device_address,
714 int result = BLUETOOTH_ERROR_NONE;
715 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
716 bt_audio_function_data_t *func_data;
717 GDBusProxy *adapter_proxy;
718 GDBusConnection *g_conn;
723 BT_CHECK_PARAMETER(device_address, return);
725 adapter_proxy = _bt_get_adapter_proxy();
726 retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
728 g_conn = _bt_get_system_gconn();
729 retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
731 _bt_convert_addr_type_to_string(address, device_address->addr);
733 func_data = g_malloc0(sizeof(bt_audio_function_data_t));
734 retv_if(func_data == NULL, BLUETOOTH_ERROR_INTERNAL);
736 func_data->address = g_strdup(address);
737 func_data->req_id = request_id;
738 func_data->pending = BT_PENDING_NONE;
739 func_data->out_param = out_param1;
740 func_data->type = type;
747 uuid = A2DP_SINK_UUID;
750 uuid = AVRCP_TARGET_UUID;
752 case BT_AUDIO_A2DP_SOURCE:
753 uuid = A2DP_SOURCE_UUID;
756 if (_bt_is_service_connected(address, BT_AUDIO_HSP)) {
758 func_data->pending = BT_PENDING_DISCONNECT;
759 } else if (_bt_is_service_connected(address, BT_AUDIO_A2DP)) {
760 uuid = A2DP_SINK_UUID;
762 BT_ERR("No audio service connected");
763 result = BLUETOOTH_ERROR_NOT_CONNECTED;
768 BT_ERR("Unknown role");
769 result = BLUETOOTH_ERROR_INTERNAL;
773 BT_INFO("Disconnecting service %s", uuid);
774 ret = _bt_disconnect_profile(address, uuid,
775 __bt_audio_request_cb, func_data);
777 if (ret != BLUETOOTH_ERROR_NONE) {
778 BT_ERR("_bt_disconnect_profile Error");
779 g_free(func_data->address);
785 * This logic is added for dual HF mode issue.
787 node = g_list_first(g_connected_list);
788 while (node != NULL) {
789 bt_connected_headset_data_t *connected_device = node->data;
791 if (g_strcmp0(connected_device->device_address, address) == 0) {
792 BT_DBG("Connection type update");
793 type = connected_device->type;
796 node = g_list_next(node);
798 _bt_add_headset_to_list(type, BT_STATE_DISCONNECTING, address);
800 return BLUETOOTH_ERROR_NONE;
802 if (out_param1 != NULL)
803 g_array_append_vals(*out_param1, address,
809 void _bt_remove_from_connected_list(const char *address)
811 bt_connected_headset_data_t *connected_device;
814 node = g_list_first(g_connected_list);
815 while (node != NULL) {
816 connected_device = node->data;
817 if (connected_device != NULL &&
818 g_strcmp0(connected_device->device_address, address) == 0) {
819 BT_ERR("Device is removed from the list");
820 g_connected_list = g_list_remove(g_connected_list, connected_device);
821 g_free(connected_device);
824 node = g_list_next(node);
828 int _bt_hf_connect(int request_id,
829 bluetooth_device_address_t *device_address,
832 int result = BLUETOOTH_ERROR_NONE;
833 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
834 bt_function_data_t *func_data;
835 GDBusProxy *adapter_proxy;
836 GDBusConnection *g_conn;
840 BT_CHECK_PARAMETER(device_address, return);
842 _bt_convert_addr_type_to_string(address, device_address->addr);
844 adapter_proxy = _bt_get_adapter_proxy();
845 if (adapter_proxy == NULL) {
846 result = BLUETOOTH_ERROR_INTERNAL;
850 g_conn = _bt_get_system_gconn();
851 if (g_conn == NULL) {
852 result = BLUETOOTH_ERROR_INTERNAL;
856 func_data = g_malloc0(sizeof(bt_function_data_t));
857 /* Fix : NULL_RETURNS */
858 if (func_data == NULL) {
859 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
863 func_data->address = g_strdup(address);
864 func_data->req_id = request_id;
865 uuid = g_strdup(HFP_AG_UUID);
867 BT_DBG("Connecting to service %s", uuid);
869 ret = _bt_connect_profile(address, uuid,
870 __bt_hf_request_cb, func_data);
872 if (ret != BLUETOOTH_ERROR_NONE) {
873 BT_ERR("_bt_connect_profile Error");
874 g_free(func_data->address);
880 return BLUETOOTH_ERROR_NONE;
882 if (out_param1 != NULL)
883 g_array_append_vals(*out_param1, address,
889 int _bt_hf_disconnect(int request_id,
890 bluetooth_device_address_t *device_address,
893 int result = BLUETOOTH_ERROR_NONE;
894 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
895 bt_function_data_t *func_data;
896 GDBusProxy *adapter_proxy;
897 GDBusConnection *g_conn;
902 BT_CHECK_PARAMETER(device_address, return);
904 _bt_convert_addr_type_to_string(address, device_address->addr);
906 adapter_proxy = _bt_get_adapter_proxy();
907 if (adapter_proxy == NULL) {
908 result = BLUETOOTH_ERROR_INTERNAL;
912 g_conn = _bt_get_system_gconn();
913 if (g_conn == NULL) {
914 result = BLUETOOTH_ERROR_INTERNAL;
918 func_data = g_malloc0(sizeof(bt_function_data_t));
919 /* Fix : NULL_RETURNS */
920 if (func_data == NULL) {
921 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
925 func_data->address = g_strdup(address);
926 func_data->req_id = request_id;
927 uuid = g_strdup(HFP_AG_UUID);
929 BT_DBG("Disconnecting service %s", uuid);
930 ret = _bt_disconnect_profile(address, uuid,
931 __bt_hf_request_cb, func_data);
933 if (ret != BLUETOOTH_ERROR_NONE) {
934 BT_ERR("_bt_disconnect_profile Error");
935 g_free(func_data->address);
941 return BLUETOOTH_ERROR_NONE;
943 if (out_param1 != NULL)
944 g_array_append_vals(*out_param1, address,
950 int _bt_audio_set_content_protect(gboolean status)
952 GDBusConnection *conn;
953 GError *error = NULL;
957 conn = _bt_get_system_gconn();
958 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
960 BT_DBG("Content Protection status = [%d]", status);
962 g_dbus_connection_emit_signal(conn,
963 NULL, BT_CONTENT_PROTECTION_PATH,
964 BT_CONTENT_PROTECTION_INTERFACE,
965 "ProtectionRequired",
966 g_variant_new("(b)", status),
970 /* dBUS gives error cause */
971 ERR("Could not Emit Signal: errCode[%x], message[%s]",
972 error->code, error->message);
973 g_clear_error(&error);
974 return BLUETOOTH_ERROR_INTERNAL;
977 BT_DBG("Emit Signal done = [ProtectionRequired]");
978 return BLUETOOTH_ERROR_NONE;