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);
374 while (g_variant_iter_loop(char_value_iter, "y", &char_value))
375 g_byte_array_append(manufacturer_data, &char_value, 1);
377 g_variant_iter_free(char_value_iter);
379 if (manufacturer_data) {
380 if (manufacturer_data->len > 0) {
381 memcpy(dev_info->manufacturer_data.data, manufacturer_data->data,
382 manufacturer_data->len);
387 g_variant_iter_free(property_iter);
389 BT_DBG("trust: %d, paired: %d", trust, paired);
391 g_variant_unref(result);
393 if ((paired == FALSE) && (trust == FALSE)) {
394 return BLUETOOTH_ERROR_NOT_PAIRED;
397 _bt_convert_addr_string_to_type(dev_info->device_address.addr,
400 _bt_divide_device_class(&dev_info->device_class, cod);
402 g_strlcpy(dev_info->device_name.name, name,
403 BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
405 dev_info->rssi = rssi;
406 dev_info->trust = trust;
407 dev_info->paired = paired;
408 dev_info->connected = connected;
409 ret = BLUETOOTH_ERROR_NONE;
414 void _bt_set_discovery_status(gboolean mode)
416 is_discovering = mode;
419 void _bt_set_cancel_by_user(gboolean value)
421 cancel_by_user = value;
424 gboolean _bt_get_cancel_by_user(void)
426 return cancel_by_user;
429 void _bt_adapter_set_status(bt_status_t status)
431 BT_INFO("adapter_status changed [%d] -> [%d]", adapter_status, status);
432 adapter_status = status;
435 bt_status_t _bt_adapter_get_status(void)
437 return adapter_status;
440 void _bt_adapter_set_le_status(bt_le_status_t status)
442 BT_INFO("adapter_le_status changed [%d] -> [%d]", adapter_le_status, status);
443 adapter_le_status = status;
446 bt_le_status_t _bt_adapter_get_le_status(void)
448 return adapter_le_status;
451 static void __bt_phone_name_changed_cb(keynode_t *node, void *data)
453 char *phone_name = NULL;
459 if (vconf_keynode_get_type(node) == VCONF_TYPE_STRING) {
460 phone_name = vconf_keynode_get_str(node);
462 if (phone_name && strlen(phone_name) != 0) {
463 if (!g_utf8_validate(phone_name, -1,
464 (const char **)&ptr))
467 _bt_set_local_name(phone_name);
473 static void __bt_set_visible_mode(void)
477 if (vconf_get_int(BT_FILE_VISIBLE_TIME, &timeout) != 0)
478 BT_ERR("Fail to get the timeout value");
480 #ifdef TIZEN_DPM_ENABLE
482 _bt_dpm_get_bluetooth_limited_discoverable_state() == DPM_RESTRICTED) {
483 if (_bt_set_discoverable_mode(
484 BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,
485 timeout) != BLUETOOTH_ERROR_NONE) {
486 if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
487 BT_ERR("Set vconf failed");
490 if (_bt_set_discoverable_mode(
491 BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE,
492 timeout) != BLUETOOTH_ERROR_NONE) {
493 BT_ERR("Set connectable mode failed");
498 if (_bt_set_discoverable_mode(
499 BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE,
500 timeout) != BLUETOOTH_ERROR_NONE) {
501 if (vconf_set_int(BT_FILE_VISIBLE_TIME, 0) != 0)
502 BT_ERR("Set vconf failed");
505 if (_bt_set_discoverable_mode(
506 BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE,
507 timeout) != BLUETOOTH_ERROR_NONE) {
508 BT_ERR("Set connectable mode failed");
515 static void __bt_set_local_name(void)
517 char *phone_name = NULL;
520 phone_name = vconf_get_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR);
525 if (strlen(phone_name) != 0) {
526 if (!g_utf8_validate(phone_name, -1, (const char **)&ptr))
529 _bt_set_local_name(phone_name);
534 static int __bt_set_enabled(void)
537 int adapter_status = BT_ADAPTER_DISABLED;
538 int result = BLUETOOTH_ERROR_NONE;
540 _bt_check_adapter(&adapter_status);
542 if (adapter_status == BT_ADAPTER_DISABLED) {
543 BT_ERR("Bluetoothd is not running");
544 return BLUETOOTH_ERROR_INTERNAL;
548 __bt_set_visible_mode();
551 if (_bt_set_discoverable_mode(
552 BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE, 0) != BLUETOOTH_ERROR_NONE)
553 BT_ERR("Fail to set discoverable mode");
556 __bt_set_local_name();
558 /* Update Bluetooth Status to notify other modules */
559 if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_ON) != 0)
560 BT_ERR("Set vconf failed\n");
562 if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0)
563 BT_ERR("Set vconf failed\n");
565 if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
566 EVT_VAL_BT_ON) != ES_R_OK)
567 BT_ERR("Fail to set value");
570 /* Send enabled event to API */
571 _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_ENABLED,
572 g_variant_new("(i)", result));
575 return BLUETOOTH_ERROR_NONE;
578 void _bt_set_disabled(int result)
580 int power_off_status = 0;
583 int pm_ignore_mode = 0;
585 ret = vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &power_off_status);
586 BT_DBG("ret : %d, power_off_status : %d", ret, power_off_status);
588 ret_pm_ignore = vconf_get_int(VCONFKEY_PM_KEY_IGNORE, &pm_ignore_mode);
590 /* Update the vconf BT status in normal Deactivation case only */
591 if (ret == 0 && power_off_status == VCONFKEY_SYSMAN_POWER_OFF_NONE &&
592 ret_pm_ignore == 0 && pm_ignore_mode != VCONFKEY_PM_KEY_LOCK) {
594 BT_DBG("Update vconf for BT normal Deactivation");
596 if (result == BLUETOOTH_ERROR_TIMEOUT)
597 if (vconf_set_int(BT_OFF_DUE_TO_TIMEOUT, 1) != 0)
598 BT_ERR("Set vconf failed");
600 /* Update Bluetooth Status to notify other modules */
601 if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
602 BT_ERR("Set vconf failed");
604 if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_STATE,
605 EVT_VAL_BT_OFF) != ES_R_OK)
606 BT_ERR("Fail to set value");
609 if (vconf_set_int(VCONFKEY_BT_DEVICE, VCONFKEY_BT_DEVICE_NONE) != 0)
610 BT_ERR("Set vconf failed\n");
612 _bt_adapter_set_status(BT_DEACTIVATED);
614 if (_bt_adapter_get_le_status() != BT_LE_DEACTIVATED) {
615 /* Send disabled event */
616 _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_DISABLED,
617 g_variant_new("(i)", result));
620 BT_INFO("Adapter disabled");
623 static int __bt_set_le_enabled(void)
626 int result = BLUETOOTH_ERROR_NONE;
629 __bt_set_local_name();
631 /* Update Bluetooth Status to notify other modules */
632 if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_ON) != 0)
633 BT_ERR("Set vconf failed\n");
635 if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
636 EVT_VAL_BT_LE_ON) != ES_R_OK)
637 BT_ERR("Fail to set value");
639 /* Send enabled event to API */
641 _bt_send_event(BT_ADAPTER_EVENT, BLUETOOTH_EVENT_ENABLED,
642 DBUS_TYPE_INT32, &result, DBUS_TYPE_INVALID);
644 status = _bt_adapter_get_status();
645 if (status == BT_DEACTIVATED) {
646 BT_INFO("BREDR is off, turn off PSCAN");
647 _bt_set_connectable(FALSE);
649 if (le_timer_id > 0) {
650 g_source_remove(le_timer_id);
654 /* Send enabled event to API */
655 _bt_send_event(BT_LE_ADAPTER_EVENT, BLUETOOTH_EVENT_LE_ENABLED,
656 g_variant_new("(i)", result));
659 return BLUETOOTH_ERROR_NONE;
662 void _bt_set_le_disabled(int result)
664 int power_off_status;
667 ret = vconf_get_int(VCONFKEY_SYSMAN_POWER_OFF_STATUS, &power_off_status);
668 BT_DBG("ret : %d", ret);
669 BT_DBG("power_off_status : %d", power_off_status);
671 /* Update Bluetooth Status to notify other modules */
672 BT_DBG("Update vconf for BT LE normal Deactivation");
673 if (vconf_set_int(VCONFKEY_BT_LE_STATUS, VCONFKEY_BT_LE_STATUS_OFF) != 0)
674 BT_ERR("Set vconf failed\n");
675 _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
677 if (_bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_LE_STATE,
678 EVT_VAL_BT_LE_OFF) != ES_R_OK)
679 BT_ERR("Fail to set value");
681 /* Send disabled event */
682 _bt_send_event(BT_LE_ADAPTER_EVENT, BLUETOOTH_EVENT_LE_DISABLED,
683 g_variant_new_int32(result));
686 void *_bt_get_adapter_agent(void)
688 return adapter_agent;
691 int _bt_enable_core(void)
695 GError *error = NULL;
697 proxy = __bt_get_core_proxy();
698 retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
700 /* Clean up the process */
701 result = g_dbus_proxy_call_sync(proxy,
704 G_DBUS_CALL_FLAGS_NONE,
711 BT_ERR("Bt core call failed(Error: %s)", error->message);
712 g_clear_error(&error);
714 BT_ERR("Bt core call failed");
715 return BLUETOOTH_ERROR_INTERNAL;
718 g_variant_unref(result);
719 return BLUETOOTH_ERROR_NONE;
722 #if defined(TIZEN_TELEPHONY_ENABLED) || (!defined(TIZEN_WEARABLE) && defined(ENABLE_TIZEN_2_4))
723 static void __bt_service_flight_ps_mode_cb(keynode_t *node, void *data)
725 gboolean flight_mode = FALSE;
726 int power_saving_mode = 0;
729 DBG_SECURE("key=%s", vconf_keynode_get_name(node));
730 type = vconf_keynode_get_type(node);
731 if (type == VCONF_TYPE_BOOL) {
732 flight_mode = vconf_keynode_get_bool(node);
733 if (flight_mode != TRUE) {
734 BT_ERR("Ignore the event");
737 } else if (type == VCONF_TYPE_INT) {
738 power_saving_mode = vconf_keynode_get_int(node);
739 if (power_saving_mode != 2) {
740 BT_ERR("Ignore the event");
744 BT_ERR("Invaild vconf key type : %d", type);
752 void _bt_service_register_vconf_handler(void)
756 #ifdef TIZEN_TELEPHONY_ENABLED
757 if (vconf_notify_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
758 (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
759 BT_ERR("Unable to register key handler");
761 BT_DBG("Telephony is disabled");
764 #ifndef TIZEN_WEARABLE
765 #ifdef ENABLE_TIZEN_2_4
766 if (vconf_notify_key_changed(VCONFKEY_SETAPPL_PSMODE,
767 (vconf_callback_fn)__bt_service_flight_ps_mode_cb, NULL) < 0)
768 BT_ERR("Unable to register key handler");
773 void _bt_service_unregister_vconf_handler(void)
777 #ifdef TIZEN_TELEPHONY_ENABLED
778 vconf_ignore_key_changed(VCONFKEY_TELEPHONY_FLIGHT_MODE,
779 (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
782 #ifndef TIZEN_WEARABLE
783 #ifdef ENABLE_TIZEN_2_4
784 vconf_ignore_key_changed(VCONFKEY_SETAPPL_PSMODE,
785 (vconf_callback_fn)__bt_service_flight_ps_mode_cb);
790 static void __bt_state_event_handler(const char *event_name, bundle *data, void *user_data)
792 #ifdef ENABLE_TIZEN_2_4
793 const char *bt_status = NULL;
794 const char *bt_le_status = NULL;
795 BT_DBG("bt state set event(%s) received", event_name);
796 bt_status = bundle_get_val(data, EVT_KEY_BT_STATE);
797 BT_DBG("bt_state: (%s)", bt_status);
799 bt_le_status = bundle_get_val(data, EVT_KEY_BT_LE_STATE);
800 BT_DBG("bt_state: (%s)", bt_le_status);
804 void _bt_handle_adapter_added(void)
808 bt_le_status_t le_status;
812 BT_DBG("g_source is removed");
813 g_source_remove(timer_id);
817 status = _bt_adapter_get_status();
818 le_status = _bt_adapter_get_le_status();
819 BT_DBG("status : %d", status);
820 BT_DBG("le_status : %d", le_status);
822 adapter_agent = _bt_create_agent(BT_ADAPTER_AGENT_PATH, TRUE);
823 if (!adapter_agent) {
824 BT_ERR("Fail to register agent");
828 if (_bt_register_media_player() != BLUETOOTH_ERROR_NONE)
829 BT_ERR("Fail to register media player");
831 if (_bt_register_obex_server() != BLUETOOTH_ERROR_NONE)
832 BT_ERR("Fail to init obex server");
834 #ifdef TIZEN_BT_PAN_NAP_ENABLE
835 if (_bt_network_activate() != BLUETOOTH_ERROR_NONE)
836 BT_ERR("Fail to activate network");
839 /* add the vconf noti handler */
840 ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR,
841 __bt_phone_name_changed_cb, NULL);
843 BT_ERR("Unable to register key handler");
845 if (le_status == BT_LE_ACTIVATING ||
846 status == BT_ACTIVATING) {
847 __bt_set_le_enabled();
848 _bt_adapter_set_le_status(BT_LE_ACTIVATED);
851 if (status == BT_ACTIVATING) {
853 _bt_adapter_set_status(BT_ACTIVATED);
855 #ifdef ENABLE_TIZEN_2_4
859 _bt_service_register_vconf_handler();
862 if (eventsystem_register_event(SYS_EVENT_BT_STATE, &status_reg_id,
863 (eventsystem_handler)__bt_state_event_handler, NULL) != ES_R_OK) {
864 BT_ERR("Fail to register system event");
868 void _bt_handle_adapter_removed(void)
872 _bt_adapter_set_status(BT_DEACTIVATED);
873 #ifdef ENABLE_TIZEN_2_4
877 __bt_visibility_alarm_remove();
879 if (visible_timer.alarm_init) {
881 visible_timer.alarm_init = FALSE;
884 ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEVICE_NAME_STR,
885 (vconf_callback_fn)__bt_phone_name_changed_cb);
887 ERR("vconf_ignore_key_changed failed\n");
890 _bt_destroy_agent(adapter_agent);
891 adapter_agent = NULL;
893 _bt_reliable_terminate_service(NULL);
895 if (eventsystem_unregister_event(status_reg_id) != ES_R_OK) {
896 BT_ERR("Fail to unregister system event");
901 static gboolean __bt_enable_timeout_cb(gpointer user_data)
905 GError *error = NULL;
909 retv_if(_bt_adapter_get_status() == BT_ACTIVATED, FALSE);
911 BT_ERR("EnableAdapter is failed");
913 proxy = __bt_get_core_proxy();
917 /* Clean up the process */
918 result = g_dbus_proxy_call_sync(proxy,
921 G_DBUS_CALL_FLAGS_NONE,
928 BT_ERR("Bt core call failed(Error: %s)", error->message);
929 g_clear_error(&error);
931 BT_ERR("Bt core call failed");
936 g_variant_unref(result);
937 _bt_set_disabled(BLUETOOTH_ERROR_TIMEOUT);
939 _bt_terminate_service(NULL);
944 static gboolean __bt_enable_le_timeout_cb(gpointer user_data)
948 GError *error = NULL;
952 retv_if(_bt_adapter_get_le_status() == BT_LE_ACTIVATED, FALSE);
954 BT_ERR("EnableAdapterLE is failed");
956 proxy = __bt_get_core_proxy();
960 /* Clean up the process */
961 result = g_dbus_proxy_call_sync(proxy,
964 G_DBUS_CALL_FLAGS_NONE,
971 BT_ERR("Bt core call failed(Error: %s)", error->message);
972 g_clear_error(&error);
974 BT_ERR("Bt core call failed");
978 g_variant_unref(result);
979 _bt_adapter_set_le_status(BT_LE_DEACTIVATED);
981 _bt_set_le_disabled(BLUETOOTH_ERROR_TIMEOUT);
983 if (_bt_adapter_get_status() == BT_DEACTIVATED)
984 _bt_terminate_service(NULL);
989 void _bt_adapter_start_le_enable_timer(void)
991 if (le_timer_id > 0) {
992 g_source_remove(le_timer_id);
996 le_timer_id = g_timeout_add(BT_ENABLE_TIMEOUT,
997 __bt_enable_le_timeout_cb, NULL);
1002 void _bt_adapter_start_enable_timer(void)
1005 g_source_remove(timer_id);
1009 timer_id = g_timeout_add(BT_ENABLE_TIMEOUT,
1010 __bt_enable_timeout_cb, NULL);
1016 static gboolean __bt_adapter_enabled_cb(gpointer user_data)
1021 _bt_adapter_set_status(BT_ACTIVATED);
1027 int _bt_enable_adapter(void)
1030 GError *error = NULL;
1032 GVariant *result = NULL;
1033 bt_status_t status = _bt_adapter_get_status();
1034 bt_le_status_t le_status = _bt_adapter_get_le_status();
1038 if (status == BT_ACTIVATING) {
1039 BT_ERR("Enabling in progress");
1040 return BLUETOOTH_ERROR_IN_PROGRESS;
1043 if (status == BT_ACTIVATED) {
1044 BT_ERR("Already enabled");
1045 return BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
1048 if (status == BT_DEACTIVATING || le_status == BT_LE_DEACTIVATING) {
1049 BT_ERR("Disabling in progress");
1050 return BLUETOOTH_ERROR_DEVICE_BUSY;
1053 _bt_adapter_set_status(BT_ACTIVATING);
1057 int adapter_status = BT_ADAPTER_DISABLED;
1059 if (vconf_set_int(VCONFKEY_BT_STATUS, VCONFKEY_BT_STATUS_OFF) != 0)
1060 BT_ERR("Set vconf failed");
1062 _bt_check_adapter(&adapter_status);
1063 if (adapter_status == BT_ADAPTER_ENABLED) {
1064 g_idle_add(__bt_adapter_enabled_cb, NULL);
1065 _bt_adapter_start_enable_timer();
1066 return BLUETOOTH_ERROR_NONE;
1071 proxy = __bt_get_core_proxy();
1073 return BLUETOOTH_ERROR_INTERNAL;
1075 if (le_status == BT_LE_ACTIVATED) {
1076 BT_INFO("LE Already enabled. Just turn on PSCAN");
1077 ret = _bt_set_connectable(TRUE);
1078 if (ret == BLUETOOTH_ERROR_NONE) {
1079 _bt_adapter_set_status(BT_ACTIVATED);
1081 return BLUETOOTH_ERROR_INTERNAL;
1085 result = g_dbus_proxy_call_sync(proxy, "EnableAdapter",
1087 G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
1090 BT_ERR("EnableAdapterLe failed: %s", error->message);
1091 _bt_adapter_set_status(BT_DEACTIVATED);
1092 g_clear_error(&error);
1094 result = g_dbus_proxy_call_sync(proxy,
1097 G_DBUS_CALL_FLAGS_NONE,
1102 if (error != NULL) {
1103 BT_ERR("Bt core call failed(Error: %s)", error->message);
1104 g_clear_error(&error);
1106 g_variant_unref(result);
1107 /* Terminate myself */
1108 g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
1109 return BLUETOOTH_ERROR_INTERNAL;
1111 g_variant_unref(result);
1112 if (le_status == BT_LE_ACTIVATED) {
1115 _bt_adapter_start_enable_timer();
1118 return BLUETOOTH_ERROR_NONE;
1121 static gboolean __bt_disconnect_all(void)
1124 GDBusConnection *conn;
1125 GDBusProxy *dev_proxy;
1126 gboolean ret = FALSE;
1128 GError *error = NULL;
1129 GArray *device_list;
1130 bluetooth_device_info_t info;
1132 char *device_path = NULL;
1133 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
1138 conn = _bt_get_system_gconn();
1140 device_list = g_array_new(FALSE, FALSE, sizeof(gchar));
1142 if (_bt_get_bonded_devices(&device_list)
1143 != BLUETOOTH_ERROR_NONE) {
1144 g_array_free(device_list, TRUE);
1148 size = (device_list->len) / sizeof(bluetooth_device_info_t);
1150 for (i = 0; i < size; i++) {
1152 info = g_array_index(device_list,
1153 bluetooth_device_info_t, i);
1155 if (info.connected != BLUETOOTH_CONNECTED_LINK_NONE) {
1156 BT_DBG("Found Connected device");
1157 _bt_convert_addr_type_to_string(address, info.device_address.addr);
1158 device_path = _bt_get_device_object_path(address);
1159 if (device_path == NULL)
1162 BT_DBG("Disconnecting : %s", device_path);
1164 dev_proxy = g_dbus_proxy_new_sync(conn, G_DBUS_PROXY_FLAGS_NONE,
1168 BT_DEVICE_INTERFACE,
1171 if (dev_proxy == NULL)
1174 result = g_dbus_proxy_call_sync(dev_proxy,
1177 G_DBUS_CALL_FLAGS_NONE,
1183 if (error != NULL) {
1184 BT_ERR("Disconnect call failed(Error: %s)", error->message);
1185 g_clear_error(&error);
1187 BT_ERR("Disconnect call failed");
1188 g_object_unref(dev_proxy);
1192 g_variant_unref(result);
1193 g_object_unref(dev_proxy);
1197 g_array_free(device_list, TRUE);
1202 static gboolean __bt_set_disabled_timeout_cb(gpointer user_data)
1205 _bt_set_disabled(BLUETOOTH_ERROR_NONE);
1210 int __bt_disable_cb(void)
1214 bt_le_status_t le_status;
1217 GError *error = NULL;
1219 _bt_adapter_set_status(BT_DEACTIVATING);
1220 le_status = _bt_adapter_get_le_status();
1221 BT_DBG("le_status : %d", le_status);
1222 if (le_status == BT_LE_ACTIVATED) {
1223 BT_INFO("LE is enabled. Just turn off PSCAN");
1225 if (_bt_is_discovering())
1226 _bt_cancel_discovery();
1228 if (_bt_is_connectable() == FALSE) {
1229 g_timeout_add(100, (GSourceFunc)__bt_set_disabled_timeout_cb, NULL);
1231 ret = _bt_set_connectable(FALSE);
1232 if (ret != BLUETOOTH_ERROR_NONE) {
1233 BT_ERR("_bt_set_connectable fail!");
1234 _bt_adapter_set_status(BT_ACTIVATED);
1235 return BLUETOOTH_ERROR_INTERNAL;
1240 proxy = __bt_get_core_proxy();
1241 retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
1243 result = g_dbus_proxy_call_sync(proxy,
1246 G_DBUS_CALL_FLAGS_NONE,
1252 if (error != NULL) {
1253 BT_ERR("Failed to DisableAdapter (Error: %s)", error->message);
1254 g_clear_error(&error);
1256 BT_ERR("Failed to DisableAdapter");
1257 _bt_adapter_set_status(BT_ACTIVATED);
1258 return BLUETOOTH_ERROR_INTERNAL;
1261 g_variant_unref(result);
1262 return BLUETOOTH_ERROR_NONE;
1265 int _bt_disable_adapter(void)
1270 if (_bt_adapter_get_status() == BT_DEACTIVATING) {
1271 BT_DBG("Disabling in progress");
1272 return BLUETOOTH_ERROR_IN_PROGRESS;
1275 if (_bt_adapter_get_status() == BT_DEACTIVATED) {
1276 BT_DBG("Already disabled");
1277 return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
1281 g_source_remove(timer_id);
1285 __bt_disconnect_all();
1286 ret = __bt_disable_cb();
1292 int _bt_recover_adapter(void)
1297 GError *error = NULL;
1299 if (_bt_adapter_get_status() == BT_DEACTIVATING) {
1300 BT_DBG("Disabling in progress");
1301 return BLUETOOTH_ERROR_IN_PROGRESS;
1304 if (_bt_adapter_get_status() == BT_DEACTIVATED) {
1305 BT_DBG("Already disabled");
1306 return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
1309 _bt_adapter_set_status(BT_DEACTIVATING);
1311 proxy = __bt_get_core_proxy();
1312 retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
1314 result = g_dbus_proxy_call_sync(proxy,
1317 G_DBUS_CALL_FLAGS_NONE,
1323 if (error != NULL) {
1324 BT_ERR("Failed to RecoverAdapter (Error: %s)", error->message);
1325 g_clear_error(&error);
1327 BT_ERR("Failed to RecoverAdapter");
1328 return BLUETOOTH_ERROR_INTERNAL;
1331 g_variant_unref(result);
1332 __bt_disconnect_all();
1335 return BLUETOOTH_ERROR_NONE;
1338 int _bt_reset_adapter(void)
1342 GError *error = NULL;
1346 proxy = __bt_get_core_proxy();
1348 return BLUETOOTH_ERROR_INTERNAL;
1350 result = g_dbus_proxy_call_sync(proxy,
1353 G_DBUS_CALL_FLAGS_NONE,
1359 if (error != NULL) {
1360 BT_ERR("Failed to ResetAdapter (Error: %s)", error->message);
1361 g_clear_error(&error);
1363 BT_ERR("Failed to ResetAdapter");
1364 return BLUETOOTH_ERROR_INTERNAL;
1367 g_variant_unref(result);
1368 /* Terminate myself */
1369 if (_bt_adapter_get_status() == BT_DEACTIVATED) {
1370 g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
1373 return BLUETOOTH_ERROR_NONE;
1377 int _bt_check_adapter(int *status)
1380 char *adapter_path = NULL;
1382 BT_CHECK_PARAMETER(status, return);
1384 *status = BT_ADAPTER_DISABLED;
1386 adapter_path = _bt_get_adapter_path();
1389 if (adapter_path != NULL)
1390 *status = BT_ADAPTER_ENABLED;
1392 g_free(adapter_path);
1393 return BLUETOOTH_ERROR_NONE;
1396 int _bt_check_adapter(int *status)
1399 GError *error = NULL;
1402 gboolean powered = FALSE;
1404 BT_CHECK_PARAMETER(status, return);
1406 *status = BT_ADAPTER_DISABLED;
1408 proxy = _bt_get_adapter_properties_proxy();
1409 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1411 result = g_dbus_proxy_call_sync(proxy,
1413 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1415 G_DBUS_CALL_FLAGS_NONE,
1421 BT_ERR("Failed to get local address");
1422 if (error != NULL) {
1423 BT_ERR("Failed to get local address (Error: %s)", error->message);
1424 g_clear_error(&error);
1426 return BLUETOOTH_ERROR_INTERNAL;
1429 g_variant_get(result, "(v)", &temp);
1430 powered = g_variant_get_boolean(temp);
1431 BT_DBG("powered: %d", powered);
1434 *status = BT_ADAPTER_ENABLED;
1436 g_variant_unref(result);
1437 g_variant_unref(temp);
1438 return BLUETOOTH_ERROR_NONE;
1442 int _bt_enable_adapter_le(void)
1446 GError *error = NULL;
1447 bt_status_t status = _bt_adapter_get_status();
1448 bt_le_status_t le_status = _bt_adapter_get_le_status();
1451 if (le_status == BT_LE_ACTIVATING) {
1452 BT_ERR("Enabling in progress");
1453 return BLUETOOTH_ERROR_IN_PROGRESS;
1456 if (le_status == BT_LE_ACTIVATED) {
1457 BT_ERR("Already enabled");
1458 return BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
1461 if (status == BT_DEACTIVATING || le_status == BT_LE_DEACTIVATING) {
1462 BT_ERR("Disabling in progress");
1463 return BLUETOOTH_ERROR_DEVICE_BUSY;
1466 _bt_adapter_set_le_status(BT_LE_ACTIVATING);
1468 proxy = __bt_get_core_proxy();
1469 retv_if(!proxy, BLUETOOTH_ERROR_INTERNAL);
1471 result = g_dbus_proxy_call_sync(proxy, "EnableAdapterLe",
1473 G_DBUS_CALL_FLAGS_NONE, BT_ENABLE_TIMEOUT,
1476 BT_ERR("EnableAdapterLe failed: %s", error->message);
1477 _bt_adapter_set_le_status(BT_DEACTIVATED);
1478 g_clear_error(&error);
1480 /* Clean up the process */
1481 result = g_dbus_proxy_call_sync(proxy,
1484 G_DBUS_CALL_FLAGS_NONE,
1490 BT_ERR("Bt core call failed");
1492 BT_ERR("EnableAdapterLE Failed %s", error->message);
1493 g_clear_error(&error);
1496 g_variant_unref(result);
1497 /* Terminate myself */
1498 if (_bt_adapter_get_status() == BT_DEACTIVATED)
1499 g_idle_add((GSourceFunc)_bt_terminate_service, NULL);
1500 return BLUETOOTH_ERROR_INTERNAL;
1504 g_variant_unref(result);
1506 _bt_adapter_start_le_enable_timer();
1508 if (status == BT_ACTIVATED) {
1509 _bt_adapter_set_le_status(BT_LE_ACTIVATED);
1510 __bt_set_le_enabled();
1512 BT_DBG("le status : %d", _bt_adapter_get_le_status());
1514 return BLUETOOTH_ERROR_NONE;
1517 int _bt_disable_adapter_le(void)
1521 bt_le_status_t bt_le_state;
1523 GError *error = NULL;
1525 bt_le_state = _bt_adapter_get_le_status();
1526 if (bt_le_state == BT_LE_DEACTIVATING) {
1527 BT_DBG("Disabling in progress");
1528 return BLUETOOTH_ERROR_IN_PROGRESS;
1531 if (bt_le_state == BT_LE_DEACTIVATED) {
1532 BT_DBG("Already disabled");
1533 return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
1536 _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
1538 proxy = __bt_get_core_proxy();
1540 return BLUETOOTH_ERROR_INTERNAL;
1542 result = g_dbus_proxy_call_sync(proxy,
1545 G_DBUS_CALL_FLAGS_NONE,
1551 if (error != NULL) {
1552 BT_ERR("Bt core call failed (Error: %s)", error->message);
1553 g_clear_error(&error);
1555 BT_ERR("Bt core call failed");
1556 _bt_adapter_set_le_status(BT_LE_ACTIVATED);
1557 return BLUETOOTH_ERROR_INTERNAL;
1560 g_variant_unref(result);
1561 _bt_set_le_disabled(BLUETOOTH_ERROR_NONE);
1562 BT_DBG("le status : %d", _bt_adapter_get_le_status());
1564 return BLUETOOTH_ERROR_NONE;
1567 int _bt_get_local_address(bluetooth_device_address_t *local_address)
1571 GError *error = NULL;
1572 const char *address;
1576 BT_CHECK_PARAMETER(local_address, return);
1578 proxy = _bt_get_adapter_properties_proxy();
1579 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1581 result = g_dbus_proxy_call_sync(proxy,
1583 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1585 G_DBUS_CALL_FLAGS_NONE,
1591 BT_ERR("Failed to get local address");
1592 if (error != NULL) {
1593 BT_ERR("Failed to get local address (Error: %s)", error->message);
1594 g_clear_error(&error);
1596 return BLUETOOTH_ERROR_INTERNAL;
1599 g_variant_get(result, "(v)", &temp);
1600 address = g_variant_get_string(temp, NULL);
1601 BT_DBG("Address:%s", address);
1604 _bt_convert_addr_string_to_type(local_address->addr, address);
1606 return BLUETOOTH_ERROR_INTERNAL;
1609 g_variant_unref(result);
1610 g_variant_unref(temp);
1611 return BLUETOOTH_ERROR_NONE;
1614 int _bt_get_local_version(bluetooth_version_t *local_version)
1617 const char *ver = NULL;
1619 int ret = BLUETOOTH_ERROR_NONE;
1623 BT_CHECK_PARAMETER(local_version, return);
1625 GError *error = NULL;
1627 proxy = _bt_get_adapter_properties_proxy();
1628 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1630 result = g_dbus_proxy_call_sync(proxy,
1632 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1634 G_DBUS_CALL_FLAGS_NONE,
1640 if (error != NULL) {
1641 BT_ERR("Failed to get local version (Error: %s)", error->message);
1642 g_clear_error(&error);
1644 BT_ERR("Failed to get local version");
1645 return BLUETOOTH_ERROR_INTERNAL;
1648 g_variant_get(result, "(v)", &temp);
1649 ver = g_variant_get_string(temp, NULL);
1650 BT_DBG("VERSION: %s", ver);
1652 if (ver && (strlen(ver) > 0)) {
1653 /* Check the utf8 valitation & Fill the NULL in the invalid location*/
1654 if (!g_utf8_validate(ver, -1, (const char **)&ptr))
1657 g_strlcpy(local_version->version, ver,
1658 BLUETOOTH_VERSION_LENGTH_MAX + 1);
1661 ret = BLUETOOTH_ERROR_INTERNAL;
1664 g_variant_unref(result);
1665 g_variant_unref(temp);
1669 int _bt_get_local_name(bluetooth_device_name_t *local_name)
1672 const char *name = NULL;
1674 int ret = BLUETOOTH_ERROR_NONE;
1677 GError *error = NULL;
1679 BT_CHECK_PARAMETER(local_name, return);
1681 proxy = _bt_get_adapter_properties_proxy();
1682 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1684 result = g_dbus_proxy_call_sync(proxy,
1686 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1688 G_DBUS_CALL_FLAGS_NONE,
1694 if (error != NULL) {
1695 BT_ERR("Failed to get local name (Error: %s)", error->message);
1696 g_clear_error(&error);
1698 BT_ERR("Failed to get local name");
1699 return BLUETOOTH_ERROR_INTERNAL;
1702 g_variant_get(result, "(v)", &temp);
1703 name = g_variant_get_string(temp, NULL);
1704 BT_DBG("LOCAL NAME:%s", name);
1706 if (name && (strlen(name) > 0)) {
1707 /* Check the utf8 valitation & Fill the NULL in the invalid location*/
1708 if (!g_utf8_validate(name, -1, (const char **)&ptr))
1711 g_strlcpy(local_name->name, name,
1712 BLUETOOTH_DEVICE_NAME_LENGTH_MAX + 1);
1714 ret = BLUETOOTH_ERROR_INTERNAL;
1716 g_variant_unref(result);
1717 g_variant_unref(temp);
1721 int _bt_set_local_name(char *local_name)
1724 GError *error = NULL;
1728 BT_CHECK_PARAMETER(local_name, return);
1730 proxy = _bt_get_adapter_properties_proxy();
1732 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1734 if (!g_utf8_validate(local_name, -1, (const char **)&ptr))
1737 result = g_dbus_proxy_call_sync(proxy,
1739 g_variant_new("(ssv)", BT_ADAPTER_INTERFACE,
1740 "Alias", g_variant_new("s", local_name)),
1741 G_DBUS_CALL_FLAGS_NONE,
1747 if (error != NULL) {
1748 BT_ERR("Failed to set Alias (Error: %s)", error->message);
1749 g_clear_error(&error);
1751 BT_ERR("Failed to set Alias");
1752 return BLUETOOTH_ERROR_INTERNAL;
1755 g_variant_unref(result);
1756 return BLUETOOTH_ERROR_NONE;
1759 int _bt_is_service_used(char *service_uuid, gboolean *used)
1762 GError *error = NULL;
1763 int ret = BLUETOOTH_ERROR_NONE;
1766 GVariantIter *iter = NULL;
1770 BT_CHECK_PARAMETER(service_uuid, return);
1771 BT_CHECK_PARAMETER(used, return);
1773 proxy = _bt_get_adapter_properties_proxy();
1774 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1776 result = g_dbus_proxy_call_sync(proxy,
1778 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1780 G_DBUS_CALL_FLAGS_NONE,
1786 if (error != NULL) {
1787 BT_ERR("Failed to get UUIDs (Error: %s)", error->message);
1788 g_clear_error(&error);
1790 BT_ERR("Failed to get UUIDs");
1791 return BLUETOOTH_ERROR_INTERNAL;
1794 g_variant_get(result, "(v)", &value);
1795 g_variant_get(value, "as", &iter);
1797 BT_ERR("Failed to get UUIDs(%s)", service_uuid);
1799 g_variant_unref(result);
1800 g_variant_unref(value);
1804 while (g_variant_iter_loop(iter, "s", &uuid)) {
1805 if (strcasecmp(uuid, service_uuid) == 0) {
1815 g_variant_iter_free(iter);
1816 g_variant_unref(value);
1817 g_variant_unref(result);
1818 BT_DBG("Service Used? %d", *used);
1822 static gboolean __bt_get_discoverable_property(void)
1825 gboolean discoverable_v;
1826 GError *error = NULL;
1830 proxy = _bt_get_adapter_properties_proxy();
1831 retv_if(proxy == NULL, FALSE);
1833 result = g_dbus_proxy_call_sync(proxy,
1835 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
1837 G_DBUS_CALL_FLAGS_NONE,
1843 if (error != NULL) {
1844 BT_ERR("Failed to get Discoverable property (Error: %s)", error->message);
1845 g_clear_error(&error);
1847 BT_ERR("Failed to get Discoverable property");
1848 return BLUETOOTH_ERROR_INTERNAL;
1851 g_variant_get(result, "(v)", &temp);
1852 discoverable_v = g_variant_get_boolean(temp);
1853 BT_DBG("discoverable_v:%d", discoverable_v);
1855 g_variant_unref(result);
1856 g_variant_unref(temp);
1858 return discoverable_v;
1861 int _bt_get_discoverable_mode(int *mode)
1863 gboolean discoverable;
1864 unsigned int timeout;
1866 BT_CHECK_PARAMETER(mode, return);
1868 discoverable = __bt_get_discoverable_property();
1869 timeout = _bt_get_discoverable_timeout_property();
1871 if (discoverable == TRUE) {
1873 *mode = BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE;
1875 *mode = BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE;
1877 *mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
1879 return BLUETOOTH_ERROR_NONE;
1883 int _bt_set_discoverable_mode(int discoverable_mode, int timeout)
1885 int ret = BLUETOOTH_ERROR_NONE;
1888 GError *error = NULL;
1892 proxy = _bt_get_adapter_properties_proxy();
1894 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
1896 #ifdef TIZEN_DPM_ENABLE
1897 if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE &&
1898 _bt_dpm_get_bluetooth_limited_discoverable_state() == DPM_RESTRICTED) {
1899 _bt_launch_dpm_popup("DPM_POLICY_DISABLE_BT_HANDSFREE");
1900 return BLUETOOTH_ERROR_ACCESS_DENIED;
1902 if (discoverable_mode != BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE &&
1903 _bt_dpm_get_bluetooth_limited_discoverable_state() == DPM_RESTRICTED) {
1904 _bt_launch_dpm_popup("DPM_POLICY_DISABLE_BT");
1905 return BLUETOOTH_ERROR_ACCESS_DENIED;
1909 switch (discoverable_mode) {
1910 case BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE:
1915 case BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE:
1920 case BLUETOOTH_DISCOVERABLE_MODE_TIME_LIMITED_DISCOVERABLE:
1925 return BLUETOOTH_ERROR_INVALID_PARAM;
1928 BT_INFO("Req. discoverable_mode : %d, timeout : %d",
1929 discoverable_mode, timeout);
1931 result = g_dbus_proxy_call_sync(proxy,
1933 g_variant_new("(ssv)", BT_ADAPTER_INTERFACE,
1934 "Connectable", g_variant_new("b", pg_scan)),
1935 G_DBUS_CALL_FLAGS_NONE,
1941 if (error != NULL) {
1942 BT_ERR("Failed to set connectable property (Error: %s)", error->message);
1943 g_clear_error(&error);
1945 BT_ERR("Failed to set connectable property");
1946 return BLUETOOTH_ERROR_INTERNAL;
1948 g_variant_unref(result);
1949 result = g_dbus_proxy_call_sync(proxy,
1951 g_variant_new("(ssv)", BT_ADAPTER_INTERFACE, "Discoverable",
1952 g_variant_new("b", inq_scan)),
1953 G_DBUS_CALL_FLAGS_NONE,
1959 if (error != NULL) {
1960 BT_ERR("Failed to set Discoverable property (Error: %s)", error->message);
1961 g_clear_error(&error);
1963 BT_ERR("Failed to set Discoverable property");
1964 return BLUETOOTH_ERROR_INTERNAL;
1966 g_variant_unref(result);
1967 result = g_dbus_proxy_call_sync(proxy,
1969 g_variant_new("(ssv)", BT_ADAPTER_INTERFACE,
1970 "DiscoverableTimeout", g_variant_new("u", timeout)),
1971 G_DBUS_CALL_FLAGS_NONE,
1977 if (error != NULL) {
1978 BT_ERR("Failed to set DiscoverableTimeout property (Error: %s)", error->message);
1979 g_clear_error(&error);
1981 BT_ERR("Failed to set DiscoverableTimeout property");
1982 return BLUETOOTH_ERROR_INTERNAL;
1985 if (discoverable_mode == BLUETOOTH_DISCOVERABLE_MODE_GENERAL_DISCOVERABLE)
1988 ret = __bt_set_visible_time(timeout);
1990 g_variant_unref(result);
1995 int _bt_start_discovery(void)
1998 GError *error = NULL;
2001 if (_bt_is_discovering() == TRUE) {
2002 BT_ERR("BT is already in discovering");
2003 return BLUETOOTH_ERROR_IN_PROGRESS;
2004 } else if (_bt_is_device_creating() == TRUE) {
2005 BT_ERR("Bonding device is going on");
2006 return BLUETOOTH_ERROR_DEVICE_BUSY;
2009 proxy = _bt_get_adapter_proxy();
2010 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2012 result = g_dbus_proxy_call_sync(proxy,
2015 G_DBUS_CALL_FLAGS_NONE,
2021 if (error != NULL) {
2022 BT_ERR("StartDiscovery failed (Error: %s)", error->message);
2023 g_clear_error(&error);
2025 BT_ERR("StartDiscovery failed");
2026 return BLUETOOTH_ERROR_INTERNAL;
2029 is_discovering = TRUE;
2030 cancel_by_user = FALSE;
2031 /* discovery status will be change in event */
2032 g_variant_unref(result);
2033 return BLUETOOTH_ERROR_NONE;
2036 int _bt_start_custom_discovery(bt_discovery_role_type_t role)
2040 GError *error = NULL;
2041 const gchar *disc_type;
2043 if (_bt_is_discovering() == TRUE) {
2044 BT_ERR("BT is already in discovering");
2045 return BLUETOOTH_ERROR_IN_PROGRESS;
2048 proxy = _bt_get_adapter_proxy();
2049 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2051 if (role == DISCOVERY_ROLE_BREDR)
2052 disc_type = "BREDR";
2053 else if (role == DISCOVERY_ROLE_LE)
2055 else if (role == DISCOVERY_ROLE_LE_BREDR)
2056 disc_type = "LE_BREDR";
2058 return BLUETOOTH_ERROR_INVALID_PARAM;
2060 result = g_dbus_proxy_call_sync(proxy,
2061 "StartCustomDiscovery",
2062 g_variant_new("s", disc_type),
2063 G_DBUS_CALL_FLAGS_NONE,
2069 if (error != NULL) {
2070 BT_ERR("StartCustomDiscovery failed (Error: %s)", error->message);
2071 g_clear_error(&error);
2073 BT_ERR("StartCustomDiscovery failed");
2074 return BLUETOOTH_ERROR_INTERNAL;
2077 is_discovering = TRUE;
2078 cancel_by_user = FALSE;
2079 /* discovery status will be change in event */
2080 g_variant_unref(result);
2081 return BLUETOOTH_ERROR_NONE;
2084 int _bt_cancel_discovery(void)
2087 GError *error = NULL;
2090 if (_bt_is_discovering() == FALSE) {
2091 BT_ERR("BT is not in discovering");
2092 return BLUETOOTH_ERROR_NOT_IN_OPERATION;
2095 proxy = _bt_get_adapter_proxy();
2096 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2098 result = g_dbus_proxy_call_sync(proxy,
2101 G_DBUS_CALL_FLAGS_NONE,
2107 if (error != NULL) {
2108 BT_ERR("StopDiscovery failed (Error: %s)", error->message);
2109 g_clear_error(&error);
2111 BT_ERR("StopDiscovery failed");
2112 return BLUETOOTH_ERROR_INTERNAL;
2115 cancel_by_user = TRUE;
2116 /* discovery status will be change in event */
2117 g_variant_unref(result);
2118 return BLUETOOTH_ERROR_NONE;
2121 gboolean _bt_is_discovering(void)
2123 return is_discovering;
2126 gboolean _bt_is_connectable(void)
2129 GError *error = NULL;
2130 gboolean is_connectable = FALSE;
2134 proxy = _bt_get_adapter_properties_proxy();
2135 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2137 result = g_dbus_proxy_call_sync(proxy,
2139 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
2141 G_DBUS_CALL_FLAGS_NONE,
2147 if (error != NULL) {
2148 BT_ERR("Failed to get connectable property (Error: %s)", error->message);
2149 g_clear_error(&error);
2151 BT_ERR("Failed to get connectable property");
2152 return BLUETOOTH_ERROR_INTERNAL;
2155 g_variant_get(result, "(v)", &temp);
2156 is_connectable = g_variant_get_boolean(temp);
2157 BT_DBG("discoverable_v:%d", is_connectable);
2159 g_variant_unref(result);
2160 g_variant_unref(temp);
2162 BT_INFO("Get connectable [%d]", is_connectable);
2163 return is_connectable;
2166 int _bt_set_connectable(gboolean is_connectable)
2169 GError *error = NULL;
2172 if (__bt_is_factory_test_mode()) {
2173 BT_ERR("Unable to set connectable in factory binary !!");
2174 return BLUETOOTH_ERROR_NOT_SUPPORT;
2177 proxy = _bt_get_adapter_properties_proxy();
2179 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2181 result = g_dbus_proxy_call_sync(proxy,
2183 g_variant_new("(ssv)", BT_ADAPTER_INTERFACE, "Connectable",
2184 g_variant_new("b", is_connectable)),
2185 G_DBUS_CALL_FLAGS_NONE,
2191 if (error != NULL) {
2192 BT_ERR("Failed to set connectable property (Error: %s)", error->message);
2193 g_clear_error(&error);
2195 BT_ERR("Failed to set connectable property");
2196 return BLUETOOTH_ERROR_INTERNAL;
2199 BT_INFO("Set connectable [%d]", is_connectable);
2200 g_variant_unref(result);
2201 return BLUETOOTH_ERROR_NONE;
2204 gboolean _bt_get_discovering_property(bt_discovery_role_type_t discovery_type)
2207 gboolean discovering_v;
2208 GError *error = NULL;
2209 char *discovering_type = NULL;
2213 proxy = _bt_get_adapter_properties_proxy();
2214 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2216 if (discovery_type == DISCOVERY_ROLE_BREDR)
2217 discovering_type = "Discovering";
2218 else if (discovery_type == DISCOVERY_ROLE_LE)
2219 discovering_type = "LEDiscovering";
2221 result = g_dbus_proxy_call_sync(proxy,
2223 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
2225 G_DBUS_CALL_FLAGS_NONE,
2231 if (error != NULL) {
2232 BT_ERR("Failed to get discovering property (Error: %s)", error->message);
2233 g_clear_error(&error);
2235 BT_ERR("Failed to get discovering property");
2236 return BLUETOOTH_ERROR_INTERNAL;
2239 g_variant_get(result, "(v)", &temp);
2240 discovering_v = g_variant_get_boolean(temp);
2241 BT_DBG("discoverable_v:%d", discovering_v);
2243 g_variant_unref(result);
2244 g_variant_unref(temp);
2246 return discovering_v;
2249 unsigned int _bt_get_discoverable_timeout_property(void)
2252 unsigned int timeout_v;
2253 GError *error = NULL;
2257 proxy = _bt_get_adapter_properties_proxy();
2258 retv_if(proxy == NULL, 0);
2260 result = g_dbus_proxy_call_sync(proxy,
2262 g_variant_new("(ss)", BT_ADAPTER_INTERFACE,
2263 "DiscoverableTimeout"),
2264 G_DBUS_CALL_FLAGS_NONE,
2270 BT_ERR("Fail to get discoverable timeout");
2271 if (error != NULL) {
2272 BT_ERR("Fail to get discoverable timeout (Error: %s)", error->message);
2273 g_clear_error(&error);
2278 g_variant_get(result, "(v)", &temp);
2279 timeout_v = g_variant_get_uint32(temp);
2280 BT_DBG("discoverable_v:%d", timeout_v);
2282 g_variant_unref(result);
2283 g_variant_unref(temp);
2288 static bluetooth_device_info_t *__bt_parse_device_info(GVariantIter *item_iter)
2290 bluetooth_device_info_t *dev_info;
2293 GByteArray *manufacturer_data = NULL;
2295 GVariantIter *char_value_iter;
2297 dev_info = g_malloc0(sizeof(bluetooth_device_info_t));
2299 while (g_variant_iter_loop(item_iter, "{sv}", &key, &value)) {
2304 if (!g_strcmp0(key, "Address")) {
2305 const char *address = NULL;
2306 address = g_variant_get_string(value, NULL);
2307 _bt_convert_addr_string_to_type(dev_info->device_address.addr,
2309 } else if (!g_strcmp0(key, "Class")) {
2311 cod = g_variant_get_uint32(value);
2312 _bt_divide_device_class(&dev_info->device_class, cod);
2313 } else if (!g_strcmp0(key, "Name")) {
2314 const char *name = NULL;
2315 name = g_variant_get_string(value, NULL);
2316 /* If there is no Alias */
2317 if (strlen(dev_info->device_name.name) == 0) {
2318 g_strlcpy(dev_info->device_name.name, name,
2319 BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
2321 } else if (!g_strcmp0(key, "Alias")) {
2322 const char *alias = NULL;
2323 alias = g_variant_get_string(value, NULL);
2324 /* Overwrite the name */
2326 memset(dev_info->device_name.name, 0x00,
2327 BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
2328 g_strlcpy(dev_info->device_name.name, alias,
2329 BLUETOOTH_DEVICE_NAME_LENGTH_MAX+1);
2331 } else if (!g_strcmp0(key, "Connected")) {
2332 dev_info->connected = g_variant_get_byte(value);
2333 } else if (!g_strcmp0(key, "Paired")) {
2334 dev_info->paired = g_variant_get_boolean(value);
2335 } else if (!g_strcmp0(key, "Trusted")) {
2336 dev_info->trust = g_variant_get_boolean(value);
2337 } else if (!g_strcmp0(key, "RSSI")) {
2338 dev_info->rssi = g_variant_get_int16(value);
2339 } else if (!g_strcmp0(key, "UUIDs")) {
2345 dev_info->service_index = 0;
2346 g_variant_get(value, "as", &iter);
2347 while (g_variant_iter_loop(iter, "s", &uuid)) {
2348 g_strlcpy(dev_info->uuids[i], uuid, BLUETOOTH_UUID_STRING_MAX);
2349 parts = g_strsplit(uuid, "-", -1);
2351 if (parts == NULL || parts[0] == NULL) {
2356 dev_info->service_list_array[i] = g_ascii_strtoull(parts[0], NULL, 16);
2361 dev_info->service_index = i;
2362 g_variant_iter_free(iter);
2363 } else if (strcasecmp(key, "ManufacturerDataLen") == 0) {
2364 dev_info->manufacturer_data.data_len = g_variant_get_uint16(value);
2365 } else if (strcasecmp(key, "ManufacturerData") == 0) {
2366 manufacturer_data = g_byte_array_new();
2367 g_variant_get(value, "ay", &char_value_iter);
2369 while (g_variant_iter_loop(char_value_iter, "y", &char_value))
2370 g_byte_array_append(manufacturer_data, &char_value, 1);
2372 if (manufacturer_data) {
2373 if (manufacturer_data->len > 0) {
2374 memcpy(dev_info->manufacturer_data.data, manufacturer_data->data, manufacturer_data->len);
2377 g_variant_iter_free(char_value_iter);
2378 g_byte_array_free(manufacturer_data, TRUE);
2385 static void __bt_extract_device_info(GVariantIter *iter,
2388 bluetooth_device_info_t *dev_info = NULL;
2389 char *object_path = NULL;
2390 GVariantIter *interface_iter;
2391 GVariantIter *svc_iter;
2392 char *interface_str = NULL;
2394 /* Parse the signature: oa{sa{sv}}} */
2395 while (g_variant_iter_loop(iter, "{&oa{sa{sv}}}", &object_path,
2398 if (object_path == NULL)
2401 while (g_variant_iter_loop(interface_iter, "{sa{sv}}",
2402 &interface_str, &svc_iter)) {
2403 if (g_strcmp0(interface_str, "org.bluez.Device1") == 0) {
2404 BT_DBG("Found a device: %s", object_path);
2405 dev_info = __bt_parse_device_info(svc_iter);
2407 if (dev_info->paired == TRUE) {
2408 g_array_append_vals(*dev_list, dev_info,
2409 sizeof(bluetooth_device_info_t));
2413 g_free(interface_str);
2414 g_variant_iter_free(svc_iter);
2422 int _bt_get_bonded_devices(GArray **dev_list)
2425 GDBusConnection *conn;
2426 GDBusProxy *manager_proxy;
2427 GVariant *result = NULL;
2428 GVariantIter *iter = NULL;
2429 GError *error = NULL;
2431 conn = _bt_get_system_conn();
2432 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
2434 manager_proxy = _bt_get_manager_proxy();
2435 retv_if(manager_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2437 result = g_dbus_proxy_call_sync(manager_proxy, "GetManagedObjects",
2439 G_DBUS_CALL_FLAGS_NONE,
2445 if (error != NULL) {
2446 BT_ERR("Failed to GetManagedObjects (Error: %s)", error->message);
2447 g_clear_error(&error);
2449 BT_ERR("Failed to Failed to GetManagedObjects");
2450 return BLUETOOTH_ERROR_INTERNAL;
2453 /* signature of GetManagedObjects: a{oa{sa{sv}}} */
2454 g_variant_get(result, "(a{oa{sa{sv}}})", &iter);
2456 __bt_extract_device_info(iter, dev_list);
2457 g_variant_iter_free(iter);
2458 g_variant_unref(result);
2461 return BLUETOOTH_ERROR_NONE;
2464 int _bt_get_bonded_device_info(bluetooth_device_address_t *device_address,
2465 bluetooth_device_info_t *dev_info)
2467 char *object_path = NULL;
2468 GDBusProxy *adapter_proxy;
2469 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
2470 int ret = BLUETOOTH_ERROR_NONE;
2472 BT_CHECK_PARAMETER(device_address, return);
2473 BT_CHECK_PARAMETER(dev_info, return);
2475 adapter_proxy = _bt_get_adapter_proxy();
2476 retv_if(adapter_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2478 _bt_convert_addr_type_to_string(address, device_address->addr);
2480 object_path = _bt_get_device_object_path(address);
2482 retv_if(object_path == NULL, BLUETOOTH_ERROR_NOT_PAIRED);
2484 ret = __bt_get_bonded_device_info(object_path, dev_info);
2485 g_free(object_path);
2490 int _bt_get_timeout_value(int *timeout)
2492 time_t current_time;
2495 /* Take current time */
2496 time(¤t_time);
2497 time_diff = difftime(current_time, visible_timer.start_time);
2499 BT_DBG("Time diff = %d\n", time_diff);
2501 *timeout = visible_timer.timeout - time_diff;
2503 return BLUETOOTH_ERROR_NONE;
2506 int _bt_set_le_privacy(gboolean set_privacy)
2509 GError *error = NULL;
2510 GVariant *result = NULL;
2512 if (__bt_is_factory_test_mode()) {
2513 BT_ERR("Unable to set le privacy in factory binary !!");
2514 return BLUETOOTH_ERROR_NOT_SUPPORT;
2517 if (_bt_adapter_get_status() != BT_ACTIVATED &&
2518 _bt_adapter_get_le_status() != BT_LE_ACTIVATED) {
2519 return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
2522 proxy = _bt_get_adapter_proxy();
2523 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2525 result = g_dbus_proxy_call_sync(proxy,
2527 g_variant_new("(b)", set_privacy),
2528 G_DBUS_CALL_FLAGS_NONE,
2534 if (error != NULL) {
2535 BT_ERR("Failed to SetLePrivacy (Error: %s)", error->message);
2536 g_clear_error(&error);
2538 BT_ERR("Failed to SetLePrivacy");
2539 return BLUETOOTH_ERROR_INTERNAL;
2542 g_variant_unref(result);
2543 BT_INFO("SetLePrivacy as %d", set_privacy);
2544 return BLUETOOTH_ERROR_NONE;
2547 int _bt_set_manufacturer_data(bluetooth_manufacturer_data_t *m_data)
2550 GError *error = NULL;
2554 GVariantBuilder *builder;
2556 BT_CHECK_PARAMETER(m_data, return);
2558 if (_bt_adapter_get_status() != BT_ACTIVATED &&
2559 _bt_adapter_get_le_status() != BT_LE_ACTIVATED) {
2560 return BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
2563 proxy = _bt_get_adapter_proxy();
2564 retv_if(proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
2566 builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
2568 for (i = 0; i < (m_data->data_len) + 2; i++) {
2569 g_variant_builder_add(builder, "y", m_data->data[i]);
2572 val = g_variant_new("(ay)", builder);
2574 result = g_dbus_proxy_call_sync(proxy,
2575 "SetManufacturerData",
2577 G_DBUS_CALL_FLAGS_NONE,
2581 g_variant_builder_unref(builder);
2583 if (error != NULL) {
2584 BT_ERR("Failed to SetManufacturerData (Error: %s)", error->message);
2585 g_clear_error(&error);
2587 BT_ERR("Failed to SetManufacturerData");
2589 return BLUETOOTH_ERROR_INTERNAL;
2591 builder = g_variant_builder_new(G_VARIANT_TYPE("ay"));
2593 for (i = 0; i < (m_data->data_len) + 2; i++) {
2594 g_variant_builder_add(builder, "y", m_data->data[i]);
2597 val = g_variant_new("(ay)", builder);
2599 _bt_send_event(BT_ADAPTER_EVENT,
2600 BLUETOOTH_EVENT_MANUFACTURER_DATA_CHANGED,
2603 BT_INFO("Set manufacturer data");
2605 g_variant_builder_unref(builder);
2606 g_variant_unref(result);
2608 return BLUETOOTH_ERROR_NONE;
2612 int _bt_get_enable_timer_id(void)