4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hocheol Seo <hocheol.seo@samsung.com>
7 * Girishashok Joshi <girish.joshi@samsung.com>
8 * Chanyeol Park <chanyeol.park@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
28 #if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
29 #include <syspopup_caller.h>
32 #include "bluetooth-api.h"
33 #include "bt-internal-types.h"
35 #include "bt-service-audio.h"
36 #include "bt-service-adapter.h"
37 #include "bt-service-common.h"
38 #include "bt-service-device.h"
39 #include "bt-service-event.h"
40 #include "bt-service-util.h"
42 #include "bt-service-headset-connection.h"
44 #ifdef TIZEN_SUPPORT_DUAL_HF
46 #define VCONF_KEY_BT_HOST_BT_MAC_ADDR "db/wms/host_bt_mac"
53 char device_address[BT_ADDRESS_STRING_SIZE + 1];
54 } bt_connected_headset_data_t;
56 static GList *g_connected_list;
58 static bt_headset_wait_t *g_wait_data;
60 static bt_audio_function_data_t *pdata;
62 static void __bt_remove_device_from_wait_list();
64 static void __bt_free_wait_data();
66 static gboolean __bt_device_support_uuid(char *remote_address,
67 bt_audio_type_t type);
69 static void __bt_hf_request_cb(GDBusProxy *proxy, GAsyncResult *res,
72 GError *g_error = NULL;
73 GVariant *out_param1 = NULL;
74 GVariant *reply = NULL;
75 int result = BLUETOOTH_ERROR_NONE;
76 bt_function_data_t *func_data;
77 request_info_t *req_info;
79 reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
80 g_object_unref(proxy);
82 func_data = user_data;
84 if (func_data == NULL) {
86 BT_ERR("func_data == NULL");
90 req_info = _bt_get_request_info(func_data->req_id);
91 if (req_info == NULL) {
92 BT_ERR("req_info == NULL");
97 BT_ERR("HF Connect Dbus Call Error");
99 BT_ERR("Error: %s\n", g_error->message);
100 g_clear_error(&g_error);
102 result = BLUETOOTH_ERROR_INTERNAL;
104 g_variant_unref(reply);
107 if (req_info->context == NULL)
110 out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
111 func_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
113 g_dbus_method_invocation_return_value(req_info->context,
114 g_variant_new("(iv)", result, out_param1));
116 _bt_delete_request_list(req_info->req_id);
120 g_free(func_data->address);
125 void _bt_audio_check_pending_connect()
128 bluetooth_device_address_t device_address;
133 if (pdata->pending == BT_PENDING_CONNECT) {
135 _bt_convert_addr_string_to_type(device_address.addr,
137 _bt_audio_connect(pdata->req_id,
142 g_free(pdata->address);
151 static void __bt_audio_request_cb(GDBusProxy *proxy, GAsyncResult *res,
154 GError *g_error = NULL;
155 GVariant *out_param1 = NULL;
156 GVariant *reply = NULL;
157 int result = BLUETOOTH_ERROR_NONE;
158 bt_audio_function_data_t *func_data;
159 request_info_t *req_info;
161 reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
162 g_object_unref(proxy);
163 g_variant_unref(reply);
165 func_data = user_data;
167 if (func_data == NULL) {
169 BT_ERR("func_data == NULL");
173 if (func_data->pending != BT_PENDING_NONE && g_error == NULL) {
175 bluetooth_device_address_t device_address;
176 _bt_convert_addr_string_to_type(device_address.addr,
179 if (func_data->pending == BT_PENDING_CONNECT) {
181 if (__bt_device_support_uuid(func_data->address,
184 pdata = g_new0(bt_audio_function_data_t, 1);
185 pdata->req_id = func_data->req_id;
186 pdata->out_param = func_data->out_param;
187 pdata->address = strdup(func_data->address);
188 pdata->pending = func_data->pending;
194 if (_bt_is_service_connected(func_data->address
196 _bt_audio_disconnect(func_data->req_id,
199 func_data->out_param);
208 req_info = _bt_get_request_info(func_data->req_id);
209 if (req_info == NULL) {
210 BT_ERR("req_info == NULL");
217 BT_ERR("Audio Connect/Disconnect Dbus Call Error: %s\n", g_error->message);
219 result = BLUETOOTH_ERROR_INTERNAL;
221 /* Remove the device from the list */
222 _bt_remove_headset_from_list(func_data->type, func_data->address);
224 /* Error, check if any waiting device is there */
225 if (g_wait_data == NULL)
228 if (g_strcmp0(g_wait_data->address, func_data->address) != 0) {
229 bluetooth_device_address_t device_address;
230 _bt_convert_addr_string_to_type(device_address.addr,
231 g_wait_data->address);
232 _bt_audio_connect(g_wait_data->req_id, g_wait_data->type,
233 &device_address, g_wait_data->out_param1);
236 /* Event will be sent by the event reciever */
238 if (req_info->context == NULL) {
239 BT_DBG("req_info->context is NULL");
243 out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
244 func_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
246 g_dbus_method_invocation_return_value(req_info->context,
247 g_variant_new("(iv)", result, out_param1));
249 _bt_delete_request_list(req_info->req_id);
251 g_clear_error(&g_error);
254 g_free(func_data->address);
259 static void __bt_free_wait_data()
261 if (g_wait_data != NULL) {
262 g_free(g_wait_data->address);
268 static void __bt_remove_device_from_wait_list()
270 /* Before deleting the request update the UI */
271 GVariant *out_param_1 = NULL;
272 int result = BLUETOOTH_ERROR_INTERNAL;
273 request_info_t *req_info;
275 req_info = _bt_get_request_info(g_wait_data->req_id);
276 if (req_info == NULL) {
277 BT_ERR("req_info == NULL");
281 out_param_1 = g_variant_new_from_data((const GVariantType *)"ay",
282 g_wait_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
284 g_dbus_method_invocation_return_value(req_info->context,
285 g_variant_new("(iv)", result, out_param_1));
287 _bt_delete_request_list(g_wait_data->req_id);
290 static void __bt_set_headset_disconnection_type(const char *address)
292 bt_connected_headset_data_t *connected_device;
295 node = g_list_first(g_connected_list);
296 while (node != NULL) {
297 connected_device = node->data;
298 if (g_strcmp0(connected_device->device_address, address) == 0) {
299 g_wait_data->disconnection_type = connected_device->type;
302 node = g_list_next(node);
306 gboolean _bt_is_headset_type_connected(int type, char *address)
310 node = g_list_first(g_connected_list);
311 while (node != NULL) {
312 bt_connected_headset_data_t *connected_device = node->data;
314 if (connected_device->type & type) {
316 g_strlcpy(address, connected_device->device_address,
317 BT_ADDRESS_STRING_SIZE + 1);
321 node = g_list_next(node);
326 #ifdef TIZEN_SUPPORT_DUAL_HF
327 gboolean __bt_is_companion_device(const char *addr)
329 #ifdef TIZEN_WEARABLE
330 char *host_device_address = NULL;
331 host_device_address = vconf_get_str(VCONF_KEY_BT_HOST_BT_MAC_ADDR);
333 if (!host_device_address) {
334 BT_INFO("Failed to get a companion device address");
338 if (g_strcmp0(host_device_address, addr) == 0) {
339 BT_INFO("addr[%s] is companion device", addr);
345 /* TODO : Need to add companion device check condition for Phone models */
351 static int __bt_is_headset_connected(int type, int req_id,
352 const char *address, GArray **out_param1)
354 gboolean connected = FALSE;
355 char connected_address[BT_ADDRESS_STRING_SIZE + 1];
356 bluetooth_device_address_t device_address;
357 bt_connected_headset_data_t *connected_device = NULL;
358 #ifdef TIZEN_SUPPORT_DUAL_HF
359 gboolean is_companion_device = FALSE;
362 /* Check if any other headset is connected */
365 node = g_list_first(g_connected_list);
366 while (node != NULL) {
367 connected_device = node->data;
368 if ((connected_device->type & type) == type) {
369 g_strlcpy(connected_address, connected_device->device_address,
370 BT_ADDRESS_STRING_SIZE + 1);
371 #ifdef TIZEN_SUPPORT_DUAL_HF
372 is_companion_device = __bt_is_companion_device(connected_address);
373 BT_INFO(" is_companion_device[%d]", is_companion_device);
375 if (!is_companion_device) {
384 node = g_list_next(node);
388 return BLUETOOTH_ERROR_NOT_CONNECTED;
390 BT_DBG("connected headset %s", connected_address);
392 if (g_strcmp0(connected_address, address) == 0)
393 return BLUETOOTH_ERROR_ALREADY_CONNECT;
394 #ifdef TIZEN_SUPPORT_DUAL_HF
395 else if (TRUE == __bt_is_companion_device(address))
396 return BLUETOOTH_ERROR_NOT_CONNECTED;
399 /* If already one device is waiting, remove current waiting device and add new */
400 if (g_wait_data != NULL) {
401 if (g_strcmp0(g_wait_data->address, address) != 0) {
402 __bt_remove_device_from_wait_list();
403 __bt_free_wait_data();
407 if (g_wait_data == NULL) {
408 g_wait_data = g_malloc0(sizeof(bt_headset_wait_t));
409 g_wait_data->address = g_strdup(address);
410 g_wait_data->req_id = req_id;
411 g_wait_data->type = type;
412 g_wait_data->ag_flag = FALSE;
413 g_wait_data->out_param1 = out_param1;
415 /* Set disconnection type */
416 __bt_set_headset_disconnection_type(connected_address);
419 /* Convert BD adress from string type */
420 _bt_convert_addr_string_to_type(device_address.addr, connected_address);
421 _bt_audio_disconnect(0, connected_device->type & type, &device_address, NULL);
422 return BLUETOOTH_ERROR_NONE;
425 void _bt_set_audio_wait_data_flag(gboolean flag)
427 BT_DBG("_bt_set_audio_wait_data_flag \n");
428 g_wait_data->ag_flag = flag;
431 bt_headset_wait_t *_bt_get_audio_wait_data(void)
433 BT_DBG("_bt_get_audio_wait_data \n");
437 void _bt_rel_wait_data(void)
439 BT_DBG("_bt_rel_wait_data \n");
440 __bt_free_wait_data();
443 void _bt_add_headset_to_list(int type, int status, const char *address)
445 bt_connected_headset_data_t *connected_device;
446 bt_connected_headset_data_t *device;
449 BT_DBG("_bt_add_headset_to_list \n");
451 node = g_list_first(g_connected_list);
452 while (node != NULL) {
453 device = (bt_connected_headset_data_t *)node->data;
455 if (g_strcmp0(device->device_address, address) == 0) {
456 BT_DBG("Address match, update connection type \n");
457 if (status == BT_STATE_CONNECTED)
458 device->type |= type;
459 device->device_state = status;
462 node = g_list_next(node);
465 connected_device = g_malloc0(sizeof(bt_connected_headset_data_t));
466 /* Fix : NULL_RETURNS */
467 if (connected_device == NULL) {
468 BT_ERR("No memory allocated");
472 connected_device->device_state = status;
473 if (status == BT_STATE_CONNECTED)
474 connected_device->type |= type;
475 g_strlcpy(connected_device->device_address, address,
476 sizeof(connected_device->device_address));
477 g_connected_list = g_list_append(g_connected_list, connected_device);
480 int _bt_get_device_state_from_list(int type, const char *address)
483 bt_connected_headset_data_t *device;
486 node = g_list_first(g_connected_list);
487 while (node != NULL) {
488 device = (bt_connected_headset_data_t *)node->data;
489 if (g_strcmp0(device->device_address, address) == 0) {
490 BT_DBG("Device found");
491 return device->device_state;
493 node = g_list_next(node);
496 BT_DBG("Device not found");
497 return BLUETOOTH_ERROR_INTERNAL;
500 void _bt_remove_headset_from_list(int type, const char *address)
504 BT_DBG("_bt_remove_headset_from_list \n");
506 node = g_list_first(g_connected_list);
507 while (node != NULL) {
508 bt_connected_headset_data_t *connected_device = node->data;
510 if (g_strcmp0(connected_device->device_address, address) != 0) {
511 node = g_list_next(node);
515 BT_DBG("Address match \n");
517 BT_DBG("Connection type = %x\n", connected_device->type);
521 if (connected_device->type & BT_AUDIO_A2DP)
522 connected_device->type &= ~(BT_AUDIO_A2DP);
525 if (connected_device->type & BT_AUDIO_HSP)
526 connected_device->type &= ~(BT_AUDIO_HSP);
529 if (connected_device->type & BT_AUDIO_ALL)
530 connected_device->type &= ~(BT_AUDIO_ALL);
533 if (connected_device->type & BT_AVRCP)
534 connected_device->type &= ~(BT_AVRCP);
538 BT_DBG("Connection type = %x\n", connected_device->type);
540 if (connected_device->type == 0x00) {
541 g_connected_list = g_list_remove(g_connected_list, connected_device);
542 g_free(connected_device);
545 node = g_list_next(node);
549 static gboolean __bt_device_support_uuid(char *remote_address,
550 bt_audio_type_t type)
552 GArray *dev_list = NULL;
554 bluetooth_device_info_t info;
555 char bond_address[BT_ADDRESS_STRING_SIZE] = { 0 };
556 gboolean ret = FALSE;
560 dev_list = g_array_new (FALSE, FALSE, sizeof(gchar));
562 _bt_get_bonded_devices(&dev_list);
563 size = (dev_list->len) / sizeof(bluetooth_device_info_t);
565 for (i=0; i < size; i++) {
566 info = g_array_index(dev_list, bluetooth_device_info_t, i);
567 _bt_convert_addr_type_to_string(bond_address,
568 info.device_address.addr);
569 if (strcmp(bond_address, remote_address) != 0)
572 BT_INFO("Device address Matched");
574 while (j != info.service_index) {
575 if (type == BT_AUDIO_HSP) {
576 if (strcmp(info.uuids[j], HFP_HS_UUID) == 0) {
577 BT_INFO("HFP HS UUID exists");
581 } else if (type == BT_AUDIO_A2DP) {
582 if (strcmp(info.uuids[j], A2DP_SINK_UUID) == 0) {
583 BT_INFO("A2DP SINK UUID exists");
592 g_array_free(dev_list, TRUE);
597 gboolean _bt_is_service_connected(char* address, int type)
601 node = g_list_first(g_connected_list);
602 while (node != NULL) {
603 bt_connected_headset_data_t *conn_device = node->data;
605 if ((g_strcmp0(conn_device->device_address, address) == 0) &&
606 (conn_device->type & type)) {
607 BT_INFO("Service connected");
611 node = g_list_next(node);
613 BT_INFO("Service not connected");
617 int _bt_audio_connect(int request_id, int type,
618 bluetooth_device_address_t *device_address,
621 int result = BLUETOOTH_ERROR_NONE;
622 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
623 GDBusProxy *adapter_proxy;
624 GDBusConnection *g_conn;
627 int value = BLUETOOTH_ERROR_NONE;
628 bt_audio_function_data_t *func_data;
630 BT_CHECK_PARAMETER(device_address, return);
632 adapter_proxy = _bt_get_adapter_proxy();
633 retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
635 g_conn = _bt_get_system_gconn();
636 retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
638 _bt_convert_addr_type_to_string(address, device_address->addr);
640 func_data = g_malloc0(sizeof(bt_audio_function_data_t));
641 /* Fix : NULL_RETURNS */
642 if (func_data == NULL) {
643 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
647 func_data->address = g_strdup(address);
648 func_data->req_id = request_id;
649 func_data->type = type;
650 func_data->pending = BT_PENDING_NONE;
651 func_data->out_param = out_param1;
658 uuid = A2DP_SINK_UUID;
661 uuid = AVRCP_TARGET_UUID;
663 case BT_AUDIO_A2DP_SOURCE:
664 uuid = A2DP_SOURCE_UUID;
667 if (__bt_device_support_uuid(address, BT_AUDIO_HSP)) {
669 func_data->pending = BT_PENDING_CONNECT;
670 } else if (__bt_device_support_uuid(address, BT_AUDIO_A2DP)) {
671 uuid = A2DP_SINK_UUID;
673 BT_ERR("No audio role supported");
674 result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
679 BT_ERR("Unknown role");
680 result = BLUETOOTH_ERROR_INTERNAL;
683 BT_INFO("Connecting to service %s", uuid);
685 value = __bt_is_headset_connected(type, request_id, address, out_param1);
687 if (value == BLUETOOTH_ERROR_ALREADY_CONNECT) {
688 return BLUETOOTH_ERROR_ALREADY_CONNECT;
689 } else if (value == BLUETOOTH_ERROR_NOT_CONNECTED) {
690 _bt_headset_set_local_connection(TRUE);
691 ret = _bt_connect_profile(address, uuid,
692 __bt_audio_request_cb, func_data);
694 if (ret != BLUETOOTH_ERROR_NONE) {
695 BT_ERR("_bt_connect_profile Error");
696 _bt_headset_set_local_connection(FALSE);
697 g_free(func_data->address);
702 /* Add data to the connected list */
703 _bt_add_headset_to_list(type, BT_STATE_CONNECTING, address);
706 return BLUETOOTH_ERROR_NONE;
708 g_array_append_vals(*out_param1, address,
714 int _bt_audio_disconnect(int request_id, int type,
715 bluetooth_device_address_t *device_address,
718 int result = BLUETOOTH_ERROR_NONE;
719 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
720 bt_audio_function_data_t *func_data;
721 GDBusProxy *adapter_proxy;
722 GDBusConnection *g_conn;
727 BT_CHECK_PARAMETER(device_address, return);
729 adapter_proxy = _bt_get_adapter_proxy();
730 retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
732 g_conn = _bt_get_system_gconn();
733 retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
735 _bt_convert_addr_type_to_string(address, device_address->addr);
737 func_data = g_malloc0(sizeof(bt_audio_function_data_t));
739 func_data->address = g_strdup(address);
740 func_data->req_id = request_id;
741 func_data->pending = BT_PENDING_NONE;
742 func_data->out_param = out_param1;
743 func_data->type = type;
750 uuid = A2DP_SINK_UUID;
753 uuid = AVRCP_TARGET_UUID;
755 case BT_AUDIO_A2DP_SOURCE:
756 uuid = A2DP_SOURCE_UUID;
759 if (_bt_is_service_connected(address, BT_AUDIO_HSP)) {
761 func_data->pending = BT_PENDING_DISCONNECT;
762 } else if (_bt_is_service_connected(address, BT_AUDIO_A2DP)) {
763 uuid = A2DP_SINK_UUID;
765 BT_ERR("No audio service connected");
766 result = BLUETOOTH_ERROR_NOT_CONNECTED;
771 BT_ERR("Unknown role");
772 result = BLUETOOTH_ERROR_INTERNAL;
776 BT_INFO("Disconnecting service %s", uuid);
777 ret = _bt_disconnect_profile(address, uuid,
778 __bt_audio_request_cb, func_data);
780 if (ret != BLUETOOTH_ERROR_NONE) {
781 BT_ERR("_bt_disconnect_profile Error");
782 g_free(func_data->address);
788 * This logic is added for dual HF mode issue.
790 node = g_list_first(g_connected_list);
791 while (node != NULL) {
792 bt_connected_headset_data_t *connected_device = node->data;
794 if (g_strcmp0(connected_device->device_address, address) == 0) {
795 BT_DBG("Connection type update");
796 type = connected_device->type;
799 node = g_list_next(node);
801 _bt_add_headset_to_list(type, BT_STATE_DISCONNECTING, address);
803 return BLUETOOTH_ERROR_NONE;
805 if (out_param1 != NULL)
806 g_array_append_vals(*out_param1, address,
812 void _bt_remove_from_connected_list(const char *address)
814 bt_connected_headset_data_t *connected_device;
817 node = g_list_first(g_connected_list);
818 while (node != NULL) {
819 connected_device = node->data;
820 if (connected_device != NULL &&
821 g_strcmp0(connected_device->device_address, address) == 0) {
822 BT_ERR("Device is removed from the list");
823 g_connected_list = g_list_remove(g_connected_list, connected_device);
824 g_free(connected_device);
827 node = g_list_next(node);
831 int _bt_hf_connect(int request_id,
832 bluetooth_device_address_t *device_address,
835 int result = BLUETOOTH_ERROR_NONE;
836 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
837 bt_function_data_t *func_data;
838 GDBusProxy *adapter_proxy;
839 GDBusConnection *g_conn;
843 BT_CHECK_PARAMETER(device_address, return);
845 _bt_convert_addr_type_to_string(address, device_address->addr);
847 adapter_proxy = _bt_get_adapter_proxy();
848 if (adapter_proxy == NULL) {
849 result = BLUETOOTH_ERROR_INTERNAL;
853 g_conn = _bt_get_system_gconn();
854 if (g_conn == NULL) {
855 result = BLUETOOTH_ERROR_INTERNAL;
859 func_data = g_malloc0(sizeof(bt_function_data_t));
860 /* Fix : NULL_RETURNS */
861 if (func_data == NULL) {
862 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
866 func_data->address = g_strdup(address);
867 func_data->req_id = request_id;
868 uuid = g_strdup(HFP_AG_UUID);
870 BT_DBG("Connecting to service %s", uuid);
872 ret = _bt_connect_profile(address, uuid,
873 __bt_hf_request_cb, func_data);
875 if (ret != BLUETOOTH_ERROR_NONE) {
876 BT_ERR("_bt_connect_profile Error");
877 g_free(func_data->address);
883 return BLUETOOTH_ERROR_NONE;
885 if (out_param1 != NULL)
886 g_array_append_vals(*out_param1, address,
892 int _bt_hf_disconnect(int request_id,
893 bluetooth_device_address_t *device_address,
896 int result = BLUETOOTH_ERROR_NONE;
897 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
898 bt_function_data_t *func_data;
899 GDBusProxy *adapter_proxy;
900 GDBusConnection *g_conn;
905 BT_CHECK_PARAMETER(device_address, return);
907 _bt_convert_addr_type_to_string(address, device_address->addr);
909 adapter_proxy = _bt_get_adapter_proxy();
910 if (adapter_proxy == NULL) {
911 result = BLUETOOTH_ERROR_INTERNAL;
915 g_conn = _bt_get_system_gconn();
916 if (g_conn == NULL) {
917 result = BLUETOOTH_ERROR_INTERNAL;
921 func_data = g_malloc0(sizeof(bt_function_data_t));
922 /* Fix : NULL_RETURNS */
923 if (func_data == NULL) {
924 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
928 func_data->address = g_strdup(address);
929 func_data->req_id = request_id;
930 uuid = g_strdup(HFP_AG_UUID);
932 BT_DBG("Disconnecting service %s", uuid);
933 ret = _bt_disconnect_profile(address, uuid,
934 __bt_hf_request_cb, func_data);
936 if (ret != BLUETOOTH_ERROR_NONE) {
937 BT_ERR("_bt_disconnect_profile Error");
938 g_free(func_data->address);
944 return BLUETOOTH_ERROR_NONE;
946 if (out_param1 != NULL)
947 g_array_append_vals(*out_param1, address,
953 int _bt_audio_set_content_protect(gboolean status)
955 GDBusConnection *conn;
956 GError *error = NULL;
960 conn = _bt_get_system_gconn();
961 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
963 BT_DBG("Content Protection status = [%d]", status);
965 g_dbus_connection_emit_signal(conn,
966 NULL, BT_CONTENT_PROTECTION_PATH,
967 BT_CONTENT_PROTECTION_INTERFACE,
968 "ProtectionRequired",
969 g_variant_new("(b)", status),
973 /* dBUS gives error cause */
974 ERR("Could not Emit Signal: errCode[%x], message[%s]",
975 error->code, error->message);
976 g_clear_error(&error);
977 return BLUETOOTH_ERROR_INTERNAL;
980 BT_DBG("Emit Signal done = [ProtectionRequired]");
981 return BLUETOOTH_ERROR_NONE;