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.
23 #include <gio/gunixfdlist.h>
24 #include <cynara-client.h>
25 #include <cynara-creds-gdbus.h>
26 #include <systemd/sd-daemon.h>
29 #include "bluetooth-api.h"
30 #include "bluetooth-audio-api.h"
31 #include "bluetooth-gatt-server-api.h"
32 #include "bluetooth-mesh-api.h"
33 #include "bt-request-handler.h"
34 #include "bt-service-common.h"
35 #include "bt-service-util.h"
37 #include "bt-service-core-adapter.h"
38 #include "bt-service-core-adapter-le.h"
39 #include "bt-service-core-device.h"
41 #include "bt-service-audio-common.h"
42 #include "bt-service-avrcp-tg.h"
43 #include "bt-service-avrcp-ctrl.h"
44 #include "bt-service-gatt.h"
45 #include "bt-service-mesh-main.h"
46 #include "bt-service-mesh-util.h"
47 #include "bt-service-mesh-network.h"
48 #include "bt-service-mesh-config-client.h"
49 #include "bt-service-mesh-model.h"
50 #include "bt-service-dpm.h"
51 #include "bt-service-hidhost.h"
52 #include "bt-service-rfcomm.h"
53 #include "bt-service-hdp.h"
54 #include "bt-service-tds.h"
57 #include "bt-service-obex-server.h"
58 #include "bt-service-opp-client.h"
59 #include "bt-service-map-client.h"
60 #include "bt-service-pbap.h"
61 #include "bt-service-oob.h"
63 #include "bt-service-battery-monitor.h"
65 #include "bt-service-l2cap-le.h"
67 #ifdef TIZEN_FEATURE_BT_PAN_NAP
68 #include "bt-service-network.h"
71 #ifdef TIZEN_FEATURE_BT_IPSP
72 #include "bt-service-ipsp.h"
74 /* For maintaining Application Sync API call requests */
75 static GSList *invocation_list = NULL;
77 #ifdef TIZEN_FEATURE_BT_CONTAINER
80 gboolean is_container;
82 static GSList *nspid_list = NULL;
85 static GDBusConnection *bt_service_conn;
86 static guint owner_id = 0;
87 static guint owner_sig_id = 0;
88 static gboolean is_le_intended = FALSE;
90 static cynara *p_cynara;
91 static cynara_configuration *conf;
92 static const char *requester_unique_creds = NULL;
94 static const gchar bt_service_introspection_xml[] =
95 "<node name='/org/projectx/bt_service'>"
96 " <interface name='org.projectx.bt'>"
97 " <method name='service_request'>"
98 /* Input Parameters */
99 " <arg type='i' name='service_type' direction='in' />"
100 " <arg type='i' name='service_function' direction='in' />"
101 " <arg type='i' name='request_type' direction='in' />"
102 " <arg type='ay' name='input_param1' direction='in' />"
103 " <arg type='ay' name='input_param2' direction='in' />"
104 " <arg type='ay' name='input_param3' direction='in' />"
105 " <arg type='ay' name='input_param4' direction='in' />"
106 " <arg type='ay' name='input_param5' direction='in' />"
107 /* Return Parameters */
108 " <arg type='i' name='output_param1' direction='out' />"
109 " <arg type='v' name='output_param2' direction='out' />"
111 " <method name='get_avc_mode'>"
113 " <arg type='u' name='avc_mode' direction='out' />"
118 static gboolean name_acquired = FALSE;
120 static char *current_sender_playing = NULL;
122 GDBusNodeInfo *node_info_g = NULL;
124 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param);
126 static void __bt_service_method(GDBusConnection *connection,
128 const gchar *object_path,
129 const gchar *interface_name,
130 const gchar *method_name,
131 GVariant *parameters,
132 GDBusMethodInvocation *invocation,
135 int __bt_bluez_request(int function_name,
138 GDBusMethodInvocation *context,
143 GArray **out_param1);
144 int __bt_obexd_request(int function_name,
147 GDBusMethodInvocation *context,
152 GArray **out_param1);
153 int __bt_agent_request(int function_name,
156 GDBusMethodInvocation *context,
161 GArray **out_param1);
162 int __bt_core_request(int function_name,
165 GDBusMethodInvocation *context,
166 GVariant *in_param1);
168 gboolean __bt_service_check_privilege(int function_name,
170 const char *unique_name);
172 /* Function definitions*/
173 GSList *_bt_get_invocation_list(void)
175 return invocation_list;
178 void _bt_free_info_from_invocation_list(invocation_info_t *req_info)
180 ret_if(NULL == req_info);
181 invocation_list = g_slist_remove(invocation_list, req_info);
182 g_free(req_info->sender);
183 g_free(req_info->user_data);
187 void _bt_set_le_intended_status(gboolean value)
189 is_le_intended = value;
192 static void __bt_service_get_parameters(GVariant *in_param,
193 void *value, int size)
196 buf = (void *)g_variant_get_data(in_param);
197 memcpy(value, buf, size);
200 static gboolean __bt_is_sync_function(int service_function)
202 /*TODO: Keep adding sync methods with expect replies from bluetooth service */
203 if (service_function == BT_GET_LOCAL_ADDRESS
204 || service_function == BT_GET_LOCAL_NAME
205 || service_function == BT_GET_LOCAL_VERSION
206 || service_function == BT_GET_BONDED_DEVICES
207 || service_function == BT_GET_BONDED_DEVICE
208 || service_function == BT_GET_PROFILE_CONNECTED_DEVICES
209 || service_function == BT_GET_IS_ALIAS_SET
210 || service_function == BT_GET_CONNECTED_LINK_TYPE
211 || service_function == BT_IS_SERVICE_USED
212 || service_function == BT_RFCOMM_LISTEN_AND_ACCEPT
213 || service_function == BT_RFCOMM_LISTEN
214 || service_function == BT_HDP_REGISTER_SINK_APP
215 || service_function == BT_HDP_UNREGISTER_SINK_APP
216 || service_function == BT_HDP_GET_FD
217 || service_function == BT_AVRCP_GET_TRACK_INFO
218 || service_function == BT_AVRCP_CONTROL_GET_PROPERTY
219 || service_function == BT_SET_ADVERTISING_DATA
220 || service_function == BT_SET_SCAN_RESPONSE_DATA
221 || service_function == BT_SET_ADVERTISING
222 || service_function == BT_SET_CUSTOM_ADVERTISING
223 || service_function == BT_GATT_SERVER_REGISTER
224 || service_function == BT_GATT_SERVER_ADD_SERVICE
225 || service_function == BT_GATT_SERVER_ADD_CHARACTERISTIC
226 || service_function == BT_GATT_SERVER_ADD_DESCRIPTOR
227 || service_function == BT_GATT_SERVER_START_SERVICE
228 || service_function == BT_GATT_SERVER_STOP_SERVICE
229 || service_function == BT_GATT_SERVER_DELETE_SERVICE
230 || service_function == BT_START_LE_DISCOVERY
231 || service_function == BT_STOP_LE_DISCOVERY
232 || service_function == BT_GET_CONNECTABLE
233 || service_function == BT_GATT_CLIENT_REGISTER
234 || service_function == BT_GATT_GET_PRIMARY_SERVICES
235 || service_function == BT_GATT_GET_SERVICE_PROPERTIES
236 || service_function == BT_GATT_GET_INCLUDED_SERVICES
237 || service_function == BT_GATT_GET_CHARACTERISTIC_PROPERTIES
238 || service_function == BT_GATT_WATCH_CHARACTERISTIC
239 || service_function == BT_GATT_ACQUIRE_WRITE
240 || service_function == BT_AUDIO_SELECT_ROLE
242 || service_function == BT_MESH_INIT
243 || service_function == BT_MESH_NETWORK_CREATE
244 || service_function == BT_MESH_NETWORK_DESTROY
245 || service_function == BT_MESH_NETWORK_LOAD
246 || service_function == BT_MESH_NETWORK_SCAN
247 || service_function == BT_MESH_NETWORK_ADD_NETKEY
248 || service_function == BT_MESH_NETWORK_DELETE_NETKEY
249 || service_function == BT_MESH_NETWORK_UPDATE_NETKEY
250 || service_function == BT_MESH_NETWORK_ADD_APPKEY
251 || service_function == BT_MESH_NETWORK_DELETE_APPKEY
252 || service_function == BT_MESH_NETWORK_UPDATE_APPKEY
253 || service_function == BT_L2CAP_LE_LISTEN_AND_ACCEPT
254 || service_function == BT_L2CAP_LE_LISTEN)
260 void _bt_save_invocation_context(GDBusMethodInvocation *invocation, int result,
261 char *sender, int service_function,
262 gpointer invocation_data)
264 invocation_info_t *info;
265 info = g_malloc0(sizeof(invocation_info_t));
266 info->context = invocation;
267 info->result = result;
268 info->sender = g_strdup(sender);
269 info->service_function = service_function;
270 info->user_data = invocation_data;
271 invocation_list = g_slist_append(invocation_list, info);
275 static int __bt_service_get_sender_pid(const char *unique_name, pid_t *pid)
278 char err_msg[256] = {0, };
280 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
282 ret = cynara_creds_gdbus_get_pid(bt_service_conn, unique_name, pid);
283 if (ret != CYNARA_API_SUCCESS) {
284 cynara_strerror(ret, err_msg, sizeof(err_msg));
285 BT_ERR("Fail to get user credential: %s", err_msg);
287 return BLUETOOTH_ERROR_INTERNAL;
290 return BLUETOOTH_ERROR_NONE;
293 static int __bt_bm_request_data(_bt_battery_data_t *latest)
295 int ret = _bt_bm_read_data(latest);
296 if (ret == BLUETOOTH_ERROR_NONE) {
297 BT_DBG("Received data from bluetooth battery monitor: %ld %ld %d %d",
298 latest->session_start_time, latest->session_end_time,
299 latest->session_scan_time, latest->session_connected_time);
301 if (latest->atm_list == NULL) {
302 BT_DBG("No app data transaction for this session");
306 for (GSList *l = latest->atm_list; l != NULL; l = g_slist_next(l)) {
307 _bt_battery_app_data_t *t = (_bt_battery_app_data_t *)(l->data);
308 BT_DBG("%ld %ld %d %d", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
312 BT_ERR("Error encountered");
316 static void __bt_service_method(GDBusConnection *connection,
318 const gchar *object_path,
319 const gchar *interface_name,
320 const gchar *method_name,
321 GVariant *parameters,
322 GDBusMethodInvocation *invocation,
327 BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
328 method_name, object_path, interface_name);
330 if (g_strcmp0(method_name, "service_request") == 0) {
332 int service_function;
334 GVariant *param1 = NULL;
335 GVariant *param2 = NULL;
336 GVariant *param3 = NULL;
337 GVariant *param4 = NULL;
338 GVariant *param5 = NULL;
339 GArray *out_param1 = NULL;
340 GVariant *out_var = NULL;
341 GVariant *temp = NULL;
344 const char *unique_name = NULL;
346 g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
347 &service_function, &request_type,
348 ¶m1, ¶m2, ¶m3, ¶m4, ¶m5);
350 out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
352 #ifdef TIZEN_FEATURE_BT_CONTAINER
353 /* In case of the bt-service in container, only privilege check request is coming
354 * from the bt-service in host. At this time, the original sender's privilege
355 * should be checked not bt-service's privilege */
356 if (_bt_service_is_container() == TRUE)
357 unique_name = (const char *)g_variant_get_data(param1);
359 unique_name = sender;
361 unique_name = sender;
364 if (service_type == BT_CORE_SERVICE) {
365 BT_DBG("No need to check privilege from bt-core");
366 } else if (__bt_service_check_privilege(service_function,
367 service_type, unique_name) == FALSE) {
368 BT_ERR("Client don't have the privilege to excute this function");
369 result = BLUETOOTH_ERROR_PERMISSION_DEINED;
373 BT_DBG("SERVICE TYPE [%d] SERVICE FUNC [%d]",
374 service_type, service_function);
375 switch (service_type) {
376 case BT_BLUEZ_SERVICE:
377 result = __bt_bluez_request(service_function,
378 request_type, request_id,
379 invocation, param1, param2,
380 param3, param4, &out_param1);
382 case BT_OBEX_SERVICE:
383 result = __bt_obexd_request(service_function,
384 request_type, request_id,
387 param4, &out_param1);
389 case BT_AGENT_SERVICE:
390 result = __bt_agent_request(service_function,
391 request_type, request_id,
394 param4, &out_param1);
396 case BT_CORE_SERVICE:
397 result = __bt_core_request(service_function,
398 request_type, request_id,
401 case BT_CHECK_PRIVILEGE:
402 result = BLUETOOTH_ERROR_NONE;
405 BT_ERR("Unknown service type");
406 result = BLUETOOTH_ERROR_INTERNAL;
410 if (result != BLUETOOTH_ERROR_NONE)
413 if (service_type == BT_CHECK_PRIVILEGE)
416 if (service_function == BT_OPP_PUSH_FILES)
419 if (request_type == BT_ASYNC_REQ ||
420 __bt_is_sync_function(service_function)) {
421 /* Do not send reply to bt-api over dbus,
422 Invocation context is already saved in service_function */
427 out_var = g_variant_new_from_data((const GVariantType *)"ay",
428 out_param1->data, out_param1->len,
431 temp = g_variant_new("(iv)", result, out_var);
432 g_dbus_method_invocation_return_value(invocation, temp);
433 g_array_free(out_param1, TRUE);
437 g_variant_unref(param1);
438 g_variant_unref(param2);
439 g_variant_unref(param3);
440 g_variant_unref(param4);
441 g_variant_unref(param5);
445 BT_ERR_C("Request is failed [%s] [0x%x]",
446 _bt_convert_error_to_string(result), result);
448 out_var = g_variant_new_from_data((const GVariantType *)"ay",
449 out_param1->data, out_param1->len,
452 temp = g_variant_new("(iv)", result, out_var);
453 g_dbus_method_invocation_return_value(invocation, temp);
455 g_array_free(out_param1, TRUE);
458 g_variant_unref(param1);
459 g_variant_unref(param2);
460 g_variant_unref(param3);
461 g_variant_unref(param4);
462 g_variant_unref(param5);
464 else if (g_strcmp0(method_name, "get_avc_mode") == 0) {
465 unsigned int mode = 0;
467 if (_bt_audio_get_avc_mode(&mode) != BLUETOOTH_ERROR_NONE)
468 BT_ERR("Fail to get the avc mode");
470 BT_DBG("Absolute Volume Control mode: %d", mode);
472 g_dbus_method_invocation_return_value(invocation,
473 g_variant_new("(u)", mode));
481 static const GDBusInterfaceVTable method_table = {
488 int __bt_bluez_request(int function_name,
491 GDBusMethodInvocation *context,
498 int result = BLUETOOTH_ERROR_NONE;
501 switch (function_name) {
502 case BT_ENABLE_ADAPTER: {
503 result = _bt_enable_adapter();
504 _bt_adapter_start_enable_timer();
507 case BT_DISABLE_ADAPTER: {
508 result = _bt_disable_adapter();
511 case BT_RECOVER_ADAPTER:
512 result = _bt_recover_adapter();
514 case BT_RESET_ADAPTER:
515 result = _bt_reset_adapter();
517 case BT_BATTERY_READ_DATA: {
518 _bt_battery_data_t *data = NULL;
519 data = g_malloc0(sizeof(_bt_battery_data_t));
520 result = __bt_bm_request_data(data);
522 bt_battery_dbus_data_t dbus_data;
523 memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
524 dbus_data.session_start_time = data->session_start_time;
525 dbus_data.session_end_time = data->session_end_time;
526 dbus_data.session_scan_time = data->session_scan_time;
527 dbus_data.session_connected_time = data->session_connected_time;
528 dbus_data.tx_time = data->tx_time;
529 dbus_data.rx_time = data->rx_time;
530 dbus_data.idle_time = data->idle_time;
532 /*Populating app data*/
534 for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
535 bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
536 memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
539 dbus_data.num_app = n;
540 g_array_append_vals(*out_param1, &dbus_data, sizeof(bt_battery_dbus_data_t));
541 g_slist_free_full(data->atm_list, g_free);
546 case BT_CHECK_ADAPTER: {
547 int enabled = BT_ADAPTER_DISABLED;
548 result = _bt_check_adapter(&enabled);
550 g_array_append_vals(*out_param1, &enabled,
554 case BT_ENABLE_ADAPTER_LE:
555 _bt_set_le_intended_status(TRUE);
556 result = _bt_enable_adapter_le();
558 case BT_DISABLE_ADAPTER_LE:
559 _bt_set_le_intended_status(FALSE);
560 result = _bt_disable_adapter_le();
562 case BT_START_DISCOVERY: {
563 unsigned short max_response;
564 unsigned short discovery_duration;
565 unsigned int classOfDeviceMask;
568 __bt_service_get_parameters(in_param1,
569 &max_response, sizeof(unsigned short));
570 __bt_service_get_parameters(in_param2,
571 &discovery_duration, sizeof(unsigned short));
572 __bt_service_get_parameters(in_param3,
573 &classOfDeviceMask, sizeof(unsigned int));
574 __bt_service_get_parameters(in_param4, &uid, sizeof(uid_t));
576 result = _bt_start_discovery(max_response, discovery_duration, classOfDeviceMask);
578 if (result == BLUETOOTH_ERROR_NONE) {
581 sender = (char*)g_dbus_method_invocation_get_sender(context);
583 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
584 BT_ERR("Fail to get the sender pid");
586 BT_DBG("Remeber pid / uid for the scan operation");
587 _bt_bm_add_scan_app(SCAN_REGACY, uid, pid);
592 case BT_START_CUSTOM_DISCOVERY: {
593 bt_discovery_role_type_t role;
595 __bt_service_get_parameters(in_param1,
596 &role, sizeof(bt_discovery_role_type_t));
597 result = _bt_start_custom_discovery(role);
601 case BT_CANCEL_DISCOVERY:
602 result = _bt_cancel_discovery();
604 case BT_IS_DISCOVERYING: {
605 gboolean discovering = FALSE;
606 discovering = _bt_is_discovering();
607 g_array_append_vals(*out_param1,
608 &discovering, sizeof(gboolean));
611 case BT_GET_LOCAL_ADDRESS: {
612 result = _bt_get_local_address();
614 /* Save invocation */
615 if (result == BLUETOOTH_ERROR_NONE) {
616 sender = (char*)g_dbus_method_invocation_get_sender(context);
617 _bt_save_invocation_context(context, result, sender,
618 function_name, NULL);
622 case BT_GET_LOCAL_VERSION: {
623 result = _bt_get_local_version();
625 /* Save invocation */
626 if (result == BLUETOOTH_ERROR_NONE) {
627 sender = (char*)g_dbus_method_invocation_get_sender(context);
628 _bt_save_invocation_context(context, result, sender,
629 function_name, NULL);
633 case BT_GET_LOCAL_NAME: {
634 result = _bt_get_local_name();
636 /* Save invocation */
637 if (result == BLUETOOTH_ERROR_NONE) {
638 sender = (char*)g_dbus_method_invocation_get_sender(context);
639 _bt_save_invocation_context(context, result, sender,
640 function_name, NULL);
644 case BT_SET_LOCAL_NAME: {
645 bluetooth_device_name_t local_name = { {0} };
646 __bt_service_get_parameters(in_param1,
647 &local_name, sizeof(bluetooth_device_name_t));
648 result = _bt_set_local_name(local_name.name);
651 case BT_GET_DISCOVERABLE_MODE: {
652 int discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
653 result = _bt_get_discoverable_mode(&discoverable_mode);
654 g_array_append_vals(*out_param1, &discoverable_mode, sizeof(int));
657 case BT_GET_DISCOVERABLE_TIME: {
660 result = _bt_get_timeout_value(&timeout);
661 g_array_append_vals(*out_param1, &timeout, sizeof(int));
664 case BT_SET_DISCOVERABLE_MODE: {
665 int mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
668 __bt_service_get_parameters(in_param1, &mode, sizeof(int));
669 __bt_service_get_parameters(in_param2, &time, sizeof(int));
671 result = _bt_set_discoverable_mode(mode, time);
674 case BT_IS_CONNECTABLE: {
675 gboolean is_connectable = FALSE;
677 is_connectable = _bt_is_connectable();
678 g_array_append_vals(*out_param1, &is_connectable, sizeof(gboolean));
681 case BT_GET_CONNECTABLE: {
682 result = _bt_get_connectable();
684 /* Save invocation */
685 if (result == BLUETOOTH_ERROR_NONE) {
686 sender = (char*)g_dbus_method_invocation_get_sender(context);
687 _bt_save_invocation_context(context, result, sender,
688 function_name, NULL);
692 case BT_SET_CONNECTABLE: {
693 gboolean is_connectable;
695 __bt_service_get_parameters(in_param1,
696 &is_connectable, sizeof(gboolean));
697 result = _bt_set_connectable(is_connectable);
700 case BT_IS_SERVICE_USED: {
703 uuid = (char *)g_variant_get_data(in_param1);
704 BT_INFO("UUID to be searched [%s]", uuid);
705 result = _bt_is_service_used();
707 /* Save invocation */
708 if (result == BLUETOOTH_ERROR_NONE) {
709 sender = (char*)g_dbus_method_invocation_get_sender(context);
710 _bt_save_invocation_context(context, result, sender,
711 function_name, g_strdup(uuid));
715 case BT_GET_BONDED_DEVICES: {
716 result = _bt_get_bonded_devices();
717 /* Save invocation */
718 if (result == BLUETOOTH_ERROR_NONE) {
719 sender = (char*)g_dbus_method_invocation_get_sender(context);
720 _bt_save_invocation_context(context, result, sender,
721 function_name, NULL);
725 case BT_GET_BONDED_DEVICE: {
726 bluetooth_device_address_t address = { {0} };
728 __bt_service_get_parameters(in_param1,
729 &address, sizeof(bluetooth_device_address_t));
731 result = _bt_get_bonded_device_info(&address);
732 /* Save invocation */
733 if (result == BLUETOOTH_ERROR_NONE) {
734 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
736 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
740 _bt_convert_addr_type_to_string(addr, address.addr);
741 sender = (char*)g_dbus_method_invocation_get_sender(context);
742 _bt_save_invocation_context(context, result, sender,
743 function_name, addr);
747 case BT_GET_PROFILE_CONNECTED_DEVICES: {
749 uuid = (char *)g_variant_get_data(in_param1);
750 result = _bt_get_profile_connected_devices(uuid);
752 /* Save invocation */
753 if (result == BLUETOOTH_ERROR_NONE) {
754 sender = (char *)g_dbus_method_invocation_get_sender(context);
755 _bt_save_invocation_context(context, result, sender,
756 function_name, NULL);
761 bluetooth_device_address_t address = { {0} };
762 const char *local_name;
764 __bt_service_get_parameters(in_param1,
765 &address, sizeof(bluetooth_device_address_t));
766 local_name = (const char *)g_variant_get_data(in_param2);
768 result = _bt_set_alias(&address, local_name);
771 case BT_BOND_DEVICE: {
772 bluetooth_device_address_t address = { {0} };
774 __bt_service_get_parameters(in_param1,
775 &address, sizeof(bluetooth_device_address_t));
776 result = _bt_bond_device(&address, BLUETOOTH_DEV_CONN_DEFAULT, out_param1);
778 /* Save invocation */
779 if (result == BLUETOOTH_ERROR_NONE) {
780 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
781 _bt_convert_addr_type_to_string(addr, address.addr);
782 sender = (char*)g_dbus_method_invocation_get_sender(context);
783 _bt_save_invocation_context(context, result, sender,
784 function_name, (gpointer)addr);
786 bluetooth_device_info_t dev_info;
788 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
789 memcpy(&dev_info.device_address, &address,
790 sizeof(bluetooth_device_address_t));
791 g_array_append_vals(*out_param1, &dev_info,
792 sizeof(bluetooth_device_info_t));
796 case BT_BOND_DEVICE_BY_TYPE: {
797 bluetooth_device_address_t address = { {0} };
798 unsigned short conn_type = 0;
800 __bt_service_get_parameters(in_param1,
801 &address, sizeof(bluetooth_device_address_t));
802 __bt_service_get_parameters(in_param2,
803 &conn_type, sizeof(unsigned short));
805 result = _bt_bond_device(&address, conn_type, out_param1);
806 /* Save invocation */
807 if (result == BLUETOOTH_ERROR_NONE) {
808 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
809 _bt_convert_addr_type_to_string(addr, address.addr);
810 sender = (char*)g_dbus_method_invocation_get_sender(context);
811 _bt_save_invocation_context(context, result, sender,
812 function_name, (gpointer)addr);
814 bluetooth_device_info_t dev_info;
816 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
817 memcpy(&dev_info.device_address, &address,
818 sizeof(bluetooth_device_address_t));
819 g_array_append_vals(*out_param1, &dev_info,
820 sizeof(bluetooth_device_info_t));
824 case BT_UNBOND_DEVICE: {
825 bluetooth_device_address_t address = { {0} };
827 __bt_service_get_parameters(in_param1,
828 &address, sizeof(bluetooth_device_address_t));
829 result = _bt_unbond_device(&address, out_param1);
831 /* Save invocation */
832 if (result == BLUETOOTH_ERROR_NONE) {
833 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
834 _bt_convert_addr_type_to_string(addr, address.addr);
835 sender = (char*)g_dbus_method_invocation_get_sender(context);
836 _bt_save_invocation_context(context, result, sender,
837 function_name, (gpointer)addr);
839 g_array_append_vals(*out_param1, &address,
840 sizeof(bluetooth_device_address_t));
844 case BT_CANCEL_BONDING:{
845 result = _bt_cancel_bonding();
848 case BT_SEARCH_SERVICE: {
849 bluetooth_device_address_t address = { {0} };
850 __bt_service_get_parameters(in_param1,
851 &address, sizeof(bluetooth_device_address_t));
852 result = _bt_search_device(&address);
853 /* Save invocation */
854 if (result == BLUETOOTH_ERROR_NONE) {
855 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
856 _bt_convert_addr_type_to_string(addr, address.addr);
857 sender = (char*)g_dbus_method_invocation_get_sender(context);
858 _bt_save_invocation_context(context, result, sender,
859 function_name, (gpointer)addr);
861 bt_sdp_info_t sdp_info;
863 memset(&sdp_info, 0x00, sizeof(bt_sdp_info_t));
864 memcpy(&sdp_info.device_addr, &address,
865 sizeof(bluetooth_device_address_t));
866 g_array_append_vals(*out_param1, &sdp_info, sizeof(bt_sdp_info_t));
870 case BT_CANCEL_SEARCH_SERVICE: {
871 result = _bt_cancel_search_device();
874 case BT_SET_PASSKEY_NOTIFICATION: {
878 sender = (char *)g_dbus_method_invocation_get_sender(context);
879 __bt_service_get_parameters(in_param1,
880 &enable, sizeof(gboolean));
882 result = _bt_set_passkey_notification(sender, enable);
885 case BT_SET_PIN_CODE: {
886 bluetooth_device_address_t address = { {0} };
887 bluetooth_device_pin_code_t pin_code = { {0} };
889 __bt_service_get_parameters(in_param1,
890 &address, sizeof(bluetooth_device_address_t));
891 __bt_service_get_parameters(in_param2,
892 &pin_code, sizeof(bluetooth_device_pin_code_t));
894 result = _bt_set_pin_code(&address, &pin_code);
897 case BT_UNSET_PIN_CODE: {
898 bluetooth_device_address_t address = { {0} };
900 __bt_service_get_parameters(in_param1,
901 &address, sizeof(bluetooth_device_address_t));
903 result = _bt_unset_pin_code(&address);
906 case BT_PASSKEY_REPLY: {
907 const char *passkey = NULL;
908 gboolean authentication_reply = FALSE;
909 passkey = g_variant_get_data(in_param1);
910 __bt_service_get_parameters(in_param2,
911 &authentication_reply, sizeof(gboolean));
912 result = _bt_passkey_reply(passkey, authentication_reply);
915 case BT_PASSKEY_CONFIRMATION_REPLY: {
916 gboolean confirmation_reply = FALSE;
917 __bt_service_get_parameters(in_param1,
918 &confirmation_reply, sizeof(gboolean));
919 result = _bt_passkey_confirmation_reply(confirmation_reply);
922 case BT_GET_IS_ALIAS_SET: {
923 bluetooth_device_address_t address = { {0} };
925 __bt_service_get_parameters(in_param1,
926 &address, sizeof(bluetooth_device_address_t));
928 result = _bt_is_alias_set(&address);
929 if (result == BLUETOOTH_ERROR_NONE) {
930 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
932 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
936 _bt_convert_addr_type_to_string(addr, address.addr);
937 sender = (char*)g_dbus_method_invocation_get_sender(context);
938 _bt_save_invocation_context(context, result, sender,
939 function_name, addr);
943 case BT_SET_AUTHORIZATION: {
944 bluetooth_device_address_t address = { {0} };
946 __bt_service_get_parameters(in_param1,
947 &address, sizeof(bluetooth_device_address_t));
948 __bt_service_get_parameters(in_param2,
949 &authorize, sizeof(gboolean));
950 result = _bt_set_authorization(&address, authorize);
953 case BT_SET_LE_PRIVACY: {
954 gboolean set_privacy;
955 __bt_service_get_parameters(in_param1, &set_privacy,
957 result = _bt_set_le_privacy(set_privacy);
960 case BT_ADD_WHITE_LIST: {
961 bluetooth_device_address_t address = { {0} };
962 int address_type = 0;
964 __bt_service_get_parameters(in_param1,
965 &address, sizeof(bluetooth_device_address_t));
966 __bt_service_get_parameters(in_param2,
967 &address_type, sizeof(int));
968 result = _bt_set_white_list(&address, address_type, is_add);
971 case BT_REMOVE_WHITE_LIST: {
972 bluetooth_device_address_t address = { {0} };
973 int address_type = 0;
975 __bt_service_get_parameters(in_param1,
976 &address, sizeof(bluetooth_device_address_t));
977 __bt_service_get_parameters(in_param2,
978 &address_type, sizeof(int));
979 result = _bt_set_white_list(&address, address_type, is_add);
982 case BT_UPDATE_LE_CONNECTION_MODE: {
984 bluetooth_device_address_t remote_address = { { 0 } };
985 bluetooth_le_connection_param_t parameters = { 0 };
986 bluetooth_le_connection_mode_t mode = BLUETOOTH_LE_CONNECTION_MODE_BALANCED;
988 __bt_service_get_parameters(in_param1, &remote_address,
989 sizeof(bluetooth_device_address_t));
990 __bt_service_get_parameters(in_param2, &mode,
991 sizeof(bluetooth_le_connection_mode_t));
993 result = _bt_get_le_connection_parameter(mode, ¶meters);
994 if (result != BLUETOOTH_ERROR_NONE)
997 sender = (char *)g_dbus_method_invocation_get_sender(context);
999 result = _bt_le_connection_update(sender,
1000 remote_address.addr,
1001 parameters.interval_min,
1002 parameters.interval_max,
1004 parameters.timeout);
1007 case BT_SET_MANUFACTURER_DATA: {
1008 bluetooth_manufacturer_data_t m_data = { 0 };
1009 __bt_service_get_parameters(in_param1,
1010 &m_data, sizeof(bluetooth_manufacturer_data_t));
1011 result = _bt_set_manufacturer_data(&m_data);
1015 case BT_IS_DEVICE_CONNECTED: {
1016 bluetooth_device_address_t address = { {0} };
1017 gboolean connected = FALSE;
1020 __bt_service_get_parameters(in_param1,
1021 &address, sizeof(bluetooth_device_address_t));
1022 __bt_service_get_parameters(in_param2,
1023 &service_type, sizeof(int));
1025 #if defined(TIZEN_FEATURE_BT_PAN_NAP)
1026 if ((service_type == BLUETOOTH_NAP_SERVICE) || (service_type == BLUETOOTH_NAP_SERVER_SERVICE))
1027 connected = _bt_is_nap_panu_device_connected(&address, service_type);
1029 connected = _bt_is_device_connected(&address, service_type);
1031 connected = _bt_is_device_connected(&address, service_type);
1033 BT_INFO("is_connected: %d", connected);
1034 g_array_append_vals(*out_param1, &connected, sizeof(gboolean));
1037 case BT_GET_CONNECTED_LINK_TYPE: {
1038 bluetooth_device_address_t address = { {0} };
1040 __bt_service_get_parameters(in_param1,
1041 &address, sizeof(bluetooth_device_address_t));
1043 result = _bt_get_connected_link(&address);
1044 if (result == BLUETOOTH_ERROR_NONE) {
1045 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
1047 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
1051 _bt_convert_addr_type_to_string(addr, address.addr);
1052 sender = (char*)g_dbus_method_invocation_get_sender(context);
1053 _bt_save_invocation_context(context, result, sender,
1054 function_name, addr);
1058 case BT_IS_SCAN_FILTER_SUPPORTED:{
1059 int is_supported = 0;
1061 if (_bt_is_scan_filter_supported() == TRUE)
1064 g_array_append_vals(*out_param1,
1065 &is_supported, sizeof(int));
1069 case BT_ENABLE_RSSI: {
1070 bluetooth_device_address_t bd_addr;
1072 bt_rssi_threshold_t rssi_threshold;
1074 int in_range_threshold;
1077 BT_DBG("Enable RSSI");
1079 __bt_service_get_parameters(in_param1,
1080 &bd_addr, sizeof(bluetooth_device_address_t));
1081 __bt_service_get_parameters(in_param2,
1082 &link_type, sizeof(int));
1083 __bt_service_get_parameters(in_param3,
1084 &rssi_threshold, sizeof(bt_rssi_threshold_t));
1086 low_threshold = rssi_threshold.low_threshold;
1087 in_range_threshold = rssi_threshold.in_range_threshold;
1088 high_threshold = rssi_threshold.high_threshold;
1090 result = _bt_enable_rssi(&bd_addr, link_type, low_threshold,
1091 in_range_threshold, high_threshold);
1096 bluetooth_device_address_t bd_addr;
1098 BT_DBG("Get RSSI Strength");
1100 __bt_service_get_parameters(in_param1,
1101 &bd_addr, sizeof(bluetooth_device_address_t));
1102 __bt_service_get_parameters(in_param2,
1103 &link_type, sizeof(int));
1105 result = _bt_get_rssi_strength(&bd_addr, link_type);
1108 case BT_SET_PROFILE_TRUSTED: {
1109 bluetooth_device_address_t bd_addr = { {0} };
1113 __bt_service_get_parameters(in_param1, &bd_addr,
1114 sizeof(bluetooth_device_address_t));
1115 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1116 __bt_service_get_parameters(in_param3, &trust, sizeof(int));
1118 result = _bt_set_trust_profile(&bd_addr, profile, trust);
1121 case BT_GET_PROFILE_TRUSTED: {
1122 bluetooth_device_address_t bd_addr = { {0} };
1124 guint trusted_profile = 0;
1126 __bt_service_get_parameters(in_param1, &bd_addr,
1127 sizeof(bluetooth_device_address_t));
1128 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1130 result = _bt_get_trust_profile(&bd_addr, profile, &trusted_profile);
1131 BT_DBG("TRUST %d", trusted_profile);
1132 if (result == BLUETOOTH_ERROR_NONE) {
1133 g_array_append_vals(*out_param1, &trusted_profile,
1139 case BT_HID_CONNECT: {
1140 bluetooth_device_address_t address = { {0} };
1142 __bt_service_get_parameters(in_param1,
1143 &address, sizeof(bluetooth_device_address_t));
1145 result = _bt_hid_connect(&address);
1146 if (result != BLUETOOTH_ERROR_NONE) {
1147 g_array_append_vals(*out_param1, &address,
1148 sizeof(bluetooth_device_address_t));
1150 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1151 _bt_convert_addr_type_to_string(addr, address.addr);
1152 sender = (char*)g_dbus_method_invocation_get_sender(context);
1153 _bt_save_invocation_context(context, result, sender,
1154 function_name, (gpointer)addr);
1158 case BT_HID_DISCONNECT: {
1159 bluetooth_device_address_t address = { {0} };
1161 __bt_service_get_parameters(in_param1,
1162 &address, sizeof(bluetooth_device_address_t));
1164 result = _bt_hid_disconnect(&address);
1165 if (result != BLUETOOTH_ERROR_NONE) {
1166 g_array_append_vals(*out_param1, &address,
1167 sizeof(bluetooth_device_address_t));
1169 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1170 _bt_convert_addr_type_to_string(addr, address.addr);
1171 sender = (char*)g_dbus_method_invocation_get_sender(context);
1172 _bt_save_invocation_context(context, result, sender,
1173 function_name, (gpointer)addr);
1177 case BT_DPM_SET_ALLOW_BT_MODE: {
1178 dpm_bt_allow_t value = DPM_BT_ERROR;
1180 __bt_service_get_parameters(in_param1, &value,
1183 result = _bt_dpm_set_allow_bluetooth_mode(value);
1186 case BT_DPM_GET_ALLOW_BT_MODE: {
1187 int value = DPM_BT_ERROR;
1189 result = _bt_dpm_get_allow_bluetooth_mode(&value);
1190 g_array_append_vals(*out_param1, &value, sizeof(int));
1193 case BT_DPM_SET_DEVICE_RESTRITION: {
1194 dpm_status_t value = DPM_STATUS_ERROR;
1196 __bt_service_get_parameters(in_param1, &value,
1199 result = _bt_dpm_activate_bluetooth_device_restriction(value);
1202 case BT_DPM_GET_DEVICE_RESTRITION: {
1203 int value = DPM_STATUS_ERROR;
1205 result = _bt_dpm_is_bluetooth_device_restriction_active(&value);
1206 g_array_append_vals(*out_param1, &value, sizeof(int));
1209 case BT_DPM_SET_UUID_RESTRITION: {
1210 dpm_status_t value = DPM_STATUS_ERROR;
1212 __bt_service_get_parameters(in_param1, &value,
1215 result = _bt_dpm_activate_bluetoooth_uuid_restriction(value);
1218 case BT_DPM_GET_UUID_RESTRITION: {
1219 int value = DPM_STATUS_ERROR;
1221 result = _bt_dpm_is_bluetooth_uuid_restriction_active(&value);
1222 g_array_append_vals(*out_param1, &value, sizeof(int));
1225 case BT_DPM_ADD_DEVICES_BLACKLIST: {
1226 bluetooth_device_address_t address = { {0} };
1228 __bt_service_get_parameters(in_param1, &address,
1229 sizeof(bluetooth_device_address_t));
1231 result = _bt_dpm_add_bluetooth_devices_to_blacklist(&address);
1234 case BT_DPM_ADD_DEVICES_WHITELIST: {
1235 bluetooth_device_address_t address = { {0} };
1237 __bt_service_get_parameters(in_param1, &address,
1238 sizeof(bluetooth_device_address_t));
1240 result = _bt_dpm_add_bluetooth_devices_to_whitelist(&address);
1243 case BT_DPM_ADD_UUIDS_BLACKLIST: {
1244 const char *uuid = NULL;
1246 uuid = g_variant_get_data(in_param1);
1248 result = _bt_dpm_add_bluetooth_uuids_to_blacklist(uuid);
1251 case BT_DPM_ADD_UUIDS_WHITELIST: {
1252 const char *uuid = NULL;
1254 uuid = g_variant_get_data(in_param1);
1256 result = _bt_dpm_add_bluetooth_uuids_to_whitelist(uuid);
1259 case BT_DPM_CLEAR_DEVICES_BLACKLIST: {
1260 result = _bt_dpm_clear_bluetooth_devices_from_blacklist();
1263 case BT_DPM_CLEAR_DEVICES_WHITELIST: {
1264 result = _bt_dpm_clear_bluetooth_devices_from_whitelist();
1267 case BT_DPM_CLEAR_UUIDS_BLACKLIST: {
1268 result = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
1271 case BT_DPM_CLEAR_UUIDS_WHITELIST: {
1272 result = _bt_dpm_clear_bluetooth_uuids_from_whitelist();
1275 case BT_DPM_REMOVE_DEVICE_BLACKLIST: {
1276 bluetooth_device_address_t address = { {0} };
1278 __bt_service_get_parameters(in_param1, &address,
1279 sizeof(bluetooth_device_address_t));
1281 result = _bt_dpm_remove_bluetooth_devices_from_blacklist(&address);
1284 case BT_DPM_REMOVE_DEVICE_WHITELIST: {
1285 bluetooth_device_address_t address = { {0} };
1287 __bt_service_get_parameters(in_param1, &address,
1288 sizeof(bluetooth_device_address_t));
1290 result = _bt_dpm_remove_bluetooth_devices_from_whitelist(&address);
1293 case BT_DPM_REMOVE_UUID_BLACKLIST: {
1294 const char *uuid = NULL;
1296 uuid = g_variant_get_data(in_param1);
1298 result = _bt_dpm_remove_bluetooth_uuids_from_blacklist(uuid);
1301 case BT_DPM_REMOVE_UUID_WHITELIST: {
1302 const char *uuid = NULL;
1304 uuid = g_variant_get_data(in_param1);
1306 result = _bt_dpm_remove_bluetooth_uuids_from_whitelist(uuid);
1310 case BT_DPM_GET_DEVICES_BLACKLIST: {
1311 result = _bt_dpm_get_bluetooth_devices_from_blacklist(out_param1);
1314 case BT_DPM_GET_DEVICES_WHITELIST: {
1315 result = _bt_dpm_get_bluetooth_devices_from_whitelist(out_param1);
1318 case BT_DPM_GET_UUIDS_BLACKLIST: {
1319 result = _bt_dpm_get_bluetooth_uuids_from_blacklist(out_param1);
1322 case BT_DPM_GET_UUIDS_WHITELIST: {
1323 result = _bt_dpm_get_bluetooth_uuids_from_whitelist(out_param1);
1326 case BT_DPM_SET_ALLOW_OUTGOING_CALL: {
1327 dpm_status_t value = DPM_STATUS_ERROR;
1329 __bt_service_get_parameters(in_param1, &value,
1332 result = _bt_dpm_set_allow_bluetooth_outgoing_call(value);
1336 case BT_DPM_GET_ALLOW_OUTGOING_CALL: {
1337 int value = DPM_STATUS_ERROR;
1339 result = _bt_dpm_get_allow_bluetooth_outgoing_call(&value);
1340 g_array_append_vals(*out_param1, &value, sizeof(int));
1343 case BT_DPM_SET_PAIRING_STATE: {
1344 dpm_status_t value = DPM_STATUS_ERROR;
1346 __bt_service_get_parameters(in_param1, &value,
1349 result = _bt_dpm_set_bluetooth_pairing_state(value);
1353 case BT_DPM_GET_PAIRING_STATE: {
1354 int value = DPM_STATUS_ERROR;
1356 result = _bt_dpm_get_bluetooth_pairing_state(&value);
1357 g_array_append_vals(*out_param1, &value, sizeof(int));
1360 case BT_DPM_SET_PROFILE_STATE: {
1361 int value = DPM_STATUS_ERROR;
1362 int profile = DPM_PROFILE_NONE;
1364 __bt_service_get_parameters(in_param1, &profile,
1366 __bt_service_get_parameters(in_param2, &value,
1369 result = _bt_dpm_set_bluetooth_profile_state(profile, value);
1373 case BT_DPM_GET_PROFILE_STATE: {
1374 int value = DPM_STATUS_ERROR;
1375 int profile = DPM_PROFILE_NONE;
1377 __bt_service_get_parameters(in_param1, &profile,
1380 result = _bt_dpm_get_bluetooth_profile_state(profile, &value);
1381 g_array_append_vals(*out_param1, &value, sizeof(int));
1384 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE: {
1385 int value = DPM_BT_ERROR;
1387 __bt_service_get_parameters(in_param1, &value,
1390 result = _bt_dpm_set_bluetooth_desktop_connectivity_state(value);
1394 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE: {
1395 int value = DPM_STATUS_ERROR;
1397 result = _bt_dpm_get_bluetooth_desktop_connectivity_state(&value);
1398 g_array_append_vals(*out_param1, &value, sizeof(int));
1401 case BT_DPM_SET_DISCOVERABLE_STATE: {
1402 int value = DPM_STATUS_ERROR;
1404 __bt_service_get_parameters(in_param1, &value,
1407 result = _bt_dpm_set_bluetooth_discoverable_state(value);
1411 case BT_DPM_GET_DISCOVERABLE_STATE: {
1412 int value = DPM_STATUS_ERROR;
1414 result = _bt_dpm_get_bluetooth_discoverable_state(&value);
1415 g_array_append_vals(*out_param1, &value, sizeof(int));
1418 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE: {
1419 int value = DPM_STATUS_ERROR;
1421 __bt_service_get_parameters(in_param1, &value,
1424 result = _bt_dpm_set_bluetooth_limited_discoverable_state(value);
1428 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE: {
1429 int value = DPM_STATUS_ERROR;
1431 result = _bt_dpm_get_bluetooth_limited_discoverable_state(&value);
1432 g_array_append_vals(*out_param1, &value, sizeof(int));
1435 case BT_DPM_SET_DATA_TRANSFER_STATE: {
1436 int value = DPM_STATUS_ERROR;
1438 __bt_service_get_parameters(in_param1, &value,
1441 result = _bt_dpm_set_bluetooth_data_transfer_state(value);
1445 case BT_DPM_GET_DATA_TRANSFER_STATE: {
1446 int value = DPM_STATUS_ERROR;
1448 result = _bt_dpm_get_allow_bluetooth_data_transfer_state(&value);
1449 g_array_append_vals(*out_param1, &value, sizeof(int));
1452 case BT_RFCOMM_CLIENT_CONNECT: {
1453 bluetooth_device_address_t address = { {0} };
1457 __bt_service_get_parameters(in_param1,
1458 &address, sizeof(bluetooth_device_address_t));
1459 input_string = (char *)g_variant_get_data(in_param2);
1460 __bt_service_get_parameters(in_param3, &connect_type, sizeof(int));
1462 if (connect_type == BT_RFCOMM_UUID)
1463 result = _bt_rfcomm_connect_using_uuid(&address, input_string);
1465 result = _bt_rfcomm_connect_using_channel(&address, input_string);
1467 if (result != BLUETOOTH_ERROR_NONE) {
1468 bluetooth_rfcomm_connection_t conn_info;
1470 BT_ERR("BT_RFCOMM_CLIENT_CONNECT failed, send error");
1471 memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
1472 if (connect_type == BT_RFCOMM_UUID)
1473 g_strlcpy(conn_info.uuid, input_string, BLUETOOTH_UUID_STRING_MAX);
1475 g_strlcpy(conn_info.uuid, "not_used", BLUETOOTH_UUID_STRING_MAX);
1477 conn_info.device_role = RFCOMM_ROLE_CLIENT;
1478 conn_info.socket_fd = -1;
1479 g_array_append_vals(*out_param1, &conn_info,
1480 sizeof(bluetooth_rfcomm_connection_t));
1482 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1483 _bt_convert_addr_type_to_string(addr, address.addr);
1484 sender = (char*)g_dbus_method_invocation_get_sender(context);
1485 _bt_save_invocation_context(context, result, sender, function_name, addr);
1489 case BT_RFCOMM_SOCKET_DISCONNECT: {
1491 * Bluetooth RFCOMM socket disconnection will be done from bt-api, call to bt-service
1492 * is only used for privilege check, so return BLUETOOTH_ERROR_NONE from here.
1494 result = BLUETOOTH_ERROR_NONE;
1497 case BT_RFCOMM_SOCKET_WRITE: {
1499 * This call to bt-service is only used for privilege check, so return
1500 * BLUETOOTH_ERROR_NONE from here.
1502 result = BLUETOOTH_ERROR_NONE;
1505 case BT_RFCOMM_CREATE_SOCKET: {
1507 * This call to bt-service is only used for privilege check, so return
1508 * BLUETOOTH_ERROR_NONE from here.
1510 result = BLUETOOTH_ERROR_NONE;
1513 case BT_RFCOMM_LISTEN_AND_ACCEPT: {
1517 sender = (char *)g_dbus_method_invocation_get_sender(context);
1518 uuid = (char *)g_variant_get_data(in_param1);
1520 result = _bt_rfcomm_socket_listen(sender, uuid, true);
1522 result = BLUETOOTH_ERROR_NONE;
1523 _bt_save_invocation_context(context,
1524 result, sender, function_name, NULL);
1526 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1530 case BT_RFCOMM_LISTEN: {
1534 sender = (char *)g_dbus_method_invocation_get_sender(context);
1535 uuid = (char *)g_variant_get_data(in_param1);
1537 result = _bt_rfcomm_socket_listen(sender, uuid, false);
1539 result = BLUETOOTH_ERROR_NONE;
1540 _bt_save_invocation_context(context,
1541 result, sender, function_name, NULL);
1543 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1547 case BT_RFCOMM_ACCEPT_CONNECTION: {
1550 address = (char *)g_variant_get_data(in_param1);
1551 result = _bt_socket_reply_conn_authorization(address, TRUE);
1554 case BT_RFCOMM_REJECT_CONNECTION: {
1557 address = (char *)g_variant_get_data(in_param1);
1558 result = _bt_socket_reply_conn_authorization(address, FALSE);
1561 case BT_RFCOMM_REMOVE_SOCKET: {
1563 * This call to bt-service is only used for privilege check, so return
1564 * BLUETOOTH_ERROR_NONE from here.
1566 result = BLUETOOTH_ERROR_NONE;
1569 case BT_RFCOMM_SEND_RX_DETAILS: {
1573 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1574 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1575 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1576 _bt_bm_add_transaction_details(uid, pid, size, RX_DATA);
1579 case BT_RFCOMM_SEND_TX_DETAILS: {
1583 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1584 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1585 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1586 _bt_bm_add_transaction_details(uid, pid, size, TX_DATA);
1589 case BT_RFCOMM_UPDATE_CONNECTION_INFO: {
1590 gboolean connected = FALSE;
1592 int role = RFCOMM_ROLE_SERVER;
1594 sender = (char *)g_dbus_method_invocation_get_sender(context);
1596 __bt_service_get_parameters(in_param1, &role, sizeof(int));
1597 __bt_service_get_parameters(in_param2, &connected, sizeof(gboolean));
1598 __bt_service_get_parameters(in_param3, &socket_fd, sizeof(int));
1600 if (connected == TRUE)
1601 result = _bt_rfcomm_conn_added(sender, role, socket_fd);
1603 result = _bt_rfcomm_conn_removed(sender, role, socket_fd);
1607 case BT_AUDIO_SELECT_ROLE: {
1608 bluetooth_audio_role_t role;
1610 __bt_service_get_parameters(in_param1,
1611 &role, sizeof(bluetooth_audio_role_t));
1613 result = _bt_audio_select_role(role);
1614 if (result == BLUETOOTH_ERROR_NONE) {
1615 sender = (char*)g_dbus_method_invocation_get_sender(context);
1616 _bt_save_invocation_context(context, result, sender,
1617 function_name, NULL);
1621 case BT_AUDIO_SET_ABSOLUTE_VOLUME: {
1622 unsigned int volume = 0;
1624 __bt_service_get_parameters(in_param1,
1625 &volume, sizeof(unsigned int));
1627 result = _bt_audio_set_absolute_volume(volume);
1630 case BT_AUDIO_GET_ABSOLUTE_VOLUME: {
1631 unsigned int volume = 0;
1633 result = _bt_audio_get_absolute_volume(&volume);
1634 g_array_append_vals(*out_param1, &volume, sizeof(unsigned int));
1637 case BT_AUDIO_IS_AVC_ACTIVATED: {
1640 result = _bt_audio_is_avc_activated(&activated);
1641 g_array_append_vals(*out_param1, &activated, sizeof(bool));
1644 case BT_AV_CONNECT: {
1645 bluetooth_device_address_t address = { {0} };
1646 __bt_service_get_parameters(in_param1,
1647 &address, sizeof(bluetooth_device_address_t));
1649 result = _bt_audio_is_profile_connection_in_progress(BT_AV_CONNECT, &address);
1651 if (result == BLUETOOTH_ERROR_NONE)
1652 result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
1654 if (result != BLUETOOTH_ERROR_NONE) {
1655 BT_ERR("AV Connect Request has failed to execute");
1656 char addr[BT_ADDRESS_STRING_SIZE];
1657 _bt_convert_addr_type_to_string(addr, address.addr);
1658 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1660 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1661 _bt_convert_addr_type_to_string(addr, address.addr);
1662 sender = (char*)g_dbus_method_invocation_get_sender(context);
1663 _bt_save_invocation_context(context, result, sender,
1664 function_name, (gpointer)addr);
1668 case BT_AUDIO_CONNECT: {
1669 bluetooth_device_address_t address = { {0} };
1670 __bt_service_get_parameters(in_param1,
1671 &address, sizeof(bluetooth_device_address_t));
1673 result = _bt_audio_is_profile_connection_in_progress(BT_AUDIO_CONNECT, &address);
1675 if (result == BLUETOOTH_ERROR_NONE)
1676 result = _bt_audio_connect(BT_AUDIO_ALL, &address);
1678 if (result != BLUETOOTH_ERROR_NONE) {
1679 BT_ERR("Audio All Connect Request has failed to execute");
1680 char addr[BT_ADDRESS_STRING_SIZE];
1681 _bt_convert_addr_type_to_string(addr, address.addr);
1682 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1684 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1685 _bt_convert_addr_type_to_string(addr, address.addr);
1686 sender = (char*)g_dbus_method_invocation_get_sender(context);
1687 _bt_save_invocation_context(context, result, sender,
1688 function_name, (gpointer)addr);
1692 case BT_AUDIO_DISCONNECT: {
1693 bluetooth_device_address_t address = { {0} };
1694 __bt_service_get_parameters(in_param1,
1695 &address, sizeof(bluetooth_device_address_t));
1697 result = _bt_audio_disconnect(BT_AUDIO_ALL, &address);
1699 if (result != BLUETOOTH_ERROR_NONE) {
1700 char addr[BT_ADDRESS_STRING_SIZE];
1701 _bt_convert_addr_type_to_string(addr, address.addr);
1702 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1704 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1705 _bt_convert_addr_type_to_string(addr, address.addr);
1706 sender = (char*)g_dbus_method_invocation_get_sender(context);
1707 _bt_save_invocation_context(context, result, sender,
1708 function_name, (gpointer)addr);
1712 case BT_AV_DISCONNECT: {
1713 bluetooth_device_address_t address = { {0} };
1714 __bt_service_get_parameters(in_param1,
1715 &address, sizeof(bluetooth_device_address_t));
1717 result = _bt_audio_disconnect(BT_AUDIO_A2DP, &address);
1719 if (result != BLUETOOTH_ERROR_NONE) {
1720 char addr[BT_ADDRESS_STRING_SIZE];
1721 _bt_convert_addr_type_to_string(addr, address.addr);
1722 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1724 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1725 _bt_convert_addr_type_to_string(addr, address.addr);
1726 sender = (char*)g_dbus_method_invocation_get_sender(context);
1727 _bt_save_invocation_context(context, result, sender,
1728 function_name, (gpointer)addr);
1732 case BT_AG_CONNECT: {
1733 bluetooth_device_address_t address = { {0} };
1734 __bt_service_get_parameters(in_param1,
1735 &address, sizeof(bluetooth_device_address_t));
1737 result = _bt_audio_is_profile_connection_in_progress(BT_AG_CONNECT, &address);
1739 if (result == BLUETOOTH_ERROR_NONE)
1740 result = _bt_audio_connect(BT_AUDIO_HSP, &address);
1742 if (result != BLUETOOTH_ERROR_NONE) {
1743 BT_ERR("AG Connect Request has failed to execute");
1744 char addr[BT_ADDRESS_STRING_SIZE];
1745 _bt_convert_addr_type_to_string(addr, address.addr);
1746 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1748 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1749 _bt_convert_addr_type_to_string(addr, address.addr);
1750 sender = (char*)g_dbus_method_invocation_get_sender(context);
1751 _bt_save_invocation_context(context, result, sender,
1752 function_name, (gpointer)addr);
1756 case BT_AG_DISCONNECT: {
1757 bluetooth_device_address_t address = { {0} };
1759 __bt_service_get_parameters(in_param1,
1760 &address, sizeof(bluetooth_device_address_t));
1762 result = _bt_audio_disconnect(BT_AUDIO_HSP, &address);
1764 if (result != BLUETOOTH_ERROR_NONE) {
1765 char addr[BT_ADDRESS_STRING_SIZE];
1766 _bt_convert_addr_type_to_string(addr, address.addr);
1767 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1769 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1770 _bt_convert_addr_type_to_string(addr, address.addr);
1771 sender = (char*)g_dbus_method_invocation_get_sender(context);
1772 _bt_save_invocation_context(context, result, sender,
1773 function_name, (gpointer)addr);
1777 case BT_AV_SOURCE_CONNECT: {
1778 bluetooth_device_address_t address = { {0} };
1780 __bt_service_get_parameters(in_param1,
1781 &address, sizeof(bluetooth_device_address_t));
1783 result = _bt_audio_is_profile_connection_in_progress(BT_AV_SOURCE_CONNECT,
1786 if (result == BLUETOOTH_ERROR_NONE)
1787 result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
1789 if (result != BLUETOOTH_ERROR_NONE) {
1790 BT_ERR("A2DP Source Connect Request has failed to execute");
1791 char addr[BT_ADDRESS_STRING_SIZE];
1792 _bt_convert_addr_type_to_string(addr, address.addr);
1793 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1795 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1796 _bt_convert_addr_type_to_string(addr, address.addr);
1797 sender = (char*)g_dbus_method_invocation_get_sender(context);
1798 _bt_save_invocation_context(context, result, sender,
1799 function_name, (gpointer)addr);
1803 case BT_AV_SOURCE_DISCONNECT: {
1804 bluetooth_device_address_t address = { {0} };
1806 __bt_service_get_parameters(in_param1,
1807 &address, sizeof(bluetooth_device_address_t));
1809 result = _bt_audio_disconnect(BT_AUDIO_A2DP_SOURCE, &address);
1810 if (result != BLUETOOTH_ERROR_NONE) {
1811 char addr[BT_ADDRESS_STRING_SIZE];
1812 _bt_convert_addr_type_to_string(addr, address.addr);
1813 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1815 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1816 _bt_convert_addr_type_to_string(addr, address.addr);
1817 sender = (char*)g_dbus_method_invocation_get_sender(context);
1818 _bt_save_invocation_context(context, result, sender,
1819 function_name, (gpointer)addr);
1823 case BT_HF_CONNECT: {
1824 bluetooth_device_address_t address = { {0} };
1826 __bt_service_get_parameters(in_param1,
1827 &address, sizeof(bluetooth_device_address_t));
1829 result = _bt_audio_is_profile_connection_in_progress(BT_HF_CONNECT,
1832 if (result == BLUETOOTH_ERROR_NONE)
1833 result = _bt_hf_connect(&address);
1835 if (result != BLUETOOTH_ERROR_NONE) {
1836 BT_ERR("HF Connect Request has failed to execute");
1837 char addr[BT_ADDRESS_STRING_SIZE];
1838 _bt_convert_addr_type_to_string(addr, address.addr);
1839 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1841 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1842 _bt_convert_addr_type_to_string(addr, address.addr);
1843 sender = (char*)g_dbus_method_invocation_get_sender(context);
1844 _bt_save_invocation_context(context, result, sender,
1845 function_name, (gpointer)addr);
1849 case BT_HF_DISCONNECT: {
1850 bluetooth_device_address_t address = { {0} };
1852 __bt_service_get_parameters(in_param1,
1853 &address, sizeof(bluetooth_device_address_t));
1855 result = _bt_hf_disconnect(&address);
1856 if (result != BLUETOOTH_ERROR_NONE) {
1857 char addr[BT_ADDRESS_STRING_SIZE];
1858 _bt_convert_addr_type_to_string(addr, address.addr);
1859 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1861 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1862 _bt_convert_addr_type_to_string(addr, address.addr);
1863 sender = (char*)g_dbus_method_invocation_get_sender(context);
1864 _bt_save_invocation_context(context, result, sender,
1865 function_name, (gpointer)addr);
1869 case BT_AVRCP_TARGET_CONNECT: {
1870 bluetooth_device_address_t address = { {0} };
1872 __bt_service_get_parameters(in_param1,
1873 &address, sizeof(bluetooth_device_address_t));
1875 result = _bt_audio_is_profile_connection_in_progress(BT_AVRCP_TARGET_CONNECT,
1878 if (result == BLUETOOTH_ERROR_NONE)
1879 result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
1881 if (result != BLUETOOTH_ERROR_NONE) {
1882 BT_ERR("AVRCP Target Connect Request has failed to execute");
1883 char addr[BT_ADDRESS_STRING_SIZE];
1884 _bt_convert_addr_type_to_string(addr, address.addr);
1885 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1887 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1888 _bt_convert_addr_type_to_string(addr, address.addr);
1889 sender = (char*)g_dbus_method_invocation_get_sender(context);
1890 _bt_save_invocation_context(context, result, sender,
1891 function_name, (gpointer)addr);
1895 case BT_AVRCP_TARGET_DISCONNECT: {
1896 bluetooth_device_address_t address = { {0} };
1898 __bt_service_get_parameters(in_param1,
1899 &address, sizeof(bluetooth_device_address_t));
1901 result = _bt_audio_disconnect(BT_AVRCP_TARGET, &address);
1902 if (result != BLUETOOTH_ERROR_NONE) {
1903 char addr[BT_ADDRESS_STRING_SIZE];
1904 _bt_convert_addr_type_to_string(addr, address.addr);
1905 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1907 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1908 _bt_convert_addr_type_to_string(addr, address.addr);
1909 sender = (char*)g_dbus_method_invocation_get_sender(context);
1910 _bt_save_invocation_context(context, result, sender,
1911 function_name, (gpointer)addr);
1915 case BT_AVRCP_CONTROL_CONNECT: {
1916 bluetooth_device_address_t address = { {0} };
1918 __bt_service_get_parameters(in_param1,
1919 &address, sizeof(bluetooth_device_address_t));
1921 result = _bt_audio_is_profile_connection_in_progress(BT_AVRCP_CONTROL_CONNECT,
1924 if (result == BLUETOOTH_ERROR_NONE)
1925 result = _bt_audio_connect(BT_AVRCP, &address);
1927 if (result != BLUETOOTH_ERROR_NONE) {
1928 BT_ERR("AVRCP Control Connect Request has failed to execute");
1929 char addr[BT_ADDRESS_STRING_SIZE];
1930 _bt_convert_addr_type_to_string(addr, address.addr);
1931 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1933 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1934 _bt_convert_addr_type_to_string(addr, address.addr);
1935 sender = (char*)g_dbus_method_invocation_get_sender(context);
1936 _bt_save_invocation_context(context, result, sender,
1937 function_name, (gpointer)addr);
1941 case BT_AVRCP_CONTROL_DISCONNECT: {
1942 bluetooth_device_address_t address = { {0} };
1944 __bt_service_get_parameters(in_param1,
1945 &address, sizeof(bluetooth_device_address_t));
1947 result = _bt_audio_disconnect(BT_AVRCP, &address);
1948 if (result != BLUETOOTH_ERROR_NONE) {
1949 char addr[BT_ADDRESS_STRING_SIZE];
1950 _bt_convert_addr_type_to_string(addr, address.addr);
1951 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1953 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1954 _bt_convert_addr_type_to_string(addr, address.addr);
1955 sender = (char*)g_dbus_method_invocation_get_sender(context);
1956 _bt_save_invocation_context(context, result, sender,
1957 function_name, (gpointer)addr);
1961 case BT_AVRCP_HANDLE_CONTROL: {
1963 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1964 result = _bt_avrcp_control_cmd(key_code);
1967 case BT_AVRCP_HANDLE_CONTROL_TO_DEST: {
1969 bluetooth_device_address_t address = { { 0 } };
1971 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1972 __bt_service_get_parameters(in_param2,
1973 &address, sizeof(bluetooth_device_address_t));
1975 result = _bt_avrcp_control_cmd_to_dest(key_code, &address);
1978 case BT_AVRCP_CONTROL_SET_PROPERTY: {
1982 __bt_service_get_parameters(in_param1,
1983 &type, sizeof(int));
1984 __bt_service_get_parameters(in_param2,
1985 &value, sizeof(unsigned int));
1987 result = _bt_avrcp_control_set_property(type, value);
1990 case BT_AVRCP_TRANSPORT_SET_PROPERTY: {
1995 __bt_service_get_parameters(in_param1,
1996 &type, sizeof(int));
1997 __bt_service_get_parameters(in_param2,
1998 &value, sizeof(unsigned int));
2000 result = _bt_avrcp_transport_set_property(type, value);
2004 case BT_AVRCP_CONTROL_GET_PROPERTY: {
2007 __bt_service_get_parameters(in_param1, &type, sizeof(int));
2009 result = _bt_avrcp_control_get_property(type);
2010 /* Save invocation */
2011 if (result == BLUETOOTH_ERROR_NONE) {
2012 sender = (char*)g_dbus_method_invocation_get_sender(context);
2013 _bt_save_invocation_context(context, result, sender,
2014 function_name, g_memdup2(&type, sizeof(int)));
2018 case BT_AVRCP_GET_TRACK_INFO: {
2019 result = _bt_avrcp_control_get_track_info();
2020 /* Save invocation */
2021 if (result == BLUETOOTH_ERROR_NONE) {
2022 sender = (char*)g_dbus_method_invocation_get_sender(context);
2023 _bt_save_invocation_context(context, result, sender,
2024 function_name, NULL);
2028 case BT_HDP_REGISTER_SINK_APP: {
2029 unsigned short data_type;
2030 bt_hdp_role_type_t role;
2031 bt_hdp_qos_type_t channel_type;
2032 int *app_id = g_new0(int, 1);
2034 __bt_service_get_parameters(in_param1,
2035 &data_type, sizeof(short));
2036 __bt_service_get_parameters(in_param2,
2037 &role, sizeof(bt_hdp_role_type_t));
2038 __bt_service_get_parameters(in_param3,
2039 &channel_type, sizeof(bt_hdp_qos_type_t));
2040 sender = (char*)g_dbus_method_invocation_get_sender(context);
2042 result = _bt_hdp_app_register(role,
2043 channel_type, data_type, sender, app_id);
2044 if (result != BLUETOOTH_ERROR_NONE) {
2045 g_array_append_vals(*out_param1, &app_id, sizeof(app_id));
2048 _bt_save_invocation_context(context, result, sender,
2049 function_name, (gpointer)app_id);
2053 case BT_HDP_UNREGISTER_SINK_APP: {
2055 int *app_id = g_new0(int, 1);
2057 app_handle = (char *)g_variant_get_data(in_param1);
2058 sscanf(app_handle, "health_app_%d", app_id);
2059 result = _bt_hdp_app_unregister(*app_id);
2060 if (result != BLUETOOTH_ERROR_NONE) {
2063 sender = (char*)g_dbus_method_invocation_get_sender(context);
2064 _bt_save_invocation_context(context, result, sender,
2065 function_name, (gpointer)app_id);
2069 case BT_HDP_CONNECT: {
2073 bt_hdp_connected_t *conn_info = NULL;
2075 conn_info = g_malloc0(sizeof(bt_hdp_connected_t));
2077 app_handle = (char *)g_variant_get_data(in_param1);
2078 conn_info->app_handle = app_handle;
2079 sscanf(app_handle, "health_app_%d", &app_id);
2081 __bt_service_get_parameters(in_param2,
2082 &(conn_info->type), sizeof(bt_hdp_qos_type_t));
2083 __bt_service_get_parameters(in_param3,
2084 &(conn_info->device_address),
2085 sizeof(bluetooth_device_address_t));
2087 result = _bt_hdp_connect(app_id, &(conn_info->device_address),
2088 conn_info->type, (int *)(&(conn_info->channel_id)));
2089 if (result != BLUETOOTH_ERROR_NONE) {
2090 g_array_append_vals(*out_param1, conn_info,
2091 sizeof(bt_hdp_connected_t));
2094 sender = (char*)g_dbus_method_invocation_get_sender(context);
2095 _bt_save_invocation_context(context, result, sender,
2096 function_name, (gpointer)conn_info);
2100 case BT_HDP_DISCONNECT: {
2101 bt_hdp_disconnected_t *hdp_disconn_info = NULL;
2103 hdp_disconn_info = g_malloc0(sizeof(bt_hdp_disconnected_t));
2105 __bt_service_get_parameters(in_param1,
2106 &(hdp_disconn_info->channel_id), sizeof(int));
2107 __bt_service_get_parameters(in_param2,
2108 &(hdp_disconn_info->device_address),
2109 sizeof(bluetooth_device_address_t));
2111 result = _bt_hdp_disconnect(hdp_disconn_info->channel_id);
2112 if (result != BLUETOOTH_ERROR_NONE) {
2113 g_array_append_vals(*out_param1, hdp_disconn_info,
2114 sizeof(bt_hdp_disconnected_t));
2115 g_free(hdp_disconn_info);
2117 sender = (char*)g_dbus_method_invocation_get_sender(context);
2118 _bt_save_invocation_context(context, result, sender,
2119 function_name, (gpointer)hdp_disconn_info);
2123 case BT_HDP_GET_FD: {
2124 int *channel_id = g_new0(int, 1);
2126 __bt_service_get_parameters(in_param1, channel_id, sizeof(int));
2128 result = _bt_hdp_get_fd(*channel_id);
2129 if (result != BLUETOOTH_ERROR_NONE) {
2132 sender = (char*)g_dbus_method_invocation_get_sender(context);
2133 _bt_save_invocation_context(context, result, sender,
2134 function_name, (gpointer)channel_id);
2138 case BT_HDP_SEND_DATA: {
2140 * This call to bt-service is only used for privilege check, so return
2141 * BLUETOOTH_ERROR_NONE from here.
2143 result = BLUETOOTH_ERROR_NONE;
2146 case BT_OOB_READ_LOCAL_DATA: { //208
2147 bt_oob_data_t local_oob_data;
2149 memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
2150 result = _bt_oob_read_local_data(&local_oob_data);
2152 g_array_append_vals(*out_param1, &local_oob_data,
2153 sizeof(bt_oob_data_t));
2157 case BT_OOB_ADD_REMOTE_DATA: { //209
2158 bluetooth_device_address_t address = { {0} };
2159 unsigned short address_type;
2160 bt_oob_data_t remote_oob_data;
2162 __bt_service_get_parameters(in_param1,
2163 &address, sizeof(bluetooth_device_address_t));
2164 __bt_service_get_parameters(in_param2,
2165 &address_type, sizeof(unsigned short));
2166 __bt_service_get_parameters(in_param3,
2167 &remote_oob_data, sizeof(bt_oob_data_t));
2169 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2173 case BT_OOB_REMOVE_REMOTE_DATA: { //210
2174 bluetooth_device_address_t address = { {0} };
2176 __bt_service_get_parameters(in_param1,
2177 &address, sizeof(bluetooth_device_address_t));
2179 result = _bt_oob_remove_remote_data(&address);
2183 case BT_LE_OOB_READ_LOCAL_DATA: {
2184 bt_oob_data_t local_oob_data;
2185 bt_oob_data_t *local_oob_cache_data;
2187 local_oob_cache_data = _bt_le_oob_get_local_cache_data();
2188 if (local_oob_cache_data && local_oob_cache_data->eir_len) {
2189 g_array_append_vals(*out_param1, local_oob_cache_data,
2190 sizeof(bt_oob_data_t));
2191 return BLUETOOTH_ERROR_NONE;
2194 /* We should modify this logic in later */
2195 if (_bt_is_le_static_random_address_enabled() == false) {
2196 /* Seperate BT & LE address */
2197 _bt_set_le_static_random_address(TRUE);
2200 result = _bt_le_oob_read_local_data(&local_oob_data);
2201 _bt_le_oob_set_local_cache_data(&local_oob_data);
2203 g_array_append_vals(*out_param1, &local_oob_data,
2204 sizeof(bt_oob_data_t));
2208 case BT_LE_OOB_ADD_REMOTE_DATA: {
2209 bluetooth_device_address_t address = { {0} };
2210 unsigned short address_type;
2211 bt_oob_data_t remote_oob_data;
2213 __bt_service_get_parameters(in_param1,
2214 &address, sizeof(bluetooth_device_address_t));
2215 __bt_service_get_parameters(in_param2,
2216 &address_type, sizeof(unsigned short));
2217 __bt_service_get_parameters(in_param3,
2218 &remote_oob_data, sizeof(bt_oob_data_t));
2220 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2224 case BT_AVRCP_SET_TRACK_INFO: {
2225 media_metadata_t data;
2226 media_metadata_attributes_t meta_data;
2228 memset(&data, 0x00, sizeof(media_metadata_t));
2229 memset(&meta_data, 0x00, sizeof(media_metadata_attributes_t));
2231 __bt_service_get_parameters(in_param1,
2232 &data, sizeof(media_metadata_t));
2234 meta_data.title = g_strdup(data.title);
2235 meta_data.artist = g_strdup(data.artist);
2236 meta_data.album = g_strdup(data.album);
2237 meta_data.genre = g_strdup(data.genre);
2238 meta_data.total_tracks = data.total_tracks;
2239 meta_data.number = data.number;
2240 meta_data.duration = (int64_t) data.duration;
2242 result = _bt_avrcp_set_track_info(&meta_data);
2244 g_free((gpointer)meta_data.title);
2245 g_free((gpointer)meta_data.artist);
2246 g_free((gpointer)meta_data.album);
2247 g_free((gpointer)meta_data.genre);
2251 case BT_AVRCP_SET_PROPERTY: {
2255 sender = (char *)g_dbus_method_invocation_get_sender(context);
2257 __bt_service_get_parameters(in_param1,
2258 &type, sizeof(int));
2259 __bt_service_get_parameters(in_param2,
2260 &value, sizeof(unsigned int));
2262 if (value == STATUS_PLAYING) {
2263 if (current_sender_playing)
2264 g_free(current_sender_playing);
2265 current_sender_playing = g_strdup(sender);
2267 if (g_strcmp0(sender, current_sender_playing) == 0 ||
2268 current_sender_playing == NULL) {
2269 BT_INFO("Current Player Status %d type %d Sender %s", value, type, sender);
2271 BT_INFO("Current Player and this sender (%s) are different", sender);
2272 result = BLUETOOTH_ERROR_NONE;
2275 result = _bt_avrcp_set_property(type, value);
2279 case BT_AVRCP_SET_PROPERTIES: {
2280 media_player_settings_t properties;
2282 memset(&properties, 0x00, sizeof(media_player_settings_t));
2283 __bt_service_get_parameters(in_param1,
2284 &properties, sizeof(media_player_settings_t));
2286 result = _bt_avrcp_set_properties(&properties);
2290 case BT_SET_ADVERTISING_DATA: {
2293 bluetooth_advertising_data_t adv = { {0} };
2295 gboolean use_reserved_slot = FALSE;
2297 app = (char *)g_dbus_method_invocation_get_sender(context);
2298 adv_handle = g_malloc0(sizeof(int));
2300 __bt_service_get_parameters(in_param1,
2301 adv_handle, sizeof(int));
2302 __bt_service_get_parameters(in_param3,
2303 &length, sizeof(int));
2304 __bt_service_get_parameters(in_param2,
2306 __bt_service_get_parameters(in_param4,
2307 &use_reserved_slot, sizeof(gboolean));
2308 result = _bt_set_advertising_data(app, *adv_handle,
2309 &adv, length, use_reserved_slot);
2310 if (result != BLUETOOTH_ERROR_NONE) {
2311 BT_ERR("Set Advertising data failed!!");
2314 _bt_save_invocation_context(context, result, app,
2315 function_name, (gpointer)adv_handle);
2319 case BT_SET_SCAN_RESPONSE_DATA: {
2322 bluetooth_scan_resp_data_t rsp = { {0} };
2324 gboolean use_reserved_slot = FALSE;
2326 app = (char *)g_dbus_method_invocation_get_sender(context);
2327 adv_handle = g_malloc0(sizeof(int));
2329 __bt_service_get_parameters(in_param1,
2330 adv_handle, sizeof(int));
2331 __bt_service_get_parameters(in_param3,
2332 &length, sizeof(int));
2333 __bt_service_get_parameters(in_param2,
2335 __bt_service_get_parameters(in_param4,
2336 &use_reserved_slot, sizeof(gboolean));
2338 result = _bt_set_scan_response_data(app, *adv_handle,
2339 &rsp, length, use_reserved_slot);
2341 if (result != BLUETOOTH_ERROR_NONE) {
2342 BT_ERR("Set Scan Response Data failed!!");
2345 _bt_save_invocation_context(context, result, app,
2346 function_name, (gpointer)adv_handle);
2350 case BT_SET_ADVERTISING: {
2353 gboolean enable = FALSE;
2354 gboolean use_reserved_slot = FALSE;
2356 adv_handle = g_malloc0(sizeof(int));
2357 __bt_service_get_parameters(in_param1,
2358 adv_handle, sizeof(int));
2359 __bt_service_get_parameters(in_param2,
2360 &enable, sizeof(gboolean));
2361 __bt_service_get_parameters(in_param3,
2362 &use_reserved_slot, sizeof(gboolean));
2364 app = (char *)g_dbus_method_invocation_get_sender(context);
2366 result = _bt_set_advertising(app, *adv_handle,
2367 enable, use_reserved_slot);
2368 if (result != BLUETOOTH_ERROR_NONE) {
2369 BT_ERR("Start Advertising failed!!");
2372 _bt_save_invocation_context(context, result, app,
2373 function_name, (gpointer)adv_handle);
2377 case BT_SET_CUSTOM_ADVERTISING: {
2380 gboolean enable = FALSE;
2381 bluetooth_advertising_params_t adv_params;
2382 gboolean use_reserved_slot = FALSE;
2384 app = (char *)g_dbus_method_invocation_get_sender(context);
2385 adv_handle = g_malloc0(sizeof(int));
2387 __bt_service_get_parameters(in_param1, adv_handle,
2389 __bt_service_get_parameters(in_param2, &enable,
2391 __bt_service_get_parameters(in_param3, &adv_params,
2392 sizeof(bluetooth_advertising_params_t));
2393 __bt_service_get_parameters(in_param4, &use_reserved_slot,
2396 BT_DBG("bluetooth_advertising_params_t [%d %d %d %d %d]",
2397 adv_params.interval_min, adv_params.interval_max,
2398 adv_params.filter_policy, adv_params.type, adv_params.tx_power_level);
2399 result = _bt_set_custom_advertising(app, *adv_handle,
2400 enable, &adv_params, use_reserved_slot);
2401 if (result != BLUETOOTH_ERROR_NONE) {
2402 BT_ERR("Start Custom Advertising failed!!");
2405 _bt_save_invocation_context(context, result, app,
2406 function_name, (gpointer)adv_handle);
2410 case BT_GET_SCAN_RESPONSE_DATA: {
2411 bluetooth_scan_resp_data_t rsp = { {0} };
2415 app = (char *)g_dbus_method_invocation_get_sender(context);
2417 __bt_service_get_parameters(in_param1, &adv_handle,
2420 result = _bt_get_scan_response_data(app, adv_handle, &rsp, &length);
2421 if (result == BLUETOOTH_ERROR_NONE)
2422 g_array_append_vals(*out_param1, rsp.data, length);
2426 case BT_GET_ADVERTISING_DATA: {
2427 bluetooth_advertising_data_t adv = { {0} };
2431 app = (char *)g_dbus_method_invocation_get_sender(context);
2433 __bt_service_get_parameters(in_param1, &adv_handle,
2436 result = _bt_get_advertising_data(app, adv_handle, &adv, &length);
2437 if (result == BLUETOOTH_ERROR_NONE)
2438 g_array_append_vals(*out_param1, adv.data, length);
2442 case BT_GATT_REGISTER_APPLICATION: {
2443 BT_DBG("Register GATT application:Unhandled!!");
2446 case BT_GATT_SERVER_REGISTER: {
2447 BT_DBG("GATT Server instance initialization");
2450 app = (char *)g_dbus_method_invocation_get_sender(context);
2451 BT_DBG("GATT Server Unique Name [%s]", app);
2453 /* No ADV handle: Set 0 */
2454 result = _bt_register_server_instance(app, 0);
2456 if (result != BLUETOOTH_ERROR_NONE) {
2457 BT_ERR("GATT Server registration failed. result %d", result);
2459 _bt_save_invocation_context(context, result, app,
2460 function_name, NULL);
2464 case BT_GATT_SERVER_DEREGISTER: {
2466 app = (char*)g_dbus_method_invocation_get_sender(context);
2468 result = _bt_unregister_server_instance(app, 0/* Adv Handle*/);
2471 case BT_GATT_SERVER_ADD_SERVICE: {
2472 BT_DBG("GATT Server Add Service");
2478 int *tmp_inst_id = NULL;
2480 app = (char *)g_dbus_method_invocation_get_sender(context);
2482 __bt_service_get_parameters(in_param1, &service_type,
2484 __bt_service_get_parameters(in_param2, &num_handles,
2486 svc_uuid = (char *)g_variant_get_data(in_param3);
2487 __bt_service_get_parameters(in_param4, &instance_id,
2490 result = _bt_gatt_server_add_service(app, service_type, num_handles, svc_uuid, instance_id);
2491 if (result != BLUETOOTH_ERROR_NONE) {
2492 BT_ERR("GATT Server Add Service failed!!");
2494 tmp_inst_id = g_malloc0(sizeof(int));
2495 *tmp_inst_id = instance_id;
2496 _bt_save_invocation_context(context, result, app,
2497 function_name, (gpointer)tmp_inst_id);
2501 case BT_GATT_SERVER_ADD_CHARACTERISTIC: {
2502 BT_DBG("GATT Server Add Characteristic");
2505 int *tmp_inst_id = NULL;
2506 bluetooth_gatt_server_attribute_params_t param;
2507 memset(¶m, 0, sizeof(bluetooth_gatt_server_attribute_params_t));
2509 app = (char*)g_dbus_method_invocation_get_sender(context);
2511 __bt_service_get_parameters(in_param1, ¶m,
2512 sizeof(bluetooth_gatt_server_attribute_params_t));
2513 char_uuid = (char *)g_variant_get_data(in_param2);
2515 result = _bt_gatt_server_add_characteristic(app, char_uuid, ¶m);
2516 if (result != BLUETOOTH_ERROR_NONE) {
2517 BT_ERR("GATT Server Add Service failed!!");
2519 tmp_inst_id = g_malloc0(sizeof(int));
2520 *tmp_inst_id = param.instance_id;
2522 _bt_save_invocation_context(context, result, app,
2523 function_name, (gpointer)tmp_inst_id);
2527 case BT_GATT_SERVER_ADD_DESCRIPTOR: {
2528 BT_DBG("GATT Server Add Descriptor");
2532 bt_gatt_permission_t perm;
2534 int *tmp_inst_id = NULL;
2535 memset(&perm, 0, sizeof(bt_gatt_permission_t));
2537 app = (char *)g_dbus_method_invocation_get_sender(context);
2539 __bt_service_get_parameters(in_param1, &service_handle,
2541 __bt_service_get_parameters(in_param2, &instance_id,
2543 desc_uuid = (char *)g_variant_get_data(in_param4);
2544 __bt_service_get_parameters(in_param3, &perm,
2545 sizeof(bt_gatt_permission_t));
2547 result = _bt_gatt_server_add_descriptor(app, desc_uuid, &perm, service_handle, instance_id);
2548 if (result != BLUETOOTH_ERROR_NONE) {
2549 BT_ERR("GATT Server Add Service failed!!");
2551 tmp_inst_id = g_malloc0(sizeof(int));
2552 *tmp_inst_id = instance_id;
2553 _bt_save_invocation_context(context, result, app,
2554 function_name, (gpointer)tmp_inst_id);
2558 case BT_GATT_SERVER_START_SERVICE: {
2563 int *tmp_inst_id = NULL;
2564 app = (char*)g_dbus_method_invocation_get_sender(context);
2566 __bt_service_get_parameters(in_param1, &service_handle,
2568 __bt_service_get_parameters(in_param2, &instance_id,
2571 result = _bt_gatt_server_start_service(app, service_handle, instance_id);
2573 if (BLUETOOTH_ERROR_NONE == result) {
2574 tmp_inst_id = g_malloc0(sizeof(int));
2575 *tmp_inst_id = instance_id;
2576 _bt_save_invocation_context(context, result, app,
2577 function_name, (gpointer)tmp_inst_id);
2581 case BT_GATT_SERVER_STOP_SERVICE: {
2585 int *tmp_inst_id = NULL;
2586 app = (char*)g_dbus_method_invocation_get_sender(context);
2588 __bt_service_get_parameters(in_param1, &service_handle,
2590 __bt_service_get_parameters(in_param2, &instance_id,
2593 result = _bt_gatt_server_stop_service(app, service_handle, instance_id);
2595 if (BLUETOOTH_ERROR_NONE == result) {
2596 tmp_inst_id = g_malloc0(sizeof(int));
2597 *tmp_inst_id = instance_id;
2598 _bt_save_invocation_context(context, result, app,
2599 function_name, (gpointer)tmp_inst_id);
2603 case BT_GATT_SERVER_DELETE_SERVICE: {
2606 int *tmp_inst_id = NULL;
2608 app = (char*)g_dbus_method_invocation_get_sender(context);
2610 __bt_service_get_parameters(in_param1, &service_handle,
2612 __bt_service_get_parameters(in_param2, &instance_id,
2615 result = _bt_gatt_server_delete_service(app, service_handle, instance_id);
2617 if (BLUETOOTH_ERROR_NONE == result) {
2618 tmp_inst_id = g_malloc0(sizeof(int));
2619 *tmp_inst_id = instance_id;
2620 _bt_save_invocation_context(context, result, app,
2621 function_name, (gpointer)tmp_inst_id);
2625 case BT_GATT_SERVER_SEND_RESPONSE: {
2626 bluetooth_gatt_server_response_params_t param;
2627 bluetooth_gatt_att_data_t data;
2630 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_response_params_t));
2631 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2633 app = (char*)g_dbus_method_invocation_get_sender(context);
2635 __bt_service_get_parameters(in_param1, &data,
2636 sizeof(bluetooth_gatt_att_data_t));
2637 __bt_service_get_parameters(in_param2, ¶m,
2638 sizeof(bluetooth_gatt_server_response_params_t));
2640 result = _bt_gatt_server_send_response(app, &data, ¶m);
2644 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE: {
2646 bluetooth_gatt_server_acquire_response_params_t param;
2649 msg = g_dbus_method_invocation_get_message(context);
2650 GUnixFDList *fd_list;
2655 fd_list = g_dbus_message_get_unix_fd_list(msg);
2657 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2659 app = (char*)g_dbus_method_invocation_get_sender(context);
2661 __bt_service_get_parameters(in_param1, ¶m,
2662 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2664 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2665 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2666 fd = fd_list_array[0];
2669 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2673 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE: {
2675 bluetooth_gatt_server_acquire_response_params_t param;
2678 msg = g_dbus_method_invocation_get_message(context);
2679 GUnixFDList *fd_list;
2684 fd_list = g_dbus_message_get_unix_fd_list(msg);
2686 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2688 app = (char*)g_dbus_method_invocation_get_sender(context);
2690 __bt_service_get_parameters(in_param1, ¶m,
2691 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2693 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2694 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2695 fd = fd_list_array[0];
2698 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2702 case BT_GATT_SERVER_SEND_INDICATION: {
2703 bluetooth_gatt_server_indication_params_t param;
2704 bluetooth_gatt_att_data_t data;
2705 bluetooth_device_address_t address;
2708 app = (char*)g_dbus_method_invocation_get_sender(context);
2710 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_indication_params_t));
2711 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2712 memset(&address, 0x00, sizeof(bluetooth_device_address_t));
2714 __bt_service_get_parameters(in_param1, &data,
2715 sizeof(bluetooth_gatt_att_data_t));
2716 __bt_service_get_parameters(in_param2, ¶m,
2717 sizeof(bluetooth_gatt_server_indication_params_t));
2718 __bt_service_get_parameters(in_param3, &address,
2719 sizeof(bluetooth_device_address_t));
2721 result = _bt_gatt_server_send_indication(app, &address, &data, ¶m);
2725 case BT_GATT_SERVER_UPDATE_VALUE: {
2726 bluetooth_gatt_server_update_value_t param;
2730 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_update_value_t));
2732 app = (char*)g_dbus_method_invocation_get_sender(context);
2734 __bt_service_get_parameters(in_param1, &instance_id,
2736 __bt_service_get_parameters(in_param2, ¶m,
2737 sizeof(bluetooth_gatt_server_update_value_t));
2739 result = _bt_gatt_server_update_attribute_value(app, instance_id, ¶m);
2742 case BT_GET_ATT_MTU: {
2743 bluetooth_device_address_t address = { {0} };
2744 unsigned int mtu = 0;
2746 __bt_service_get_parameters(in_param1,
2747 &address, sizeof(bluetooth_device_address_t));
2748 result = _bt_get_att_mtu(&address, &mtu);
2749 BT_DBG("MTU: %d", mtu);
2751 if (result == BLUETOOTH_ERROR_NONE) {
2752 g_array_append_vals(*out_param1, &mtu,
2753 sizeof(unsigned int));
2757 case BT_REQ_ATT_MTU: {
2758 bluetooth_device_address_t address = { {0} };
2762 sender = (char*)g_dbus_method_invocation_get_sender(context);
2764 __bt_service_get_parameters(in_param1,
2765 &address, sizeof(bluetooth_device_address_t));
2766 __bt_service_get_parameters(in_param2,
2767 &mtu, sizeof(unsigned int));
2768 BT_DBG("BT_REQ_ATT_MTU: %d", mtu);
2769 result = _bt_request_att_mtu(&address, mtu);
2770 if (BLUETOOTH_ERROR_NONE == result) {
2771 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2773 _bt_convert_addr_type_to_string(addr, address.addr);
2775 /* Save the informations to invocation */
2776 _bt_save_invocation_context(context, result, sender,
2777 function_name, (gpointer)addr);
2779 g_array_append_vals(*out_param1, &address,
2780 sizeof(bluetooth_device_address_t));
2784 case BT_GET_DEVICE_IDA: {
2785 bluetooth_device_address_t address = { {0} };
2786 bluetooth_device_address_t id_addr = { {0} };
2788 __bt_service_get_parameters(in_param1,
2789 &address, sizeof(bluetooth_device_address_t));
2791 result = _bt_device_get_ida(&address, &id_addr);
2793 if (result == BLUETOOTH_ERROR_NONE) {
2794 g_array_append_vals(*out_param1, &id_addr,
2795 sizeof(bluetooth_device_address_t));
2799 case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
2802 __bt_service_get_parameters(in_param1, &is_enable,
2805 result = _bt_set_le_static_random_address(is_enable);
2810 case BT_GATT_CLIENT_REGISTER: {
2811 bluetooth_device_address_t address = { {0} };
2814 sender = (char*)g_dbus_method_invocation_get_sender(context);
2816 __bt_service_get_parameters(in_param1,
2817 &address, sizeof(bluetooth_device_address_t));
2819 result = _bt_register_gatt_client_instance(sender, &address);
2820 if (BLUETOOTH_ERROR_NONE == result) {
2821 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2823 _bt_convert_addr_type_to_string(addr, address.addr);
2825 /* Save the informations to invocation */
2826 _bt_save_invocation_context(context, result, sender,
2827 function_name, (gpointer)addr);
2832 case BT_GATT_CLIENT_UNREGISTER: {
2835 sender = (char*)g_dbus_method_invocation_get_sender(context);
2836 __bt_service_get_parameters(in_param1,
2837 &client_id, sizeof(int));
2839 result = _bt_unregister_gatt_client_instance(sender, client_id);
2843 /* Async: Remote Interaction */
2844 case BT_GATT_ACQUIRE_WRITE: {
2848 bluetooth_gatt_client_char_prop_info_t param;
2850 sender = (char*)g_dbus_method_invocation_get_sender(context);
2852 __bt_service_get_parameters(in_param1, ¶m,
2853 sizeof(bluetooth_gatt_client_char_prop_info_t));
2856 result = _bt_gatt_acquire_write(¶m , &fd, &mtu);
2858 g_array_append_vals(*out_param1, &mtu, sizeof(int));
2860 if (BLUETOOTH_ERROR_NONE == result)
2861 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
2863 BT_ERR("GATT Client: gatt acquire write failed");
2867 GUnixFDList *fd_list = NULL;
2868 GError *error = NULL;
2870 /* Add socket fd to unix_fd_list */
2871 fd_list = g_unix_fd_list_new();
2872 g_unix_fd_list_append(fd_list, fd, &error);
2873 g_assert_no_error(error);
2875 _bt_service_method_return_with_unix_fd_list(
2876 context, *out_param1, result, fd_list);
2879 g_object_unref(fd_list);
2883 /* Async: Remote Interaction */
2884 case BT_CONNECT_LE: {
2885 bluetooth_device_address_t address = { {0} };
2886 gboolean auto_connect;
2890 sender = (char*)g_dbus_method_invocation_get_sender(context);
2892 __bt_service_get_parameters(in_param1,
2893 &address, sizeof(bluetooth_device_address_t));
2894 __bt_service_get_parameters(in_param2,
2895 &auto_connect, sizeof(gboolean));
2896 __bt_service_get_parameters(in_param3,
2897 &client_id, sizeof(int));
2899 BT_DBG("GATT Client: client_id[%d]", client_id);
2900 result = _bt_connect_le_device(&address, auto_connect, client_id);
2901 if (BLUETOOTH_ERROR_NONE == result) {
2902 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2903 _bt_convert_addr_type_to_string(addr, address.addr);
2905 /* Save the informations to invocation */
2906 _bt_save_invocation_context(context, result, sender,
2907 function_name, (gpointer)addr);
2910 _bt_handle_invocation_context(function_name, (void *)addr);
2912 BT_ERR("GATT Client: gatt connect failed. client_id[%d]", client_id);
2913 g_array_append_vals(*out_param1, &address,
2914 sizeof(bluetooth_device_address_t));
2918 /* Async: Remote Interaction */
2919 case BT_DISCONNECT_LE: {
2920 bluetooth_device_address_t address = { {0} };
2924 sender = (char*)g_dbus_method_invocation_get_sender(context);
2926 __bt_service_get_parameters(in_param1,
2927 &address, sizeof(bluetooth_device_address_t));
2928 __bt_service_get_parameters(in_param2,
2929 &client_id, sizeof(int));
2931 BT_INFO("GATT Disconnect using client Interface [%d]", client_id);
2932 result = _bt_disconnect_le_device(&address, client_id);
2933 if (BLUETOOTH_ERROR_NONE == result) {
2934 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2936 _bt_convert_addr_type_to_string(addr, address.addr);
2938 /* Save the informations to invocation */
2939 _bt_save_invocation_context(context, result, sender,
2940 function_name, (gpointer)addr);
2942 g_array_append_vals(*out_param1, &address,
2943 sizeof(bluetooth_device_address_t));
2948 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS: {
2949 guint available_packets = 0;
2951 result = _bt_gatt_get_data_batching_available_packets(&available_packets);
2952 BT_DBG("LE batching available packets %u", available_packets);
2953 if (result == BLUETOOTH_ERROR_NONE) {
2954 g_array_append_vals(*out_param1, &available_packets,
2961 case BT_ENABLE_GATT_DATA_BATCHING: {
2962 bluetooth_device_address_t address = { {0} };
2963 int packet_threshold;
2966 __bt_service_get_parameters(in_param1,
2967 &address, sizeof(bluetooth_device_address_t));
2968 __bt_service_get_parameters(in_param2,
2969 &packet_threshold, sizeof(int));
2970 __bt_service_get_parameters(in_param3,
2971 &timeout, sizeof(int));
2972 result = _bt_gatt_enable_data_batching(&address, packet_threshold, timeout);
2977 case BT_DISABLE_GATT_DATA_BATCHING: {
2978 bluetooth_device_address_t address = { {0} };
2980 __bt_service_get_parameters(in_param1,
2981 &address, sizeof(bluetooth_device_address_t));
2982 result = _bt_gatt_disable_data_batching(&address);
2987 case BT_GATT_GET_PRIMARY_SERVICES: {
2990 sender = (char*)g_dbus_method_invocation_get_sender(context);
2991 bluetooth_device_address_t address = { {0} };
2993 __bt_service_get_parameters(in_param1, &address,
2994 sizeof(bluetooth_device_address_t));
2996 addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
2997 _bt_convert_addr_type_to_string(addr, address.addr);
2999 result = _bt_gatt_get_primary_services(addr);
3000 if (BLUETOOTH_ERROR_NONE == result) {
3001 _bt_save_invocation_context(context, result, sender,
3002 function_name, (gpointer)addr);
3008 case BT_GATT_GET_SERVICE_PROPERTIES: {
3009 bluetooth_gatt_client_svc_prop_info_t param;
3011 sender = (char*)g_dbus_method_invocation_get_sender(context);
3012 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_svc_prop_info_t));
3014 __bt_service_get_parameters(in_param1, ¶m,
3015 sizeof(bluetooth_gatt_client_svc_prop_info_t));
3017 result = _bt_gatt_get_all_characteristic(¶m);
3018 if (BLUETOOTH_ERROR_NONE == result) {
3019 /* Save the informations to invocation */
3020 _bt_save_invocation_context(context, result, sender,
3022 (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_svc_prop_info_t)));
3026 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: {
3027 bluetooth_gatt_client_char_prop_info_t param;
3029 sender = (char*)g_dbus_method_invocation_get_sender(context);
3030 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3032 __bt_service_get_parameters(in_param1, ¶m,
3033 sizeof(bluetooth_gatt_client_char_prop_info_t));
3035 result = _bt_gatt_get_all_characteristic_properties(¶m);
3036 if (BLUETOOTH_ERROR_NONE == result) {
3037 /* Save the informations to invocation */
3038 _bt_save_invocation_context(context, result, sender,
3040 (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3044 /* Async: Remote Interaction */
3045 case BT_GATT_READ_CHARACTERISTIC: {
3046 bluetooth_gatt_client_char_prop_info_t param;
3048 sender = (char*)g_dbus_method_invocation_get_sender(context);
3049 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3051 __bt_service_get_parameters(in_param1, ¶m,
3052 sizeof(bluetooth_gatt_client_char_prop_info_t));
3054 result = _bt_gatt_read_characteristic_value(¶m);
3055 if (BLUETOOTH_ERROR_NONE == result) {
3056 /* Save the informations to invocation */
3057 _bt_save_invocation_context(context, result, sender,
3059 (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3063 /* Async: Remote Interaction */
3064 case BT_GATT_READ_DESCRIPTOR_VALUE: {
3065 bluetooth_gatt_client_desc_prop_info_t param;
3067 sender = (char*)g_dbus_method_invocation_get_sender(context);
3068 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3070 __bt_service_get_parameters(in_param1, ¶m,
3071 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3073 result = _bt_gatt_read_descriptor_value(¶m);
3074 if (BLUETOOTH_ERROR_NONE == result) {
3075 /* Save the informations to invocation */
3076 _bt_save_invocation_context(context, result, sender,
3078 (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3082 /* Async: Remote Interaction */
3083 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: {
3084 bluetooth_gatt_client_char_prop_info_t param;
3085 bluetooth_gatt_att_data_t data;
3086 bluetooth_gatt_write_type_e write_type;
3088 sender = (char*)g_dbus_method_invocation_get_sender(context);
3090 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3091 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3093 __bt_service_get_parameters(in_param1, ¶m,
3094 sizeof(bluetooth_gatt_client_char_prop_info_t));
3095 __bt_service_get_parameters(in_param2, &data,
3096 sizeof(bluetooth_gatt_att_data_t));
3097 __bt_service_get_parameters(in_param3, &write_type,
3098 sizeof(bluetooth_gatt_write_type_e));
3100 result = _bt_gatt_write_characteristic_value_by_type(¶m , &data, write_type);
3101 if (BLUETOOTH_ERROR_NONE == result) {
3102 /* Save the informations to invocation */
3103 _bt_save_invocation_context(context, result, sender,
3105 (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3109 /* Async: Remote Interaction */
3110 case BT_GATT_WRITE_DESCRIPTOR_VALUE: {
3111 bluetooth_gatt_client_desc_prop_info_t param;
3112 bluetooth_gatt_att_data_t data;
3113 bluetooth_gatt_write_type_e write_type;
3115 sender = (char*)g_dbus_method_invocation_get_sender(context);
3116 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3117 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3119 __bt_service_get_parameters(in_param1, ¶m,
3120 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3121 __bt_service_get_parameters(in_param2, &data,
3122 sizeof(bluetooth_gatt_att_data_t));
3123 __bt_service_get_parameters(in_param3, &write_type,
3124 sizeof(bluetooth_gatt_write_type_e));
3126 result = _bt_gatt_write_descriptor_value_by_type(¶m, &data, write_type);
3127 if (BLUETOOTH_ERROR_NONE == result) {
3128 /* Save the informations to invocation */
3129 _bt_save_invocation_context(context, result, sender,
3131 (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3136 case BT_GATT_WATCH_CHARACTERISTIC: {
3137 bluetooth_gatt_client_char_prop_info_t param;
3142 gboolean is_indicate;
3145 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3147 sender = (char*)g_dbus_method_invocation_get_sender(context);
3149 __bt_service_get_parameters(in_param1, ¶m,
3150 sizeof(bluetooth_gatt_client_char_prop_info_t));
3151 __bt_service_get_parameters(in_param2, &client_id,
3153 __bt_service_get_parameters(in_param3, &is_notify,
3155 __bt_service_get_parameters(in_param4, &is_indicate,
3158 #ifdef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
3162 if (is_indicate == false) {
3163 result = _bt_gatt_acquire_notify(¶m , &fd, &mtu);
3164 if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
3165 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
3167 GUnixFDList *fd_list = NULL;
3168 GError *error = NULL;
3170 g_array_append_vals(*out_param1, &mtu, sizeof(int));
3171 /* Add socket fd to unix_fd_list */
3172 fd_list = g_unix_fd_list_new();
3173 g_unix_fd_list_append(fd_list, fd, &error);
3174 g_assert_no_error(error);
3176 _bt_service_method_return_with_unix_fd_list(
3177 context, *out_param1, result, fd_list);
3179 g_object_unref(fd_list);
3185 result = _bt_gatt_watch_characteristic(¶m , client_id, is_notify);
3186 if (BLUETOOTH_ERROR_NONE == result) {
3187 /* Save the informations to invocation */
3188 _bt_save_invocation_context(context, result, sender, function_name,
3189 (gpointer)g_memdup2(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3194 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: {
3195 gboolean is_enabled;
3196 bluetooth_device_address_t address;
3198 sender = (char*)g_dbus_method_invocation_get_sender(context);
3200 __bt_service_get_parameters(in_param1,
3201 &address, sizeof(bluetooth_device_address_t));
3202 __bt_service_get_parameters(in_param2, &is_enabled,
3204 result = _bt_gatt_watch_service_changed_indication(sender, &address, is_enabled);
3205 BT_INFO("Service changed indication from app [%s]", sender);
3209 case BT_LE_CONN_UPDATE: {
3210 char *sender = NULL;
3211 bluetooth_device_address_t local_address = { {0} };
3212 bluetooth_le_connection_param_t parameters = {0};
3214 sender = (char *)g_dbus_method_invocation_get_sender(context);
3216 __bt_service_get_parameters(in_param1, &local_address,
3217 sizeof(bluetooth_device_address_t));
3218 __bt_service_get_parameters(in_param2, ¶meters,
3219 sizeof(bluetooth_le_connection_param_t));
3221 result = _bt_le_connection_update(sender,
3223 parameters.interval_min,
3224 parameters.interval_max,
3226 parameters.timeout);
3229 case BT_START_LE_DISCOVERY: {
3233 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3235 sender = (char *)g_dbus_method_invocation_get_sender(context);
3237 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3238 BT_ERR("Fail to get the sender pid");
3240 result = _bt_start_le_scan(sender, uid, pid);
3241 if (result == BLUETOOTH_ERROR_NONE) {
3242 _bt_save_invocation_context(context, result, sender,
3243 function_name, NULL);
3245 BT_DBG("Remeber pid / uid for the scan operation");
3246 _bt_bm_add_scan_app(SCAN_LE, uid, pid);
3250 case BT_STOP_LE_DISCOVERY: {
3254 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3256 sender = (char *)g_dbus_method_invocation_get_sender(context);
3258 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3259 BT_ERR("Fail to get the sender pid");
3261 result = _bt_stop_le_scan(sender);
3262 if (result == BLUETOOTH_ERROR_NONE) {
3263 _bt_save_invocation_context(context, result, sender,
3264 function_name, NULL);
3267 BT_DBG("Remove pid / uid for the scan operation");
3268 _bt_bm_remove_scan_app(SCAN_LE, uid, pid);
3272 case BT_IS_LE_DISCOVERYING: {
3273 gboolean le_discovering = FALSE;
3275 le_discovering = _bt_is_le_scanning();
3276 g_array_append_vals(*out_param1,
3277 &le_discovering, sizeof(gboolean));
3280 case BT_SET_SCAN_PARAMETERS: {
3281 bluetooth_le_scan_params_t scan_params;
3283 __bt_service_get_parameters(in_param1, &scan_params,
3284 sizeof(bluetooth_le_scan_params_t));
3286 BT_DBG("bluetooth_le_scan_params_t [%f %f %d]",
3287 scan_params.interval, scan_params.window,
3290 result = _bt_prepare_scan_parameters(&scan_params, 0);
3293 case BT_SET_SCAN_TYPE: {
3295 __bt_service_get_parameters(in_param1, &scan_type, sizeof(int));
3297 BT_DBG("bluetooth_le_scan_type [%d]", scan_type);
3298 result = _bt_prepare_scan_parameters(NULL, scan_type);
3301 #ifdef TIZEN_FEATURE_BT_PAN_NAP
3302 case BT_NETWORK_ACTIVATE:
3303 BT_DBG("BT_NETWORK_ACTIVATE Request recieved Request Handler ");
3304 result = _bt_network_activate();
3306 case BT_NETWORK_DEACTIVATE:
3307 result = _bt_network_deactivate();
3309 case BT_NETWORK_CONNECT: {
3310 bluetooth_device_address_t address = { {0} };
3313 __bt_service_get_parameters(in_param1,
3314 &address, sizeof(bluetooth_device_address_t));
3315 __bt_service_get_parameters(in_param2,
3316 &role, sizeof(int));
3318 result = _bt_network_connect(request_id, role, &address);
3319 if (result != BLUETOOTH_ERROR_NONE) {
3320 g_array_append_vals(*out_param1, &address,
3321 sizeof(bluetooth_device_address_t));
3325 case BT_NETWORK_DISCONNECT: {
3326 bluetooth_device_address_t address = { {0} };
3328 __bt_service_get_parameters(in_param1,
3329 &address, sizeof(bluetooth_device_address_t));
3331 result = _bt_network_disconnect(request_id, &address);
3332 if (result != BLUETOOTH_ERROR_NONE) {
3333 g_array_append_vals(*out_param1, &address,
3334 sizeof(bluetooth_device_address_t));
3338 case BT_NETWORK_SERVER_DISCONNECT: {
3339 bluetooth_device_address_t address = { {0} };
3341 __bt_service_get_parameters(in_param1,
3342 &address, sizeof(bluetooth_device_address_t));
3344 result = _bt_network_server_disconnect(request_id, &address);
3345 if (result != BLUETOOTH_ERROR_NONE) {
3346 g_array_append_vals(*out_param1, &address,
3347 sizeof(bluetooth_device_address_t));
3353 #ifdef TIZEN_FEATURE_BT_IPSP
3354 case BT_LE_IPSP_INIT:
3355 result = _bt_initialize_ipsp();
3357 case BT_LE_IPSP_DEINIT:
3358 result = _bt_deinitialize_ipsp();
3360 case BT_LE_IPSP_CONNECT: {
3361 bluetooth_device_address_t address = { {0} };
3362 __bt_service_get_parameters(in_param1, &address,
3363 sizeof(bluetooth_device_address_t));
3364 result = _bt_connect_le_ipsp_device(&address);
3367 case BT_LE_IPSP_DISCONNECT: {
3368 bluetooth_device_address_t address = { {0} };
3369 __bt_service_get_parameters(in_param1, &address,
3370 sizeof(bluetooth_device_address_t));
3371 result = _bt_disconnect_le_ipsp_device(&address);
3375 case BT_IS_ADVERTISING: {
3376 gboolean advertising = FALSE;
3377 advertising = _bt_is_advertising();
3378 g_array_append_vals(*out_param1, &advertising,
3382 case BT_IS_LE_2M_PHY_SUPPORTED: {
3383 gboolean is_2m_phy_supported = FALSE;
3385 is_2m_phy_supported = _bt_is_le_2m_phy_supported();
3386 g_array_append_vals(*out_param1, &is_2m_phy_supported, sizeof(gboolean));
3389 case BT_IS_LE_CODED_PHY_SUPPORTED: {
3390 gboolean is_coded_phy_supported = FALSE;
3392 is_coded_phy_supported = _bt_is_le_coded_phy_supported();
3393 g_array_append_vals(*out_param1, &is_coded_phy_supported, sizeof(gboolean));
3396 case BT_DISCONNECT_DEVICE: {
3397 bluetooth_device_address_t address = { {0} };
3399 __bt_service_get_parameters(in_param1,
3400 &address, sizeof(bluetooth_device_address_t));
3402 result = _bt_disconnect_device(&address);
3405 case BT_REGISTER_SCAN_FILTER: {
3406 bluetooth_le_scan_filter_t scan_filter;
3408 sender = (char*)g_dbus_method_invocation_get_sender(context);
3409 __bt_service_get_parameters(in_param1, &scan_filter,
3410 sizeof(bluetooth_le_scan_filter_t));
3412 BT_DBG("bluetooth_le_scan_filter_t [features : 0x%.2x]",
3413 scan_filter.added_features);
3415 result = _bt_register_scan_filter(sender, &scan_filter);
3420 case BT_TDS_PROVIDER_REGISTER: {
3421 char *sender = NULL;
3423 sender = (char *)g_dbus_method_invocation_get_sender(context);
3424 result = _bt_tds_provider_register(sender);
3429 case BT_TDS_PROVIDER_UNREGISTER: {
3430 char *sender = NULL;
3432 sender = (char *)g_dbus_method_invocation_get_sender(context);
3433 result = _bt_tds_provider_unregister(sender);
3438 case BT_TDS_PROVIDER_SET_MANUF_DATA: {
3439 char *sender = NULL;
3440 unsigned int length = 0;
3441 bluetooth_advertising_data_t manuf_data;
3443 __bt_service_get_parameters(in_param1,
3444 &length, sizeof(unsigned int));
3445 __bt_service_get_parameters(in_param2,
3446 &manuf_data, sizeof(bluetooth_advertising_data_t));
3447 sender = (char *)g_dbus_method_invocation_get_sender(context);
3449 result = _bt_tds_provider_set_manuf_data(sender, manuf_data.data, length);
3453 case BT_TDS_PROVIDER_CREATE: {
3454 char *sender = NULL;
3455 unsigned int tds_handle = 0;
3458 __bt_service_get_parameters(in_param1,
3459 &tds_handle, sizeof(unsigned int));
3460 __bt_service_get_parameters(in_param2,
3461 &transport, sizeof(int));
3462 sender = (char *)g_dbus_method_invocation_get_sender(context);
3463 result = _bt_tds_provider_transport_create(sender, transport, tds_handle);
3468 case BT_TDS_PROVIDER_DESTROY: {
3469 char *sender = NULL;
3470 unsigned int tds_handle = 0;
3472 __bt_service_get_parameters(in_param1,
3473 &tds_handle, sizeof(unsigned int));
3474 sender = (char *)g_dbus_method_invocation_get_sender(context);
3475 result = _bt_tds_provider_transport_remove(sender, tds_handle);
3480 case BT_TDS_PROVIDER_SET_TRANSPORT_DATA: {
3481 char *sender = NULL;
3482 unsigned int tds_handle = 0;
3483 int transport_state = 0;
3484 bluetooth_tds_data_t tds_data;
3486 __bt_service_get_parameters(in_param1,
3487 &tds_handle, sizeof(unsigned int));
3488 __bt_service_get_parameters(in_param2,
3489 &transport_state, sizeof(int));
3490 __bt_service_get_parameters(in_param3,
3491 &tds_data, sizeof(bluetooth_tds_data_t));
3492 sender = (char *)g_dbus_method_invocation_get_sender(context);
3494 result = _bt_tds_provider_set_transport_data(sender, tds_handle,
3495 transport_state, tds_data.data, tds_data.length);
3499 case BT_TDS_SEND_ACTIVATION_RESPONSE: {
3500 bluetooth_device_address_t address = { {0} };
3501 bluetooth_tds_data_t tds_data;
3502 char *sender = NULL;
3503 unsigned int tds_handle = 0;
3506 __bt_service_get_parameters(in_param1,
3507 &tds_handle, sizeof(unsigned int));
3508 __bt_service_get_parameters(in_param2,
3509 &response, sizeof(int));
3510 __bt_service_get_parameters(in_param3, &address,
3511 sizeof(bluetooth_device_address_t));
3512 __bt_service_get_parameters(in_param4,
3513 &tds_data, sizeof(bluetooth_tds_data_t));
3514 sender = (char *)g_dbus_method_invocation_get_sender(context);
3516 result = _bt_tds_provider_send_activation_response(sender, tds_handle,
3517 &address, response, tds_data.data, tds_data.length);
3522 sender = (char*)g_dbus_method_invocation_get_sender(context);
3523 BT_INFO("Mesh: Init by [%s]", sender);
3524 result = _bt_mesh_init(sender);
3525 /* Save invocation */
3526 if (result == BLUETOOTH_ERROR_NONE) {
3527 BT_INFO("Mesh: Save Invoation");
3528 sender = (char*)g_dbus_method_invocation_get_sender(context);
3529 _bt_save_invocation_context(context,
3531 function_name, NULL);
3535 case BT_MESH_DEINIT:
3536 sender = (char*)g_dbus_method_invocation_get_sender(context);
3537 BT_INFO("Mesh: De-Init by [%s]", sender);
3538 result = _bt_mesh_deinit(sender);
3541 case BT_MESH_NETWORK_CREATE: {
3542 bluetooth_mesh_node_t node;
3543 GSList *model_list = NULL;
3544 int total_models = 0;
3547 const char *network_name = NULL;
3548 bluetooth_mesh_network_t *network;
3550 memset(&node, 0x00, sizeof(bluetooth_mesh_node_t));
3551 sender = (char*)g_dbus_method_invocation_get_sender(context);
3553 __bt_service_get_parameters(in_param1,
3554 &node, sizeof(bluetooth_mesh_node_t));
3555 network_name = (const char *)g_variant_get_data(in_param2);
3557 BT_INFO("MESH: Network name [%s]", network_name);
3559 param3 = g_array_new(TRUE, TRUE, sizeof(gchar));
3560 __bt_fill_garray_from_variant(in_param3, param3);
3562 total_models = (param3->len) / sizeof(bluetooth_mesh_model_t);
3563 for (i = 0; i < total_models; i++) {
3564 bluetooth_mesh_model_t *info = NULL;
3565 bluetooth_mesh_model_t *mod = NULL;
3567 info = &g_array_index(param3,
3568 bluetooth_mesh_model_t, i);
3570 mod = g_memdup2(info, sizeof(bluetooth_mesh_model_t));
3573 model_list = g_slist_append(model_list,
3576 result = _bt_mesh_network_create(requester_unique_creds,
3577 sender, network_name, &node, model_list);
3579 /* Save invocation */
3580 if (result == BLUETOOTH_ERROR_NONE) {
3581 BT_INFO("Mesh: Save Invoation");
3582 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3584 /* Save Network name & UUID, Token will be received in event */
3585 _bt_mesh_util_convert_hex_to_string(
3586 (uint8_t *) node.uuid, 16,
3588 BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
3589 BT_INFO("Mesh: Mesh Netwok UUID [%s]", network->uuid);
3590 g_strlcpy(network->name.name, network_name,
3591 sizeof(network->name.name));
3592 g_strlcpy(network->app_cred,
3593 requester_unique_creds,
3594 sizeof(network->app_cred));
3595 sender = (char*)g_dbus_method_invocation_get_sender(context);
3596 BT_INFO("Mesh: Network Create by [%s]", sender);
3597 _bt_save_invocation_context(context,
3599 function_name, (gpointer)network);
3601 g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
3602 BT_ERR("Mesh: Mesh Network creation schedule failed");
3603 g_slist_free_full(model_list, g_free);
3607 BT_INFO("Mesh: Cleanup");
3608 g_free((gpointer)requester_unique_creds);
3609 g_array_free(param3, TRUE);
3610 BT_INFO("Mesh: Cleanup Done");
3613 case BT_MESH_NETWORK_DESTROY: {
3614 bluetooth_mesh_network_t network;
3615 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3617 __bt_service_get_parameters(in_param1,
3618 &network, sizeof(bluetooth_mesh_network_t));
3620 BT_INFO("Mesh: Destroy Network");
3621 result = _bt_mesh_network_destroy(requester_unique_creds,
3624 if (result != BLUETOOTH_ERROR_NONE) {
3625 g_array_append_vals(*out_param1,
3626 &network, sizeof(bluetooth_mesh_network_t));
3628 BT_INFO("Mesh: Destroy Network scheduled: add invocation");
3629 bluetooth_mesh_network_t *net = \
3630 g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
3632 sender = (char*)g_dbus_method_invocation_get_sender(context);
3633 _bt_save_invocation_context(context, result, sender,
3634 function_name, (gpointer)net);
3638 case BT_MESH_NETWORK_LOAD: {
3640 bluetooth_mesh_network_t *network;
3641 token = (char *)g_variant_get_data(in_param1);
3642 BT_INFO("MESH: Network Load: Token string [%s]", token);
3643 result = _bt_mesh_network_load(requester_unique_creds, sender, token);
3644 /* Save invocation */
3645 if (result == BLUETOOTH_ERROR_NONE) {
3646 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3647 g_strlcpy(network->token.token, token,
3648 BLUETOOTH_MESH_NETWORK_TOKEN_STRING_LENGTH + 1);
3649 g_strlcpy(network->app_cred, requester_unique_creds,
3650 sizeof(network->app_cred));
3652 sender = (char*)g_dbus_method_invocation_get_sender(context);
3653 _bt_save_invocation_context(context, result, sender,
3654 function_name, (gpointer)network);
3656 g_free((gpointer)requester_unique_creds);
3659 case BT_MESH_NETWORK_UNLOAD: {
3660 bluetooth_mesh_network_t network;
3661 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3663 __bt_service_get_parameters(in_param1,
3664 &network, sizeof(bluetooth_mesh_network_t));
3666 BT_INFO("MESH: Network Unload: Network UUID [%s]", network.uuid);
3667 result = _bt_mesh_network_unload(requester_unique_creds,
3671 case BT_MESH_NETWORK_JOIN: {
3672 bluetooth_mesh_node_t node;
3673 GSList *model_list = NULL;
3674 int total_models = 0;
3678 memset(&node, 0x00, sizeof(bluetooth_mesh_node_t));
3679 sender = (char*)g_dbus_method_invocation_get_sender(context);
3681 __bt_service_get_parameters(in_param1,
3682 &node, sizeof(bluetooth_mesh_node_t));
3684 param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
3685 __bt_fill_garray_from_variant(in_param2, param2);
3687 total_models = (param2->len) / sizeof(bluetooth_mesh_model_t);
3688 for (i = 0; i < total_models; i++) {
3689 bluetooth_mesh_model_t *info = NULL;
3690 bluetooth_mesh_model_t *mod = NULL;
3691 info = &g_array_index(param2,
3692 bluetooth_mesh_model_t, i);
3693 mod = g_memdup2(info, sizeof(bluetooth_mesh_model_t));
3696 model_list = g_slist_append(model_list,
3700 BT_INFO("MESH: Network Join bt-service");
3701 //result = BLUETOOTH_ERROR_NONE;
3702 result = _bt_mesh_network_join(requester_unique_creds,
3703 sender, &node, model_list);
3704 if (result != BLUETOOTH_ERROR_NONE) {
3705 g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
3706 BT_ERR("Mesh: Mesh Join Network schedule failed");
3707 g_slist_free_full(model_list, g_free);
3710 BT_INFO("return of _bt_mesh_network_join : [%d]", result);
3713 case BT_MESH_CANCEL_JOIN: {
3714 bluetooth_mesh_node_info_t node;
3715 memset(&node, 0x00, sizeof(bluetooth_mesh_node_info_t));
3717 __bt_service_get_parameters(in_param1,
3718 &node, sizeof(bluetooth_mesh_node_info_t));
3720 BT_INFO("Mesh: Cancel Join request");
3721 result = _bt_mesh_cancel_join(requester_unique_creds,
3723 if (result != BLUETOOTH_ERROR_NONE) {
3724 g_array_append_vals(*out_param1,
3725 &node, sizeof(bluetooth_mesh_node_t));
3729 case BT_MESH_NETWORK_SCAN: {
3730 bluetooth_mesh_network_t network;
3731 bluetooth_mesh_scan_param_t param;
3732 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3733 memset(¶m, 0x00, sizeof(bluetooth_mesh_scan_param_t));
3735 __bt_service_get_parameters(in_param1,
3736 &network, sizeof(bluetooth_mesh_network_t));
3738 __bt_service_get_parameters(in_param2,
3739 ¶m, sizeof(bluetooth_mesh_scan_param_t));
3741 result = _bt_mesh_network_scan(requester_unique_creds,
3742 sender, &network, ¶m);
3744 if (result != BLUETOOTH_ERROR_NONE) {
3745 g_array_append_vals(*out_param1,
3746 &network, sizeof(bluetooth_mesh_network_t));
3748 bluetooth_mesh_network_t *net = \
3749 g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
3751 sender = (char*)g_dbus_method_invocation_get_sender(context);
3752 _bt_save_invocation_context(context, result, sender,
3753 function_name, (gpointer)net);
3757 case BT_MESH_NETWORK_CANCEL_SCAN: {
3758 bluetooth_mesh_network_t network;
3759 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3761 __bt_service_get_parameters(in_param1,
3762 &network, sizeof(bluetooth_mesh_network_t));
3764 result = _bt_mesh_network_scan_cancel(requester_unique_creds,
3767 if (result != BLUETOOTH_ERROR_NONE)
3768 g_array_append_vals(*out_param1,
3769 &network, sizeof(bluetooth_mesh_network_t));
3772 case BT_MESH_NETWORK_SET_CAPABILITIES: {
3773 bluetooth_mesh_network_t network;
3774 bluetooth_mesh_provisioner_caps_t caps;
3775 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3776 memset(&caps, 0x00, sizeof(bluetooth_mesh_provisioner_caps_t));
3778 __bt_service_get_parameters(in_param1,
3779 &network, sizeof(bluetooth_mesh_network_t));
3781 __bt_service_get_parameters(in_param2,
3782 &caps, sizeof(bluetooth_mesh_provisioner_caps_t));
3784 result = _bt_mesh_network_set_provisioner_caps(
3785 requester_unique_creds, sender, &network, &caps);
3789 case BT_MESH_NETWORK_PROVISION_DEVICE: {
3790 bluetooth_mesh_provisioning_request_t req;
3791 memset(&req, 0x00, sizeof(bluetooth_mesh_provisioning_request_t));
3793 __bt_service_get_parameters(in_param1,
3794 &req, sizeof(bluetooth_mesh_provisioning_request_t));
3796 BT_INFO("Mesh: Provision Device UUID [%s]", req.dev_uuid);
3797 BT_INFO("Mesh: Provision Device in network[%s]", req.net_uuid);
3799 result = _bt_mesh_network_provision_device(
3800 requester_unique_creds, sender, &req);
3802 /* Save invocation */
3803 if (result != BLUETOOTH_ERROR_NONE) {
3804 g_array_append_vals(*out_param1, &req,
3805 sizeof(bluetooth_mesh_provisioning_request_t));
3807 bluetooth_mesh_provisioning_request_t *param = \
3808 g_memdup2(&req, sizeof(bluetooth_mesh_provisioning_request_t));
3810 sender = (char*)g_dbus_method_invocation_get_sender(context);
3811 _bt_save_invocation_context(context, result, sender,
3812 function_name, (gpointer)param);
3816 case BT_MESH_AUTHENTICATION_REPLY: {
3817 BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REPLY");
3818 const char *auth_value = NULL;
3819 gboolean authentication_reply = FALSE;
3821 auth_value = g_variant_get_data(in_param2);
3822 __bt_service_get_parameters(in_param3,
3823 &authentication_reply, sizeof(gboolean));
3824 __bt_service_get_parameters(in_param1,
3825 &auth_type, sizeof(int));
3826 BT_INFO("Mesh: Auth Reply Type [%d]", auth_type);
3827 BT_INFO("Mesh: Auth Value [%s]", auth_value);
3828 BT_INFO("Mesh: Auth Accept [%d]", authentication_reply);
3829 result = _bt_mesh_authentication_reply(auth_type,
3830 auth_value, authentication_reply);
3833 case BT_MESH_NETWORK_SET_NAME: {
3834 bluetooth_mesh_network_t network;
3835 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3837 __bt_service_get_parameters(in_param1,
3838 &network, sizeof(bluetooth_mesh_network_t));
3840 result = _bt_mesh_network_set_name(requester_unique_creds, sender, &network);
3844 case BT_MESH_NETWORK_ADD_NETKEY: {
3845 bluetooth_mesh_network_t network;
3846 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3848 __bt_service_get_parameters(in_param1,
3849 &network, sizeof(bluetooth_mesh_network_t));
3851 result = _bt_mesh_network_add_netkey(requester_unique_creds,
3854 if (result != BLUETOOTH_ERROR_NONE) {
3855 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3857 bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
3859 sender = (char*)g_dbus_method_invocation_get_sender(context);
3860 _bt_save_invocation_context(context, result, sender,
3861 function_name, (gpointer)net);
3865 case BT_MESH_NETWORK_DELETE_NETKEY: {
3866 bluetooth_mesh_network_t network;
3869 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3871 __bt_service_get_parameters(in_param1,
3872 &network, sizeof(bluetooth_mesh_network_t));
3873 __bt_service_get_parameters(in_param2,
3874 &index, sizeof(guint16));
3876 result = _bt_mesh_network_delete_netkey(requester_unique_creds,
3877 sender, &network, index);
3879 if (result != BLUETOOTH_ERROR_NONE) {
3880 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3882 bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
3884 sender = (char*)g_dbus_method_invocation_get_sender(context);
3885 _bt_save_invocation_context(context, result, sender,
3886 function_name, (gpointer)net);
3890 case BT_MESH_NETWORK_UPDATE_NETKEY: {
3891 bluetooth_mesh_network_t network;
3894 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3896 __bt_service_get_parameters(in_param1,
3897 &network, sizeof(bluetooth_mesh_network_t));
3898 __bt_service_get_parameters(in_param2,
3899 &index, sizeof(guint16));
3901 result = _bt_mesh_network_update_netkey(requester_unique_creds,
3902 sender, &network, index);
3904 if (result != BLUETOOTH_ERROR_NONE) {
3905 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3907 bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
3909 sender = (char*)g_dbus_method_invocation_get_sender(context);
3910 _bt_save_invocation_context(context, result, sender,
3911 function_name, (gpointer)net);
3915 case BT_MESH_NETWORK_ADD_APPKEY: {
3916 bluetooth_mesh_network_t network;
3919 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3921 __bt_service_get_parameters(in_param1,
3922 &network, sizeof(bluetooth_mesh_network_t));
3923 __bt_service_get_parameters(in_param2,
3924 &net_idx, sizeof(guint16));
3926 result = _bt_mesh_network_add_appkey(requester_unique_creds,
3927 sender, &network, net_idx);
3929 if (result != BLUETOOTH_ERROR_NONE) {
3930 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3932 bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
3934 sender = (char*)g_dbus_method_invocation_get_sender(context);
3935 _bt_save_invocation_context(context, result, sender,
3936 function_name, (gpointer)net);
3940 case BT_MESH_NETWORK_UPDATE_APPKEY: {
3941 bluetooth_mesh_network_t network;
3945 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3947 __bt_service_get_parameters(in_param1,
3948 &network, sizeof(bluetooth_mesh_network_t));
3949 __bt_service_get_parameters(in_param2,
3950 &net_idx, sizeof(guint16));
3951 __bt_service_get_parameters(in_param3,
3952 &app_idx, sizeof(guint16));
3954 result = _bt_mesh_network_update_appkey(requester_unique_creds,
3955 sender, &network, net_idx, app_idx);
3957 if (result != BLUETOOTH_ERROR_NONE) {
3958 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3960 bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
3962 sender = (char*)g_dbus_method_invocation_get_sender(context);
3963 _bt_save_invocation_context(context, result, sender,
3964 function_name, (gpointer)net);
3968 case BT_MESH_NETWORK_DELETE_APPKEY: {
3969 bluetooth_mesh_network_t network;
3973 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3975 __bt_service_get_parameters(in_param1,
3976 &network, sizeof(bluetooth_mesh_network_t));
3977 __bt_service_get_parameters(in_param2,
3978 &net_idx, sizeof(guint16));
3979 __bt_service_get_parameters(in_param3,
3980 &app_idx, sizeof(guint16));
3982 result = _bt_mesh_network_delete_appkey(requester_unique_creds,
3983 sender, &network, net_idx, app_idx);
3985 if (result != BLUETOOTH_ERROR_NONE) {
3986 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3988 bluetooth_mesh_network_t *net = g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
3990 sender = (char*)g_dbus_method_invocation_get_sender(context);
3991 _bt_save_invocation_context(context, result, sender,
3992 function_name, (gpointer)net);
3996 case BT_MESH_NETWORK_GET_NETKEYS: {
3997 bluetooth_mesh_network_t network;
3998 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3999 __bt_service_get_parameters(in_param1,
4000 &network, sizeof(bluetooth_mesh_network_t));
4001 result = _bt_mesh_network_get_netkeys(requester_unique_creds,
4002 sender, &network, out_param1);
4005 case BT_MESH_NETWORK_GET_APPKEYS: {
4006 bluetooth_mesh_network_t network;
4009 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
4010 __bt_service_get_parameters(in_param1,
4011 &network, sizeof(bluetooth_mesh_network_t));
4012 __bt_service_get_parameters(in_param2,
4013 &net_idx, sizeof(guint16));
4014 result = _bt_mesh_network_get_appkeys(
4015 requester_unique_creds, sender,
4016 &network, net_idx, out_param1);
4019 case BT_MESH_NETWORK_GET_NODES: {
4020 bluetooth_mesh_network_t network;
4021 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
4022 __bt_service_get_parameters(in_param1,
4023 &network, sizeof(bluetooth_mesh_network_t));
4024 result = _bt_mesh_network_get_nodes(
4025 requester_unique_creds, sender,
4026 &network, out_param1);
4029 case BT_MESH_ELEMENT_GET_MODELS: {
4030 bluetooth_mesh_network_t network;
4034 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
4035 __bt_service_get_parameters(in_param1,
4036 &network, sizeof(bluetooth_mesh_network_t));
4037 __bt_service_get_parameters(in_param2,
4038 &node_addr, sizeof(guint16));
4039 __bt_service_get_parameters(in_param3,
4040 &elem_idx, sizeof(int));
4041 result = _bt_mesh_element_get_models(requester_unique_creds, sender,
4042 &network, node_addr, elem_idx, out_param1);
4045 case BT_MESH_NODE_BROWSE: {
4046 bluetooth_mesh_node_discover_t req;
4047 memset(&req, 0x00, sizeof(bluetooth_mesh_node_discover_t));
4049 __bt_service_get_parameters(in_param1,
4050 &req, sizeof(bluetooth_mesh_node_discover_t));
4052 result = _bt_mesh_browse_remote_node(
4053 requester_unique_creds, sender, &req);
4055 /* Save invocation */
4056 if (result != BLUETOOTH_ERROR_NONE) {
4057 g_array_append_vals(*out_param1, &req,
4058 sizeof(bluetooth_mesh_node_discover_t));
4060 bluetooth_mesh_node_discover_t *param = \
4061 g_memdup2(&req, sizeof(bluetooth_mesh_node_discover_t));
4063 sender = (char*)g_dbus_method_invocation_get_sender(context);
4064 _bt_save_invocation_context(context, result, sender,
4065 function_name, (gpointer)param);
4069 case BT_MESH_NODE_GET_VENDOR_FEATURES: {
4070 bluetooth_mesh_node_features_t req;
4071 memset(&req, 0x00, sizeof(bluetooth_mesh_node_features_t));
4073 __bt_service_get_parameters(in_param1,
4074 &req, sizeof(bluetooth_mesh_node_features_t));
4076 result = _bt_mesh_node_discover_vendor_features(
4077 requester_unique_creds, sender, &req);
4079 /* Save invocation */
4080 if (result != BLUETOOTH_ERROR_NONE) {
4081 g_array_append_vals(*out_param1,
4082 &req, sizeof(bluetooth_mesh_node_features_t));
4084 bluetooth_mesh_node_features_t *param = \
4085 g_memdup2(&req, sizeof(bluetooth_mesh_node_features_t));
4087 sender = (char*)g_dbus_method_invocation_get_sender(context);
4088 _bt_save_invocation_context(context, result, sender,
4089 function_name, (gpointer)param);
4093 case BT_MESH_NODE_CONFIGURE_KEY: {
4094 bluetooth_mesh_key_configure_t req;
4096 memset(&req, 0x00, sizeof(bluetooth_mesh_key_configure_t));
4098 __bt_service_get_parameters(in_param1,
4099 &req, sizeof(bluetooth_mesh_key_configure_t));
4101 result = _bt_mesh_node_configure_key(
4102 requester_unique_creds, sender, &req);
4104 /* Save invocation */
4105 if (result != BLUETOOTH_ERROR_NONE) {
4106 g_array_append_vals(*out_param1,
4107 &req, sizeof(bluetooth_mesh_key_configure_t));
4109 bluetooth_mesh_key_configure_t *param = \
4110 g_memdup2(&req, sizeof(bluetooth_mesh_key_configure_t));
4112 sender = (char*)g_dbus_method_invocation_get_sender(context);
4113 _bt_save_invocation_context(context, result, sender,
4114 function_name, (gpointer)param);
4118 case BT_MESH_NODE_TTL_EXECUTE: {
4119 bluetooth_mesh_node_ttl_info_t req;
4121 memset(&req, 0x00, sizeof(bluetooth_mesh_node_ttl_info_t));
4123 __bt_service_get_parameters(in_param1,
4124 &req, sizeof(bluetooth_mesh_node_ttl_info_t));
4126 result = _bt_mesh_ttl_execute_remote_node(
4127 requester_unique_creds, sender, &req);
4129 /* Save invocation */
4130 if (result != BLUETOOTH_ERROR_NONE) {
4131 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_node_ttl_info_t));
4133 bluetooth_mesh_node_ttl_info_t *param = \
4134 g_memdup2(&req, sizeof(bluetooth_mesh_node_ttl_info_t));
4136 sender = (char*)g_dbus_method_invocation_get_sender(context);
4137 _bt_save_invocation_context(context, result, sender,
4138 function_name, (gpointer)param);
4142 case BT_MESH_MODEL_CONFIGURE_APPKEY: {
4143 bluetooth_mesh_model_configure_t req;
4145 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4147 __bt_service_get_parameters(in_param1,
4148 &req, sizeof(bluetooth_mesh_model_configure_t));
4150 result = _bt_mesh_node_model_appkey_execute(
4151 requester_unique_creds, sender, &req);
4153 /* Save invocation */
4154 if (result != BLUETOOTH_ERROR_NONE) {
4155 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4157 bluetooth_mesh_model_configure_t *param = \
4158 g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
4160 sender = (char*)g_dbus_method_invocation_get_sender(context);
4161 _bt_save_invocation_context(context, result, sender,
4162 function_name, (gpointer)param);
4166 case BT_MESH_MODEL_EXECUTE_MSG: {
4167 bluetooth_mesh_model_msg_t req;
4169 memset(&req, 0x00, sizeof(bluetooth_mesh_model_msg_t));
4171 __bt_service_get_parameters(in_param1,
4172 &req, sizeof(bluetooth_mesh_model_msg_t));
4174 result = _bt_mesh_model_execute_msg(
4175 requester_unique_creds, sender, &req);
4177 /* Save invocation */
4178 if (result != BLUETOOTH_ERROR_NONE) {
4179 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_msg_t));
4181 bluetooth_mesh_model_msg_t *param = \
4182 g_memdup2(&req, sizeof(bluetooth_mesh_model_msg_t));
4184 sender = (char*)g_dbus_method_invocation_get_sender(context);
4185 _bt_save_invocation_context(context, result, sender,
4186 function_name, (gpointer)param);
4190 case BT_MESH_MODEL_RESPONSE_MSG: {
4191 bluetooth_mesh_model_msg_t req;
4192 memset(&req, 0x00, sizeof(bluetooth_mesh_model_msg_t));
4193 __bt_service_get_parameters(in_param1,
4194 &req, sizeof(bluetooth_mesh_model_msg_t));
4196 result = _bt_mesh_model_send_response(
4197 requester_unique_creds, sender, &req);
4198 if (result != BLUETOOTH_ERROR_NONE)
4199 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_msg_t));
4202 case BT_MESH_NODE_GET_NETKEYS: {
4203 bluetooth_mesh_node_discover_t node;
4204 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
4205 __bt_service_get_parameters(in_param1,
4206 &node, sizeof(bluetooth_mesh_node_discover_t));
4207 result = _bt_mesh_network_node_get_netkeys(
4208 requester_unique_creds, &node, out_param1);
4211 case BT_MESH_NODE_GET_APPKEYS: {
4212 bluetooth_mesh_node_discover_t node;
4213 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
4214 __bt_service_get_parameters(in_param1,
4215 &node, sizeof(bluetooth_mesh_node_discover_t));
4216 result = _bt_mesh_network_node_get_appkeys(
4217 requester_unique_creds, sender, &node, out_param1);
4220 case BT_MESH_NODE_RESET: {
4221 bluetooth_mesh_node_info_t node;
4222 memset(&node, 0x00, sizeof(bluetooth_mesh_node_info_t));
4224 __bt_service_get_parameters(in_param1,
4225 &node, sizeof(bluetooth_mesh_node_info_t));
4227 BT_INFO("Mesh: Reset the Node");
4228 result = _bt_mesh_network_reset_node(requester_unique_creds,
4233 case BT_MESH_MODEL_GET_APPKEY_LIST: {
4234 bluetooth_mesh_model_configure_t req;
4236 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4238 __bt_service_get_parameters(in_param1,
4239 &req, sizeof(bluetooth_mesh_model_configure_t));
4241 result = _bt_mesh_node_model_get_appkey_list(
4242 requester_unique_creds, sender, &req);
4244 /* Save invocation */
4245 if (result != BLUETOOTH_ERROR_NONE) {
4246 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4248 bluetooth_mesh_model_configure_t *param = \
4249 g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
4251 sender = (char*)g_dbus_method_invocation_get_sender(context);
4252 _bt_save_invocation_context(context, result, sender,
4253 function_name, (gpointer)param);
4257 case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST: {
4258 bluetooth_mesh_model_configure_t req;
4260 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4262 __bt_service_get_parameters(in_param1,
4263 &req, sizeof(bluetooth_mesh_model_configure_t));
4265 result = _bt_mesh_node_model_get_subscription_list(
4266 requester_unique_creds, sender, &req);
4268 /* Save invocation */
4269 if (result != BLUETOOTH_ERROR_NONE) {
4270 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4272 bluetooth_mesh_model_configure_t *param = \
4273 g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
4275 sender = (char*)g_dbus_method_invocation_get_sender(context);
4276 _bt_save_invocation_context(context, result, sender,
4277 function_name, (gpointer)param);
4282 case BT_MESH_NETWORK_CREATE_GROUP: {
4283 bluetooth_mesh_network_t net;
4284 bluetooth_mesh_network_group_info_t res;
4285 gboolean is_virtual;
4288 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
4289 memset(&res, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
4291 __bt_service_get_parameters(in_param1,
4292 &net, sizeof(bluetooth_mesh_network_t));
4293 __bt_service_get_parameters(in_param2,
4294 &is_virtual, sizeof(gboolean));
4295 __bt_service_get_parameters(in_param3,
4296 &grp_addr, sizeof(guint16));
4298 result = _bt_mesh_network_create_group(
4299 requester_unique_creds, sender, &net,
4300 is_virtual, grp_addr, &res);
4302 if (result == BLUETOOTH_ERROR_NONE)
4303 g_array_append_vals(*out_param1, &res,
4304 sizeof(bluetooth_mesh_network_group_info_t));
4307 case BT_MESH_NETWORK_REMOVE_GROUP: {
4308 bluetooth_mesh_network_t net;
4309 bluetooth_mesh_network_group_info_t req;
4311 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
4312 memset(&req, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
4314 __bt_service_get_parameters(in_param1,
4315 &net, sizeof(bluetooth_mesh_network_t));
4316 __bt_service_get_parameters(in_param2,
4317 &req, sizeof(bluetooth_mesh_network_group_info_t));
4319 result = _bt_mesh_network_remove_group(
4320 requester_unique_creds, sender, &net, &req);
4324 case BT_MESH_MODEL_CONFIG_GROUP_SUB: {
4325 bluetooth_mesh_model_configure_t req;
4327 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4329 __bt_service_get_parameters(in_param1,
4330 &req, sizeof(bluetooth_mesh_model_configure_t));
4332 result = _bt_mesh_model_configure_group_subscription(
4333 requester_unique_creds, sender, &req);
4335 /* Save invocation */
4336 if (result != BLUETOOTH_ERROR_NONE) {
4337 g_array_append_vals(*out_param1,
4338 &req, sizeof(bluetooth_mesh_model_configure_t));
4340 bluetooth_mesh_model_configure_t *param = \
4341 g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
4343 sender = (char*)g_dbus_method_invocation_get_sender(context);
4344 _bt_save_invocation_context(context, result, sender,
4345 function_name, (gpointer)param);
4349 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB: {
4350 bluetooth_mesh_model_configure_t req;
4352 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4354 __bt_service_get_parameters(in_param1,
4355 &req, sizeof(bluetooth_mesh_model_configure_t));
4357 result = _bt_mesh_model_configure_virtual_group_subscription(
4358 requester_unique_creds, sender, &req);
4360 /* Save invocation */
4361 if (result != BLUETOOTH_ERROR_NONE) {
4362 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4364 bluetooth_mesh_model_configure_t *param = \
4365 g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
4367 sender = (char*)g_dbus_method_invocation_get_sender(context);
4368 _bt_save_invocation_context(context, result, sender,
4369 function_name, (gpointer)param);
4373 case BT_MESH_MODEL_SET_PUBLICATION: {
4374 bluetooth_mesh_model_configure_t req;
4376 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4378 __bt_service_get_parameters(in_param1,
4379 &req, sizeof(bluetooth_mesh_model_configure_t));
4381 result = _bt_mesh_model_set_publication(
4382 requester_unique_creds, sender, &req);
4384 /* Save invocation */
4385 if (result != BLUETOOTH_ERROR_NONE) {
4386 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4388 bluetooth_mesh_model_configure_t *param = g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
4390 sender = (char*)g_dbus_method_invocation_get_sender(context);
4391 _bt_save_invocation_context(context, result, sender,
4392 function_name, (gpointer)param);
4396 case BT_MESH_MODEL_GET_PUBLICATION: {
4397 bluetooth_mesh_model_configure_t req;
4399 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4401 __bt_service_get_parameters(in_param1,
4402 &req, sizeof(bluetooth_mesh_model_configure_t));
4404 result = _bt_mesh_model_get_publication(
4405 requester_unique_creds, sender, &req);
4407 /* Save invocation */
4408 if (result != BLUETOOTH_ERROR_NONE) {
4409 g_array_append_vals(*out_param1,
4410 &req, sizeof(bluetooth_mesh_model_configure_t));
4412 bluetooth_mesh_model_configure_t *param = \
4413 g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
4415 sender = (char*)g_dbus_method_invocation_get_sender(context);
4416 _bt_save_invocation_context(context, result, sender,
4417 function_name, (gpointer)param);
4421 case BT_MESH_NETWORK_GET_GROUPS: {
4422 bluetooth_mesh_network_t network;
4423 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
4424 __bt_service_get_parameters(in_param1,
4425 &network, sizeof(bluetooth_mesh_network_t));
4426 BT_INFO("Mesh: Request:: Get Groups");
4427 result = _bt_mesh_network_get_groups(
4428 requester_unique_creds, sender, &network, out_param1);
4431 case BT_L2CAP_LE_CLIENT_CONNECT: {
4432 bluetooth_device_address_t address = { {0} };
4435 __bt_service_get_parameters(in_param1,
4436 &address, sizeof(bluetooth_device_address_t));
4438 __bt_service_get_parameters(in_param2, &psm, sizeof(int));
4440 result = _bt_l2cap_le_connect_using_psm(&address, psm);
4442 if (result != BLUETOOTH_ERROR_NONE) {
4443 bluetooth_l2cap_le_connection_t conn_info;
4445 BT_ERR("BT_L2CAP_LE_CLIENT_CONNECT failed, send error errcode %d", result);
4446 memset(&conn_info, 0x00, sizeof(bluetooth_l2cap_le_connection_t));
4447 conn_info.device_role = L2CAP_LE_ROLE_CLIENT;
4448 conn_info.socket_fd = -1;
4449 conn_info.psm = psm;
4450 g_array_append_vals(*out_param1, &conn_info,
4451 sizeof(bluetooth_l2cap_le_connection_t));
4453 bluetooth_l2cap_le_connection_t *conn_info;
4455 BT_INFO("BT_L2CAP_LE_CLIENT_CONNECT success, save context");
4456 sender = (char*)g_dbus_method_invocation_get_sender(context);
4457 conn_info = g_malloc0(sizeof(bluetooth_l2cap_le_connection_t));
4458 conn_info->socket_fd = -1;
4459 conn_info->device_role = L2CAP_LE_ROLE_CLIENT;
4460 conn_info->psm = psm;
4462 memcpy(&conn_info->device_addr, &address, sizeof(bluetooth_device_address_t));
4464 _bt_save_invocation_context(context, result, sender, function_name, (gpointer)conn_info);
4468 case BT_L2CAP_LE_SOCKET_DISCONNECT: {
4470 * Bluetooth L2CAP_LE socket disconnection will be done from bt-api, call to bt-service
4471 * is only used for privilege check, so return BLUETOOTH_ERROR_NONE from here.
4473 result = BLUETOOTH_ERROR_NONE;
4476 case BT_L2CAP_LE_SOCKET_WRITE: {
4478 * This call to bt-service is only used for privilege check, so return
4479 * BLUETOOTH_ERROR_NONE from here.
4481 result = BLUETOOTH_ERROR_NONE;
4484 case BT_L2CAP_LE_CREATE_SOCKET: {
4486 * This call to bt-service is only used for privilege check, so return
4487 * BLUETOOTH_ERROR_NONE from here.
4489 result = BLUETOOTH_ERROR_NONE;
4492 case BT_L2CAP_LE_LISTEN_AND_ACCEPT: {
4496 __bt_service_get_parameters(in_param1, &psm, sizeof(int));
4498 socket_fd = _bt_l2cap_le_socket_listen(psm, true);
4499 if (socket_fd > 0) {
4500 result = BLUETOOTH_ERROR_NONE;
4501 _bt_save_invocation_context(context,
4502 result, sender, function_name, NULL);
4504 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
4508 case BT_L2CAP_LE_LISTEN: {
4512 __bt_service_get_parameters(in_param1, &psm, sizeof(int));
4514 socket_fd = _bt_l2cap_le_socket_listen(psm, false);
4515 if (socket_fd > 0) {
4516 result = BLUETOOTH_ERROR_NONE;
4517 _bt_save_invocation_context(context, result,
4518 sender, function_name, NULL);
4520 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
4524 case BT_L2CAP_LE_ACCEPT_CONNECTION: {
4527 address = (char *)g_variant_get_data(in_param1);
4528 result = _bt_socket_reply_conn_authorization(address, TRUE);
4531 case BT_L2CAP_LE_REJECT_CONNECTION: {
4534 address = (char *)g_variant_get_data(in_param1);
4535 result = _bt_socket_reply_conn_authorization(address, FALSE);
4538 case BT_L2CAP_LE_REMOVE_SOCKET: {
4540 * This call to bt-service is only used for privilege check, so return
4541 * BLUETOOTH_ERROR_NONE from here.
4543 result = BLUETOOTH_ERROR_NONE;
4547 BT_INFO("UnSupported function [%d]", function_name);
4548 result = BLUETOOTH_ERROR_NOT_SUPPORT;
4554 #ifdef TIZEN_FEATURE_BT_OBEX
4555 /* Function definitions*/
4556 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
4561 size = g_variant_get_size(var);
4563 data = (char *)g_variant_get_data(var);
4565 param = g_array_append_vals(param, data, size);
4571 int __bt_obexd_request(int function_name,
4574 GDBusMethodInvocation *context,
4575 GVariant *in_param1,
4576 GVariant *in_param2,
4577 GVariant *in_param3,
4578 GVariant *in_param4,
4579 GArray **out_param1)
4583 int result = BLUETOOTH_ERROR_NONE;
4585 BT_DBG("function_name : %x", function_name);
4587 switch (function_name) {
4588 case BT_OPP_PUSH_FILES: {
4589 BT_DBG("BT_OPP_PUSH_FILES");
4591 bluetooth_device_address_t address = { {0} };
4592 bt_file_path_t *path;
4597 __bt_service_get_parameters(in_param1, &address,
4598 sizeof(bluetooth_device_address_t));
4599 __bt_service_get_parameters(in_param3, &file_count,
4602 file_path = g_new0(char *, file_count + 1);
4604 param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
4605 __bt_fill_garray_from_variant(in_param2, param2);
4607 for (i = 0; i < file_count; i++) {
4608 path = &g_array_index(param2, bt_file_path_t, i);
4609 file_path[i] = g_strdup(path->path);
4611 BT_DBG("_bt_opp_client_push_files");
4612 result = _bt_opp_client_push_files(request_id, context,
4613 &address, file_path,
4616 for (i = 0; i < file_count; i++)
4617 g_free(file_path[i]);
4620 g_array_free(param2, TRUE);
4624 case BT_OPP_CANCEL_PUSH: {
4625 result = _bt_opp_client_cancel_push();
4629 case BT_OPP_IS_PUSHING_FILES: {
4630 gboolean is_sending = FALSE;
4632 result = _bt_opp_client_is_sending(&is_sending);
4634 g_array_append_vals(*out_param1, &is_sending,
4638 case BT_OPP_GET_TRANSFER_PROGRESS: {
4641 guint8 progress = 0;
4643 __bt_service_get_parameters(in_param1, &direction,
4645 __bt_service_get_parameters(in_param2, &transfer_id,
4648 result = _bt_opp_get_client_progress(&progress);
4650 result = _bt_opp_get_server_progress(transfer_id, &progress);
4652 g_array_append_vals(*out_param1, &progress,
4658 case BT_MAP_CREATE_SESSION: {
4659 BT_DBG("BT_MAP_CREATE_SESSION");
4660 char *address = (char *)g_variant_get_data(in_param1);
4661 char *session_id = NULL;
4662 result = _bt_create_session_sync(address, &session_id);
4663 if (result == BLUETOOTH_ERROR_NONE)
4664 g_array_append_vals(*out_param1, session_id, strlen(session_id)+1);
4668 case BT_MAP_DESTROY_SESSION: {
4669 BT_DBG("BT_MAP_DESTROY_SESSION");
4670 char* session_id = (char *)g_variant_get_data(in_param1);
4671 result = _bt_destroy_session_sync(session_id);
4672 if (result == BLUETOOTH_ERROR_NONE)
4673 BT_DBG("successfully destroyed session");
4677 case BT_MAP_SET_FOLDER: {
4678 BT_DBG("BT_MAP_SET_FOLDER");
4679 char *session_id = (char *)g_variant_get_data(in_param1);
4680 char *name = (char *)g_variant_get_data(in_param2);
4681 result = _bt_map_client_set_folder(session_id, name);
4685 case BT_MAP_LIST_FOLDERS: {
4686 BT_DBG("BT_MAP_LIST_FOLDERS");
4688 char* session_id = (char *)g_variant_get_data(in_param1);
4689 char* filter_serialized = (char*)g_variant_get_data(in_param2);
4691 result = _bt_map_client_list_folders(request_id, context, session_id, filter_serialized);
4692 if (result == BLUETOOTH_ERROR_NONE)
4693 BT_DBG("_bt_map_client_list_folders succeed");
4698 case BT_MAP_LIST_FILTER_FIELDS: {
4699 BT_DBG("BT_MAP_LIST_FILTER_FIELDS");
4701 char* session_id = (char *)g_variant_get_data(in_param1);
4703 result = _bt_map_client_list_filter_fields(request_id, context, session_id);
4704 if (result == BLUETOOTH_ERROR_NONE)
4705 BT_DBG("_bt_map_client_list_filter_fields succeed");
4710 case BT_MAP_LIST_MESSAGES: {
4711 BT_DBG("BT_MAP_LIST_MESSAGES");
4713 char* session_id = (char*)g_variant_get_data(in_param1);
4714 char* folder = (char*)g_variant_get_data(in_param2);
4715 char* filter_serialized = (char*)g_variant_get_data(in_param3);
4717 result = _bt_map_client_list_messages(request_id, context, session_id, folder, filter_serialized);
4718 if (result == BLUETOOTH_ERROR_NONE)
4719 BT_DBG("_bt_map_client_list_messages succeed");
4721 BT_DBG("_bt_map_client_list_messages failed");
4726 case BT_MAP_UPDATE_INBOX: {
4727 BT_DBG("BT_MAP_UPDATE_INBOX");
4728 char* session_id = (char *)g_variant_get_data(in_param1);
4729 result = _bt_map_client_update_inbox(session_id);
4733 case BT_MAP_PUSH_MESSAGE: {
4734 BT_DBG("BT_MAP_PUSH_MESSAGE");
4736 char* session_id = (char *)g_variant_get_data(in_param1);
4737 char* source_file = (char *)g_variant_get_data(in_param2);
4738 char* folder = (char *)g_variant_get_data(in_param3);
4739 char* args_serialized = (char *)g_variant_get_data(in_param4);
4741 result = _bt_map_client_push_message(
4742 request_id, context, session_id, source_file, folder, args_serialized);
4743 if (result == BLUETOOTH_ERROR_NONE)
4744 BT_DBG("_bt_map_client_push_message succeed");
4746 BT_ERR("_bt_map_client_push_message failed");
4751 case BT_MAP_GET_MESSAGE: {
4752 BT_DBG("BT_MAP_GET_MESSAGE");
4753 // TODO session currently is not used, but should be valid
4754 //char* session_id = (char *)g_variant_get_data(in_param1);
4755 char* message_object = (char *)g_variant_get_data(in_param2);
4756 char* target_file = (char *)g_variant_get_data(in_param3);
4757 bool attachment = false;
4758 __bt_service_get_parameters(in_param4, &attachment, sizeof(bool));
4760 result = _bt_map_client_get_message(request_id, context, message_object,
4761 target_file, attachment);
4762 if (result == BLUETOOTH_ERROR_NONE)
4763 BT_DBG("_bt_map_client_get_message succeed");
4768 case BT_OBEX_SERVER_ALLOCATE: {
4774 sender = (char *)g_dbus_method_invocation_get_sender(context);
4776 path = (char *)g_variant_get_data(in_param1);
4777 __bt_service_get_parameters(in_param2, &is_native,
4779 __bt_service_get_parameters(in_param3, &app_pid,
4782 result = _bt_obex_server_allocate(sender,
4783 path, app_pid, is_native);
4787 case BT_OBEX_SERVER_DEALLOCATE: {
4791 __bt_service_get_parameters(in_param1, &is_native,
4793 __bt_service_get_parameters(in_param2, &app_pid,
4796 result = _bt_obex_server_deallocate(app_pid, is_native);
4799 case BT_OBEX_SERVER_IS_ACTIVATED: {
4800 gboolean is_activated = FALSE;
4802 result = _bt_obex_server_is_activated(&is_activated);
4804 g_array_append_vals(*out_param1, &is_activated,
4809 case BT_OBEX_SERVER_ACCEPT_CONNECTION: {
4810 result = _bt_obex_server_accept_connection(request_id);
4814 case BT_OBEX_SERVER_REJECT_CONNECTION: {
4815 result = _bt_obex_server_reject_connection();
4819 case BT_OBEX_SERVER_ACCEPT_FILE: {
4822 file_name = (char *)g_variant_get_data(in_param1);
4824 result = _bt_obex_server_accept_authorize(file_name, TRUE);
4828 case BT_OBEX_SERVER_REJECT_FILE: {
4829 result = _bt_obex_server_reject_authorize();
4833 case BT_OBEX_SERVER_SET_PATH: {
4835 char *destination_path;
4837 destination_path = (char *)g_variant_get_data(in_param1);
4838 __bt_service_get_parameters(in_param2, &is_native,
4841 result = _bt_obex_server_set_destination_path(destination_path,
4846 case BT_OBEX_SERVER_SET_ROOT: {
4849 root = (char *)g_variant_get_data(in_param1);
4851 result = _bt_obex_server_set_root(root);
4855 case BT_OBEX_SERVER_CANCEL_TRANSFER: {
4858 __bt_service_get_parameters(in_param1, &transfer_id,
4861 result = _bt_obex_server_cancel_transfer(transfer_id);
4865 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS: {
4866 result = _bt_obex_server_cancel_all_transfers();
4870 case BT_OBEX_SERVER_IS_RECEIVING: {
4871 gboolean is_receiving = FALSE;
4873 result = _bt_obex_server_is_receiving(&is_receiving);
4875 g_array_append_vals(*out_param1, &is_receiving,
4879 case BT_PBAP_CONNECT: {
4880 bluetooth_device_address_t address = { {0} };
4882 __bt_service_get_parameters(in_param1, &address,
4883 sizeof(bluetooth_device_address_t));
4885 result = _bt_pbap_connect(&address);
4888 case BT_PBAP_DISCONNECT: {
4889 bluetooth_device_address_t address = { {0} };
4891 __bt_service_get_parameters(in_param1, &address,
4892 sizeof(bluetooth_device_address_t));
4894 result = _bt_pbap_disconnect(&address);
4897 case BT_PBAP_GET_PHONEBOOK_SIZE: {
4898 bluetooth_device_address_t address = { {0} };
4899 bt_pbap_folder_t folder = { 0, };
4901 __bt_service_get_parameters(in_param1, &address,
4902 sizeof(bluetooth_device_address_t));
4903 __bt_service_get_parameters(in_param2, &folder,
4904 sizeof(bt_pbap_folder_t));
4906 result = _bt_pbap_get_phonebook_size(&address,
4907 folder.addressbook, folder.folder_type);
4910 case BT_PBAP_GET_PHONEBOOK: {
4911 bluetooth_device_address_t address = { {0} };
4912 bt_pbap_folder_t folder = { 0, };
4913 bt_pbap_pull_parameters_t app_param = { 0, };
4915 __bt_service_get_parameters(in_param1, &address,
4916 sizeof(bluetooth_device_address_t));
4917 __bt_service_get_parameters(in_param2, &folder,
4918 sizeof(bt_pbap_folder_t));
4919 __bt_service_get_parameters(in_param3, &app_param,
4920 sizeof(bt_pbap_pull_parameters_t));
4922 result = _bt_pbap_get_phonebook(&address, folder.addressbook,
4923 folder.folder_type, &app_param);
4926 case BT_PBAP_GET_LIST: {
4927 bluetooth_device_address_t address = { {0} };
4928 bt_pbap_folder_t folder = { 0, };
4929 bt_pbap_list_parameters_t app_param = { 0, };
4931 __bt_service_get_parameters(in_param1, &address,
4932 sizeof(bluetooth_device_address_t));
4933 __bt_service_get_parameters(in_param2, &folder,
4934 sizeof(bt_pbap_folder_t));
4935 __bt_service_get_parameters(in_param3, &app_param,
4936 sizeof(bt_pbap_list_parameters_t));
4938 result = _bt_pbap_get_list(&address, folder.addressbook,
4939 folder.folder_type, &app_param);
4942 case BT_PBAP_PULL_VCARD: {
4943 bluetooth_device_address_t address = { {0} };
4944 bt_pbap_folder_t folder = { 0, };
4945 bt_pbap_pull_vcard_parameters_t app_param = { 0, };
4947 __bt_service_get_parameters(in_param1, &address,
4948 sizeof(bluetooth_device_address_t));
4949 __bt_service_get_parameters(in_param2, &folder,
4950 sizeof(bt_pbap_folder_t));
4951 __bt_service_get_parameters(in_param3, &app_param,
4952 sizeof(bt_pbap_pull_vcard_parameters_t));
4954 result = _bt_pbap_pull_vcard(&address, folder.addressbook,
4955 folder.folder_type, &app_param);
4958 case BT_PBAP_PHONEBOOK_SEARCH: {
4959 bluetooth_device_address_t address = { {0} };
4960 bt_pbap_folder_t folder = { 0, };
4961 bt_pbap_search_parameters_t app_param = { 0, };
4963 __bt_service_get_parameters(in_param1, &address,
4964 sizeof(bluetooth_device_address_t));
4965 __bt_service_get_parameters(in_param2, &folder,
4966 sizeof(bt_pbap_folder_t));
4967 __bt_service_get_parameters(in_param3, &app_param,
4968 sizeof(bt_pbap_search_parameters_t));
4970 result = _bt_pbap_phonebook_search(&address, folder.addressbook,
4971 folder.folder_type, &app_param);
4976 BT_ERR("Unknown function!");
4977 result = BLUETOOTH_ERROR_INTERNAL;
4986 int __bt_agent_request(int function_name,
4989 GDBusMethodInvocation *context,
4990 GVariant *in_param1,
4991 GVariant *in_param2,
4992 GVariant *in_param3,
4993 GVariant *in_param4,
4994 GArray **out_param1)
4997 switch (function_name) {
4998 case BT_SET_AUTHORIZATION: {
5005 sender = (char *)g_dbus_method_invocation_get_sender(context);
5006 __bt_service_get_parameters(in_param1, &type, sizeof(int));
5007 uuid = (char *)g_variant_get_data(in_param2);
5008 path = (char *)g_variant_get_data(in_param3);
5009 __bt_service_get_parameters(in_param4, &fd, sizeof(int));
5011 result = _bt_register_osp_server_in_agent(sender, type, uuid, path, fd);
5014 case BT_UNSET_AUTHORIZATION: {
5018 __bt_service_get_parameters(in_param1, &type, sizeof(int));
5019 uuid = (char *)g_variant_get_data(in_param2);
5021 result = _bt_unregister_osp_server_in_agent(type, uuid);
5025 BT_ERR("Unknown function!");
5026 result = BLUETOOTH_ERROR_INTERNAL;
5033 int __bt_core_request(int function_name,
5036 GDBusMethodInvocation *context,
5037 GVariant *in_param1)
5041 switch (function_name) {
5042 case BT_ENABLE_ADAPTER:
5045 _bt_set_adapter_request_state(TRUE);
5046 status = _bt_adapter_get_status();
5048 if (status == BT_ACTIVATING) {
5049 BT_DBG("Enabling in progress");
5050 result = BLUETOOTH_ERROR_IN_PROGRESS;
5051 } else if (status == BT_ACTIVATED) {
5052 BT_DBG("Already enabled");
5053 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
5055 _bt_adapter_set_status(BT_ACTIVATING);
5056 result = BLUETOOTH_ERROR_NONE;
5061 case BT_DISABLE_ADAPTER:
5065 status = _bt_adapter_get_status();
5066 if (status == BT_DEACTIVATING) {
5067 BT_DBG("Disabling in progress");
5068 result = BLUETOOTH_ERROR_IN_PROGRESS;
5069 } else if (status == BT_DEACTIVATED) {
5070 BT_DBG("Already disabled");
5071 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
5073 _bt_adapter_set_status(BT_DEACTIVATING);
5074 result = BLUETOOTH_ERROR_NONE;
5079 case BT_ENABLE_ADAPTER_LE:
5081 bt_le_status_t le_status;
5082 _bt_set_le_request_state(TRUE);
5083 le_status = _bt_adapter_get_le_status();
5084 if (le_status == BT_LE_ACTIVATING) {
5085 BT_DBG("Enabling in progress");
5086 result = BLUETOOTH_ERROR_IN_PROGRESS;
5087 } else if (le_status == BT_LE_ACTIVATED) {
5088 BT_DBG("Already enabled");
5089 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
5091 _bt_adapter_set_le_status(BT_LE_ACTIVATING);
5092 result = BLUETOOTH_ERROR_NONE;
5097 case BT_DISABLE_ADAPTER_LE:
5099 bt_le_status_t le_status;
5101 le_status = _bt_adapter_get_le_status();
5102 if (le_status == BT_LE_DEACTIVATING) {
5103 BT_DBG("Disabling in progress");
5104 result = BLUETOOTH_ERROR_IN_PROGRESS;
5105 } else if (le_status == BT_LE_DEACTIVATED) {
5106 BT_DBG("Already disabled");
5107 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
5109 _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
5110 result = BLUETOOTH_ERROR_NONE;
5116 BT_ERR("Unknown function!");
5117 result = BLUETOOTH_ERROR_INTERNAL;
5124 static int __bt_service_get_requester_app_id(const char *unique_name, char *app_id, int len)
5129 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
5130 retv_if(unique_name == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
5132 ret = __bt_service_get_sender_pid(unique_name, &pid);
5133 if (ret != BLUETOOTH_ERROR_NONE) {
5134 BT_ERR("Fail to get the sender pid");
5138 ret = aul_app_get_appid_bypid(pid, app_id, len);
5139 if (ret != AUL_R_OK) {
5140 BT_ERR("app_id not found");
5141 return BLUETOOTH_ERROR_NOT_SUPPORT;
5143 BT_DBG("Sender app_id: %s", app_id);
5145 return BLUETOOTH_ERROR_NONE;
5148 #ifdef TIZEN_FEATURE_BT_CONTAINER
5149 static void __bt_service_free_nspid(struct nspid_t *nspid)
5151 g_free(nspid->unique_name);
5155 static void __bt_service_cleanup_nspid_list(const char *unique_name)
5158 struct nspid_t *nspid;
5160 for (l = nspid_list; l; l = g_slist_next(l)) {
5164 if (!g_strcmp0(nspid->unique_name, unique_name)) {
5165 nspid_list = g_slist_remove(nspid_list, nspid);
5166 __bt_service_free_nspid(nspid);
5172 static gboolean __bt_service_is_container_request(const char *unique_name)
5176 char path[1024], buf[1024];
5178 gboolean is_container = FALSE;
5180 struct nspid_t *nspid;
5182 for (l = nspid_list; l; l = g_slist_next(l)) {
5186 if (!g_strcmp0(nspid->unique_name, unique_name))
5187 return nspid->is_container;
5190 ret = __bt_service_get_sender_pid(unique_name, &pid);
5191 if (ret != BLUETOOTH_ERROR_NONE)
5194 sprintf(path, "/proc/%d/status", pid);
5195 fp = fopen(path, "r");
5197 BT_ERR("fopen() failed. %d(%s)", errno, strerror(errno));
5201 while (fgets(buf, sizeof(buf), fp)) {
5202 if (strstr(buf, "NSpid:")) {
5203 char *p = strchr(buf + 7, '\t'); /* find 2nd '\t' */
5205 BT_DBG("caller is container process");
5206 is_container = TRUE;
5214 nspid = g_malloc0(sizeof(struct nspid_t));
5215 nspid->unique_name = g_strdup(unique_name);
5216 nspid->is_container = is_container;
5217 nspid_list = g_slist_append(nspid_list, nspid);
5219 return is_container;
5223 #ifdef TIZEN_FEATURE_BT_CONTAINER
5224 static gboolean __bt_service_check_privilege_in_container(int function_name,
5225 const char *unique_name)
5227 int result = BLUETOOTH_ERROR_NONE;
5228 GError *error = NULL;
5230 GArray *in_param1, *in_param2, *in_param3, *in_param4, *in_param5;
5231 GVariant *param1, *param2, *param3, *param4, *param5, *out_param;
5233 proxy = _bt_get_container_proxy();
5234 if (proxy == NULL) {
5235 BT_ERR("container proxy is NULL");
5239 in_param1 = g_array_new(TRUE, TRUE, sizeof(gchar));
5240 in_param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
5241 in_param3 = g_array_new(TRUE, TRUE, sizeof(gchar));
5242 in_param4 = g_array_new(TRUE, TRUE, sizeof(gchar));
5243 in_param5 = g_array_new(TRUE, TRUE, sizeof(gchar));
5245 /* The sender's privilege should be checked not bt-service in container */
5246 g_array_append_vals(in_param1, unique_name, strlen(unique_name));
5248 param1 = g_variant_new_from_data((const GVariantType *)"ay",
5249 in_param1->data, in_param1->len, TRUE, NULL, NULL);
5250 param2 = g_variant_new_from_data((const GVariantType *)"ay",
5251 in_param2->data, in_param2->len, TRUE, NULL, NULL);
5252 param3 = g_variant_new_from_data((const GVariantType *)"ay",
5253 in_param3->data, in_param3->len, TRUE, NULL, NULL);
5254 param4 = g_variant_new_from_data((const GVariantType *)"ay",
5255 in_param4->data, in_param4->len, TRUE, NULL, NULL);
5256 param5 = g_variant_new_from_data((const GVariantType *)"ay",
5257 in_param5->data, in_param5->len, TRUE, NULL, NULL);
5259 BT_DBG("This request is from container. Privilege will be checked in container. unique_name: %s", unique_name);
5261 GVariant *ret = g_dbus_proxy_call_sync(proxy, "service_request",
5262 g_variant_new("(iii@ay@ay@ay@ay@ay)",
5263 BT_CHECK_PRIVILEGE, function_name,
5264 BT_SYNC_REQ, param1, param2,
5265 param3, param4, param5),
5266 G_DBUS_CALL_FLAGS_NONE, -1,
5269 BT_ERR("dBUS-RPC is failed");
5271 if (error != NULL) {
5272 BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
5273 error->code, error->message);
5274 g_clear_error(&error);
5276 BT_ERR("error returned was NULL");
5279 result = BLUETOOTH_ERROR_INTERNAL;
5281 g_variant_get(ret, "(iv)", &result, &out_param);
5282 g_variant_unref(out_param);
5283 g_variant_unref(ret);
5286 g_array_free(in_param1, TRUE);
5287 g_array_free(in_param2, TRUE);
5288 g_array_free(in_param3, TRUE);
5289 g_array_free(in_param4, TRUE);
5290 g_array_free(in_param5, TRUE);
5292 return (result == BLUETOOTH_ERROR_NONE) ? TRUE : FALSE;
5296 gboolean __bt_service_check_privilege(int function_name,
5298 const char *unique_name)
5301 gboolean result = TRUE;
5302 char *client_creds = NULL;
5303 char *user_creds = NULL;
5304 char *client_session = "";
5305 enum cynara_client_creds client_creds_method = CLIENT_METHOD_SMACK;
5306 enum cynara_user_creds user_creds_method = USER_METHOD_UID;
5307 char err_msg[256] = {0, };
5309 retv_if(unique_name == NULL, FALSE);
5310 retv_if(bt_service_conn == NULL, FALSE);
5312 #ifdef TIZEN_FEATURE_BT_CONTAINER
5313 if (_bt_service_is_container() == FALSE)
5314 if (__bt_service_is_container_request(unique_name) == TRUE)
5315 return __bt_service_check_privilege_in_container(function_name, unique_name);
5318 ret_val = cynara_creds_get_default_client_method(&client_creds_method);
5319 if (ret_val != CYNARA_API_SUCCESS) {
5320 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
5321 BT_ERR("Fail to get default client method: %s", err_msg);
5325 ret_val = cynara_creds_get_default_user_method(&user_creds_method);
5326 if (ret_val != CYNARA_API_SUCCESS) {
5327 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
5328 BT_ERR("Fail to get default user method: %s", err_msg);
5332 ret_val = cynara_creds_gdbus_get_client(bt_service_conn, unique_name, client_creds_method, &client_creds);
5333 if (ret_val != CYNARA_API_SUCCESS) {
5334 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
5335 BT_ERR("Fail to get client credential: %s", err_msg);
5339 ret_val = cynara_creds_gdbus_get_user(bt_service_conn, unique_name, user_creds_method, &user_creds);
5340 if (ret_val != CYNARA_API_SUCCESS) {
5341 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
5342 BT_ERR("Fail to get user credential: %s", err_msg);
5348 BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
5350 switch (function_name) {
5351 case BT_SET_LOCAL_NAME:
5352 case BT_START_DISCOVERY:
5353 case BT_START_CUSTOM_DISCOVERY:
5354 case BT_CANCEL_DISCOVERY:
5355 case BT_OOB_ADD_REMOTE_DATA:
5356 case BT_OOB_REMOVE_REMOTE_DATA:
5357 case BT_OOB_READ_LOCAL_DATA:
5358 case BT_SET_ADVERTISING:
5359 case BT_SET_CUSTOM_ADVERTISING:
5360 case BT_SET_ADVERTISING_PARAMETERS:
5361 case BT_START_LE_DISCOVERY:
5362 case BT_STOP_LE_DISCOVERY:
5363 case BT_SET_SCAN_PARAMETERS:
5364 case BT_SET_SCAN_TYPE:
5365 case BT_UPDATE_LE_CONNECTION_MODE:
5367 case BT_BOND_DEVICE:
5368 case BT_CANCEL_BONDING:
5369 case BT_UNBOND_DEVICE:
5371 case BT_SET_AUTHORIZATION:
5372 case BT_UNSET_AUTHORIZATION:
5373 case BT_SEARCH_SERVICE:
5375 case BT_RFCOMM_CLIENT_CONNECT:
5376 if (function_name == BT_RFCOMM_CLIENT_CONNECT)
5377 BT_PERMANENT_LOG("Connect socket");
5378 case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
5379 case BT_RFCOMM_SOCKET_DISCONNECT:
5380 if (function_name == BT_RFCOMM_SOCKET_DISCONNECT)
5381 BT_PERMANENT_LOG("Disconnect socket");
5382 case BT_RFCOMM_SOCKET_WRITE:
5383 case BT_RFCOMM_CREATE_SOCKET:
5384 case BT_RFCOMM_REMOVE_SOCKET:
5385 case BT_RFCOMM_SEND_RX_DETAILS:
5386 case BT_RFCOMM_SEND_TX_DETAILS:
5387 case BT_RFCOMM_UPDATE_CONNECTION_INFO:
5389 case BT_OPP_PUSH_FILES:
5390 case BT_OPP_CANCEL_PUSH:
5391 /* TODO: MAP? MAP functions, see above */
5393 case BT_OBEX_SERVER_ACCEPT_CONNECTION:
5394 case BT_OBEX_SERVER_REJECT_CONNECTION:
5395 case BT_OBEX_SERVER_ACCEPT_FILE:
5396 case BT_OBEX_SERVER_REJECT_FILE:
5397 case BT_OBEX_SERVER_SET_PATH:
5398 case BT_OBEX_SERVER_SET_ROOT:
5399 case BT_OBEX_SERVER_CANCEL_TRANSFER:
5400 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS:
5402 case BT_AUDIO_SELECT_ROLE:
5403 case BT_AUDIO_CONNECT:
5404 case BT_AUDIO_DISCONNECT:
5406 case BT_AG_DISCONNECT:
5408 case BT_AV_DISCONNECT:
5409 case BT_AV_SOURCE_CONNECT:
5410 case BT_AV_SOURCE_DISCONNECT:
5411 case BT_AVRCP_TARGET_CONNECT:
5412 case BT_AVRCP_TARGET_DISCONNECT:
5413 case BT_AVRCP_CONTROL_CONNECT:
5414 case BT_AVRCP_CONTROL_DISCONNECT:
5415 case BT_AVRCP_HANDLE_CONTROL:
5416 case BT_AVRCP_SET_TRACK_INFO:
5417 case BT_AVRCP_SET_PROPERTY:
5418 case BT_AVRCP_SET_PROPERTIES:
5419 case BT_AVRCP_CONTROL_SET_PROPERTY:
5421 case BT_AUDIO_SET_ABSOLUTE_VOLUME:
5422 case BT_AUDIO_GET_ABSOLUTE_VOLUME:
5423 case BT_AUDIO_IS_AVC_ACTIVATED:
5426 case BT_HF_DISCONNECT:
5428 case BT_HID_CONNECT:
5429 case BT_HID_DISCONNECT:
5431 case BT_HID_DEVICE_ACTIVATE:
5432 case BT_HID_DEVICE_DEACTIVATE:
5433 case BT_HID_DEVICE_CONNECT:
5434 case BT_HID_DEVICE_DISCONNECT:
5435 case BT_HID_DEVICE_SEND_MOUSE_EVENT:
5436 case BT_HID_DEVICE_SEND_KEY_EVENT:
5437 case BT_HID_DEVICE_SEND_REPLY_TO_REPORT:
5438 case BT_HID_DEVICE_SEND_CUSTOM_EVENT:
5441 case BT_DISCONNECT_LE:
5443 case BT_SET_ADVERTISING_DATA:
5444 case BT_SET_SCAN_RESPONSE_DATA:
5446 case BT_HDP_CONNECT:
5447 case BT_HDP_DISCONNECT:
5448 case BT_HDP_SEND_DATA:
5449 case BT_HDP_REGISTER_SINK_APP:
5450 case BT_HDP_UNREGISTER_SINK_APP:
5453 case BT_DPM_SET_ALLOW_BT_MODE:
5454 case BT_DPM_GET_ALLOW_BT_MODE:
5455 case BT_DPM_SET_DEVICE_RESTRITION:
5456 case BT_DPM_GET_DEVICE_RESTRITION:
5457 case BT_DPM_SET_UUID_RESTRITION:
5458 case BT_DPM_GET_UUID_RESTRITION:
5459 case BT_DPM_ADD_DEVICES_BLACKLIST:
5460 case BT_DPM_ADD_DEVICES_WHITELIST:
5461 case BT_DPM_ADD_UUIDS_BLACKLIST:
5462 case BT_DPM_ADD_UUIDS_WHITELIST:
5463 case BT_DPM_CLEAR_DEVICES_BLACKLIST:
5464 case BT_DPM_CLEAR_DEVICES_WHITELIST:
5465 case BT_DPM_CLEAR_UUIDS_BLACKLIST:
5466 case BT_DPM_CLEAR_UUIDS_WHITELIST:
5467 case BT_DPM_REMOVE_DEVICE_BLACKLIST:
5468 case BT_DPM_REMOVE_DEVICE_WHITELIST:
5469 case BT_DPM_REMOVE_UUID_BLACKLIST:
5470 case BT_DPM_REMOVE_UUID_WHITELIST:
5471 case BT_DPM_GET_DEVICES_BLACKLIST:
5472 case BT_DPM_GET_DEVICES_WHITELIST:
5473 case BT_DPM_GET_UUIDS_BLACKLIST:
5474 case BT_DPM_GET_UUIDS_WHITELIST:
5475 case BT_DPM_SET_ALLOW_OUTGOING_CALL:
5476 case BT_DPM_GET_ALLOW_OUTGOING_CALL:
5477 case BT_DPM_SET_PAIRING_STATE:
5478 case BT_DPM_GET_PAIRING_STATE:
5479 case BT_DPM_SET_PROFILE_STATE:
5480 case BT_DPM_GET_PROFILE_STATE:
5481 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE:
5482 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE:
5483 case BT_DPM_SET_DISCOVERABLE_STATE:
5484 case BT_DPM_GET_DISCOVERABLE_STATE:
5485 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE:
5486 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE:
5487 case BT_DPM_SET_DATA_TRANSFER_STATE:
5488 case BT_DPM_GET_DATA_TRANSFER_STATE:
5490 case BT_NETWORK_ACTIVATE:
5491 case BT_NETWORK_DEACTIVATE:
5492 case BT_NETWORK_CONNECT:
5493 case BT_NETWORK_DISCONNECT:
5494 case BT_NETWORK_SERVER_DISCONNECT:
5496 case BT_GATT_GET_PRIMARY_SERVICES:
5497 case BT_GATT_GET_SERVICE_PROPERTIES: /* GATT Client */
5498 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: /* GATT Client */
5499 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: /* GATT Client */
5500 case BT_GATT_DISCOVER_CHARACTERISTICS:
5501 case BT_GATT_SET_PROPERTY_REQUEST:
5502 case BT_GATT_READ_CHARACTERISTIC:
5503 case BT_GATT_READ_DESCRIPTOR_VALUE: /* GATT Client */
5504 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: /* GATT Client */
5505 case BT_GATT_ACQUIRE_WRITE:
5506 case BT_GATT_WRITE_DESCRIPTOR_VALUE: /* GATT Client */
5507 case BT_GATT_WATCH_CHARACTERISTIC: /* GATT Client */
5508 case BT_GATT_CLIENT_REGISTER: /* GATT Client */
5509 case BT_GATT_CLIENT_UNREGISTER: /* GATT Client */
5510 case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
5511 case BT_GATT_REGISTER_APPLICATION:
5512 case BT_GATT_REGISTER_SERVICE:
5513 case BT_GATT_SEND_RESPONSE:
5515 case BT_GATT_SERVER_REGISTER:
5516 case BT_GATT_SERVER_ADD_SERVICE:
5517 case BT_GATT_SERVER_ADD_CHARACTERISTIC:
5518 case BT_GATT_SERVER_ADD_DESCRIPTOR:
5519 case BT_GATT_SERVER_START_SERVICE:
5520 case BT_GATT_SERVER_STOP_SERVICE:
5521 case BT_GATT_SERVER_DELETE_SERVICE:
5522 case BT_GATT_SERVER_SEND_RESPONSE:
5523 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE:
5524 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE:
5525 case BT_GATT_SERVER_SEND_INDICATION:
5526 case BT_GATT_SERVER_UPDATE_VALUE:
5527 case BT_GATT_SERVER_DEREGISTER:
5529 case BT_REQ_ATT_MTU:
5530 case BT_PBAP_CONNECT:
5531 case BT_PBAP_DISCONNECT:
5532 case BT_PBAP_GET_PHONEBOOK_SIZE:
5533 case BT_PBAP_GET_PHONEBOOK:
5534 case BT_PBAP_GET_LIST:
5535 case BT_PBAP_PULL_VCARD:
5536 case BT_PBAP_PHONEBOOK_SEARCH:
5538 case BT_RFCOMM_LISTEN_AND_ACCEPT:
5540 case BT_L2CAP_LE_CLIENT_CONNECT:
5541 case BT_L2CAP_LE_CLIENT_CANCEL_CONNECT:
5542 case BT_L2CAP_LE_SOCKET_DISCONNECT:
5543 case BT_L2CAP_LE_SOCKET_WRITE:
5544 case BT_L2CAP_LE_CREATE_SOCKET:
5545 case BT_L2CAP_LE_REMOVE_SOCKET:
5546 case BT_L2CAP_LE_LISTEN_AND_ACCEPT:
5548 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5549 BT_PRIVILEGE_PUBLIC);
5551 BT_INFO("Client Credentials [%s]", client_creds);
5552 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5553 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PUBLIC);
5557 /* Need to check mediastorage privilege */
5558 if (function_name == BT_PBAP_GET_PHONEBOOK ||
5559 function_name == BT_PBAP_PULL_VCARD) {
5560 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5561 MEDIASTORAGE_PRIVILEGE);
5563 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5564 BT_ERR("Fail to access: %s", MEDIASTORAGE_PRIVILEGE);
5570 case BT_ENABLE_ADAPTER:
5571 case BT_DISABLE_ADAPTER:
5572 case BT_RESET_ADAPTER:
5573 case BT_RECOVER_ADAPTER:
5574 case BT_BATTERY_READ_DATA:
5575 case BT_ENABLE_ADAPTER_LE:
5576 case BT_DISABLE_ADAPTER_LE:
5577 case BT_SET_CONNECTABLE:
5578 case BT_SET_DISCOVERABLE_MODE:
5579 case BT_ADD_WHITE_LIST:
5580 case BT_REMOVE_WHITE_LIST:
5581 case BT_CLEAR_WHITE_LIST:
5582 case BT_SET_MANUFACTURER_DATA:
5584 case BT_CANCEL_SEARCH_SERVICE:
5585 case BT_ENABLE_RSSI:
5586 case BT_DISCONNECT_DEVICE:
5588 case BT_RFCOMM_ACCEPT_CONNECTION:
5589 case BT_RFCOMM_REJECT_CONNECTION:
5590 case BT_RFCOMM_LISTEN:
5592 case BT_HID_ENABLE_BARCODE_FEATURE:
5594 case BT_AVRCP_TRANSPORT_SET_PROPERTY:
5595 case BT_AVRCP_HANDLE_CONTROL_TO_DEST:
5597 case BT_SET_CONTENT_PROTECT:
5598 case BT_BOND_DEVICE_BY_TYPE:
5599 case BT_SET_LE_PRIVACY:
5600 case BT_SET_LE_STATIC_RANDOM_ADDRESS:
5601 case BT_LE_CONN_UPDATE:
5602 case BT_GET_DEVICE_IDA:
5603 case BT_LE_READ_MAXIMUM_DATA_LENGTH:
5604 case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
5605 case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH:
5606 case BT_LE_SET_DATA_LENGTH:
5607 case BT_LE_OOB_READ_LOCAL_DATA:
5608 case BT_LE_OOB_ADD_REMOTE_DATA:
5610 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS:
5611 case BT_ENABLE_GATT_DATA_BATCHING:
5612 case BT_DISABLE_GATT_DATA_BATCHING:
5614 case BT_LE_IPSP_INIT:
5615 case BT_LE_IPSP_DEINIT:
5616 case BT_LE_IPSP_CONNECT:
5617 case BT_LE_IPSP_DISCONNECT:
5618 case BT_PXP_MONITOR_SET_PROPERTY:
5619 case BT_PXP_MONITOR_GET_PROPERTY:
5620 case BT_PXP_MONITOR_GET_SUPPORTED_SERIVCES:
5621 case BT_PXP_REPORTER_REGISTER:
5622 case BT_PXP_REPORTER_UNREGISTER:
5623 case BT_PXP_REPORTER_GET_PROPERTY:
5626 case BT_TDS_PROVIDER_REGISTER:
5627 case BT_TDS_PROVIDER_UNREGISTER:
5628 case BT_TDS_PROVIDER_SET_MANUF_DATA:
5629 case BT_TDS_PROVIDER_CREATE:
5630 case BT_TDS_PROVIDER_DESTROY:
5631 case BT_TDS_PROVIDER_SET_TRANSPORT_DATA:
5632 case BT_TDS_SEND_ACTIVATION_RESPONSE:
5633 case BT_TDS_READ_TRANSPORT_DATA:
5634 case BT_TDS_ENABLE_CONTROL_POINT:
5635 case BT_TDS_ACTIVATE_CONTROL_POINT:
5638 case BT_OTP_SERVER_INIT:
5639 case BT_OTP_SERVER_DEINIT:
5640 case BT_OTP_READ_VALUE:
5641 case BT_OTP_ENABLE_NOTIFICATION:
5642 case BT_OTP_WRITE_VALUE:
5643 case BT_LE_OTC_CONNECT:
5644 case BT_LE_OTC_DISCONNECT:
5646 case BT_MAP_CREATE_SESSION:
5647 case BT_MAP_DESTROY_SESSION:
5648 case BT_MAP_SET_FOLDER:
5649 case BT_MAP_LIST_FOLDERS:
5650 case BT_MAP_LIST_FILTER_FIELDS:
5651 case BT_MAP_LIST_MESSAGES:
5652 case BT_MAP_UPDATE_INBOX:
5653 case BT_MAP_PUSH_MESSAGE:
5654 case BT_MAP_GET_MESSAGE:
5657 case BT_MESH_DEINIT:
5658 case BT_MESH_NETWORK_CREATE:
5659 case BT_MESH_NETWORK_DESTROY:
5660 case BT_MESH_NETWORK_LOAD:
5661 case BT_MESH_NETWORK_UNLOAD:
5662 case BT_MESH_NETWORK_JOIN:
5663 case BT_MESH_CANCEL_JOIN:
5664 case BT_MESH_NETWORK_SCAN:
5665 case BT_MESH_NETWORK_CANCEL_SCAN:
5666 case BT_MESH_NETWORK_SET_CAPABILITIES:
5667 case BT_MESH_NETWORK_PROVISION_DEVICE:
5668 case BT_MESH_AUTHENTICATION_REPLY:
5669 case BT_MESH_NETWORK_SET_NAME:
5670 case BT_MESH_NETWORK_ADD_NETKEY:
5671 case BT_MESH_NETWORK_DELETE_NETKEY:
5672 case BT_MESH_NETWORK_UPDATE_NETKEY:
5673 case BT_MESH_NETWORK_ADD_APPKEY:
5674 case BT_MESH_NETWORK_DELETE_APPKEY:
5675 case BT_MESH_NETWORK_UPDATE_APPKEY:
5676 case BT_MESH_NETWORK_GET_NETKEYS:
5677 case BT_MESH_NETWORK_GET_APPKEYS:
5678 case BT_MESH_NETWORK_GET_NODES:
5679 case BT_MESH_ELEMENT_GET_MODELS:
5680 case BT_MESH_NODE_BROWSE:
5681 case BT_MESH_NODE_GET_VENDOR_FEATURES:
5682 case BT_MESH_NODE_CONFIGURE_KEY:
5683 case BT_MESH_NODE_TTL_EXECUTE:
5684 case BT_MESH_NODE_GET_NETKEYS:
5685 case BT_MESH_NODE_GET_APPKEYS:
5686 case BT_MESH_NODE_RESET:
5687 case BT_MESH_MODEL_CONFIGURE_APPKEY:
5688 case BT_MESH_MODEL_GET_APPKEY_LIST:
5689 case BT_MESH_MODEL_EXECUTE_MSG:
5690 case BT_MESH_MODEL_RESPONSE_MSG:
5691 case BT_MESH_NETWORK_CREATE_GROUP:
5692 case BT_MESH_NETWORK_REMOVE_GROUP:
5693 case BT_MESH_MODEL_CONFIG_GROUP_SUB:
5694 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB:
5695 case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST:
5696 case BT_MESH_MODEL_SET_PUBLICATION:
5697 case BT_MESH_MODEL_GET_PUBLICATION:
5698 case BT_MESH_NETWORK_GET_GROUPS:
5700 case BT_L2CAP_LE_ACCEPT_CONNECTION:
5701 case BT_L2CAP_LE_REJECT_CONNECTION:
5702 case BT_L2CAP_LE_LISTEN:
5704 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5705 BT_PRIVILEGE_PLATFORM);
5707 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5708 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PLATFORM);
5713 case BT_CHECK_ADAPTER:
5716 case BT_GET_LOCAL_NAME:
5717 case BT_GET_LOCAL_ADDRESS:
5718 case BT_GET_LOCAL_VERSION:
5719 case BT_IS_SERVICE_USED:
5720 case BT_GET_DISCOVERABLE_MODE:
5721 case BT_GET_DISCOVERABLE_TIME:
5722 case BT_IS_DISCOVERYING:
5723 case BT_IS_LE_DISCOVERYING:
5724 case BT_IS_CONNECTABLE:
5725 case BT_GET_CONNECTABLE:
5726 case BT_GET_BONDED_DEVICES:
5727 case BT_GET_PROFILE_CONNECTED_DEVICES:
5728 case BT_GET_BONDED_DEVICE:
5729 case BT_PASSKEY_REPLY:
5730 case BT_PASSKEY_CONFIRMATION_REPLY:
5731 case BT_GET_IS_ALIAS_SET:
5732 case BT_IS_DEVICE_CONNECTED:
5733 case BT_GET_CONNECTED_LINK_TYPE:
5734 case BT_SET_PROFILE_TRUSTED:
5735 case BT_GET_PROFILE_TRUSTED:
5736 case BT_GET_SPEAKER_GAIN:
5737 case BT_SET_SPEAKER_GAIN:
5738 case BT_RFCOMM_CLIENT_IS_CONNECTED:
5739 case BT_RFCOMM_IS_UUID_AVAILABLE:
5740 case BT_GET_ADVERTISING_DATA:
5741 case BT_GET_SCAN_RESPONSE_DATA:
5742 case BT_IS_ADVERTISING:
5743 case BT_IS_LE_2M_PHY_SUPPORTED:
5744 case BT_IS_LE_CODED_PHY_SUPPORTED:
5745 case BT_REGISTER_SCAN_FILTER:
5746 case BT_IS_SCAN_FILTER_SUPPORTED:
5747 case BT_GET_ATT_MTU:
5749 case BT_OBEX_SERVER_ALLOCATE:
5750 case BT_OBEX_SERVER_DEALLOCATE:
5751 case BT_OBEX_SERVER_IS_ACTIVATED:
5752 case BT_OPP_GET_TRANSFER_PROGRESS:
5753 case BT_AVRCP_CONTROL_GET_PROPERTY:
5754 case BT_AVRCP_GET_TRACK_INFO:
5756 case BT_L2CAP_LE_IS_PSM_AVAILABLE:
5757 /* Non-privilege control */
5760 BT_ERR("Unknown function!");
5765 if (function_name >= BT_FUNC_MESH_BASE) {
5766 BT_INFO("MESH Function called");
5767 char app_id[256] = { 0, };
5769 if (BLUETOOTH_ERROR_NONE == __bt_service_get_requester_app_id(unique_name,
5770 app_id, sizeof(app_id))) {
5771 requester_unique_creds = g_strdup(app_id);
5773 BT_DBG("Requester app_id not found, use client creds");
5774 requester_unique_creds = g_strdup(client_creds);
5776 BT_DBG("Requester unique_creds: %s", requester_unique_creds);
5778 BT_INFO("Non MESH Function called client creds [%s]", client_creds);
5790 GDBusNodeInfo *__bt_service_create_method_node_info
5791 (const gchar *introspection_data)
5794 GDBusNodeInfo *node_info = NULL;
5796 if (introspection_data == NULL) {
5797 BT_ERR("Introspection XML not present");
5801 node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
5804 BT_ERR("Unable to create node: %s", err->message);
5805 g_clear_error(&err);
5810 int __bt_service_register_object(GDBusConnection *conn,
5811 GDBusNodeInfo *node_info, gboolean reg)
5813 static guint service_id = 0;
5814 GError *error = NULL;
5817 if (node_info == NULL)
5820 service_id = g_dbus_connection_register_object(conn,
5822 node_info->interfaces[0],
5824 NULL, NULL, &error);
5825 if (service_id == 0)
5828 if (service_id > 0) {
5829 g_dbus_connection_unregister_object(conn,
5838 static void __name_owner_changed(GDBusConnection *connection,
5839 const gchar *sender_name,
5840 const gchar *object_path,
5841 const gchar *interface_name,
5842 const gchar *signal_name,
5843 GVariant *parameters,
5846 const char *name = NULL;
5847 const char *old_owner = NULL;
5848 const char *new_owner = NULL;
5850 g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner);
5851 if (*new_owner != '\0')
5854 _bt_check_hdp_app_termination(name);
5856 /* Advertising App Termination */
5857 _bt_check_adv_app_termination(name);
5859 /* Check if le_scanning app is terminated */
5860 _bt_check_le_scanner_app_termination(name);
5862 /* Check if RFCOMM app is terminated */
5863 _bt_rfcomm_check_termination(name);
5865 /* Mesh App Termination */
5866 _bt_check_mesh_app_termination(name);
5868 /* Stop the Transport Discovery service */
5869 _bt_tds_stop_by_terminated_process(name);
5871 #ifdef TIZEN_FEATURE_BT_CONTAINER
5872 /* Cleanup the NSpid list */
5873 __bt_service_cleanup_nspid_list(name);
5877 static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
5878 const gchar *name, gpointer user_data)
5880 GDBusNodeInfo *node_info = NULL;
5882 BT_INFO("bus acquired");
5884 ret_if(connection == NULL);
5886 node_info = __bt_service_create_method_node_info(
5887 bt_service_introspection_xml);
5888 ret_if(node_info == NULL);
5890 __bt_service_register_object(connection, node_info, TRUE);
5891 g_dbus_node_info_unref(node_info);
5893 bt_service_conn = connection;
5896 static void __bt_service_name_acquired_handler(GDBusConnection *connection,
5897 const gchar *name, gpointer user_data)
5899 BT_INFO("name acquired");
5900 name_acquired = TRUE;
5902 #ifdef TIZEN_FEATURE_BT_CONTAINER
5903 if (_bt_service_is_container() == TRUE)
5904 __bt_service_bus_acquired_handler(connection, name, user_data);
5908 static void __bt_service_name_lost_handler(GDBusConnection *connection,
5909 const gchar *name, gpointer user_data)
5911 BT_INFO("name lost");
5912 name_acquired = FALSE;
5915 gboolean _is_name_acquired(void)
5917 return name_acquired;
5920 void _bt_service_unref_connection(void)
5924 if (bt_service_conn) {
5925 g_dbus_connection_flush_sync(bt_service_conn, NULL, NULL);
5926 g_object_unref(bt_service_conn);
5927 bt_service_conn = NULL;
5933 int _bt_service_register(void)
5935 GDBusConnection *conn;
5938 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
5939 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
5940 bt_service_conn = conn;
5942 owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
5944 G_BUS_NAME_OWNER_FLAGS_NONE,
5945 __bt_service_bus_acquired_handler,
5946 __bt_service_name_acquired_handler,
5947 __bt_service_name_lost_handler,
5949 BT_DBG("owner_id is [%d]", owner_id);
5953 /* Subscribe for name owner changed signal */
5954 owner_sig_id = g_dbus_connection_signal_subscribe(conn,
5955 BT_FREEDESKTOP_SERVICE, BT_FREEDESKTOP_INTERFACE,
5956 BT_NAME_OWNER_CHANGED, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
5957 __name_owner_changed, NULL, NULL);
5958 BT_INFO("owner_sig_id: %d", owner_sig_id);
5960 return BLUETOOTH_ERROR_NONE;
5963 if (bt_service_conn) {
5964 g_object_unref(bt_service_conn);
5965 bt_service_conn = NULL;
5968 return BLUETOOTH_ERROR_INTERNAL;
5971 #ifdef TIZEN_FEATURE_BT_CONTAINER
5972 int _bt_service_register_in_container(void)
5974 GDBusConnection *conn;
5977 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
5978 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
5980 /* Register dbus name because systemd will down bt-service
5981 * if we don't reigster the dbus name in container */
5982 owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
5984 G_BUS_NAME_OWNER_FLAGS_NONE,
5985 NULL, NULL, NULL, NULL, NULL);
5986 BT_DBG("owner_id is [%d]", owner_id);
5990 conn = g_dbus_connection_new_for_address_sync(
5991 DBUS_HOST_SYSTEM_BUS_ADDRESS,
5992 G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
5994 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
5995 bt_service_conn = conn;
5997 /* Register to host dbus connection to call
5998 * the method toward container in host bt-service */
5999 owner_id = g_bus_own_name_on_connection(conn,
6000 BT_SERVICE_CONTAINER_NAME,
6001 G_BUS_NAME_OWNER_FLAGS_NONE,
6002 __bt_service_name_acquired_handler,
6003 __bt_service_name_lost_handler,
6005 BT_DBG("owner_id is [%d]", owner_id);
6009 return BLUETOOTH_ERROR_NONE;
6012 if (bt_service_conn) {
6013 g_object_unref(bt_service_conn);
6014 bt_service_conn = NULL;
6017 return BLUETOOTH_ERROR_INTERNAL;
6021 void _bt_service_unregister(void)
6023 if (bt_service_conn) {
6024 sd_notify(0, "STOPPING=1");
6026 if (owner_sig_id > 0) {
6027 g_dbus_connection_signal_unsubscribe(
6028 bt_service_conn, owner_sig_id);
6033 g_bus_unown_name(owner_id);
6037 __bt_service_register_object(bt_service_conn, NULL, FALSE);
6040 #ifdef TIZEN_FEATURE_BT_CONTAINER
6042 g_slist_free_full(nspid_list, (GDestroyNotify)__bt_service_free_nspid);
6048 int _bt_service_cynara_init(void)
6051 char err_msg[256] = {0, };
6053 retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
6055 result = cynara_initialize(&p_cynara, conf);
6057 if (result != CYNARA_API_SUCCESS) {
6058 cynara_strerror(result, err_msg, sizeof(err_msg));
6059 BT_ERR("Fail to initialize cynara: [%s]", err_msg);
6060 return BLUETOOTH_ERROR_INTERNAL;
6063 return BLUETOOTH_ERROR_NONE;
6066 void _bt_service_cynara_deinit(void)
6069 char err_msg[256] = {0, };
6071 ret_if(p_cynara == NULL);
6073 result = cynara_finish(p_cynara);
6075 if (result != CYNARA_API_SUCCESS) {
6076 cynara_strerror(result, err_msg, sizeof(err_msg));
6077 BT_ERR("Fail to finish cynara: [%s]", err_msg);
6085 void _bt_service_method_return(GDBusMethodInvocation *invocation,
6086 GArray *out_param, int result)
6090 out_var = g_variant_new_from_data((const GVariantType *)"ay",
6091 out_param->data, out_param->len, TRUE, NULL, NULL);
6093 g_dbus_method_invocation_return_value(invocation,
6094 g_variant_new("(iv)", result, out_var));
6097 void _bt_service_method_return_with_unix_fd_list(GDBusMethodInvocation *invocation,
6098 GArray *out_param, int result, GUnixFDList *fd_list)
6102 out_var = g_variant_new_from_data((const GVariantType *)"ay",
6103 out_param->data, out_param->len, TRUE, NULL, NULL);
6105 g_dbus_method_invocation_return_value_with_unix_fd_list(invocation,
6106 g_variant_new("(iv)", result, out_var), fd_list);