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.
24 #if !defined(LIBNOTIFY_SUPPORT) && !defined(LIBNOTIFICATION_SUPPORT)
25 #include <syspopup_caller.h>
28 #include <dbus/dbus-glib.h>
29 #include <dbus/dbus.h>
31 #include <eventsystem.h>
32 #include <bundle_internal.h>
35 #include "bluetooth-api.h"
36 #include "bt-internal-types.h"
37 #include "bt-service-common.h"
38 #include "bt-service-event.h"
39 #include "bt-service-adapter.h"
40 #include "bt-service-util.h"
41 #include "bt-service-network.h"
42 #include "bt-service-obex-server.h"
43 #include "bt-service-agent.h"
44 #include "bt-service-main.h"
45 #include "bt-service-avrcp.h"
46 #include "bt-service-device.h"
47 #ifdef TIZEN_DPM_ENABLE
48 #include "bt-service-dpm.h"
59 bt_adapter_timer_t visible_timer = {0, };
61 static gboolean is_discovering;
62 static gboolean cancel_by_user;
63 static bt_status_t adapter_status = BT_DEACTIVATED;
64 static bt_le_status_t adapter_le_status = BT_LE_DEACTIVATED;
65 static void *adapter_agent = NULL;
66 static GDBusProxy *core_proxy = NULL;
67 static guint timer_id = 0;
68 static guint le_timer_id = 0;
70 static uint status_reg_id;
72 #define BT_CORE_NAME "org.projectx.bt_core"
73 #define BT_CORE_PATH "/org/projectx/bt_core"
74 #define BT_CORE_INTERFACE "org.projectx.btcore"
76 #define BT_DISABLE_TIME 500 /* 500 ms */
78 GDBusProxy *_bt_init_core_proxy(void)
81 GDBusConnection *conn;
83 conn = _bt_get_system_gconn();
87 proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
102 static GDBusProxy *__bt_get_core_proxy(void)
104 return (core_proxy) ? core_proxy : _bt_init_core_proxy();
107 static gboolean __bt_is_factory_test_mode(void)
111 #ifdef ENABLE_TIZEN_2_4
112 if (vconf_get_bool(VCONFKEY_BT_DUT_MODE, &mode)) {
113 BT_ERR("Get the DUT Mode fail");
119 BT_INFO("DUT Test Mode !!");
126 static gboolean __bt_timeout_handler(gpointer user_data)
128 int result = BLUETOOTH_ERROR_NONE;
132 /* Take current time */
134 time_diff = difftime(current_time, visible_timer.start_time);
136 /* Send event to application */
137 _bt_send_event(BT_ADAPTER_EVENT,
138 BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED,
139 g_variant_new("(in)", result, time_diff));
141 if (visible_timer.timeout <= time_diff) {
142 g_source_remove(visible_timer.event_id);
143 visible_timer.event_id = 0;
144 visible_timer.timeout = 0;
146 #ifndef TIZEN_WEARABLE
147 if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
148 BT_ERR("Set vconf failed\n");
156 static int __bt_visibility_alarm_cb(alarm_id_t alarm_id, void* user_param)
158 BT_DBG("__bt_visibility_alarm_cb - alram id = [%d] \n", alarm_id);
160 int result = BLUETOOTH_ERROR_NONE;
163 if (alarm_id != visible_timer.alarm_id)
166 if (visible_timer.event_id) {
167 _bt_send_event(BT_ADAPTER_EVENT,
168 BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED,
169 g_variant_new("(in)", result, timeout));
170 g_source_remove(visible_timer.event_id);
171 visible_timer.event_id = 0;
172 visible_timer.timeout = 0;
174 #ifndef TIZEN_WEARABLE
175 if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
176 BT_ERR("Set vconf failed\n");
179 /* Switch Off visibility in Bluez */
180 _bt_set_discoverable_mode(BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE, 0);
181 visible_timer.alarm_id = 0;
185 static void __bt_visibility_alarm_create()
190 result = alarmmgr_add_alarm(ALARM_TYPE_VOLATILE, visible_timer.timeout,
193 BT_ERR("Failed to create alarm error = %d\n", result);
195 BT_DBG("Alarm created = %d\n", alarm_id);
196 visible_timer.alarm_id = alarm_id;
200 static void __bt_visibility_alarm_remove()
202 if (visible_timer.event_id > 0) {
203 g_source_remove(visible_timer.event_id);
204 visible_timer.event_id = 0;
207 if (visible_timer.alarm_id > 0) {
208 alarmmgr_remove_alarm(visible_timer.alarm_id);
209 visible_timer.alarm_id = 0;
213 int __bt_set_visible_time(int timeout)
217 __bt_visibility_alarm_remove();
219 visible_timer.timeout = timeout;
221 #ifndef TIZEN_WEARABLE
222 #ifdef TIZEN_DPM_ENABLE
223 if (_bt_dpm_get_bluetooth_limited_discoverable_state() != DPM_RESTRICTED) {
225 if (vconf_set_int(BT_FILE_VISIBLE_TIME, timeout) != 0)
226 BT_ERR("Set vconf failed");
227 #ifdef TIZEN_DPM_ENABLE
233 return BLUETOOTH_ERROR_NONE;
235 if (!visible_timer.alarm_init) {
236 /* Set Alarm timer to switch off BT */
237 result = alarmmgr_init("bt-service");
239 return BLUETOOTH_ERROR_INTERNAL;
241 visible_timer.alarm_init = TRUE;
244 result = alarmmgr_set_cb(__bt_visibility_alarm_cb, NULL);
246 return BLUETOOTH_ERROR_INTERNAL;
248 /* Take start time */
249 time(&(visible_timer.start_time));
250 visible_timer.event_id = g_timeout_add_seconds(1,
251 __bt_timeout_handler, NULL);
253 __bt_visibility_alarm_create();
255 return BLUETOOTH_ERROR_NONE;
258 static void __bt_get_service_list(GVariant *value, bluetooth_device_info_t *dev)
265 ret_if(value == NULL);
268 dev->service_index = 0;
270 g_variant_get(value, "as", &iter);
271 while (g_variant_iter_loop(iter, "s", &uuid)) {
272 g_strlcpy(dev->uuids[i], uuid, BLUETOOTH_UUID_STRING_MAX);
273 parts = g_strsplit(uuid, "-", -1);
275 if (parts == NULL || parts[0] == NULL) {
280 dev->service_list_array[i] = g_ascii_strtoull(parts[0], NULL, 16);
283 dev->service_index++;
286 g_variant_iter_free(iter);
289 static int __bt_get_bonded_device_info(gchar *device_path,
290 bluetooth_device_info_t *dev_info)
292 GError *error = NULL;
293 GDBusProxy *device_proxy;
294 const gchar *address = NULL;
295 const gchar *name = NULL;
296 unsigned int cod = 0;
298 gboolean trust = FALSE;
299 gboolean paired = FALSE;
300 guchar connected = 0;
301 GByteArray *manufacturer_data = NULL;
303 GDBusConnection *conn;
305 GVariantIter *property_iter;
309 GVariantIter *char_value_iter;
311 BT_CHECK_PARAMETER(device_path, return);
312 BT_CHECK_PARAMETER(dev_info, return);
314 conn = _bt_get_system_gconn();
315 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
317 device_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
321 BT_PROPERTIES_INTERFACE,
324 retv_if(device_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
326 result = g_dbus_proxy_call_sync(device_proxy,
328 g_variant_new("(s)", BT_DEVICE_INTERFACE),
329 G_DBUS_CALL_FLAGS_NONE,
335 BT_ERR("Error occured in Proxy call");
337 BT_ERR("Error occured in Proxy call (Error: %s)", error->message);
338 g_clear_error(&error);
340 g_object_unref(device_proxy);
341 return BLUETOOTH_ERROR_INTERNAL;
344 g_object_unref(device_proxy);
346 g_variant_get(result, "(a{sv})", &property_iter);
348 while (g_variant_iter_loop(property_iter, "{sv}", &key, &value)) {
349 if (!g_strcmp0(key,"Paired")) {
350 paired = g_variant_get_boolean(value);
351 } else if(!g_strcmp0(key, "Address")) {
352 address = g_variant_get_string(value, NULL);
353 } else if (!g_strcmp0(key, "Alias")) {
354 name = g_variant_get_string(value, NULL);
355 } else if (!g_strcmp0(key, "Name")) {
357 name = g_variant_get_string(value, NULL);
358 } else if (!g_strcmp0(key, "Class")) {
359 cod = g_variant_get_uint32(value);
360 } else if (!g_strcmp0(key, "Connected")) {
361 connected = g_variant_get_byte(value);
362 } else if (!g_strcmp0(key, "Trusted")) {
363 trust = g_variant_get_boolean(value);
364 } else if (!g_strcmp0(key, "RSSI")) {
365 rssi = g_variant_get_int16(value);
366 } else if (!g_strcmp0(key, "UUIDs")) {
367 __bt_get_service_list(value, dev_info);
368 } else if (!g_strcmp0(key, "ManufacturerDataLen")) {
369 dev_info->manufacturer_data.data_len = g_variant_get_uint16(value);
370 } else if (!g_strcmp0(key, "ManufacturerData")) {
371 manufacturer_data = g_byte_array_new();
372 g_variant_get(value, "ay", &char_value_iter);
373 while(g_variant_iter_loop(char_value_iter, "y", &char_value)) {
374 g_byte_array_append(manufacturer_data, &char_value, 1);
376 if (manufacturer_data) {
377 if (manufacturer_data->len > 0) {
378 memcpy(dev_info->manufacturer_data.data, manufacturer_data->data,
379 manufacturer_data->len);
385 BT_DBG("trust: %d, paired: %d", trust, paired);
387 g_variant_unref(result);
389 if ((paired == FALSE) && (trust == FALSE)) {
390 return BLUETOOTH_ERROR_NOT_PAIRED;
393 _bt_convert_addr_string_to_type(dev_info->device_address.addr,
396 _bt_divide_device_class(&dev_info->device_class, cod);
398 g_strlcpy(dev_info->device_name.name, name,
399 BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
401 dev_info->rssi = rssi;
402 dev_info->trust = trust;
403 dev_info->paired = paired;
404 dev_info->connected = connected;
405 ret = BLUETOOTH_ERROR_NONE;
410 void _bt_set_discovery_status(gboolean mode)
412 is_discovering = mode;
415 void _bt_set_cancel_by_user(gboolean value)
417 cancel_by_user = value;
420 gboolean _bt_get_cancel_by_user(void)
422 return cancel_by_user;
425 void _bt_adapter_set_status(bt_status_t status)
427 BT_INFO("adapter_status changed [%d] -> [%d]", adapter_status, status);
428 adapter_status = status;
431 bt_status_t _bt_adapter_get_status(void)
433 return adapter_status;
436 void _bt_adapter_set_le_status(bt_le_status_t status)
438 BT_INFO("adapter_le_status changed [%d] -> [%d]", adapter_le_status, status);
439 adapter_le_status = status;
442 bt_le_status_t _bt_adapter_get_le_status(void)
444 return adapter_le_status;
447 static void __bt_phone_name_changed_cb(keynode_t *node, void *data)
449 char *phone_name = NULL;
455 if (vconf_keynode_get_type(node) == VCONF_TYPE_STRING) {
456 phone_name = vconf_keynode_get_str(node);
458 if (phone_name && strlen(phone_name) != 0) {
459 if (!g_utf8_validate(phone_name, -1,
460 (const char **)&ptr))
463 _bt_set_local_name(phone_name);
469 static void __bt_set_visible_mode(void)
473 if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0)
474 BT_ERR("Fail to get the timeout value");
476 #ifdef TIZEN_DPM_ENABLE
478 _bt_dpm_get_bluetooth_limited_discoverable_state() == DPM_RESTRICTED) {
479 if (_bt_set_discoverable_mode(
480 BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,
481 timeout) != BLUETOOTH_ERROR_NONE) {
482 if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
483 BT_ERR("Set vconf failed");
486 if (_bt_set_discoverable_mode(
487 BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE,
488 timeout) != BLUETOOTH_ERROR_NONE) {
489 BT_ERR("Set connectable mode failed");
494 if (_bt_set_discoverable_mode(
495 BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,
496 timeout) != BLUETOOTH_ERROR_NONE) {
497 if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
498 BT_ERR("Set vconf failed");
501 if (_bt_set_discoverable_mode(
502 BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE,
503 timeout) != BLUETOOTH_ERROR_NONE) {
504 BT_ERR("Set connectable mode failed");
511 static void __bt_set_local_name(void)
513 char *phone_name = NULL;
516 phone_name = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
521 if (strlen(phone_name) != 0) {
522 if (!g_utf8_validate(phone_name, -1, (const char **)&ptr))
525 _bt_set_local_name(phone_name);
530 static int __bt_set_enabled(void)
533 int adapter_status = BT_ADAPTER_DISABLED;
534 int result = BLUETOOTH_ERROR_NONE;
536 _bt_check_adapter(&adapter_status);
538 if (adapter_status == BT_ADAPTER_DISABLED) {
539 BT_ERR("Bluetoothd is not running");
540 return BLUETOOTH_ERROR_INTERNAL;
544 __bt_set_visible_mode();
547 if (_bt_set_discoverable_mode(
548 BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0)!= BLUETOOTH_ERROR_NONE)
549 BT_ERR("Fail to set discoverable mode");
552 __bt_set_local_name();
554 /* Update Bluetooth Status to notify other modules */
555 if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_ON) != 0)
556 BT_ERR("Set vconf failed\n");
558 if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0)
559 BT_ERR("Set vconf failed\n");
561 if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
562 EVT_VAL_BT_ON) != ES_R_OK)
563 BT_ERR("Fail to set value");
566 /* Send enabled event to API */
567 _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_ENABLED,
568 g_variant_new("(i)", result));
571 return BLUETOOTH_ERROR_NONE;
574 void _bt_set_disabled(int result)
576 int power_off_status = 0;
579 int pm_ignore_mode = 0;
581 ret = vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &power_off_status);
582 BT_DBG("ret : %d, power_off_status : %d", ret, power_off_status);
584 ret_pm_ignore = vconf_get_int(VCONFKEY_PM_KEY_IGNORE, &pm_ignore_mode);
586 /* Update the vconf BT status in normal Deactivation case only */
587 if (ret == 0 && power_off_status == VCONFKEY_SYSMAN_POWER_OFF_NONE &&
588 ret_pm_ignore == 0 && pm_ignore_mode != VCONFKEY_PM_KEY_LOCK) {
590 BT_DBG("Update vconf for BT normal Deactivation");
592 if (result == BLUETOOTH_ERROR_TIMEOUT)
593 if (vconf_set_int(BT_OFF_DUE_TO_TIMEOUT, 1) != 0 )
594 BT_ERR("Set vconf failed");
596 /* Update Bluetooth Status to notify other modules */
597 if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
598 BT_ERR("Set vconf failed");
600 if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
601 EVT_VAL_BT_OFF) != ES_R_OK)
602 BT_ERR("Fail to set value");
605 if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0)
606 BT_ERR("Set vconf failed\n");
608 _bt_adapter_set_status(BT_DEACTIVATED);
610 if (_bt_adapter_get_le_status() != BT_LE_DEACTIVATED) {
611 /* Send disabled event */
612 _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
613 g_variant_new("(i)", result));
616 BT_INFO("Adapter disabled");
619 static int __bt_set_le_enabled(void)
622 int result = BLUETOOTH_ERROR_NONE;
625 __bt_set_local_name();
627 /* Update Bluetooth Status to notify other modules */
628 if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_ON) != 0)
629 BT_ERR("Set vconf failed\n");
631 if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
632 EVT_VAL_BT_LE_ON) != ES_R_OK)
633 BT_ERR("Fail to set value");
635 /* Send enabled event to API */
637 _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_ENABLED,
638 DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
640 status = _bt_adapter_get_status();
641 if (status == BT_DEACTIVATED) {
642 BT_INFO("BREDR is off, turn off PSCAN");
643 _bt_set_connectable(FALSE);
645 if (le_timer_id > 0) {
646 g_source_remove(le_timer_id);
650 /* Send enabled event to API */
651 _bt_send_event(BT_LE_ADAPTER_EVENT, BLUETOOTH_EVENT_LE_ENABLED,
652 g_variant_new("(i)", result));
655 return BLUETOOTH_ERROR_NONE;
658 void _bt_set_le_disabled(int result)
660 int power_off_status;
663 ret = vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &power_off_status);
664 BT_DBG("ret : %d", ret);
665 BT_DBG("power_off_status : %d", power_off_status);
667 /* Update Bluetooth Status to notify other modules */
668 BT_DBG("Update vconf for BT LE normal Deactivation");
669 if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_OFF) != 0)
670 BT_ERR("Set vconf failed\n");
671 _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
673 if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
674 EVT_VAL_BT_LE_OFF) != ES_R_OK)
675 BT_ERR("Fail to set value");
677 /* Send disabled event */
678 _bt_send_event(BT_LE_ADAPTER_EVENT, BLUETOOTH_EVENT_LE_DISABLED,
679 g_variant_new_int32(result));
682 void *_bt_get_adapter_agent(void)
684 return adapter_agent;
687 int _bt_enable_core(void)
691 GError *error = NULL;
693 proxy = __bt_get_core_proxy();
694 retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
696 /* Clean up the process */
697 result = g_dbus_proxy_call_sync(proxy,
700 G_DBUS_CALL_FLAGS_NONE,
707 BT_ERR("Bt core call failed(Error: %s)", error->message);
708 g_clear_error(&error);
710 BT_ERR("Bt core call failed");
711 return BLUETOOTH_ERROR_INTERNAL;
714 g_variant_unref(result);
715 return BLUETOOTH_ERROR_NONE;
718 #if defined(TIZEN_TELEPHONY_ENABLED) || (!defined(TIZEN_WEARABLE) && defined(ENABLE_TIZEN_2_4))
719 static void __bt_service_flight_ps_mode_cb(keynode_t *node, void *data)
721 gboolean flight_mode = FALSE;
722 int power_saving_mode = 0;
725 DBG_SECURE("key=%s", vconf_keynode_get_name(node));
726 type = vconf_keynode_get_type(node);
727 if (type == VCONF_TYPE_BOOL) {
728 flight_mode = vconf_keynode_get_bool(node);
729 if (flight_mode != TRUE) {
730 BT_ERR("Ignore the event");
733 } else if (type == VCONF_TYPE_INT) {
734 power_saving_mode = vconf_keynode_get_int(node);
735 if (power_saving_mode != 2) {
736 BT_ERR("Ignore the event");
740 BT_ERR("Invaild vconf key type : %d", type);
748 void _bt_service_register_vconf_handler(void)
752 #ifdef TIZEN_TELEPHONY_ENABLED
753 if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
754 (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
755 BT_ERR("Unable to register key handler");
757 BT_DBG("Telephony is disabled");
760 #ifndef TIZEN_WEARABLE
761 #ifdef ENABLE_TIZEN_2_4
762 if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
763 (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
764 BT_ERR("Unable to register key handler");
769 void _bt_service_unregister_vconf_handler(void)
773 #ifdef TIZEN_TELEPHONY_ENABLED
774 vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
775 (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
778 #ifndef TIZEN_WEARABLE
779 #ifdef ENABLE_TIZEN_2_4
780 vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
781 (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
786 static void __bt_state_event_handler(const char *event_name, bundle *data, void *user_data)
788 #ifdef ENABLE_TIZEN_2_4
789 const char *bt_status = NULL;
790 const char *bt_le_status = NULL;
791 BT_DBG("bt state set event(%s) received", event_name);
792 bt_status = bundle_get_val(data, EVT_KEY_BT_STATE);
793 BT_DBG("bt_state: (%s)", bt_status);
795 bt_le_status = bundle_get_val(data, EVT_KEY_BT_LE_STATE);
796 BT_DBG("bt_state: (%s)", bt_le_status);
800 void _bt_handle_adapter_added(void)
804 bt_le_status_t le_status;
808 BT_DBG("g_source is removed");
809 g_source_remove(timer_id);
813 status = _bt_adapter_get_status();
814 le_status = _bt_adapter_get_le_status();
815 BT_DBG("status : %d", status);
816 BT_DBG("le_status : %d", le_status);
818 adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
819 if (!adapter_agent) {
820 BT_ERR("Fail to register agent");
824 if (_bt_register_media_player() != BLUETOOTH_ERROR_NONE)
825 BT_ERR("Fail to register media player");
827 if (_bt_register_obex_server() != BLUETOOTH_ERROR_NONE)
828 BT_ERR("Fail to init obex server");
830 #ifdef TIZEN_BT_PAN_NAP_ENABLE
831 if (_bt_network_activate() != BLUETOOTH_ERROR_NONE)
832 BT_ERR("Fail to activate network");
835 /* add the vconf noti handler */
836 ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR,
837 __bt_phone_name_changed_cb, NULL);
839 BT_ERR("Unable to register key handler");
841 if (le_status == BT_LE_ACTIVATING ||
842 status == BT_ACTIVATING) {
843 __bt_set_le_enabled();
844 _bt_adapter_set_le_status(BT_LE_ACTIVATED);
847 if (status == BT_ACTIVATING) {
849 _bt_adapter_set_status(BT_ACTIVATED);
851 #ifdef ENABLE_TIZEN_2_4
855 _bt_service_register_vconf_handler();
858 if (eventsystem_register_event(SYS_EVENT_BT_STATE, &status_reg_id,
859 (eventsystem_handler)__bt_state_event_handler, NULL) != ES_R_OK) {
860 BT_ERR("Fail to register system event");
864 void _bt_handle_adapter_removed(void)
868 _bt_adapter_set_status(BT_DEACTIVATED);
869 #ifdef ENABLE_TIZEN_2_4
873 __bt_visibility_alarm_remove();
875 if (visible_timer.alarm_init) {
877 visible_timer.alarm_init = FALSE;
880 ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR,
881 (vconf_callback_fn)__bt_phone_name_changed_cb);
883 ERR("vconf_ignore_key_changed failed\n");
886 _bt_destroy_agent(adapter_agent);
887 adapter_agent = NULL;
889 _bt_reliable_terminate_service(NULL);
891 if (eventsystem_unregister_event(status_reg_id) != ES_R_OK) {
892 BT_ERR("Fail to unregister system event");
897 static gboolean __bt_enable_timeout_cb(gpointer user_data)
901 GError *error = NULL;
905 retv_if(_bt_adapter_get_status() == BT_ACTIVATED, FALSE);
907 BT_ERR("EnableAdapter is failed");
909 proxy = __bt_get_core_proxy();
913 /* Clean up the process */
914 result = g_dbus_proxy_call_sync(proxy,
917 G_DBUS_CALL_FLAGS_NONE,
924 BT_ERR("Bt core call failed(Error: %s)", error->message);
925 g_clear_error(&error);
927 BT_ERR("Bt core call failed");
932 g_variant_unref(result);
933 _bt_set_disabled(BLUETOOTH_ERROR_TIMEOUT);
935 _bt_terminate_service(NULL);
940 static gboolean __bt_enable_le_timeout_cb(gpointer user_data)
944 GError *error = NULL;
948 retv_if(_bt_adapter_get_le_status() == BT_LE_ACTIVATED, FALSE);
950 BT_ERR("EnableAdapterLE is failed");
952 proxy = __bt_get_core_proxy();
956 /* Clean up the process */
957 result = g_dbus_proxy_call_sync(proxy,
960 G_DBUS_CALL_FLAGS_NONE,
967 BT_ERR("Bt core call failed(Error: %s)", error->message);
968 g_clear_error(&error);
970 BT_ERR("Bt core call failed");
974 g_variant_unref(result);
975 _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
977 _bt_set_le_disabled(BLUETOOTH_ERROR_TIMEOUT);
979 if (_bt_adapter_get_status() == BT_DEACTIVATED)
980 _bt_terminate_service(NULL);
985 void _bt_adapter_start_le_enable_timer(void)
987 if (le_timer_id > 0) {
988 g_source_remove(le_timer_id);
992 le_timer_id = g_timeout_add(BT_ENABLE_TIMEOUT,
993 __bt_enable_le_timeout_cb, NULL);
998 void _bt_adapter_start_enable_timer(void)
1001 g_source_remove(timer_id);
1005 timer_id = g_timeout_add(BT_ENABLE_TIMEOUT,
1006 __bt_enable_timeout_cb, NULL);
1012 static gboolean __bt_adapter_enabled_cb(gpointer user_data)
1017 _bt_adapter_set_status(BT_ACTIVATED);
1023 int _bt_enable_adapter(void)
1026 GError *error = NULL;
1028 GVariant *result = NULL;
1029 bt_status_t status = _bt_adapter_get_status();
1030 bt_le_status_t le_status = _bt_adapter_get_le_status();
1034 if (status == BT_ACTIVATING) {
1035 BT_ERR("Enabling in progress");
1036 return BLUETOOTH_ERROR_IN_PROGRESS;
1039 if (status == BT_ACTIVATED) {
1040 BT_ERR("Already enabled");
1041 return BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
1044 if (status == BT_DEACTIVATING || le_status == BT_LE_DEACTIVATING) {
1045 BT_ERR("Disabling in progress");
1046 return BLUETOOTH_ERROR_DEVICE_BUSY;
1049 _bt_adapter_set_status(BT_ACTIVATING);
1053 int adapter_status = BT_ADAPTER_DISABLED;
1055 if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
1056 BT_ERR("Set vconf failed");
1058 _bt_check_adapter(&adapter_status);
1059 if (adapter_status == BT_ADAPTER_ENABLED) {
1060 g_idle_add(__bt_adapter_enabled_cb, NULL);
1061 _bt_adapter_start_enable_timer();
1062 return BLUETOOTH_ERROR_NONE;
1067 proxy = __bt_get_core_proxy();
1069 return BLUETOOTH_ERROR_INTERNAL;
1071 if (le_status == BT_LE_ACTIVATED) {
1072 BT_INFO("LE Already enabled. Just turn on PSCAN");
1073 ret = _bt_set_connectable(TRUE);
1074 if (ret == BLUETOOTH_ERROR_NONE) {
1075 _bt_adapter_set_status(BT_ACTIVATED);
1077 return BLUETOOTH_ERROR_INTERNAL;
1081 result = g_dbus_proxy_call_sync(proxy, "EnableAdapter",
1083 G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
1086 BT_ERR("EnableAdapterLe failed: %s", error->message);
1087 _bt_adapter_set_status(BT_DEACTIVATED);
1088 g_clear_error(&error);
1090 result = g_dbus_proxy_call_sync(proxy,
1093 G_DBUS_CALL_FLAGS_NONE,
1098 if (error != NULL) {
1099 BT_ERR("Bt core call failed(Error: %s)", error->message);
1100 g_clear_error(&error);
1102 g_variant_unref(result);
1103 /* Terminate myself */
1104 g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
1105 return BLUETOOTH_ERROR_INTERNAL;
1107 g_variant_unref(result);
1108 if (le_status == BT_LE_ACTIVATED) {
1111 _bt_adapter_start_enable_timer();
1114 return BLUETOOTH_ERROR_NONE;
1117 static gboolean __bt_disconnect_all(void)
1120 GDBusConnection *conn;
1121 GDBusProxy *dev_proxy;
1122 gboolean ret = FALSE;
1124 GError *error = NULL;
1125 GArray *device_list;
1126 bluetooth_device_info_t info;
1128 char *device_path = NULL;
1129 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
1134 conn = _bt_get_system_gconn();
1136 device_list = g_array_new(FALSE, FALSE, sizeof(gchar));
1138 if (_bt_get_bonded_devices(&device_list)
1139 != BLUETOOTH_ERROR_NONE) {
1140 g_array_free(device_list, TRUE);
1144 size = (device_list->len) / sizeof(bluetooth_device_info_t);
1146 for (i = 0; i < size; i++) {
1148 info = g_array_index(device_list,
1149 bluetooth_device_info_t, i);
1151 if (info.connected != BLUETOOTH_CONNECTED_LINK_NONE) {
1152 BT_DBG("Found Connected device");
1153 _bt_convert_addr_type_to_string(address, info.device_address.addr);
1154 device_path = _bt_get_device_object_path(address);
1155 if (device_path == NULL)
1158 BT_DBG("Disconnecting : %s", device_path);
1160 dev_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
1164 BT_DEVICE_INTERFACE,
1167 if (dev_proxy == NULL)
1170 result = g_dbus_proxy_call_sync(dev_proxy,
1173 G_DBUS_CALL_FLAGS_NONE,
1179 if (error != NULL) {
1180 BT_ERR("Disconnect call failed(Error: %s)", error->message);
1181 g_clear_error(&error);
1183 BT_ERR("Disconnect call failed");
1184 g_object_unref(dev_proxy);
1188 g_variant_unref(result);
1189 g_object_unref(dev_proxy);
1193 g_array_free(device_list, TRUE);
1198 static gboolean __bt_set_disabled_timeout_cb(gpointer user_data)
1201 _bt_set_disabled(BLUETOOTH_ERROR_NONE);
1206 int __bt_disable_cb(void)
1210 bt_le_status_t le_status;
1213 GError *error = NULL;
1215 _bt_adapter_set_status(BT_DEACTIVATING);
1216 le_status = _bt_adapter_get_le_status();
1217 BT_DBG("le_status : %d", le_status);
1218 if (le_status == BT_LE_ACTIVATED) {
1219 BT_INFO("LE is enabled. Just turn off PSCAN");
1221 if (_bt_is_discovering())
1222 _bt_cancel_discovery();
1224 if (_bt_is_connectable() == FALSE) {
1225 g_timeout_add(100, (GSourceFunc)__bt_set_disabled_timeout_cb, NULL);
1227 ret = _bt_set_connectable(FALSE);
1228 if (ret != BLUETOOTH_ERROR_NONE) {
1229 BT_ERR("_bt_set_connectable fail!");
1230 _bt_adapter_set_status(BT_ACTIVATED);
1231 return BLUETOOTH_ERROR_INTERNAL;
1236 proxy = __bt_get_core_proxy();
1237 retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
1239 result = g_dbus_proxy_call_sync(proxy,
1242 G_DBUS_CALL_FLAGS_NONE,
1248 if (error != NULL) {
1249 BT_ERR("Failed to DisableAdapter (Error: %s)", error->message);
1250 g_clear_error(&error);
1252 BT_ERR("Failed to DisableAdapter");
1253 _bt_adapter_set_status(BT_ACTIVATED);
1254 return BLUETOOTH_ERROR_INTERNAL;
1257 g_variant_unref(result);
1258 return BLUETOOTH_ERROR_NONE;
1261 int _bt_disable_adapter(void)
1266 if (_bt_adapter_get_status() == BT_DEACTIVATING) {
1267 BT_DBG("Disabling in progress");
1268 return BLUETOOTH_ERROR_IN_PROGRESS;
1271 if (_bt_adapter_get_status() == BT_DEACTIVATED) {
1272 BT_DBG("Already disabled");
1273 return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
1277 g_source_remove(timer_id);
1281 __bt_disconnect_all();
1282 ret = __bt_disable_cb();
1288 int _bt_recover_adapter(void)
1293 GError *error = NULL;
1295 if (_bt_adapter_get_status() == BT_DEACTIVATING) {
1296 BT_DBG("Disabling in progress");
1297 return BLUETOOTH_ERROR_IN_PROGRESS;
1300 if (_bt_adapter_get_status() == BT_DEACTIVATED) {
1301 BT_DBG("Already disabled");
1302 return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
1305 _bt_adapter_set_status(BT_DEACTIVATING);
1307 proxy = __bt_get_core_proxy();
1308 retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
1310 result = g_dbus_proxy_call_sync(proxy,
1313 G_DBUS_CALL_FLAGS_NONE,
1319 if (error != NULL) {
1320 BT_ERR("Failed to RecoverAdapter (Error: %s)", error->message);
1321 g_clear_error(&error);
1323 BT_ERR("Failed to RecoverAdapter");
1324 return BLUETOOTH_ERROR_INTERNAL;
1327 g_variant_unref(result);
1328 __bt_disconnect_all();
1331 return BLUETOOTH_ERROR_NONE;
1334 int _bt_reset_adapter(void)
1338 GError *error = NULL;
1342 proxy = __bt_get_core_proxy();
1344 return BLUETOOTH_ERROR_INTERNAL;
1346 result = g_dbus_proxy_call_sync(proxy,
1349 G_DBUS_CALL_FLAGS_NONE,
1355 if (error != NULL) {
1356 BT_ERR("Failed to ResetAdapter (Error: %s)", error->message);
1357 g_clear_error(&error);
1359 BT_ERR("Failed to ResetAdapter");
1360 return BLUETOOTH_ERROR_INTERNAL;
1363 g_variant_unref(result);
1364 /* Terminate myself */
1365 if (_bt_adapter_get_status() == BT_DEACTIVATED) {
1366 g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
1369 return BLUETOOTH_ERROR_NONE;
1373 int _bt_check_adapter(int *status)
1376 char *adapter_path = NULL;
1378 BT_CHECK_PARAMETER(status, return);
1380 *status = BT_ADAPTER_DISABLED;
1382 adapter_path = _bt_get_adapter_path();
1385 if (adapter_path != NULL)
1386 *status = BT_ADAPTER_ENABLED;
1388 g_free(adapter_path);
1389 return BLUETOOTH_ERROR_NONE;
1392 int _bt_check_adapter(int *status)
1395 GError *error = NULL;
1398 gboolean powered = FALSE;
1400 BT_CHECK_PARAMETER(status, return);
1402 *status = BT_ADAPTER_DISABLED;
1404 proxy = _bt_get_adapter_properties_proxy();
1405 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1407 result = g_dbus_proxy_call_sync(proxy,
1409 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1411 G_DBUS_CALL_FLAGS_NONE,
1417 BT_ERR("Failed to get local address");
1418 if (error != NULL) {
1419 BT_ERR("Failed to get local address (Error: %s)", error->message);
1420 g_clear_error(&error);
1422 return BLUETOOTH_ERROR_INTERNAL;
1425 g_variant_get(result, "(v)", &temp);
1426 powered = g_variant_get_boolean(temp);
1427 BT_DBG("powered: %d", powered);
1430 *status = BT_ADAPTER_ENABLED;
1432 g_variant_unref(result);
1433 g_variant_unref(temp);
1434 return BLUETOOTH_ERROR_NONE;
1438 int _bt_enable_adapter_le(void)
1442 GError *error = NULL;
1443 bt_status_t status = _bt_adapter_get_status();
1444 bt_le_status_t le_status = _bt_adapter_get_le_status();
1447 if (le_status == BT_LE_ACTIVATING) {
1448 BT_ERR("Enabling in progress");
1449 return BLUETOOTH_ERROR_IN_PROGRESS;
1452 if (le_status == BT_LE_ACTIVATED) {
1453 BT_ERR("Already enabled");
1454 return BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
1457 if (status == BT_DEACTIVATING || le_status == BT_LE_DEACTIVATING) {
1458 BT_ERR("Disabling in progress");
1459 return BLUETOOTH_ERROR_DEVICE_BUSY;
1462 _bt_adapter_set_le_status(BT_LE_ACTIVATING);
1464 proxy = __bt_get_core_proxy();
1465 retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
1467 result = g_dbus_proxy_call_sync(proxy, "EnableAdapterLe",
1469 G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
1472 BT_ERR("EnableAdapterLe failed: %s", error->message);
1473 _bt_adapter_set_le_status(BT_DEACTIVATED);
1474 g_clear_error(&error);
1476 /* Clean up the process */
1477 result = g_dbus_proxy_call_sync(proxy,
1480 G_DBUS_CALL_FLAGS_NONE,
1486 BT_ERR("Bt core call failed");
1488 BT_ERR("EnableAdapterLE Failed %s", error->message);
1489 g_clear_error(&error);
1492 g_variant_unref(result);
1493 /* Terminate myself */
1494 if (_bt_adapter_get_status() == BT_DEACTIVATED)
1495 g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
1496 return BLUETOOTH_ERROR_INTERNAL;
1500 g_variant_unref(result);
1502 _bt_adapter_start_le_enable_timer();
1504 if (status == BT_ACTIVATED) {
1505 _bt_adapter_set_le_status(BT_LE_ACTIVATED);
1506 __bt_set_le_enabled();
1508 BT_DBG("le status : %d", _bt_adapter_get_le_status());
1510 return BLUETOOTH_ERROR_NONE;
1513 int _bt_disable_adapter_le(void)
1517 bt_le_status_t bt_le_state;
1519 GError *error = NULL;
1521 bt_le_state = _bt_adapter_get_le_status();
1522 if (bt_le_state == BT_LE_DEACTIVATING) {
1523 BT_DBG("Disabling in progress");
1524 return BLUETOOTH_ERROR_IN_PROGRESS;
1527 if (bt_le_state == BT_LE_DEACTIVATED) {
1528 BT_DBG("Already disabled");
1529 return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
1532 _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
1534 proxy = __bt_get_core_proxy();
1536 return BLUETOOTH_ERROR_INTERNAL;
1538 result = g_dbus_proxy_call_sync(proxy,
1541 G_DBUS_CALL_FLAGS_NONE,
1547 if (error != NULL) {
1548 BT_ERR("Bt core call failed (Error: %s)", error->message);
1549 g_clear_error(&error);
1551 BT_ERR("Bt core call failed");
1552 _bt_adapter_set_le_status(BT_LE_ACTIVATED);
1553 return BLUETOOTH_ERROR_INTERNAL;
1556 g_variant_unref(result);
1557 _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
1558 BT_DBG("le status : %d", _bt_adapter_get_le_status());
1560 return BLUETOOTH_ERROR_NONE;
1563 int _bt_get_local_address(bluetooth_device_address_t *local_address)
1567 GError *error = NULL;
1568 const char *address;
1572 BT_CHECK_PARAMETER(local_address, return);
1574 proxy = _bt_get_adapter_properties_proxy();
1575 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1577 result = g_dbus_proxy_call_sync(proxy,
1579 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1581 G_DBUS_CALL_FLAGS_NONE,
1587 BT_ERR("Failed to get local address");
1588 if (error != NULL) {
1589 BT_ERR("Failed to get local address (Error: %s)", error->message);
1590 g_clear_error(&error);
1592 return BLUETOOTH_ERROR_INTERNAL;
1595 g_variant_get(result, "(v)", &temp);
1596 address = g_variant_get_string(temp, NULL);
1597 BT_DBG("Address:%s", address);
1600 _bt_convert_addr_string_to_type(local_address->addr, address);
1602 return BLUETOOTH_ERROR_INTERNAL;
1605 g_variant_unref(result);
1606 g_variant_unref(temp);
1607 return BLUETOOTH_ERROR_NONE;
1610 int _bt_get_local_version(bluetooth_version_t *local_version)
1613 const char *ver = NULL;
1615 int ret = BLUETOOTH_ERROR_NONE;
1619 BT_CHECK_PARAMETER(local_version, return);
1621 GError *error = NULL;
1623 proxy = _bt_get_adapter_properties_proxy();
1624 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1626 result = g_dbus_proxy_call_sync(proxy,
1628 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1630 G_DBUS_CALL_FLAGS_NONE,
1636 if (error != NULL) {
1637 BT_ERR("Failed to get local version (Error: %s)", error->message);
1638 g_clear_error(&error);
1640 BT_ERR("Failed to get local version");
1641 return BLUETOOTH_ERROR_INTERNAL;
1644 g_variant_get(result, "(v)", &temp);
1645 ver = g_variant_get_string(temp, NULL);
1646 BT_DBG("VERSION: %s", ver);
1648 if (ver && (strlen(ver) > 0)) {
1649 /* Check the utf8 valitation & Fill the NULL in the invalid location*/
1650 if (!g_utf8_validate(ver, -1, (const char **)&ptr))
1653 g_strlcpy(local_version->version, ver,
1654 BLUETOOTH_VERSION_LENGTH_MAX + 1);
1657 ret = BLUETOOTH_ERROR_INTERNAL;
1660 g_variant_unref(result);
1661 g_variant_unref(temp);
1665 int _bt_get_local_name(bluetooth_device_name_t *local_name)
1668 const char *name = NULL;
1670 int ret = BLUETOOTH_ERROR_NONE;
1673 GError *error = NULL;
1675 BT_CHECK_PARAMETER(local_name, return);
1677 proxy = _bt_get_adapter_properties_proxy();
1678 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1680 result = g_dbus_proxy_call_sync(proxy,
1682 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1684 G_DBUS_CALL_FLAGS_NONE,
1690 if (error != NULL) {
1691 BT_ERR("Failed to get local name (Error: %s)", error->message);
1692 g_clear_error(&error);
1694 BT_ERR("Failed to get local name");
1695 return BLUETOOTH_ERROR_INTERNAL;
1698 g_variant_get(result, "(v)", &temp);
1699 name = g_variant_get_string(temp, NULL);
1700 BT_DBG("LOCAL NAME:%s", name);
1702 if (name && (strlen(name) > 0)) {
1703 /* Check the utf8 valitation & Fill the NULL in the invalid location*/
1704 if (!g_utf8_validate(name, -1, (const char **)&ptr))
1707 g_strlcpy(local_name->name, name,
1708 BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1);
1710 ret = BLUETOOTH_ERROR_INTERNAL;
1712 g_variant_unref(result);
1713 g_variant_unref(temp);
1717 int _bt_set_local_name(char *local_name)
1720 GError *error = NULL;
1724 BT_CHECK_PARAMETER(local_name, return);
1726 proxy = _bt_get_adapter_properties_proxy();
1728 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1730 if (!g_utf8_validate(local_name, -1, (const char **)&ptr))
1733 result = g_dbus_proxy_call_sync(proxy,
1735 g_variant_new("(ssv)", BT_ADAPTER_INTERFACE,
1736 "Alias", g_variant_new("s", local_name)),
1737 G_DBUS_CALL_FLAGS_NONE,
1743 if (error != NULL) {
1744 BT_ERR("Failed to set Alias (Error: %s)", error->message);
1745 g_clear_error(&error);
1747 BT_ERR("Failed to set Alias");
1748 return BLUETOOTH_ERROR_INTERNAL;
1751 g_variant_unref(result);
1752 return BLUETOOTH_ERROR_NONE;
1755 int _bt_is_service_used(char *service_uuid, gboolean *used)
1758 GError *error = NULL;
1759 int ret = BLUETOOTH_ERROR_NONE;
1762 GVariantIter *iter = NULL;
1766 BT_CHECK_PARAMETER(service_uuid, return);
1767 BT_CHECK_PARAMETER(used, return);
1769 proxy = _bt_get_adapter_properties_proxy();
1770 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1772 result = g_dbus_proxy_call_sync(proxy,
1774 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1776 G_DBUS_CALL_FLAGS_NONE,
1782 if (error != NULL) {
1783 BT_ERR("Failed to get UUIDs (Error: %s)", error->message);
1784 g_clear_error(&error);
1786 BT_ERR("Failed to get UUIDs");
1787 return BLUETOOTH_ERROR_INTERNAL;
1790 g_variant_get(result, "(v)", &value);
1791 g_variant_get(value, "as", &iter);
1793 BT_ERR("Failed to get UUIDs(%s)",service_uuid);
1795 g_variant_unref(result);
1796 g_variant_unref(value);
1800 while (g_variant_iter_loop(iter, "s", &uuid)) {
1801 if (strcasecmp(uuid, service_uuid) == 0) {
1811 g_variant_iter_free(iter);
1812 g_variant_unref(value);
1813 g_variant_unref(result);
1814 BT_DBG("Service Used? %d", *used);
1818 static gboolean __bt_get_discoverable_property(void)
1821 gboolean discoverable_v;
1822 GError *error = NULL;
1826 proxy = _bt_get_adapter_properties_proxy();
1827 retv_if(proxy == NULL, FALSE);
1829 result = g_dbus_proxy_call_sync(proxy,
1831 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1833 G_DBUS_CALL_FLAGS_NONE,
1839 if (error != NULL) {
1840 BT_ERR("Failed to get Discoverable property (Error: %s)", error->message);
1841 g_clear_error(&error);
1843 BT_ERR("Failed to get Discoverable property");
1844 return BLUETOOTH_ERROR_INTERNAL;
1847 g_variant_get(result, "(v)", &temp);
1848 discoverable_v = g_variant_get_boolean(temp);
1849 BT_DBG("discoverable_v:%d", discoverable_v);
1851 g_variant_unref(result);
1852 g_variant_unref(temp);
1854 return discoverable_v;
1857 int _bt_get_discoverable_mode(int *mode)
1859 gboolean discoverable;
1860 unsigned int timeout;
1862 BT_CHECK_PARAMETER(mode, return);
1864 discoverable = __bt_get_discoverable_property();
1865 timeout = _bt_get_discoverable_timeout_property();
1867 if (discoverable == TRUE) {
1869 *mode = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE;
1871 *mode = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;
1873 *mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
1875 return BLUETOOTH_ERROR_NONE;
1879 int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
1881 int ret = BLUETOOTH_ERROR_NONE;
1884 GError *error = NULL;
1888 proxy = _bt_get_adapter_properties_proxy();
1890 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1892 #ifdef TIZEN_DPM_ENABLE
1893 if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE &&
1894 _bt_dpm_get_bluetooth_limited_discoverable_state() == DPM_RESTRICTED) {
1895 _bt_launch_dpm_popup("DPM_POLICY_DISABLE_BT_HANDSFREE");
1896 return BLUETOOTH_ERROR_ACCESS_DENIED;
1898 if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE &&
1899 _bt_dpm_get_bluetooth_limited_discoverable_state() == DPM_RESTRICTED) {
1900 _bt_launch_dpm_popup("DPM_POLICY_DISABLE_BT");
1901 return BLUETOOTH_ERROR_ACCESS_DENIED;
1905 switch (discoverable_mode) {
1906 case BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE:
1911 case BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE:
1916 case BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE:
1921 return BLUETOOTH_ERROR_INVALID_PARAM;
1924 BT_INFO("Req. discoverable_mode : %d, timeout : %d",
1925 discoverable_mode, timeout);
1927 result = g_dbus_proxy_call_sync(proxy,
1929 g_variant_new("(ssv)", BT_ADAPTER_INTERFACE,
1930 "Connectable", g_variant_new("b", pg_scan)),
1931 G_DBUS_CALL_FLAGS_NONE,
1937 if (error != NULL) {
1938 BT_ERR("Failed to set connectable property (Error: %s)", error->message);
1939 g_clear_error(&error);
1941 BT_ERR("Failed to set connectable property");
1942 return BLUETOOTH_ERROR_INTERNAL;
1944 g_variant_unref(result);
1945 result = g_dbus_proxy_call_sync(proxy,
1947 g_variant_new("(ssv)", BT_ADAPTER_INTERFACE, "Discoverable",
1948 g_variant_new("b", inq_scan)),
1949 G_DBUS_CALL_FLAGS_NONE,
1955 if (error != NULL) {
1956 BT_ERR("Failed to set Discoverable property (Error: %s)", error->message);
1957 g_clear_error(&error);
1959 BT_ERR("Failed to set Discoverable property");
1960 return BLUETOOTH_ERROR_INTERNAL;
1962 g_variant_unref(result);
1963 result = g_dbus_proxy_call_sync(proxy,
1965 g_variant_new("(ssv)", BT_ADAPTER_INTERFACE,
1966 "DiscoverableTimeout", g_variant_new("u", timeout)),
1967 G_DBUS_CALL_FLAGS_NONE,
1973 if (error != NULL) {
1974 BT_ERR("Failed to set DiscoverableTimeout property (Error: %s)", error->message);
1975 g_clear_error(&error);
1977 BT_ERR("Failed to set DiscoverableTimeout property");
1978 return BLUETOOTH_ERROR_INTERNAL;
1981 if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE)
1984 ret = __bt_set_visible_time(timeout);
1986 g_variant_unref(result);
1991 int _bt_start_discovery(void)
1994 GError *error = NULL;
1997 if (_bt_is_discovering() == TRUE) {
1998 BT_ERR("BT is already in discovering");
1999 return BLUETOOTH_ERROR_IN_PROGRESS;
2000 } else if (_bt_is_device_creating() == TRUE) {
2001 BT_ERR("Bonding device is going on");
2002 return BLUETOOTH_ERROR_DEVICE_BUSY;
2005 proxy = _bt_get_adapter_proxy();
2006 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2008 result = g_dbus_proxy_call_sync(proxy,
2011 G_DBUS_CALL_FLAGS_NONE,
2017 if (error != NULL) {
2018 BT_ERR("StartDiscovery failed (Error: %s)", error->message);
2019 g_clear_error(&error);
2021 BT_ERR("StartDiscovery failed");
2022 return BLUETOOTH_ERROR_INTERNAL;
2025 is_discovering = TRUE;
2026 cancel_by_user = FALSE;
2027 /* discovery status will be change in event */
2028 g_variant_unref(result);
2029 return BLUETOOTH_ERROR_NONE;
2032 int _bt_start_custom_discovery(bt_discovery_role_type_t role)
2036 GError *error = NULL;
2037 const gchar *disc_type;
2039 if (_bt_is_discovering() == TRUE) {
2040 BT_ERR("BT is already in discovering");
2041 return BLUETOOTH_ERROR_IN_PROGRESS;
2044 proxy = _bt_get_adapter_proxy();
2045 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2047 if (role == DISCOVERY_ROLE_BREDR)
2048 disc_type = "BREDR";
2049 else if (role == DISCOVERY_ROLE_LE)
2051 else if (role == DISCOVERY_ROLE_LE_BREDR)
2052 disc_type = "LE_BREDR";
2054 return BLUETOOTH_ERROR_INVALID_PARAM;
2056 result = g_dbus_proxy_call_sync(proxy,
2057 "StartCustomDiscovery",
2058 g_variant_new("s", disc_type),
2059 G_DBUS_CALL_FLAGS_NONE,
2065 if (error != NULL) {
2066 BT_ERR("StartCustomDiscovery failed (Error: %s)", error->message);
2067 g_clear_error(&error);
2069 BT_ERR("StartCustomDiscovery failed");
2070 return BLUETOOTH_ERROR_INTERNAL;
2073 is_discovering = TRUE;
2074 cancel_by_user = FALSE;
2075 /* discovery status will be change in event */
2076 g_variant_unref(result);
2077 return BLUETOOTH_ERROR_NONE;
2080 int _bt_cancel_discovery(void)
2083 GError *error = NULL;
2086 if (_bt_is_discovering() == FALSE) {
2087 BT_ERR("BT is not in discovering");
2088 return BLUETOOTH_ERROR_NOT_IN_OPERATION;
2091 proxy = _bt_get_adapter_proxy();
2092 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2094 result = g_dbus_proxy_call_sync(proxy,
2097 G_DBUS_CALL_FLAGS_NONE,
2103 if (error != NULL) {
2104 BT_ERR("StopDiscovery failed (Error: %s)", error->message);
2105 g_clear_error(&error);
2107 BT_ERR("StopDiscovery failed");
2108 return BLUETOOTH_ERROR_INTERNAL;
2111 cancel_by_user = TRUE;
2112 /* discovery status will be change in event */
2113 g_variant_unref(result);
2114 return BLUETOOTH_ERROR_NONE;
2117 gboolean _bt_is_discovering(void)
2119 return is_discovering;
2122 gboolean _bt_is_connectable(void)
2125 GError *error = NULL;
2126 gboolean is_connectable = FALSE;
2130 proxy = _bt_get_adapter_properties_proxy();
2131 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2133 result = g_dbus_proxy_call_sync(proxy,
2135 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
2137 G_DBUS_CALL_FLAGS_NONE,
2143 if (error != NULL) {
2144 BT_ERR("Failed to get connectable property (Error: %s)", error->message);
2145 g_clear_error(&error);
2147 BT_ERR("Failed to get connectable property");
2148 return BLUETOOTH_ERROR_INTERNAL;
2151 g_variant_get(result, "(v)", &temp);
2152 is_connectable = g_variant_get_boolean(temp);
2153 BT_DBG("discoverable_v:%d", is_connectable);
2155 g_variant_unref(result);
2156 g_variant_unref(temp);
2158 BT_INFO("Get connectable [%d]", is_connectable);
2159 return is_connectable;
2162 int _bt_set_connectable(gboolean is_connectable)
2165 GError *error = NULL;
2168 if (__bt_is_factory_test_mode()) {
2169 BT_ERR("Unable to set connectable in factory binary !!");
2170 return BLUETOOTH_ERROR_NOT_SUPPORT;
2173 proxy = _bt_get_adapter_properties_proxy();
2175 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2177 result = g_dbus_proxy_call_sync(proxy,
2179 g_variant_new("(ssv)", BT_ADAPTER_INTERFACE, "Connectable",
2180 g_variant_new("b", is_connectable)),
2181 G_DBUS_CALL_FLAGS_NONE,
2187 if (error != NULL) {
2188 BT_ERR("Failed to set connectable property (Error: %s)", error->message);
2189 g_clear_error(&error);
2191 BT_ERR("Failed to set connectable property");
2192 return BLUETOOTH_ERROR_INTERNAL;
2195 BT_INFO("Set connectable [%d]", is_connectable);
2196 g_variant_unref(result);
2197 return BLUETOOTH_ERROR_NONE;
2200 gboolean _bt_get_discovering_property(bt_discovery_role_type_t discovery_type)
2203 gboolean discovering_v;
2204 GError *error = NULL;
2205 char *discovering_type = NULL;
2209 proxy = _bt_get_adapter_properties_proxy();
2210 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2212 if (discovery_type == DISCOVERY_ROLE_BREDR)
2213 discovering_type = "Discovering";
2214 else if (discovery_type == DISCOVERY_ROLE_LE)
2215 discovering_type = "LEDiscovering";
2217 result = g_dbus_proxy_call_sync(proxy,
2219 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
2221 G_DBUS_CALL_FLAGS_NONE,
2227 if (error != NULL) {
2228 BT_ERR("Failed to get discovering property (Error: %s)", error->message);
2229 g_clear_error(&error);
2231 BT_ERR("Failed to get discovering property");
2232 return BLUETOOTH_ERROR_INTERNAL;
2235 g_variant_get(result, "(v)", &temp);
2236 discovering_v = g_variant_get_boolean(temp);
2237 BT_DBG("discoverable_v:%d", discovering_v);
2239 g_variant_unref(result);
2240 g_variant_unref(temp);
2242 return discovering_v;
2245 unsigned int _bt_get_discoverable_timeout_property(void)
2248 unsigned int timeout_v;
2249 GError *error = NULL;
2253 proxy = _bt_get_adapter_properties_proxy();
2254 retv_if(proxy == NULL, 0);
2256 result = g_dbus_proxy_call_sync(proxy,
2258 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
2259 "DiscoverableTimeout"),
2260 G_DBUS_CALL_FLAGS_NONE,
2266 BT_ERR("Fail to get discoverable timeout");
2267 if (error != NULL) {
2268 BT_ERR("Fail to get discoverable timeout (Error: %s)", error->message);
2269 g_clear_error(&error);
2274 g_variant_get(result, "(v)", &temp);
2275 timeout_v = g_variant_get_uint32(temp);
2276 BT_DBG("discoverable_v:%d", timeout_v);
2278 g_variant_unref(result);
2279 g_variant_unref(temp);
2284 static bluetooth_device_info_t *__bt_parse_device_info(GVariantIter *item_iter)
2286 bluetooth_device_info_t *dev_info;
2289 GByteArray *manufacturer_data = NULL;
2291 GVariantIter *char_value_iter;
2293 dev_info = g_malloc0(sizeof(bluetooth_device_info_t));
2295 while (g_variant_iter_loop(item_iter, "{sv}", &key, &value)) {
2300 if (!g_strcmp0(key, "Address")) {
2301 const char *address = NULL;
2302 address = g_variant_get_string(value, NULL);
2303 _bt_convert_addr_string_to_type(dev_info->device_address.addr,
2305 } else if(!g_strcmp0(key, "Class")) {
2307 cod = g_variant_get_uint32(value);
2308 _bt_divide_device_class(&dev_info->device_class, cod);
2309 } else if(!g_strcmp0(key, "Name")) {
2310 const char *name = NULL;
2311 name = g_variant_get_string(value, NULL);
2312 /* If there is no Alias */
2313 if (strlen(dev_info->device_name.name) == 0) {
2314 g_strlcpy(dev_info->device_name.name, name,
2315 BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
2317 } else if(!g_strcmp0(key, "Alias")) {
2318 const char *alias = NULL;
2319 alias = g_variant_get_string(value, NULL);
2320 /* Overwrite the name */
2322 memset(dev_info->device_name.name, 0x00,
2323 BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
2324 g_strlcpy(dev_info->device_name.name, alias,
2325 BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
2327 } else if (!g_strcmp0(key, "Connected")) {
2328 dev_info->connected = g_variant_get_byte(value);
2329 } else if (!g_strcmp0(key, "Paired")) {
2330 dev_info->paired = g_variant_get_boolean(value);
2331 } else if (!g_strcmp0(key, "Trusted")) {
2332 dev_info->trust = g_variant_get_boolean(value);
2333 } else if (!g_strcmp0(key, "RSSI")) {
2334 dev_info->rssi = g_variant_get_int16(value);
2335 } else if (!g_strcmp0(key, "UUIDs")) {
2341 dev_info->service_index = 0;
2342 g_variant_get(value, "as", &iter);
2343 while (g_variant_iter_loop(iter, "s", &uuid)) {
2344 g_strlcpy(dev_info->uuids[i], uuid, BLUETOOTH_UUID_STRING_MAX);
2345 parts = g_strsplit(uuid, "-", -1);
2347 if (parts == NULL || parts[0] == NULL) {
2352 dev_info->service_list_array[i] = g_ascii_strtoull(parts[0], NULL, 16);
2357 dev_info->service_index = i;
2358 g_variant_iter_free(iter);
2359 } else if (strcasecmp(key, "ManufacturerDataLen") == 0) {
2360 dev_info->manufacturer_data.data_len = g_variant_get_uint16(value);
2361 } else if (strcasecmp(key, "ManufacturerData") == 0) {
2362 manufacturer_data = g_byte_array_new();
2363 g_variant_get(value, "ay", &char_value_iter);
2364 while(g_variant_iter_loop(char_value_iter, "y", &char_value)) {
2365 g_byte_array_append(manufacturer_data, &char_value, 1);
2367 if (manufacturer_data) {
2368 if (manufacturer_data->len > 0) {
2369 memcpy(dev_info->manufacturer_data.data, manufacturer_data->data, manufacturer_data->len);
2372 g_variant_iter_free(char_value_iter);
2373 g_byte_array_free(manufacturer_data, TRUE);
2380 static void __bt_extract_device_info(GVariantIter *iter,
2383 bluetooth_device_info_t *dev_info = NULL;
2384 char *object_path = NULL;
2385 GVariantIter *interface_iter;
2386 GVariantIter *svc_iter;
2387 char *interface_str = NULL;
2389 /* Parse the signature: oa{sa{sv}}} */
2390 while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path,
2393 if (object_path == NULL)
2396 while (g_variant_iter_loop(interface_iter, "{sa{sv}}",
2397 &interface_str, &svc_iter)) {
2398 if (g_strcmp0(interface_str, "org.bluez.Device1") == 0) {
2399 BT_DBG("Found a device: %s", object_path);
2400 dev_info = __bt_parse_device_info(svc_iter);
2402 if (dev_info->paired == TRUE) {
2403 g_array_append_vals(*dev_list, dev_info,
2404 sizeof(bluetooth_device_info_t));
2408 g_free(interface_str);
2409 g_variant_iter_free(svc_iter);
2417 int _bt_get_bonded_devices(GArray **dev_list)
2420 GDBusConnection *conn;
2421 GDBusProxy *manager_proxy;
2422 GVariant *result = NULL;
2423 GVariantIter *iter = NULL;
2424 GError *error = NULL;
2426 conn = _bt_get_system_conn();
2427 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
2429 manager_proxy = _bt_get_manager_proxy();
2430 retv_if(manager_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2432 result = g_dbus_proxy_call_sync(manager_proxy, "GetManagedObjects",
2434 G_DBUS_CALL_FLAGS_NONE,
2440 if (error != NULL) {
2441 BT_ERR("Failed to GetManagedObjects (Error: %s)", error->message);
2442 g_clear_error(&error);
2444 BT_ERR("Failed to Failed to GetManagedObjects");
2445 return BLUETOOTH_ERROR_INTERNAL;
2448 /* signature of GetManagedObjects: a{oa{sa{sv}}} */
2449 g_variant_get(result, "(a{oa{sa{sv}}})", &iter);
2451 __bt_extract_device_info(iter, dev_list);
2452 g_variant_iter_free(iter);
2453 g_variant_unref(result);
2456 return BLUETOOTH_ERROR_NONE;
2459 int _bt_get_bonded_device_info(bluetooth_device_address_t *device_address,
2460 bluetooth_device_info_t *dev_info)
2462 char *object_path = NULL;
2463 GDBusProxy *adapter_proxy;
2464 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
2465 int ret = BLUETOOTH_ERROR_NONE;
2467 BT_CHECK_PARAMETER(device_address, return);
2468 BT_CHECK_PARAMETER(dev_info, return);
2470 adapter_proxy = _bt_get_adapter_proxy();
2471 retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2473 _bt_convert_addr_type_to_string(address, device_address->addr);
2475 object_path = _bt_get_device_object_path(address);
2477 retv_if(object_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
2479 ret = __bt_get_bonded_device_info(object_path, dev_info);
2480 g_free(object_path);
2485 int _bt_get_timeout_value(int *timeout)
2487 time_t current_time;
2490 /* Take current time */
2491 time(¤t_time);
2492 time_diff = difftime(current_time, visible_timer.start_time);
2494 BT_DBG("Time diff = %d\n", time_diff);
2496 *timeout = visible_timer.timeout - time_diff;
2498 return BLUETOOTH_ERROR_NONE;
2501 int _bt_set_le_privacy(gboolean set_privacy)
2504 GError *error = NULL;
2505 GVariant *result = NULL;
2507 if (__bt_is_factory_test_mode()) {
2508 BT_ERR("Unable to set le privacy in factory binary !!");
2509 return BLUETOOTH_ERROR_NOT_SUPPORT;
2512 if (_bt_adapter_get_status() != BT_ACTIVATED &&
2513 _bt_adapter_get_le_status() != BT_LE_ACTIVATED) {
2514 return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
2517 proxy = _bt_get_adapter_proxy();
2518 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2520 result = g_dbus_proxy_call_sync(proxy,
2522 g_variant_new("(b)", set_privacy),
2523 G_DBUS_CALL_FLAGS_NONE,
2529 if (error != NULL) {
2530 BT_ERR("Failed to SetLePrivacy (Error: %s)", error->message);
2531 g_clear_error(&error);
2533 BT_ERR("Failed to SetLePrivacy");
2534 return BLUETOOTH_ERROR_INTERNAL;
2537 g_variant_unref(result);
2538 BT_INFO("SetLePrivacy as %d", set_privacy);
2539 return BLUETOOTH_ERROR_NONE;
2542 int _bt_set_manufacturer_data(bluetooth_manufacturer_data_t *m_data)
2545 GError *error = NULL;
2549 GVariantBuilder *builder;
2551 BT_CHECK_PARAMETER(m_data, return);
2553 if (_bt_adapter_get_status() != BT_ACTIVATED &&
2554 _bt_adapter_get_le_status() != BT_LE_ACTIVATED) {
2555 return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
2558 proxy = _bt_get_adapter_proxy();
2559 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2561 builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
2563 for (i = 0; i < (m_data->data_len) + 2; i++) {
2564 g_variant_builder_add(builder, "y", m_data->data[i]);
2567 val = g_variant_new("(ay)", builder);
2569 result = g_dbus_proxy_call_sync(proxy,
2570 "SetManufacturerData",
2572 G_DBUS_CALL_FLAGS_NONE,
2576 g_variant_builder_unref(builder);
2578 if (error != NULL) {
2579 BT_ERR("Failed to SetManufacturerData (Error: %s)", error->message);
2580 g_clear_error(&error);
2582 BT_ERR("Failed to SetManufacturerData");
2584 return BLUETOOTH_ERROR_INTERNAL;
2586 builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
2588 for (i = 0; i < (m_data->data_len) + 2; i++) {
2589 g_variant_builder_add(builder, "y", m_data->data[i]);
2592 val = g_variant_new("(ay)", builder);
2594 _bt_send_event(BT_ADAPTER_EVENT,
2595 BLUETOOTH_EVENT_MANUFACTURER_DATA_CHANGED,
2598 BT_INFO("Set manufacturer data");
2600 g_variant_builder_unref(builder);
2601 g_variant_unref(result);
2603 return BLUETOOTH_ERROR_NONE;
2607 int _bt_get_enable_timer_id(void)