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 #include <syspopup_caller.h>
30 #include "bluetooth-api.h"
31 #include "bt-internal-types.h"
33 #include "bt-service-audio.h"
34 #include "bt-service-adapter.h"
35 #include "bt-service-common.h"
36 #include "bt-service-device.h"
37 #include "bt-service-event.h"
38 #include "bt-service-util.h"
40 #include "bt-service-headset-connection.h"
42 #ifdef TIZEN_SUPPORT_DUAL_HF
44 #define VCONF_KEY_BT_HOST_BT_MAC_ADDR "db/wms/host_bt_mac"
51 char device_address[BT_ADDRESS_STRING_SIZE + 1];
52 } bt_connected_headset_data_t;
54 static GList *g_connected_list;
56 static bt_headset_wait_t *g_wait_data;
58 static bt_audio_function_data_t *pdata;
60 static void __bt_remove_device_from_wait_list();
62 static void __bt_free_wait_data();
64 static gboolean __bt_device_support_uuid(char *remote_address,
65 bt_audio_type_t type);
67 static void __bt_hf_request_cb(GDBusProxy *proxy, GAsyncResult *res,
70 GError *g_error = NULL;
71 GVariant *out_param1 = NULL;
72 GVariant *reply = NULL;
73 int result = BLUETOOTH_ERROR_NONE;
74 bt_function_data_t *func_data;
75 request_info_t *req_info;
77 reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
78 g_object_unref(proxy);
80 func_data = user_data;
82 if (func_data == NULL) {
84 BT_ERR("func_data == NULL");
88 req_info = _bt_get_request_info(func_data->req_id);
89 if (req_info == NULL) {
90 BT_ERR("req_info == NULL");
95 BT_ERR("HF Connect Dbus Call Error");
97 BT_ERR("Error: %s\n", g_error->message);
98 g_clear_error(&g_error);
100 result = BLUETOOTH_ERROR_INTERNAL;
102 g_variant_unref(reply);
105 if (req_info->context == NULL)
108 out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
109 func_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
111 g_dbus_method_invocation_return_value(req_info->context,
112 g_variant_new("(iv)", result, out_param1));
114 _bt_delete_request_list(req_info->req_id);
118 g_free(func_data->address);
123 void _bt_audio_check_pending_connect()
126 bluetooth_device_address_t device_address;
131 if (pdata->pending == BT_PENDING_CONNECT) {
133 _bt_convert_addr_string_to_type(device_address.addr,
135 _bt_audio_connect(pdata->req_id,
140 g_free(pdata->address);
149 static void __bt_audio_request_cb(GDBusProxy *proxy, GAsyncResult *res,
152 GError *g_error = NULL;
153 GVariant *out_param1 = NULL;
154 GVariant *reply = NULL;
155 int result = BLUETOOTH_ERROR_NONE;
156 bt_audio_function_data_t *func_data;
157 request_info_t *req_info;
159 reply = g_dbus_proxy_call_finish(proxy, res, &g_error);
160 g_object_unref(proxy);
161 g_variant_unref(reply);
163 func_data = user_data;
165 if (func_data == NULL) {
167 BT_ERR("func_data == NULL");
171 if (func_data->pending != BT_PENDING_NONE && g_error == NULL) {
173 bluetooth_device_address_t device_address;
174 _bt_convert_addr_string_to_type(device_address.addr,
177 if (func_data->pending == BT_PENDING_CONNECT) {
179 if (__bt_device_support_uuid(func_data->address,
182 pdata = g_new0(bt_audio_function_data_t, 1);
183 pdata->req_id = func_data->req_id;
184 pdata->out_param = func_data->out_param;
185 pdata->address = strdup(func_data->address);
186 pdata->pending = func_data->pending;
192 if (_bt_is_service_connected(func_data->address
194 _bt_audio_disconnect(func_data->req_id,
197 func_data->out_param);
206 req_info = _bt_get_request_info(func_data->req_id);
207 if (req_info == NULL) {
208 BT_ERR("req_info == NULL");
215 BT_ERR("Audio Connect/Disconnect Dbus Call Error: %s\n", g_error->message);
217 result = BLUETOOTH_ERROR_INTERNAL;
219 /* Remove the device from the list */
220 _bt_remove_headset_from_list(func_data->type, func_data->address);
222 /* Error, check if any waiting device is there */
223 if (g_wait_data == NULL)
226 if (g_strcmp0(g_wait_data->address, func_data->address) != 0) {
227 bluetooth_device_address_t device_address;
228 _bt_convert_addr_string_to_type(device_address.addr,
229 g_wait_data->address);
230 _bt_audio_connect(g_wait_data->req_id, g_wait_data->type,
231 &device_address, g_wait_data->out_param1);
234 /* Event will be sent by the event reciever */
236 if (req_info->context == NULL) {
237 BT_DBG("req_info->context is NULL");
241 out_param1 = g_variant_new_from_data((const GVariantType *)"ay",
242 func_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
244 g_dbus_method_invocation_return_value(req_info->context,
245 g_variant_new("(iv)", result, out_param1));
247 _bt_delete_request_list(req_info->req_id);
249 g_clear_error(&g_error);
252 g_free(func_data->address);
257 static void __bt_free_wait_data()
259 if (g_wait_data != NULL) {
260 g_free(g_wait_data->address);
266 static void __bt_remove_device_from_wait_list()
268 /* Before deleting the request update the UI */
269 GVariant *out_param_1 = NULL;
270 int result = BLUETOOTH_ERROR_INTERNAL;
271 request_info_t *req_info;
273 req_info = _bt_get_request_info(g_wait_data->req_id);
274 if (req_info == NULL) {
275 BT_ERR("req_info == NULL");
279 out_param_1 = g_variant_new_from_data((const GVariantType *)"ay",
280 g_wait_data->address, BT_ADDRESS_STR_LEN, TRUE, NULL, NULL);
282 g_dbus_method_invocation_return_value(req_info->context,
283 g_variant_new("(iv)", result, out_param_1));
285 _bt_delete_request_list(g_wait_data->req_id);
288 static void __bt_set_headset_disconnection_type(const char *address)
290 bt_connected_headset_data_t *connected_device;
293 node = g_list_first(g_connected_list);
294 while (node != NULL) {
295 connected_device = node->data;
296 if (g_strcmp0(connected_device->device_address, address) == 0) {
297 g_wait_data->disconnection_type = connected_device->type;
300 node = g_list_next(node);
304 gboolean _bt_is_headset_type_connected(int type, char *address)
308 node = g_list_first(g_connected_list);
309 while (node != NULL) {
310 bt_connected_headset_data_t *connected_device = node->data;
312 if (connected_device->type & type) {
314 g_strlcpy(address, connected_device->device_address,
315 BT_ADDRESS_STRING_SIZE + 1);
319 node = g_list_next(node);
324 #ifdef TIZEN_SUPPORT_DUAL_HF
325 gboolean __bt_is_companion_device(const char *addr)
327 #ifdef TIZEN_WEARABLE
328 char *host_device_address = NULL;
329 host_device_address = vconf_get_str(VCONF_KEY_BT_HOST_BT_MAC_ADDR);
331 if (!host_device_address) {
332 BT_INFO("Failed to get a companion device address");
336 if (g_strcmp0(host_device_address, addr) == 0) {
337 BT_INFO("addr[%s] is companion device", addr);
343 /* TODO : Need to add companion device check condition for Phone models */
349 static int __bt_is_headset_connected(int type, int req_id,
350 const char *address, GArray **out_param1)
352 gboolean connected = FALSE;
353 char connected_address[BT_ADDRESS_STRING_SIZE + 1];
354 bluetooth_device_address_t device_address;
355 bt_connected_headset_data_t *connected_device = NULL;
356 #ifdef TIZEN_SUPPORT_DUAL_HF
357 gboolean is_companion_device = FALSE;
360 /* Check if any other headset is connected */
363 node = g_list_first(g_connected_list);
364 while (node != NULL) {
365 connected_device = node->data;
366 if ((connected_device->type & type) == type) {
367 g_strlcpy(connected_address, connected_device->device_address,
368 BT_ADDRESS_STRING_SIZE + 1);
369 #ifdef TIZEN_SUPPORT_DUAL_HF
370 is_companion_device = __bt_is_companion_device(connected_address);
371 BT_INFO(" is_companion_device[%d]", is_companion_device);
373 if (!is_companion_device) {
382 node = g_list_next(node);
386 return BLUETOOTH_ERROR_NOT_CONNECTED;
388 BT_DBG("connected headset %s", connected_address);
390 if (g_strcmp0(connected_address, address) == 0)
391 return BLUETOOTH_ERROR_ALREADY_CONNECT;
392 #ifdef TIZEN_SUPPORT_DUAL_HF
393 else if (TRUE == __bt_is_companion_device(address))
394 return BLUETOOTH_ERROR_NOT_CONNECTED;
397 /* If already one device is waiting, remove current waiting device and add new */
398 if (g_wait_data != NULL) {
399 if (g_strcmp0(g_wait_data->address, address) != 0) {
400 __bt_remove_device_from_wait_list();
401 __bt_free_wait_data();
405 if (g_wait_data == NULL) {
406 g_wait_data = g_malloc0(sizeof(bt_headset_wait_t));
407 g_wait_data->address = g_strdup(address);
408 g_wait_data->req_id = req_id;
409 g_wait_data->type = type;
410 g_wait_data->ag_flag = FALSE;
411 g_wait_data->out_param1 = out_param1;
413 /* Set disconnection type */
414 __bt_set_headset_disconnection_type(connected_address);
417 /* Convert BD adress from string type */
418 _bt_convert_addr_string_to_type(device_address.addr, connected_address);
419 _bt_audio_disconnect(0, connected_device->type & type, &device_address, NULL);
420 return BLUETOOTH_ERROR_NONE;
423 void _bt_set_audio_wait_data_flag(gboolean flag)
425 BT_DBG("_bt_set_audio_wait_data_flag \n");
426 g_wait_data->ag_flag = flag;
429 bt_headset_wait_t *_bt_get_audio_wait_data(void)
431 BT_DBG("_bt_get_audio_wait_data \n");
435 void _bt_rel_wait_data(void)
437 BT_DBG("_bt_rel_wait_data \n");
438 __bt_free_wait_data();
441 void _bt_add_headset_to_list(int type, int status, const char *address)
443 bt_connected_headset_data_t *connected_device;
444 bt_connected_headset_data_t *device;
447 BT_DBG("_bt_add_headset_to_list \n");
449 node = g_list_first(g_connected_list);
450 while (node != NULL) {
451 device = (bt_connected_headset_data_t *)node->data;
453 if (g_strcmp0(device->device_address, address) == 0) {
454 BT_DBG("Address match, update connection type \n");
455 if (status == BT_STATE_CONNECTED)
456 device->type |= type;
457 device->device_state = status;
460 node = g_list_next(node);
463 connected_device = g_malloc0(sizeof(bt_connected_headset_data_t));
464 /* Fix : NULL_RETURNS */
465 if (connected_device == NULL) {
466 BT_ERR("No memory allocated");
470 connected_device->device_state = status;
471 if (status == BT_STATE_CONNECTED)
472 connected_device->type |= type;
473 g_strlcpy(connected_device->device_address, address,
474 sizeof(connected_device->device_address));
475 g_connected_list = g_list_append(g_connected_list, connected_device);
478 int _bt_get_device_state_from_list(int type, const char *address)
481 bt_connected_headset_data_t *device;
484 node = g_list_first(g_connected_list);
485 while (node != NULL) {
486 device = (bt_connected_headset_data_t *)node->data;
487 if (g_strcmp0(device->device_address, address) == 0) {
488 BT_DBG("Device found");
489 return device->device_state;
491 node = g_list_next(node);
494 BT_DBG("Device not found");
495 return BLUETOOTH_ERROR_INTERNAL;
498 void _bt_remove_headset_from_list(int type, const char *address)
502 BT_DBG("_bt_remove_headset_from_list \n");
504 node = g_list_first(g_connected_list);
505 while (node != NULL) {
506 bt_connected_headset_data_t *connected_device = node->data;
508 if (g_strcmp0(connected_device->device_address, address) != 0) {
509 node = g_list_next(node);
513 BT_DBG("Address match \n");
515 BT_DBG("Connection type = %x\n", connected_device->type);
519 if (connected_device->type & BT_AUDIO_A2DP)
520 connected_device->type &= ~(BT_AUDIO_A2DP);
523 if (connected_device->type & BT_AUDIO_HSP)
524 connected_device->type &= ~(BT_AUDIO_HSP);
527 if (connected_device->type & BT_AUDIO_ALL)
528 connected_device->type &= ~(BT_AUDIO_ALL);
531 if (connected_device->type & BT_AVRCP)
532 connected_device->type &= ~(BT_AVRCP);
536 BT_DBG("Connection type = %x\n", connected_device->type);
538 if (connected_device->type == 0x00) {
539 g_connected_list = g_list_remove(g_connected_list, connected_device);
540 g_free(connected_device);
543 node = g_list_next(node);
547 static gboolean __bt_device_support_uuid(char *remote_address,
548 bt_audio_type_t type)
550 GArray *dev_list = NULL;
552 bluetooth_device_info_t info;
553 char bond_address[BT_ADDRESS_STRING_SIZE] = { 0 };
554 gboolean ret = FALSE;
558 dev_list = g_array_new (FALSE, FALSE, sizeof(gchar));
560 _bt_get_bonded_devices(&dev_list);
561 size = (dev_list->len) / sizeof(bluetooth_device_info_t);
563 for (i=0; i < size; i++) {
564 info = g_array_index(dev_list, bluetooth_device_info_t, i);
565 _bt_convert_addr_type_to_string(bond_address,
566 info.device_address.addr);
567 if (strcmp(bond_address, remote_address) != 0)
570 BT_INFO("Device address Matched");
572 while (j != info.service_index) {
573 if (type == BT_AUDIO_HSP) {
574 if (strcmp(info.uuids[j], HFP_HS_UUID) == 0) {
575 BT_INFO("HFP HS UUID exists");
579 } else if (type == BT_AUDIO_A2DP) {
580 if (strcmp(info.uuids[j], A2DP_SINK_UUID) == 0) {
581 BT_INFO("A2DP SINK UUID exists");
590 g_array_free(dev_list, TRUE);
595 gboolean _bt_is_service_connected(char* address, int type)
599 node = g_list_first(g_connected_list);
600 while (node != NULL) {
601 bt_connected_headset_data_t *conn_device = node->data;
603 if ((g_strcmp0(conn_device->device_address, address) == 0) &&
604 (conn_device->type & type)) {
605 BT_INFO("Service connected");
609 node = g_list_next(node);
611 BT_INFO("Service not connected");
615 int _bt_audio_connect(int request_id, int type,
616 bluetooth_device_address_t *device_address,
619 int result = BLUETOOTH_ERROR_NONE;
620 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
621 GDBusProxy *adapter_proxy;
622 GDBusConnection *g_conn;
625 int value = BLUETOOTH_ERROR_NONE;
626 bt_audio_function_data_t *func_data;
628 BT_CHECK_PARAMETER(device_address, return);
630 adapter_proxy = _bt_get_adapter_proxy();
631 retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
633 g_conn = _bt_get_system_gconn();
634 retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
636 _bt_convert_addr_type_to_string(address, device_address->addr);
638 func_data = g_malloc0(sizeof(bt_audio_function_data_t));
639 /* Fix : NULL_RETURNS */
640 if (func_data == NULL) {
641 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
645 func_data->address = g_strdup(address);
646 func_data->req_id = request_id;
647 func_data->type = type;
648 func_data->pending = BT_PENDING_NONE;
649 func_data->out_param = out_param1;
656 uuid = A2DP_SINK_UUID;
659 uuid = AVRCP_TARGET_UUID;
661 case BT_AUDIO_A2DP_SOURCE:
662 uuid = A2DP_SOURCE_UUID;
665 if (__bt_device_support_uuid(address, BT_AUDIO_HSP)) {
667 func_data->pending = BT_PENDING_CONNECT;
668 } else if (__bt_device_support_uuid(address, BT_AUDIO_A2DP)) {
669 uuid = A2DP_SINK_UUID;
671 BT_ERR("No audio role supported");
672 result = BLUETOOTH_ERROR_SERVICE_NOT_FOUND;
677 BT_ERR("Unknown role");
678 result = BLUETOOTH_ERROR_INTERNAL;
681 BT_INFO("Connecting to service %s", uuid);
683 value = __bt_is_headset_connected(type, request_id, address, out_param1);
685 if (value == BLUETOOTH_ERROR_ALREADY_CONNECT) {
686 return BLUETOOTH_ERROR_ALREADY_CONNECT;
687 } else if (value == BLUETOOTH_ERROR_NOT_CONNECTED) {
688 _bt_headset_set_local_connection(TRUE);
689 ret = _bt_connect_profile(address, uuid,
690 __bt_audio_request_cb, func_data);
692 if (ret != BLUETOOTH_ERROR_NONE) {
693 BT_ERR("_bt_connect_profile Error");
694 _bt_headset_set_local_connection(FALSE);
695 g_free(func_data->address);
700 /* Add data to the connected list */
701 _bt_add_headset_to_list(type, BT_STATE_CONNECTING, address);
704 return BLUETOOTH_ERROR_NONE;
706 g_array_append_vals(*out_param1, address,
712 int _bt_audio_disconnect(int request_id, int type,
713 bluetooth_device_address_t *device_address,
716 int result = BLUETOOTH_ERROR_NONE;
717 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
718 bt_audio_function_data_t *func_data;
719 GDBusProxy *adapter_proxy;
720 GDBusConnection *g_conn;
725 BT_CHECK_PARAMETER(device_address, return);
727 adapter_proxy = _bt_get_adapter_proxy();
728 retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
730 g_conn = _bt_get_system_gconn();
731 retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
733 _bt_convert_addr_type_to_string(address, device_address->addr);
735 func_data = g_malloc0(sizeof(bt_audio_function_data_t));
737 func_data->address = g_strdup(address);
738 func_data->req_id = request_id;
739 func_data->pending = BT_PENDING_NONE;
740 func_data->out_param = out_param1;
741 func_data->type = type;
748 uuid = A2DP_SINK_UUID;
751 uuid = AVRCP_TARGET_UUID;
753 case BT_AUDIO_A2DP_SOURCE:
754 uuid = A2DP_SOURCE_UUID;
757 if (_bt_is_service_connected(address, BT_AUDIO_HSP)) {
759 func_data->pending = BT_PENDING_DISCONNECT;
760 } else if (_bt_is_service_connected(address, BT_AUDIO_A2DP)) {
761 uuid = A2DP_SINK_UUID;
763 BT_ERR("No audio service connected");
764 result = BLUETOOTH_ERROR_NOT_CONNECTED;
769 BT_ERR("Unknown role");
770 result = BLUETOOTH_ERROR_INTERNAL;
774 BT_INFO("Disconnecting service %s", uuid);
775 ret = _bt_disconnect_profile(address, uuid,
776 __bt_audio_request_cb, func_data);
778 if (ret != BLUETOOTH_ERROR_NONE) {
779 BT_ERR("_bt_disconnect_profile Error");
780 g_free(func_data->address);
786 * This logic is added for dual HF mode issue.
788 node = g_list_first(g_connected_list);
789 while (node != NULL) {
790 bt_connected_headset_data_t *connected_device = node->data;
792 if (g_strcmp0(connected_device->device_address, address) == 0) {
793 BT_DBG("Connection type update");
794 type = connected_device->type;
797 node = g_list_next(node);
799 _bt_add_headset_to_list(type, BT_STATE_DISCONNECTING, address);
801 return BLUETOOTH_ERROR_NONE;
803 if (out_param1 != NULL)
804 g_array_append_vals(*out_param1, address,
810 void _bt_remove_from_connected_list(const char *address)
812 bt_connected_headset_data_t *connected_device;
815 node = g_list_first(g_connected_list);
816 while (node != NULL) {
817 connected_device = node->data;
818 if (connected_device != NULL &&
819 g_strcmp0(connected_device->device_address, address) == 0) {
820 BT_ERR("Device is removed from the list");
821 g_connected_list = g_list_remove(g_connected_list, connected_device);
822 g_free(connected_device);
825 node = g_list_next(node);
829 int _bt_hf_connect(int request_id,
830 bluetooth_device_address_t *device_address,
833 int result = BLUETOOTH_ERROR_NONE;
834 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
835 bt_function_data_t *func_data;
836 GDBusProxy *adapter_proxy;
837 GDBusConnection *g_conn;
841 BT_CHECK_PARAMETER(device_address, return);
843 _bt_convert_addr_type_to_string(address, device_address->addr);
845 adapter_proxy = _bt_get_adapter_proxy();
846 if (adapter_proxy == NULL) {
847 result = BLUETOOTH_ERROR_INTERNAL;
851 g_conn = _bt_get_system_gconn();
852 if (g_conn == NULL) {
853 result = BLUETOOTH_ERROR_INTERNAL;
857 func_data = g_malloc0(sizeof(bt_function_data_t));
858 /* Fix : NULL_RETURNS */
859 if (func_data == NULL) {
860 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
864 func_data->address = g_strdup(address);
865 func_data->req_id = request_id;
866 uuid = g_strdup(HFP_AG_UUID);
868 BT_DBG("Connecting to service %s", uuid);
870 ret = _bt_connect_profile(address, uuid,
871 __bt_hf_request_cb, func_data);
873 if (ret != BLUETOOTH_ERROR_NONE) {
874 BT_ERR("_bt_connect_profile Error");
875 g_free(func_data->address);
881 return BLUETOOTH_ERROR_NONE;
883 if (out_param1 != NULL)
884 g_array_append_vals(*out_param1, address,
890 int _bt_hf_disconnect(int request_id,
891 bluetooth_device_address_t *device_address,
894 int result = BLUETOOTH_ERROR_NONE;
895 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
896 bt_function_data_t *func_data;
897 GDBusProxy *adapter_proxy;
898 GDBusConnection *g_conn;
903 BT_CHECK_PARAMETER(device_address, return);
905 _bt_convert_addr_type_to_string(address, device_address->addr);
907 adapter_proxy = _bt_get_adapter_proxy();
908 if (adapter_proxy == NULL) {
909 result = BLUETOOTH_ERROR_INTERNAL;
913 g_conn = _bt_get_system_gconn();
914 if (g_conn == NULL) {
915 result = BLUETOOTH_ERROR_INTERNAL;
919 func_data = g_malloc0(sizeof(bt_function_data_t));
920 /* Fix : NULL_RETURNS */
921 if (func_data == NULL) {
922 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
926 func_data->address = g_strdup(address);
927 func_data->req_id = request_id;
928 uuid = g_strdup(HFP_AG_UUID);
930 BT_DBG("Disconnecting service %s", uuid);
931 ret = _bt_disconnect_profile(address, uuid,
932 __bt_hf_request_cb, func_data);
934 if (ret != BLUETOOTH_ERROR_NONE) {
935 BT_ERR("_bt_disconnect_profile Error");
936 g_free(func_data->address);
942 return BLUETOOTH_ERROR_NONE;
944 if (out_param1 != NULL)
945 g_array_append_vals(*out_param1, address,
951 int _bt_audio_set_content_protect(gboolean status)
953 GDBusConnection *conn;
954 GError *error = NULL;
958 conn = _bt_get_system_gconn();
959 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
961 BT_DBG("Content Protection status = [%d]", status);
963 g_dbus_connection_emit_signal(conn,
964 NULL, BT_CONTENT_PROTECTION_PATH,
965 BT_CONTENT_PROTECTION_INTERFACE,
966 "ProtectionRequired",
967 g_variant_new("(b)", status),
971 /* dBUS gives error cause */
972 ERR("Could not Emit Signal: errCode[%x], message[%s]",
973 error->code, error->message);
974 g_clear_error(&error);
975 return BLUETOOTH_ERROR_INTERNAL;
978 BT_DBG("Emit Signal done = [ProtectionRequired]");
979 return BLUETOOTH_ERROR_NONE;