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-util.h"
46 #include "bt-service-mesh-network.h"
47 #include "bt-service-mesh-config-client.h"
49 #ifdef TIZEN_FEATURE_BT_DPM
50 #include "bt-service-dpm.h"
52 #include "bt-service-hidhost.h"
53 #include "bt-service-rfcomm.h"
54 #include "bt-service-hdp.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 #ifdef TIZEN_FEATURE_BT_PAN_NAP
66 #include "bt-service-network.h"
69 #ifdef TIZEN_FEATURE_BT_IPSP
70 #include "bt-service-ipsp.h"
72 /* For maintaining Application Sync API call requests */
73 GSList *invocation_list = NULL;
75 static GDBusConnection *bt_service_conn;
76 static guint owner_id = 0;
77 static guint owner_sig_id = 0;
78 static gboolean is_le_intended = FALSE;
80 static cynara *p_cynara;
81 static cynara_configuration *conf;
82 const char *requester_unique_creds = NULL;
84 static const gchar bt_service_introspection_xml[] =
85 "<node name='/org/projectx/bt_service'>"
86 " <interface name='org.projectx.bt'>"
87 " <method name='service_request'>"
88 /* Input Parameters */
89 " <arg type='i' name='service_type' direction='in' />"
90 " <arg type='i' name='service_function' direction='in' />"
91 " <arg type='i' name='request_type' direction='in' />"
92 " <arg type='ay' name='input_param1' direction='in' />"
93 " <arg type='ay' name='input_param2' direction='in' />"
94 " <arg type='ay' name='input_param3' direction='in' />"
95 " <arg type='ay' name='input_param4' direction='in' />"
96 " <arg type='ay' name='input_param5' direction='in' />"
97 /* Return Parameters */
98 " <arg type='i' name='output_param1' direction='out' />"
99 " <arg type='v' name='output_param2' direction='out' />"
101 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
102 " <method name='get_avc_mode'>"
104 " <arg type='u' name='avc_mode' direction='out' />"
110 static gboolean name_acquired = FALSE;
112 static char *current_sender_playing = NULL;
114 GDBusNodeInfo *node_info_g = NULL;
116 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param);
118 static void __bt_service_method(GDBusConnection *connection,
120 const gchar *object_path,
121 const gchar *interface_name,
122 const gchar *method_name,
123 GVariant *parameters,
124 GDBusMethodInvocation *invocation,
127 int __bt_bluez_request(int function_name,
130 GDBusMethodInvocation *context,
135 GArray **out_param1);
136 int __bt_obexd_request(int function_name,
139 GDBusMethodInvocation *context,
144 GArray **out_param1);
145 int __bt_agent_request(int function_name,
148 GDBusMethodInvocation *context,
153 GArray **out_param1);
154 int __bt_core_request(int function_name,
157 GDBusMethodInvocation *context,
158 GVariant *in_param1);
160 gboolean __bt_service_check_privilege(int function_name,
162 const char *unique_name);
164 /* Function definitions*/
165 GSList *_bt_get_invocation_list(void)
167 return invocation_list;
170 void _bt_free_info_from_invocation_list(invocation_info_t *req_info)
172 ret_if(NULL == req_info);
173 invocation_list = g_slist_remove(invocation_list, req_info);
174 g_free(req_info->sender);
175 g_free(req_info->user_data);
179 void _bt_set_le_intended_status(gboolean value)
181 is_le_intended = value;
184 static void __bt_service_get_parameters(GVariant *in_param,
185 void *value, int size)
188 buf = (void *)g_variant_get_data(in_param);
189 memcpy(value, buf, size);
192 static gboolean __bt_is_sync_function(int service_function)
194 /*TODO: Keep adding sync methods with expect replies from bluetooth service */
195 if (service_function == BT_GET_LOCAL_ADDRESS
196 || service_function == BT_GET_LOCAL_NAME
197 || service_function == BT_GET_LOCAL_VERSION
198 || service_function == BT_GET_BONDED_DEVICES
199 || service_function == BT_GET_BONDED_DEVICE
200 || service_function == BT_GET_PROFILE_CONNECTED_DEVICES
201 || service_function == BT_GET_IS_ALIAS_SET
202 || service_function == BT_GET_CONNECTED_LINK_TYPE
203 || service_function == BT_IS_SERVICE_USED
204 || service_function == BT_RFCOMM_LISTEN_AND_ACCEPT
205 || service_function == BT_RFCOMM_LISTEN
206 || service_function == BT_HDP_REGISTER_SINK_APP
207 || service_function == BT_HDP_UNREGISTER_SINK_APP
208 || service_function == BT_HDP_GET_FD
209 || service_function == BT_AVRCP_GET_TRACK_INFO
210 || service_function == BT_AVRCP_CONTROL_GET_PROPERTY
211 || service_function == BT_SET_ADVERTISING_DATA
212 || service_function == BT_SET_SCAN_RESPONSE_DATA
213 || service_function == BT_SET_ADVERTISING
214 || service_function == BT_SET_CUSTOM_ADVERTISING
215 || service_function == BT_GATT_SERVER_REGISTER
216 || service_function == BT_GATT_SERVER_ADD_SERVICE
217 || service_function == BT_GATT_SERVER_ADD_CHARACTERISTIC
218 || service_function == BT_GATT_SERVER_ADD_DESCRIPTOR
219 || service_function == BT_GATT_SERVER_START_SERVICE
220 || service_function == BT_GATT_SERVER_STOP_SERVICE
221 || service_function == BT_GATT_SERVER_DELETE_SERVICE
222 || service_function == BT_START_LE_DISCOVERY
223 || service_function == BT_STOP_LE_DISCOVERY
224 || service_function == BT_GET_CONNECTABLE
225 #ifdef TIZEN_GATT_CLIENT
226 || service_function == BT_GATT_CLIENT_REGISTER
227 || service_function == BT_GATT_GET_PRIMARY_SERVICES
228 || service_function == BT_GATT_GET_SERVICE_PROPERTIES
229 || service_function == BT_GATT_GET_INCLUDED_SERVICES
230 || service_function == BT_GATT_GET_CHARACTERISTIC_PROPERTIES
231 || service_function == BT_GATT_WATCH_CHARACTERISTIC
232 || service_function == BT_GATT_ACQUIRE_WRITE
234 || service_function == BT_AUDIO_SELECT_ROLE
236 || service_function == BT_MESH_NETWORK_CREATE
237 || service_function == BT_MESH_NETWORK_LOAD
238 || service_function == BT_MESH_NETWORK_SCAN
239 || service_function == BT_MESH_NETWORK_ADD_NETKEY
240 || service_function == BT_MESH_NETWORK_DELETE_NETKEY
241 || service_function == BT_MESH_NETWORK_UPDATE_NETKEY
242 || service_function == BT_MESH_NETWORK_ADD_APPKEY
243 || service_function == BT_MESH_NETWORK_DELETE_APPKEY
244 || service_function == BT_MESH_NETWORK_UPDATE_APPKEY)
250 void _bt_save_invocation_context(GDBusMethodInvocation *invocation, int result,
251 char *sender, int service_function,
252 gpointer invocation_data)
254 invocation_info_t *info;
255 info = g_malloc0(sizeof(invocation_info_t));
256 info->context = invocation;
257 info->result = result;
258 info->sender = g_strdup(sender);
259 info->service_function = service_function;
260 info->user_data = invocation_data;
261 invocation_list = g_slist_append(invocation_list, info);
265 static int __bt_service_get_sender_pid(const char *unique_name, pid_t *pid)
268 char err_msg[256] = {0, };
270 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
272 ret = cynara_creds_gdbus_get_pid(bt_service_conn, unique_name, pid);
273 if (ret != CYNARA_API_SUCCESS) {
274 cynara_strerror(ret, err_msg, sizeof(err_msg));
275 BT_ERR("Fail to get user credential: %s", err_msg);
277 return BLUETOOTH_ERROR_INTERNAL;
280 return BLUETOOTH_ERROR_NONE;
283 static int __bt_bm_request_data(_bt_battery_data_t *latest)
285 int ret = _bt_bm_read_data(latest);
286 if (ret == BLUETOOTH_ERROR_NONE) {
287 BT_DBG("Received data from bluetooth battery monitor: %ld %ld %d %d",
288 latest->session_start_time, latest->session_end_time,
289 latest->session_scan_time, latest->session_connected_time);
291 if (latest->atm_list == NULL) {
292 BT_DBG("No app data transaction for this session");
296 for (GSList *l = latest->atm_list; l != NULL; l = g_slist_next(l)) {
297 _bt_battery_app_data_t *t = (_bt_battery_app_data_t *)(l->data);
298 BT_DBG("%ld %ld %d %d", (long int)(t->uid), (long int)(t->pid), t->rx_bytes, t->tx_bytes);
302 BT_ERR("Error encountered");
306 static void __bt_service_method(GDBusConnection *connection,
308 const gchar *object_path,
309 const gchar *interface_name,
310 const gchar *method_name,
311 GVariant *parameters,
312 GDBusMethodInvocation *invocation,
317 BT_DBG("Method[%s] Object Path[%s] Interface Name[%s]",
318 method_name, object_path, interface_name);
320 if (g_strcmp0(method_name, "service_request") == 0) {
322 int service_function;
324 GVariant *param1 = NULL;
325 GVariant *param2 = NULL;
326 GVariant *param3 = NULL;
327 GVariant *param4 = NULL;
328 GVariant *param5 = NULL;
329 GArray *out_param1 = NULL;
330 GVariant *out_var = NULL;
331 GVariant *temp = NULL;
335 g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
336 &service_function, &request_type,
337 ¶m1, ¶m2, ¶m3, ¶m4, ¶m5);
339 out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
341 if (service_type == BT_CORE_SERVICE) {
342 BT_DBG("No need to check privilege from bt-core");
343 } else if (__bt_service_check_privilege(service_function,
344 service_type, (const char *)sender) == FALSE) {
345 BT_ERR("Client don't have the privilege to excute this function");
346 result = BLUETOOTH_ERROR_PERMISSION_DEINED;
350 BT_DBG("SERVICE TYPE [%d] SERVICE FUNC [%d]",
351 service_type, service_function);
352 switch (service_type) {
353 case BT_BLUEZ_SERVICE:
354 result = __bt_bluez_request(service_function,
355 request_type, request_id,
356 invocation, param1, param2,
357 param3, param4, &out_param1);
359 case BT_OBEX_SERVICE:
360 result = __bt_obexd_request(service_function,
361 request_type, request_id,
364 param4, &out_param1);
366 case BT_AGENT_SERVICE:
367 result = __bt_agent_request(service_function,
368 request_type, request_id,
371 param4, &out_param1);
373 case BT_CORE_SERVICE:
374 result = __bt_core_request(service_function,
375 request_type, request_id,
378 case BT_CHECK_PRIVILEGE:
379 result = BLUETOOTH_ERROR_NONE;
382 BT_ERR("Unknown service type");
383 result = BLUETOOTH_ERROR_INTERNAL;
387 if (result != BLUETOOTH_ERROR_NONE)
390 if (service_type == BT_CHECK_PRIVILEGE)
393 if (service_function == BT_OPP_PUSH_FILES)
396 if (request_type == BT_ASYNC_REQ ||
397 __bt_is_sync_function(service_function)) {
398 /* Do not send reply to bt-api over dbus,
399 Invocation context is already saved in service_function */
404 out_var = g_variant_new_from_data((const GVariantType *)"ay",
405 out_param1->data, out_param1->len,
408 temp = g_variant_new("(iv)", result, out_var);
409 g_dbus_method_invocation_return_value(invocation, temp);
410 g_array_free(out_param1, TRUE);
414 g_variant_unref(param1);
415 g_variant_unref(param2);
416 g_variant_unref(param3);
417 g_variant_unref(param4);
418 g_variant_unref(param5);
422 BT_ERR_C("Request is failed [%s] [0x%x]",
423 _bt_convert_error_to_string(result), result);
425 out_var = g_variant_new_from_data((const GVariantType *)"ay",
426 out_param1->data, out_param1->len,
429 temp = g_variant_new("(iv)", result, out_var);
430 g_dbus_method_invocation_return_value(invocation, temp);
432 g_array_free(out_param1, TRUE);
435 g_variant_unref(param1);
436 g_variant_unref(param2);
437 g_variant_unref(param3);
438 g_variant_unref(param4);
439 g_variant_unref(param5);
441 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
442 else if (g_strcmp0(method_name, "get_avc_mode") == 0) {
443 unsigned int mode = 0;
445 if (_bt_audio_get_avc_mode(&mode) != BLUETOOTH_ERROR_NONE)
446 BT_ERR("Fail to get the avc mode");
448 BT_DBG("Absolute Volume Control mode: %d", mode);
450 g_dbus_method_invocation_return_value(invocation,
451 g_variant_new("(u)", mode));
460 static const GDBusInterfaceVTable method_table = {
467 int __bt_bluez_request(int function_name,
470 GDBusMethodInvocation *context,
477 int result = BLUETOOTH_ERROR_NONE;
480 switch (function_name) {
481 case BT_ENABLE_ADAPTER: {
482 result = _bt_enable_adapter();
483 _bt_adapter_start_enable_timer();
486 case BT_DISABLE_ADAPTER: {
487 result = _bt_disable_adapter();
490 case BT_RECOVER_ADAPTER:
491 result = _bt_recover_adapter();
493 case BT_RESET_ADAPTER:
494 result = _bt_reset_adapter();
496 case BT_BATTERY_READ_DATA: {
497 _bt_battery_data_t *data = NULL;
498 data = g_malloc0(sizeof(_bt_battery_data_t));
499 result = __bt_bm_request_data(data);
501 bt_battery_dbus_data_t dbus_data;
502 memset(&dbus_data, 0, sizeof(bt_battery_dbus_data_t));
503 dbus_data.session_start_time = data->session_start_time;
504 dbus_data.session_end_time = data->session_end_time;
505 dbus_data.session_scan_time = data->session_scan_time;
506 dbus_data.session_connected_time = data->session_connected_time;
507 dbus_data.tx_time = data->tx_time;
508 dbus_data.rx_time = data->rx_time;
509 dbus_data.idle_time = data->idle_time;
511 /*Populating app data*/
513 for (GSList *l = data->atm_list; l != NULL; l = g_slist_next(l)) {
514 bt_battery_app_data *t = (bt_battery_app_data *)(l->data);
515 memcpy(&dbus_data.app_data[n], t, sizeof(bt_battery_app_data));
518 dbus_data.num_app = n;
519 g_array_append_vals(*out_param1, &dbus_data, sizeof(bt_battery_dbus_data_t));
520 g_slist_free_full(data->atm_list, g_free);
525 case BT_CHECK_ADAPTER: {
526 int enabled = BT_ADAPTER_DISABLED;
527 result = _bt_check_adapter(&enabled);
529 g_array_append_vals(*out_param1, &enabled,
533 case BT_ENABLE_ADAPTER_LE:
534 _bt_set_le_intended_status(TRUE);
535 result = _bt_enable_adapter_le();
537 case BT_DISABLE_ADAPTER_LE:
538 _bt_set_le_intended_status(FALSE);
539 result = _bt_disable_adapter_le();
541 case BT_START_DISCOVERY: {
542 unsigned short max_response;
543 unsigned short discovery_duration;
544 unsigned int classOfDeviceMask;
547 __bt_service_get_parameters(in_param1,
548 &max_response, sizeof(unsigned short));
549 __bt_service_get_parameters(in_param2,
550 &discovery_duration, sizeof(unsigned short));
551 __bt_service_get_parameters(in_param3,
552 &classOfDeviceMask, sizeof(unsigned int));
553 __bt_service_get_parameters(in_param4, &uid, sizeof(uid_t));
555 result = _bt_start_discovery(max_response, discovery_duration, classOfDeviceMask);
557 if (result == BLUETOOTH_ERROR_NONE) {
560 sender = (char*)g_dbus_method_invocation_get_sender(context);
562 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
563 BT_ERR("Fail to get the sender pid");
565 BT_DBG("Remeber pid / uid for the scan operation");
566 _bt_bm_add_scan_app(SCAN_REGACY, uid, pid);
571 case BT_START_CUSTOM_DISCOVERY: {
572 bt_discovery_role_type_t role;
574 __bt_service_get_parameters(in_param1,
575 &role, sizeof(bt_discovery_role_type_t));
576 result = _bt_start_custom_discovery(role);
580 case BT_CANCEL_DISCOVERY:
581 result = _bt_cancel_discovery();
583 case BT_IS_DISCOVERYING: {
584 gboolean discovering = FALSE;
585 discovering = _bt_is_discovering();
586 g_array_append_vals(*out_param1,
587 &discovering, sizeof(gboolean));
590 case BT_GET_LOCAL_ADDRESS: {
591 result = _bt_get_local_address();
593 /* Save invocation */
594 if (result == BLUETOOTH_ERROR_NONE) {
595 sender = (char*)g_dbus_method_invocation_get_sender(context);
596 _bt_save_invocation_context(context, result, sender,
597 function_name, NULL);
601 case BT_GET_LOCAL_VERSION: {
602 result = _bt_get_local_version();
604 /* Save invocation */
605 if (result == BLUETOOTH_ERROR_NONE) {
606 sender = (char*)g_dbus_method_invocation_get_sender(context);
607 _bt_save_invocation_context(context, result, sender,
608 function_name, NULL);
612 case BT_GET_LOCAL_NAME: {
613 result = _bt_get_local_name();
615 /* Save invocation */
616 if (result == BLUETOOTH_ERROR_NONE) {
617 sender = (char*)g_dbus_method_invocation_get_sender(context);
618 _bt_save_invocation_context(context, result, sender,
619 function_name, NULL);
623 case BT_SET_LOCAL_NAME: {
624 bluetooth_device_name_t local_name = { {0} };
625 __bt_service_get_parameters(in_param1,
626 &local_name, sizeof(bluetooth_device_name_t));
627 result = _bt_set_local_name(local_name.name);
630 case BT_GET_DISCOVERABLE_MODE: {
631 int discoverable_mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
632 result = _bt_get_discoverable_mode(&discoverable_mode);
633 g_array_append_vals(*out_param1, &discoverable_mode, sizeof(int));
636 case BT_GET_DISCOVERABLE_TIME: {
639 result = _bt_get_timeout_value(&timeout);
640 g_array_append_vals(*out_param1, &timeout, sizeof(int));
643 case BT_SET_DISCOVERABLE_MODE: {
644 int mode = BLUETOOTH_DISCOVERABLE_MODE_CONNECTABLE;
647 __bt_service_get_parameters(in_param1, &mode, sizeof(int));
648 __bt_service_get_parameters(in_param2, &time, sizeof(int));
650 result = _bt_set_discoverable_mode(mode, time);
653 case BT_IS_CONNECTABLE: {
654 gboolean is_connectable = FALSE;
656 is_connectable = _bt_is_connectable();
657 g_array_append_vals(*out_param1, &is_connectable, sizeof(gboolean));
660 case BT_GET_CONNECTABLE: {
661 result = _bt_get_connectable();
663 /* Save invocation */
664 if (result == BLUETOOTH_ERROR_NONE) {
665 sender = (char*)g_dbus_method_invocation_get_sender(context);
666 _bt_save_invocation_context(context, result, sender,
667 function_name, NULL);
671 case BT_SET_CONNECTABLE: {
672 gboolean is_connectable;
674 __bt_service_get_parameters(in_param1,
675 &is_connectable, sizeof(gboolean));
676 result = _bt_set_connectable(is_connectable);
679 case BT_IS_SERVICE_USED: {
682 uuid = (char *)g_variant_get_data(in_param1);
683 BT_INFO("UUID to be searched [%s]", uuid);
684 result = _bt_is_service_used();
686 /* Save invocation */
687 if (result == BLUETOOTH_ERROR_NONE) {
688 sender = (char*)g_dbus_method_invocation_get_sender(context);
689 _bt_save_invocation_context(context, result, sender,
690 function_name, g_strdup(uuid));
694 case BT_GET_BONDED_DEVICES: {
695 result = _bt_get_bonded_devices();
696 /* Save invocation */
697 if (result == BLUETOOTH_ERROR_NONE) {
698 sender = (char*)g_dbus_method_invocation_get_sender(context);
699 _bt_save_invocation_context(context, result, sender,
700 function_name, NULL);
704 case BT_GET_BONDED_DEVICE: {
705 bluetooth_device_address_t address = { {0} };
707 __bt_service_get_parameters(in_param1,
708 &address, sizeof(bluetooth_device_address_t));
710 result = _bt_get_bonded_device_info(&address);
711 /* Save invocation */
712 if (result == BLUETOOTH_ERROR_NONE) {
713 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
715 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
719 _bt_convert_addr_type_to_string(addr, address.addr);
720 sender = (char*)g_dbus_method_invocation_get_sender(context);
721 _bt_save_invocation_context(context, result, sender,
722 function_name, addr);
726 case BT_GET_PROFILE_CONNECTED_DEVICES: {
728 uuid = (char *)g_variant_get_data(in_param1);
729 result = _bt_get_profile_connected_devices(uuid);
731 /* Save invocation */
732 if (result == BLUETOOTH_ERROR_NONE) {
733 sender = (char *)g_dbus_method_invocation_get_sender(context);
734 _bt_save_invocation_context(context, result, sender,
735 function_name, NULL);
740 bluetooth_device_address_t address = { {0} };
741 const char *local_name;
743 __bt_service_get_parameters(in_param1,
744 &address, sizeof(bluetooth_device_address_t));
745 local_name = (const char *)g_variant_get_data(in_param2);
747 result = _bt_set_alias(&address, local_name);
750 case BT_BOND_DEVICE: {
751 bluetooth_device_address_t address = { {0} };
753 __bt_service_get_parameters(in_param1,
754 &address, sizeof(bluetooth_device_address_t));
755 result = _bt_bond_device(&address, BLUETOOTH_DEV_CONN_DEFAULT, out_param1);
757 /* Save invocation */
758 if (result == BLUETOOTH_ERROR_NONE) {
759 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
760 _bt_convert_addr_type_to_string(addr, address.addr);
761 sender = (char*)g_dbus_method_invocation_get_sender(context);
762 _bt_save_invocation_context(context, result, sender,
763 function_name, (gpointer)addr);
765 bluetooth_device_info_t dev_info;
767 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
768 memcpy(&dev_info.device_address, &address,
769 sizeof(bluetooth_device_address_t));
770 g_array_append_vals(*out_param1, &dev_info,
771 sizeof(bluetooth_device_info_t));
775 case BT_BOND_DEVICE_BY_TYPE: {
776 bluetooth_device_address_t address = { {0} };
777 unsigned short conn_type = 0;
779 __bt_service_get_parameters(in_param1,
780 &address, sizeof(bluetooth_device_address_t));
781 __bt_service_get_parameters(in_param2,
782 &conn_type, sizeof(unsigned short));
784 result = _bt_bond_device(&address, conn_type, out_param1);
785 /* Save invocation */
786 if (result == BLUETOOTH_ERROR_NONE) {
787 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
788 _bt_convert_addr_type_to_string(addr, address.addr);
789 sender = (char*)g_dbus_method_invocation_get_sender(context);
790 _bt_save_invocation_context(context, result, sender,
791 function_name, (gpointer)addr);
793 bluetooth_device_info_t dev_info;
795 memset(&dev_info, 0x00, sizeof(bluetooth_device_info_t));
796 memcpy(&dev_info.device_address, &address,
797 sizeof(bluetooth_device_address_t));
798 g_array_append_vals(*out_param1, &dev_info,
799 sizeof(bluetooth_device_info_t));
803 case BT_UNBOND_DEVICE: {
804 bluetooth_device_address_t address = { {0} };
806 __bt_service_get_parameters(in_param1,
807 &address, sizeof(bluetooth_device_address_t));
808 result = _bt_unbond_device(&address, out_param1);
810 /* Save invocation */
811 if (result == BLUETOOTH_ERROR_NONE) {
812 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
813 _bt_convert_addr_type_to_string(addr, address.addr);
814 sender = (char*)g_dbus_method_invocation_get_sender(context);
815 _bt_save_invocation_context(context, result, sender,
816 function_name, (gpointer)addr);
818 g_array_append_vals(*out_param1, &address,
819 sizeof(bluetooth_device_address_t));
823 case BT_CANCEL_BONDING:{
824 result = _bt_cancel_bonding();
827 case BT_SEARCH_SERVICE: {
828 bluetooth_device_address_t address = { {0} };
829 __bt_service_get_parameters(in_param1,
830 &address, sizeof(bluetooth_device_address_t));
831 result = _bt_search_device(&address);
832 /* Save invocation */
833 if (result == BLUETOOTH_ERROR_NONE) {
834 char * addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
835 _bt_convert_addr_type_to_string(addr, address.addr);
836 sender = (char*)g_dbus_method_invocation_get_sender(context);
837 _bt_save_invocation_context(context, result, sender,
838 function_name, (gpointer)addr);
840 bt_sdp_info_t sdp_info;
842 memset(&sdp_info, 0x00, sizeof(bt_sdp_info_t));
843 memcpy(&sdp_info.device_addr, &address,
844 sizeof(bluetooth_device_address_t));
845 g_array_append_vals(*out_param1, &sdp_info, sizeof(bt_sdp_info_t));
849 case BT_CANCEL_SEARCH_SERVICE: {
850 result = _bt_cancel_search_device();
853 case BT_SET_PASSKEY_NOTIFICATION: {
857 sender = (char *)g_dbus_method_invocation_get_sender(context);
858 __bt_service_get_parameters(in_param1,
859 &enable, sizeof(gboolean));
861 result = _bt_set_passkey_notification(sender, enable);
864 case BT_SET_PIN_CODE: {
865 bluetooth_device_address_t address = { {0} };
866 bluetooth_device_pin_code_t pin_code = { {0} };
868 __bt_service_get_parameters(in_param1,
869 &address, sizeof(bluetooth_device_address_t));
870 __bt_service_get_parameters(in_param2,
871 &pin_code, sizeof(bluetooth_device_pin_code_t));
873 result = _bt_set_pin_code(&address, &pin_code);
876 case BT_UNSET_PIN_CODE: {
877 bluetooth_device_address_t address = { {0} };
879 __bt_service_get_parameters(in_param1,
880 &address, sizeof(bluetooth_device_address_t));
882 result = _bt_unset_pin_code(&address);
885 case BT_PASSKEY_REPLY: {
886 const char *passkey = NULL;
887 gboolean authentication_reply = FALSE;
888 passkey = g_variant_get_data(in_param1);
889 __bt_service_get_parameters(in_param2,
890 &authentication_reply, sizeof(gboolean));
891 result = _bt_passkey_reply(passkey, authentication_reply);
894 case BT_PASSKEY_CONFIRMATION_REPLY: {
895 gboolean confirmation_reply = FALSE;
896 __bt_service_get_parameters(in_param1,
897 &confirmation_reply, sizeof(gboolean));
898 result = _bt_passkey_confirmation_reply(confirmation_reply);
901 case BT_GET_IS_ALIAS_SET: {
902 bluetooth_device_address_t address = { {0} };
904 __bt_service_get_parameters(in_param1,
905 &address, sizeof(bluetooth_device_address_t));
907 result = _bt_is_alias_set(&address);
908 if (result == BLUETOOTH_ERROR_NONE) {
909 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
911 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
915 _bt_convert_addr_type_to_string(addr, address.addr);
916 sender = (char*)g_dbus_method_invocation_get_sender(context);
917 _bt_save_invocation_context(context, result, sender,
918 function_name, addr);
922 case BT_SET_AUTHORIZATION: {
923 bluetooth_device_address_t address = { {0} };
925 __bt_service_get_parameters(in_param1,
926 &address, sizeof(bluetooth_device_address_t));
927 __bt_service_get_parameters(in_param2,
928 &authorize, sizeof(gboolean));
929 result = _bt_set_authorization(&address, authorize);
932 case BT_SET_LE_PRIVACY: {
933 gboolean set_privacy;
934 __bt_service_get_parameters(in_param1, &set_privacy,
936 result = _bt_set_le_privacy(set_privacy);
939 case BT_ADD_WHITE_LIST: {
940 bluetooth_device_address_t address = { {0} };
941 int address_type = 0;
943 __bt_service_get_parameters(in_param1,
944 &address, sizeof(bluetooth_device_address_t));
945 __bt_service_get_parameters(in_param2,
946 &address_type, sizeof(int));
947 result = _bt_set_white_list(&address, address_type, is_add);
950 case BT_REMOVE_WHITE_LIST: {
951 bluetooth_device_address_t address = { {0} };
952 int address_type = 0;
954 __bt_service_get_parameters(in_param1,
955 &address, sizeof(bluetooth_device_address_t));
956 __bt_service_get_parameters(in_param2,
957 &address_type, sizeof(int));
958 result = _bt_set_white_list(&address, address_type, is_add);
961 case BT_UPDATE_LE_CONNECTION_MODE: {
963 bluetooth_device_address_t remote_address = { { 0 } };
964 bluetooth_le_connection_param_t parameters = { 0 };
965 bluetooth_le_connection_mode_t mode = BLUETOOTH_LE_CONNECTION_MODE_BALANCED;
967 __bt_service_get_parameters(in_param1, &remote_address,
968 sizeof(bluetooth_device_address_t));
969 __bt_service_get_parameters(in_param2, &mode,
970 sizeof(bluetooth_le_connection_mode_t));
972 result = _bt_get_le_connection_parameter(mode, ¶meters);
973 if (result != BLUETOOTH_ERROR_NONE)
976 sender = (char *)g_dbus_method_invocation_get_sender(context);
978 result = _bt_le_connection_update(sender,
980 parameters.interval_min,
981 parameters.interval_max,
986 case BT_SET_MANUFACTURER_DATA: {
987 bluetooth_manufacturer_data_t m_data = { 0 };
988 __bt_service_get_parameters(in_param1,
989 &m_data, sizeof(bluetooth_manufacturer_data_t));
990 result = _bt_set_manufacturer_data(&m_data);
994 case BT_IS_DEVICE_CONNECTED: {
995 bluetooth_device_address_t address = { {0} };
996 gboolean connected = FALSE;
999 __bt_service_get_parameters(in_param1,
1000 &address, sizeof(bluetooth_device_address_t));
1001 __bt_service_get_parameters(in_param2,
1002 &service_type, sizeof(int));
1004 #if defined(TIZEN_FEATURE_BT_PAN_NAP)
1005 if ((service_type == BLUETOOTH_NAP_SERVICE) || (service_type == BLUETOOTH_NAP_SERVER_SERVICE))
1006 connected = _bt_is_nap_panu_device_connected(&address, service_type);
1008 connected = _bt_is_device_connected(&address, service_type);
1010 connected = _bt_is_device_connected(&address, service_type);
1012 BT_INFO("is_connected: %d", connected);
1013 g_array_append_vals(*out_param1, &connected, sizeof(gboolean));
1016 case BT_GET_CONNECTED_LINK_TYPE: {
1017 bluetooth_device_address_t address = { {0} };
1019 __bt_service_get_parameters(in_param1,
1020 &address, sizeof(bluetooth_device_address_t));
1022 result = _bt_get_connected_link(&address);
1023 if (result == BLUETOOTH_ERROR_NONE) {
1024 char *addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
1026 result = BLUETOOTH_ERROR_MEMORY_ALLOCATION;
1030 _bt_convert_addr_type_to_string(addr, address.addr);
1031 sender = (char*)g_dbus_method_invocation_get_sender(context);
1032 _bt_save_invocation_context(context, result, sender,
1033 function_name, addr);
1037 case BT_IS_SCAN_FILTER_SUPPORTED:{
1038 int is_supported = 0;
1040 if (_bt_is_scan_filter_supported() == TRUE)
1043 g_array_append_vals(*out_param1,
1044 &is_supported, sizeof(int));
1048 case BT_ENABLE_RSSI: {
1049 bluetooth_device_address_t bd_addr;
1051 bt_rssi_threshold_t rssi_threshold;
1053 int in_range_threshold;
1056 BT_DBG("Enable RSSI");
1058 __bt_service_get_parameters(in_param1,
1059 &bd_addr, sizeof(bluetooth_device_address_t));
1060 __bt_service_get_parameters(in_param2,
1061 &link_type, sizeof(int));
1062 __bt_service_get_parameters(in_param3,
1063 &rssi_threshold, sizeof(bt_rssi_threshold_t));
1065 low_threshold = rssi_threshold.low_threshold;
1066 in_range_threshold = rssi_threshold.in_range_threshold;
1067 high_threshold = rssi_threshold.high_threshold;
1069 result = _bt_enable_rssi(&bd_addr, link_type, low_threshold,
1070 in_range_threshold, high_threshold);
1075 bluetooth_device_address_t bd_addr;
1077 BT_DBG("Get RSSI Strength");
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));
1084 result = _bt_get_rssi_strength(&bd_addr, link_type);
1087 case BT_SET_PROFILE_TRUSTED: {
1088 bluetooth_device_address_t bd_addr = { {0} };
1092 __bt_service_get_parameters(in_param1, &bd_addr,
1093 sizeof(bluetooth_device_address_t));
1094 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1095 __bt_service_get_parameters(in_param3, &trust, sizeof(int));
1097 result = _bt_set_trust_profile(&bd_addr, profile, trust);
1100 case BT_GET_PROFILE_TRUSTED: {
1101 bluetooth_device_address_t bd_addr = { {0} };
1103 guint trusted_profile = 0;
1105 __bt_service_get_parameters(in_param1, &bd_addr,
1106 sizeof(bluetooth_device_address_t));
1107 __bt_service_get_parameters(in_param2, &profile, sizeof(int));
1109 result = _bt_get_trust_profile(&bd_addr, profile, &trusted_profile);
1110 BT_DBG("TRUST %d", trusted_profile);
1111 if (result == BLUETOOTH_ERROR_NONE) {
1112 g_array_append_vals(*out_param1, &trusted_profile,
1118 case BT_HID_CONNECT: {
1119 bluetooth_device_address_t address = { {0} };
1121 __bt_service_get_parameters(in_param1,
1122 &address, sizeof(bluetooth_device_address_t));
1124 result = _bt_hid_connect(&address);
1125 if (result != BLUETOOTH_ERROR_NONE) {
1126 g_array_append_vals(*out_param1, &address,
1127 sizeof(bluetooth_device_address_t));
1129 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1130 _bt_convert_addr_type_to_string(addr, address.addr);
1131 sender = (char*)g_dbus_method_invocation_get_sender(context);
1132 _bt_save_invocation_context(context, result, sender,
1133 function_name, (gpointer)addr);
1137 case BT_HID_DISCONNECT: {
1138 bluetooth_device_address_t address = { {0} };
1140 __bt_service_get_parameters(in_param1,
1141 &address, sizeof(bluetooth_device_address_t));
1143 result = _bt_hid_disconnect(&address);
1144 if (result != BLUETOOTH_ERROR_NONE) {
1145 g_array_append_vals(*out_param1, &address,
1146 sizeof(bluetooth_device_address_t));
1148 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1149 _bt_convert_addr_type_to_string(addr, address.addr);
1150 sender = (char*)g_dbus_method_invocation_get_sender(context);
1151 _bt_save_invocation_context(context, result, sender,
1152 function_name, (gpointer)addr);
1156 #ifdef TIZEN_FEATURE_BT_DPM
1157 case BT_DPM_SET_ALLOW_BT_MODE: {
1158 dpm_bt_allow_t value = DPM_BT_ERROR;
1160 __bt_service_get_parameters(in_param1, &value,
1163 result = _bt_dpm_set_allow_bluetooth_mode(value);
1166 case BT_DPM_GET_ALLOW_BT_MODE: {
1167 int value = DPM_BT_ERROR;
1169 result = _bt_dpm_get_allow_bluetooth_mode(&value);
1170 g_array_append_vals(*out_param1, &value, sizeof(int));
1173 case BT_DPM_SET_DEVICE_RESTRITION: {
1174 dpm_status_t value = DPM_STATUS_ERROR;
1176 __bt_service_get_parameters(in_param1, &value,
1179 result = _bt_dpm_activate_bluetooth_device_restriction(value);
1182 case BT_DPM_GET_DEVICE_RESTRITION: {
1183 int value = DPM_STATUS_ERROR;
1185 result = _bt_dpm_is_bluetooth_device_restriction_active(&value);
1186 g_array_append_vals(*out_param1, &value, sizeof(int));
1189 case BT_DPM_SET_UUID_RESTRITION: {
1190 dpm_status_t value = DPM_STATUS_ERROR;
1192 __bt_service_get_parameters(in_param1, &value,
1195 result = _bt_dpm_activate_bluetoooth_uuid_restriction(value);
1198 case BT_DPM_GET_UUID_RESTRITION: {
1199 int value = DPM_STATUS_ERROR;
1201 result = _bt_dpm_is_bluetooth_uuid_restriction_active(&value);
1202 g_array_append_vals(*out_param1, &value, sizeof(int));
1205 case BT_DPM_ADD_DEVICES_BLACKLIST: {
1206 bluetooth_device_address_t address = { {0} };
1208 __bt_service_get_parameters(in_param1, &address,
1209 sizeof(bluetooth_device_address_t));
1211 result = _bt_dpm_add_bluetooth_devices_to_blacklist(&address);
1214 case BT_DPM_ADD_DEVICES_WHITELIST: {
1215 bluetooth_device_address_t address = { {0} };
1217 __bt_service_get_parameters(in_param1, &address,
1218 sizeof(bluetooth_device_address_t));
1220 result = _bt_dpm_add_bluetooth_devices_to_whitelist(&address);
1223 case BT_DPM_ADD_UUIDS_BLACKLIST: {
1224 const char *uuid = NULL;
1226 uuid = g_variant_get_data(in_param1);
1228 result = _bt_dpm_add_bluetooth_uuids_to_blacklist(uuid);
1231 case BT_DPM_ADD_UUIDS_WHITELIST: {
1232 const char *uuid = NULL;
1234 uuid = g_variant_get_data(in_param1);
1236 result = _bt_dpm_add_bluetooth_uuids_to_whitelist(uuid);
1239 case BT_DPM_CLEAR_DEVICES_BLACKLIST: {
1240 result = _bt_dpm_clear_bluetooth_devices_from_blacklist();
1243 case BT_DPM_CLEAR_DEVICES_WHITELIST: {
1244 result = _bt_dpm_clear_bluetooth_devices_from_whitelist();
1247 case BT_DPM_CLEAR_UUIDS_BLACKLIST: {
1248 result = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
1251 case BT_DPM_CLEAR_UUIDS_WHITELIST: {
1252 result = _bt_dpm_clear_bluetooth_uuids_from_whitelist();
1255 case BT_DPM_REMOVE_DEVICE_BLACKLIST: {
1256 bluetooth_device_address_t address = { {0} };
1258 __bt_service_get_parameters(in_param1, &address,
1259 sizeof(bluetooth_device_address_t));
1261 result = _bt_dpm_remove_bluetooth_devices_from_blacklist(&address);
1264 case BT_DPM_REMOVE_DEVICE_WHITELIST: {
1265 bluetooth_device_address_t address = { {0} };
1267 __bt_service_get_parameters(in_param1, &address,
1268 sizeof(bluetooth_device_address_t));
1270 result = _bt_dpm_remove_bluetooth_devices_from_whitelist(&address);
1273 case BT_DPM_REMOVE_UUID_BLACKLIST: {
1274 const char *uuid = NULL;
1276 uuid = g_variant_get_data(in_param1);
1278 result = _bt_dpm_remove_bluetooth_uuids_from_blacklist(uuid);
1281 case BT_DPM_REMOVE_UUID_WHITELIST: {
1282 const char *uuid = NULL;
1284 uuid = g_variant_get_data(in_param1);
1286 result = _bt_dpm_remove_bluetooth_uuids_from_whitelist(uuid);
1290 case BT_DPM_GET_DEVICES_BLACKLIST: {
1291 result = _bt_dpm_get_bluetooth_devices_from_blacklist(out_param1);
1294 case BT_DPM_GET_DEVICES_WHITELIST: {
1295 result = _bt_dpm_get_bluetooth_devices_from_whitelist(out_param1);
1298 case BT_DPM_GET_UUIDS_BLACKLIST: {
1299 result = _bt_dpm_get_bluetooth_uuids_from_blacklist(out_param1);
1302 case BT_DPM_GET_UUIDS_WHITELIST: {
1303 result = _bt_dpm_get_bluetooth_uuids_from_whitelist(out_param1);
1306 case BT_DPM_SET_ALLOW_OUTGOING_CALL: {
1307 dpm_status_t value = DPM_STATUS_ERROR;
1309 __bt_service_get_parameters(in_param1, &value,
1312 result = _bt_dpm_set_allow_bluetooth_outgoing_call(value);
1316 case BT_DPM_GET_ALLOW_OUTGOING_CALL: {
1317 int value = DPM_STATUS_ERROR;
1319 result = _bt_dpm_get_allow_bluetooth_outgoing_call(&value);
1320 g_array_append_vals(*out_param1, &value, sizeof(int));
1323 case BT_DPM_SET_PAIRING_STATE: {
1324 dpm_status_t value = DPM_STATUS_ERROR;
1326 __bt_service_get_parameters(in_param1, &value,
1329 result = _bt_dpm_set_bluetooth_pairing_state(value);
1333 case BT_DPM_GET_PAIRING_STATE: {
1334 int value = DPM_STATUS_ERROR;
1336 result = _bt_dpm_get_bluetooth_pairing_state(&value);
1337 g_array_append_vals(*out_param1, &value, sizeof(int));
1340 case BT_DPM_SET_PROFILE_STATE: {
1341 int value = DPM_STATUS_ERROR;
1342 int profile = DPM_PROFILE_NONE;
1344 __bt_service_get_parameters(in_param1, &profile,
1346 __bt_service_get_parameters(in_param2, &value,
1349 result = _bt_dpm_set_bluetooth_profile_state(profile, value);
1353 case BT_DPM_GET_PROFILE_STATE: {
1354 int value = DPM_STATUS_ERROR;
1355 int profile = DPM_PROFILE_NONE;
1357 __bt_service_get_parameters(in_param1, &profile,
1360 result = _bt_dpm_get_bluetooth_profile_state(profile, &value);
1361 g_array_append_vals(*out_param1, &value, sizeof(int));
1364 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE: {
1365 int value = DPM_BT_ERROR;
1367 __bt_service_get_parameters(in_param1, &value,
1370 result = _bt_dpm_set_bluetooth_desktop_connectivity_state(value);
1374 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE: {
1375 int value = DPM_STATUS_ERROR;
1377 result = _bt_dpm_get_bluetooth_desktop_connectivity_state(&value);
1378 g_array_append_vals(*out_param1, &value, sizeof(int));
1381 case BT_DPM_SET_DISCOVERABLE_STATE: {
1382 int value = DPM_STATUS_ERROR;
1384 __bt_service_get_parameters(in_param1, &value,
1387 result = _bt_dpm_set_bluetooth_discoverable_state(value);
1391 case BT_DPM_GET_DISCOVERABLE_STATE: {
1392 int value = DPM_STATUS_ERROR;
1394 result = _bt_dpm_get_bluetooth_discoverable_state(&value);
1395 g_array_append_vals(*out_param1, &value, sizeof(int));
1398 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE: {
1399 int value = DPM_STATUS_ERROR;
1401 __bt_service_get_parameters(in_param1, &value,
1404 result = _bt_dpm_set_bluetooth_limited_discoverable_state(value);
1408 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE: {
1409 int value = DPM_STATUS_ERROR;
1411 result = _bt_dpm_get_bluetooth_limited_discoverable_state(&value);
1412 g_array_append_vals(*out_param1, &value, sizeof(int));
1415 case BT_DPM_SET_DATA_TRANSFER_STATE: {
1416 int value = DPM_STATUS_ERROR;
1418 __bt_service_get_parameters(in_param1, &value,
1421 result = _bt_dpm_set_bluetooth_data_transfer_state(value);
1425 case BT_DPM_GET_DATA_TRANSFER_STATE: {
1426 int value = DPM_STATUS_ERROR;
1428 result = _bt_dpm_get_allow_bluetooth_data_transfer_state(&value);
1429 g_array_append_vals(*out_param1, &value, sizeof(int));
1433 case BT_RFCOMM_CLIENT_CONNECT: {
1434 bluetooth_device_address_t address = { {0} };
1438 __bt_service_get_parameters(in_param1,
1439 &address, sizeof(bluetooth_device_address_t));
1440 input_string = (char *)g_variant_get_data(in_param2);
1441 __bt_service_get_parameters(in_param3, &connect_type, sizeof(int));
1443 if (connect_type == BT_RFCOMM_UUID)
1444 result = _bt_rfcomm_connect_using_uuid(&address, input_string);
1446 result = _bt_rfcomm_connect_using_channel(&address, input_string);
1448 if (result != BLUETOOTH_ERROR_NONE) {
1449 bluetooth_rfcomm_connection_t conn_info;
1451 BT_ERR("BT_RFCOMM_CLIENT_CONNECT failed, send error");
1452 memset(&conn_info, 0x00, sizeof(bluetooth_rfcomm_connection_t));
1453 if (connect_type == BT_RFCOMM_UUID)
1454 g_strlcpy(conn_info.uuid, input_string, BLUETOOTH_UUID_STRING_MAX);
1456 g_strlcpy(conn_info.uuid, "not_used", BLUETOOTH_UUID_STRING_MAX);
1458 conn_info.device_role = RFCOMM_ROLE_CLIENT;
1459 conn_info.socket_fd = -1;
1460 g_array_append_vals(*out_param1, &conn_info,
1461 sizeof(bluetooth_rfcomm_connection_t));
1463 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1464 _bt_convert_addr_type_to_string(addr, address.addr);
1465 sender = (char*)g_dbus_method_invocation_get_sender(context);
1466 _bt_save_invocation_context(context, result, sender, function_name, addr);
1470 case BT_RFCOMM_SOCKET_DISCONNECT: {
1472 * Bluetooth RFCOMM socket disconnection will be done from bt-api, call to bt-service
1473 * is only used for privilege check, so return BLUETOOTH_ERROR_NONE from here.
1475 result = BLUETOOTH_ERROR_NONE;
1478 case BT_RFCOMM_SOCKET_WRITE: {
1480 * This call to bt-service is only used for privilege check, so return
1481 * BLUETOOTH_ERROR_NONE from here.
1483 result = BLUETOOTH_ERROR_NONE;
1486 case BT_RFCOMM_CREATE_SOCKET: {
1488 * This call to bt-service is only used for privilege check, so return
1489 * BLUETOOTH_ERROR_NONE from here.
1491 result = BLUETOOTH_ERROR_NONE;
1494 case BT_RFCOMM_LISTEN_AND_ACCEPT: {
1498 sender = (char *)g_dbus_method_invocation_get_sender(context);
1499 uuid = (char *)g_variant_get_data(in_param1);
1501 result = _bt_rfcomm_socket_listen(sender, uuid, true);
1503 result = BLUETOOTH_ERROR_NONE;
1504 _bt_save_invocation_context(context,
1505 result, sender, function_name, NULL);
1507 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1511 case BT_RFCOMM_LISTEN: {
1515 sender = (char *)g_dbus_method_invocation_get_sender(context);
1516 uuid = (char *)g_variant_get_data(in_param1);
1518 result = _bt_rfcomm_socket_listen(sender, uuid, false);
1520 result = BLUETOOTH_ERROR_NONE;
1521 _bt_save_invocation_context(context,
1522 result, sender, function_name, NULL);
1524 g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
1528 case BT_RFCOMM_ACCEPT_CONNECTION: {
1531 address = (char *)g_variant_get_data(in_param1);
1532 result = _bt_rfcomm_reply_conn_authorization(address, TRUE);
1535 case BT_RFCOMM_REJECT_CONNECTION: {
1538 address = (char *)g_variant_get_data(in_param1);
1539 result = _bt_rfcomm_reply_conn_authorization(address, FALSE);
1542 case BT_RFCOMM_REMOVE_SOCKET: {
1544 * This call to bt-service is only used for privilege check, so return
1545 * BLUETOOTH_ERROR_NONE from here.
1547 result = BLUETOOTH_ERROR_NONE;
1550 case BT_RFCOMM_SEND_RX_DETAILS: {
1554 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1555 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1556 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1557 _bt_bm_add_transaction_details(uid, pid, size, RX_DATA);
1560 case BT_RFCOMM_SEND_TX_DETAILS: {
1564 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
1565 __bt_service_get_parameters(in_param2, &pid, sizeof(pid_t));
1566 __bt_service_get_parameters(in_param3, &size, sizeof(unsigned int));
1567 _bt_bm_add_transaction_details(uid, pid, size, TX_DATA);
1570 case BT_RFCOMM_UPDATE_CONNECTION_INFO: {
1571 gboolean connected = FALSE;
1573 int role = RFCOMM_ROLE_SERVER;
1575 sender = (char *)g_dbus_method_invocation_get_sender(context);
1577 __bt_service_get_parameters(in_param1, &role, sizeof(int));
1578 __bt_service_get_parameters(in_param2, &connected, sizeof(gboolean));
1579 __bt_service_get_parameters(in_param3, &socket_fd, sizeof(int));
1581 if (connected == TRUE)
1582 result = _bt_rfcomm_conn_added(sender, role, socket_fd);
1584 result = _bt_rfcomm_conn_removed(sender, role, socket_fd);
1588 case BT_AUDIO_SELECT_ROLE: {
1589 bluetooth_audio_role_t role;
1591 __bt_service_get_parameters(in_param1,
1592 &role, sizeof(bluetooth_audio_role_t));
1594 result = _bt_audio_select_role(role);
1595 if (result == BLUETOOTH_ERROR_NONE) {
1596 sender = (char*)g_dbus_method_invocation_get_sender(context);
1597 _bt_save_invocation_context(context, result, sender,
1598 function_name, NULL);
1602 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
1603 case BT_AUDIO_SET_ABSOLUTE_VOLUME: {
1604 unsigned int volume = 0;
1606 __bt_service_get_parameters(in_param1,
1607 &volume, sizeof(unsigned int));
1609 result = _bt_audio_set_absolute_volume(volume);
1612 case BT_AUDIO_GET_ABSOLUTE_VOLUME: {
1613 unsigned int volume = 0;
1615 result = _bt_audio_get_absolute_volume(&volume);
1616 g_array_append_vals(*out_param1, &volume, sizeof(unsigned int));
1619 case BT_AUDIO_IS_AVC_ACTIVATED: {
1622 result = _bt_audio_is_avc_activated(&activated);
1623 g_array_append_vals(*out_param1, &activated, sizeof(bool));
1627 case BT_AV_CONNECT: {
1628 bluetooth_device_address_t address = { {0} };
1629 __bt_service_get_parameters(in_param1,
1630 &address, sizeof(bluetooth_device_address_t));
1632 result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
1634 if (result != BLUETOOTH_ERROR_NONE) {
1635 char addr[BT_ADDRESS_STRING_SIZE];
1636 _bt_convert_addr_type_to_string(addr, address.addr);
1637 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1639 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1640 _bt_convert_addr_type_to_string(addr, address.addr);
1641 sender = (char*)g_dbus_method_invocation_get_sender(context);
1642 _bt_save_invocation_context(context, result, sender,
1643 function_name, (gpointer)addr);
1647 case BT_AUDIO_CONNECT: {
1648 bluetooth_device_address_t address = { {0} };
1649 __bt_service_get_parameters(in_param1,
1650 &address, sizeof(bluetooth_device_address_t));
1652 result = _bt_audio_connect(BT_AUDIO_ALL, &address);
1654 if (result != BLUETOOTH_ERROR_NONE) {
1655 char addr[BT_ADDRESS_STRING_SIZE];
1656 _bt_convert_addr_type_to_string(addr, address.addr);
1657 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1659 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1660 _bt_convert_addr_type_to_string(addr, address.addr);
1661 sender = (char*)g_dbus_method_invocation_get_sender(context);
1662 _bt_save_invocation_context(context, result, sender,
1663 function_name, (gpointer)addr);
1667 case BT_AUDIO_DISCONNECT: {
1668 bluetooth_device_address_t address = { {0} };
1669 __bt_service_get_parameters(in_param1,
1670 &address, sizeof(bluetooth_device_address_t));
1672 result = _bt_audio_disconnect(BT_AUDIO_ALL, &address);
1674 if (result != BLUETOOTH_ERROR_NONE) {
1675 char addr[BT_ADDRESS_STRING_SIZE];
1676 _bt_convert_addr_type_to_string(addr, address.addr);
1677 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1679 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1680 _bt_convert_addr_type_to_string(addr, address.addr);
1681 sender = (char*)g_dbus_method_invocation_get_sender(context);
1682 _bt_save_invocation_context(context, result, sender,
1683 function_name, (gpointer)addr);
1687 case BT_AV_DISCONNECT: {
1688 bluetooth_device_address_t address = { {0} };
1689 __bt_service_get_parameters(in_param1,
1690 &address, sizeof(bluetooth_device_address_t));
1692 result = _bt_audio_disconnect(BT_AUDIO_A2DP, &address);
1694 if (result != BLUETOOTH_ERROR_NONE) {
1695 char addr[BT_ADDRESS_STRING_SIZE];
1696 _bt_convert_addr_type_to_string(addr, address.addr);
1697 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1699 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1700 _bt_convert_addr_type_to_string(addr, address.addr);
1701 sender = (char*)g_dbus_method_invocation_get_sender(context);
1702 _bt_save_invocation_context(context, result, sender,
1703 function_name, (gpointer)addr);
1707 case BT_AG_CONNECT: {
1708 bluetooth_device_address_t address = { {0} };
1709 __bt_service_get_parameters(in_param1,
1710 &address, sizeof(bluetooth_device_address_t));
1712 result = _bt_audio_connect(BT_AUDIO_HSP, &address);
1714 if (result != BLUETOOTH_ERROR_NONE) {
1715 char addr[BT_ADDRESS_STRING_SIZE];
1716 _bt_convert_addr_type_to_string(addr, address.addr);
1717 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1719 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1720 _bt_convert_addr_type_to_string(addr, address.addr);
1721 sender = (char*)g_dbus_method_invocation_get_sender(context);
1722 _bt_save_invocation_context(context, result, sender,
1723 function_name, (gpointer)addr);
1727 case BT_AG_DISCONNECT: {
1728 bluetooth_device_address_t address = { {0} };
1730 __bt_service_get_parameters(in_param1,
1731 &address, sizeof(bluetooth_device_address_t));
1733 result = _bt_audio_disconnect(BT_AUDIO_HSP, &address);
1735 if (result != BLUETOOTH_ERROR_NONE) {
1736 char addr[BT_ADDRESS_STRING_SIZE];
1737 _bt_convert_addr_type_to_string(addr, address.addr);
1738 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1740 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1741 _bt_convert_addr_type_to_string(addr, address.addr);
1742 sender = (char*)g_dbus_method_invocation_get_sender(context);
1743 _bt_save_invocation_context(context, result, sender,
1744 function_name, (gpointer)addr);
1748 case BT_AV_SOURCE_CONNECT: {
1749 bluetooth_device_address_t address = { {0} };
1751 __bt_service_get_parameters(in_param1,
1752 &address, sizeof(bluetooth_device_address_t));
1754 result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
1755 if (result != BLUETOOTH_ERROR_NONE) {
1756 char addr[BT_ADDRESS_STRING_SIZE];
1757 _bt_convert_addr_type_to_string(addr, address.addr);
1758 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1760 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1761 _bt_convert_addr_type_to_string(addr, address.addr);
1762 sender = (char*)g_dbus_method_invocation_get_sender(context);
1763 _bt_save_invocation_context(context, result, sender,
1764 function_name, (gpointer)addr);
1768 case BT_AV_SOURCE_DISCONNECT: {
1769 bluetooth_device_address_t address = { {0} };
1771 __bt_service_get_parameters(in_param1,
1772 &address, sizeof(bluetooth_device_address_t));
1774 result = _bt_audio_disconnect(BT_AUDIO_A2DP_SOURCE, &address);
1775 if (result != BLUETOOTH_ERROR_NONE) {
1776 char addr[BT_ADDRESS_STRING_SIZE];
1777 _bt_convert_addr_type_to_string(addr, address.addr);
1778 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1780 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1781 _bt_convert_addr_type_to_string(addr, address.addr);
1782 sender = (char*)g_dbus_method_invocation_get_sender(context);
1783 _bt_save_invocation_context(context, result, sender,
1784 function_name, (gpointer)addr);
1788 case BT_HF_CONNECT: {
1789 bluetooth_device_address_t address = { {0} };
1791 __bt_service_get_parameters(in_param1,
1792 &address, sizeof(bluetooth_device_address_t));
1794 result = _bt_hf_connect(&address);
1795 if (result != BLUETOOTH_ERROR_NONE) {
1796 char addr[BT_ADDRESS_STRING_SIZE];
1797 _bt_convert_addr_type_to_string(addr, address.addr);
1798 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1800 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1801 _bt_convert_addr_type_to_string(addr, address.addr);
1802 sender = (char*)g_dbus_method_invocation_get_sender(context);
1803 _bt_save_invocation_context(context, result, sender,
1804 function_name, (gpointer)addr);
1808 case BT_HF_DISCONNECT: {
1809 bluetooth_device_address_t address = { {0} };
1811 __bt_service_get_parameters(in_param1,
1812 &address, sizeof(bluetooth_device_address_t));
1814 result = _bt_hf_disconnect(&address);
1815 if (result != BLUETOOTH_ERROR_NONE) {
1816 char addr[BT_ADDRESS_STRING_SIZE];
1817 _bt_convert_addr_type_to_string(addr, address.addr);
1818 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1820 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1821 _bt_convert_addr_type_to_string(addr, address.addr);
1822 sender = (char*)g_dbus_method_invocation_get_sender(context);
1823 _bt_save_invocation_context(context, result, sender,
1824 function_name, (gpointer)addr);
1828 case BT_AVRCP_TARGET_CONNECT: {
1829 bluetooth_device_address_t address = { {0} };
1831 __bt_service_get_parameters(in_param1,
1832 &address, sizeof(bluetooth_device_address_t));
1834 result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
1835 if (result != BLUETOOTH_ERROR_NONE) {
1836 char addr[BT_ADDRESS_STRING_SIZE];
1837 _bt_convert_addr_type_to_string(addr, address.addr);
1838 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1840 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1841 _bt_convert_addr_type_to_string(addr, address.addr);
1842 sender = (char*)g_dbus_method_invocation_get_sender(context);
1843 _bt_save_invocation_context(context, result, sender,
1844 function_name, (gpointer)addr);
1848 case BT_AVRCP_TARGET_DISCONNECT: {
1849 bluetooth_device_address_t address = { {0} };
1851 __bt_service_get_parameters(in_param1,
1852 &address, sizeof(bluetooth_device_address_t));
1854 result = _bt_audio_disconnect(BT_AVRCP_TARGET, &address);
1855 if (result != BLUETOOTH_ERROR_NONE) {
1856 char addr[BT_ADDRESS_STRING_SIZE];
1857 _bt_convert_addr_type_to_string(addr, address.addr);
1858 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1860 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1861 _bt_convert_addr_type_to_string(addr, address.addr);
1862 sender = (char*)g_dbus_method_invocation_get_sender(context);
1863 _bt_save_invocation_context(context, result, sender,
1864 function_name, (gpointer)addr);
1868 case BT_AVRCP_CONTROL_CONNECT: {
1869 bluetooth_device_address_t address = { {0} };
1871 __bt_service_get_parameters(in_param1,
1872 &address, sizeof(bluetooth_device_address_t));
1874 result = _bt_audio_connect(BT_AVRCP, &address);
1875 if (result != BLUETOOTH_ERROR_NONE) {
1876 char addr[BT_ADDRESS_STRING_SIZE];
1877 _bt_convert_addr_type_to_string(addr, address.addr);
1878 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1880 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1881 _bt_convert_addr_type_to_string(addr, address.addr);
1882 sender = (char*)g_dbus_method_invocation_get_sender(context);
1883 _bt_save_invocation_context(context, result, sender,
1884 function_name, (gpointer)addr);
1888 case BT_AVRCP_CONTROL_DISCONNECT: {
1889 bluetooth_device_address_t address = { {0} };
1891 __bt_service_get_parameters(in_param1,
1892 &address, sizeof(bluetooth_device_address_t));
1894 result = _bt_audio_disconnect(BT_AVRCP, &address);
1895 if (result != BLUETOOTH_ERROR_NONE) {
1896 char addr[BT_ADDRESS_STRING_SIZE];
1897 _bt_convert_addr_type_to_string(addr, address.addr);
1898 g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
1900 char *addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
1901 _bt_convert_addr_type_to_string(addr, address.addr);
1902 sender = (char*)g_dbus_method_invocation_get_sender(context);
1903 _bt_save_invocation_context(context, result, sender,
1904 function_name, (gpointer)addr);
1908 case BT_AVRCP_HANDLE_CONTROL: {
1910 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1911 result = _bt_avrcp_control_cmd(key_code);
1914 case BT_AVRCP_HANDLE_CONTROL_TO_DEST: {
1916 bluetooth_device_address_t address = { { 0 } };
1918 __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
1919 __bt_service_get_parameters(in_param2,
1920 &address, sizeof(bluetooth_device_address_t));
1922 result = _bt_avrcp_control_cmd_to_dest(key_code, &address);
1925 case BT_AVRCP_CONTROL_SET_PROPERTY: {
1929 __bt_service_get_parameters(in_param1,
1930 &type, sizeof(int));
1931 __bt_service_get_parameters(in_param2,
1932 &value, sizeof(unsigned int));
1934 result = _bt_avrcp_control_set_property(type, value);
1937 case BT_AVRCP_TRANSPORT_SET_PROPERTY: {
1942 __bt_service_get_parameters(in_param1,
1943 &type, sizeof(int));
1944 __bt_service_get_parameters(in_param2,
1945 &value, sizeof(unsigned int));
1947 result = _bt_avrcp_transport_set_property(type, value);
1951 case BT_AVRCP_CONTROL_GET_PROPERTY: {
1954 __bt_service_get_parameters(in_param1, &type, sizeof(int));
1956 result = _bt_avrcp_control_get_property(type);
1957 /* Save invocation */
1958 if (result == BLUETOOTH_ERROR_NONE) {
1959 sender = (char*)g_dbus_method_invocation_get_sender(context);
1960 _bt_save_invocation_context(context, result, sender,
1961 function_name, g_memdup(&type, sizeof(int)));
1965 case BT_AVRCP_GET_TRACK_INFO: {
1966 result = _bt_avrcp_control_get_track_info();
1967 /* Save invocation */
1968 if (result == BLUETOOTH_ERROR_NONE) {
1969 sender = (char*)g_dbus_method_invocation_get_sender(context);
1970 _bt_save_invocation_context(context, result, sender,
1971 function_name, NULL);
1975 case BT_HDP_REGISTER_SINK_APP: {
1976 unsigned short data_type;
1977 bt_hdp_role_type_t role;
1978 bt_hdp_qos_type_t channel_type;
1979 int *app_id = g_new0(int, 1);
1981 __bt_service_get_parameters(in_param1,
1982 &data_type, sizeof(short));
1983 __bt_service_get_parameters(in_param2,
1984 &role, sizeof(bt_hdp_role_type_t));
1985 __bt_service_get_parameters(in_param3,
1986 &channel_type, sizeof(bt_hdp_qos_type_t));
1987 sender = (char*)g_dbus_method_invocation_get_sender(context);
1989 result = _bt_hdp_app_register(role,
1990 channel_type, data_type, sender, app_id);
1991 if (result != BLUETOOTH_ERROR_NONE) {
1992 g_array_append_vals(*out_param1, &app_id, sizeof(app_id));
1995 _bt_save_invocation_context(context, result, sender,
1996 function_name, (gpointer)app_id);
2000 case BT_HDP_UNREGISTER_SINK_APP: {
2002 int *app_id = g_new0(int, 1);
2004 app_handle = (char *)g_variant_get_data(in_param1);
2005 sscanf(app_handle, "health_app_%d", app_id);
2006 result = _bt_hdp_app_unregister(*app_id);
2007 if (result != BLUETOOTH_ERROR_NONE) {
2010 sender = (char*)g_dbus_method_invocation_get_sender(context);
2011 _bt_save_invocation_context(context, result, sender,
2012 function_name, (gpointer)app_id);
2016 case BT_HDP_CONNECT: {
2020 bt_hdp_connected_t *conn_info = NULL;
2022 conn_info = g_malloc0(sizeof(bt_hdp_connected_t));
2024 app_handle = (char *)g_variant_get_data(in_param1);
2025 conn_info->app_handle = app_handle;
2026 sscanf(app_handle, "health_app_%d", &app_id);
2028 __bt_service_get_parameters(in_param2,
2029 &(conn_info->type), sizeof(bt_hdp_qos_type_t));
2030 __bt_service_get_parameters(in_param3,
2031 &(conn_info->device_address),
2032 sizeof(bluetooth_device_address_t));
2034 result = _bt_hdp_connect(app_id, &(conn_info->device_address),
2035 conn_info->type, (int *)(&(conn_info->channel_id)));
2036 if (result != BLUETOOTH_ERROR_NONE) {
2037 g_array_append_vals(*out_param1, conn_info,
2038 sizeof(bt_hdp_connected_t));
2041 sender = (char*)g_dbus_method_invocation_get_sender(context);
2042 _bt_save_invocation_context(context, result, sender,
2043 function_name, (gpointer)conn_info);
2047 case BT_HDP_DISCONNECT: {
2048 bt_hdp_disconnected_t *hdp_disconn_info = NULL;
2050 hdp_disconn_info = g_malloc0(sizeof(bt_hdp_disconnected_t));
2052 __bt_service_get_parameters(in_param1,
2053 &(hdp_disconn_info->channel_id), sizeof(int));
2054 __bt_service_get_parameters(in_param2,
2055 &(hdp_disconn_info->device_address),
2056 sizeof(bluetooth_device_address_t));
2058 result = _bt_hdp_disconnect(hdp_disconn_info->channel_id);
2059 if (result != BLUETOOTH_ERROR_NONE) {
2060 g_array_append_vals(*out_param1, hdp_disconn_info,
2061 sizeof(bt_hdp_disconnected_t));
2062 g_free(hdp_disconn_info);
2064 sender = (char*)g_dbus_method_invocation_get_sender(context);
2065 _bt_save_invocation_context(context, result, sender,
2066 function_name, (gpointer)hdp_disconn_info);
2070 case BT_HDP_GET_FD: {
2071 int *channel_id = g_new0(int, 1);
2073 __bt_service_get_parameters(in_param1, channel_id, sizeof(int));
2075 result = _bt_hdp_get_fd(*channel_id);
2076 if (result != BLUETOOTH_ERROR_NONE) {
2079 sender = (char*)g_dbus_method_invocation_get_sender(context);
2080 _bt_save_invocation_context(context, result, sender,
2081 function_name, (gpointer)channel_id);
2085 case BT_HDP_SEND_DATA: {
2087 * This call to bt-service is only used for privilege check, so return
2088 * BLUETOOTH_ERROR_NONE from here.
2090 result = BLUETOOTH_ERROR_NONE;
2093 case BT_OOB_READ_LOCAL_DATA: { //208
2094 bt_oob_data_t local_oob_data;
2096 memset(&local_oob_data, 0x00, sizeof(bt_oob_data_t));
2097 result = _bt_oob_read_local_data(&local_oob_data);
2099 g_array_append_vals(*out_param1, &local_oob_data,
2100 sizeof(bt_oob_data_t));
2104 case BT_OOB_ADD_REMOTE_DATA: { //209
2105 bluetooth_device_address_t address = { {0} };
2106 unsigned short address_type;
2107 bt_oob_data_t remote_oob_data;
2109 __bt_service_get_parameters(in_param1,
2110 &address, sizeof(bluetooth_device_address_t));
2111 __bt_service_get_parameters(in_param2,
2112 &address_type, sizeof(unsigned short));
2113 __bt_service_get_parameters(in_param3,
2114 &remote_oob_data, sizeof(bt_oob_data_t));
2116 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2120 case BT_OOB_REMOVE_REMOTE_DATA: { //210
2121 bluetooth_device_address_t address = { {0} };
2123 __bt_service_get_parameters(in_param1,
2124 &address, sizeof(bluetooth_device_address_t));
2126 result = _bt_oob_remove_remote_data(&address);
2130 case BT_LE_OOB_READ_LOCAL_DATA: {
2131 bt_oob_data_t local_oob_data;
2132 bt_oob_data_t *local_oob_cache_data;
2134 local_oob_cache_data = _bt_le_oob_get_local_cache_data();
2135 if (local_oob_cache_data && local_oob_cache_data->eir_len) {
2136 g_array_append_vals(*out_param1, local_oob_cache_data,
2137 sizeof(bt_oob_data_t));
2138 return BLUETOOTH_ERROR_NONE;
2141 /* We should modify this logic in later */
2142 if (_bt_is_le_static_random_address_enabled() == false) {
2143 /* Seperate BT & LE address */
2144 _bt_set_le_static_random_address(TRUE);
2147 result = _bt_le_oob_read_local_data(&local_oob_data);
2148 _bt_le_oob_set_local_cache_data(&local_oob_data);
2150 g_array_append_vals(*out_param1, &local_oob_data,
2151 sizeof(bt_oob_data_t));
2155 case BT_LE_OOB_ADD_REMOTE_DATA: {
2156 bluetooth_device_address_t address = { {0} };
2157 unsigned short address_type;
2158 bt_oob_data_t remote_oob_data;
2160 __bt_service_get_parameters(in_param1,
2161 &address, sizeof(bluetooth_device_address_t));
2162 __bt_service_get_parameters(in_param2,
2163 &address_type, sizeof(unsigned short));
2164 __bt_service_get_parameters(in_param3,
2165 &remote_oob_data, sizeof(bt_oob_data_t));
2167 result = _bt_oob_add_remote_data(&address, address_type, &remote_oob_data);
2171 case BT_AVRCP_SET_TRACK_INFO: {
2172 media_metadata_t data;
2173 media_metadata_attributes_t meta_data;
2175 memset(&data, 0x00, sizeof(media_metadata_t));
2176 memset(&meta_data, 0x00, sizeof(media_metadata_attributes_t));
2178 __bt_service_get_parameters(in_param1,
2179 &data, sizeof(media_metadata_t));
2181 meta_data.title = g_strdup(data.title);
2182 meta_data.artist = g_strdup(data.artist);
2183 meta_data.album = g_strdup(data.album);
2184 meta_data.genre = g_strdup(data.genre);
2185 meta_data.total_tracks = data.total_tracks;
2186 meta_data.number = data.number;
2187 meta_data.duration = (int64_t) data.duration;
2189 result = _bt_avrcp_set_track_info(&meta_data);
2191 g_free((gpointer)meta_data.title);
2192 g_free((gpointer)meta_data.artist);
2193 g_free((gpointer)meta_data.album);
2194 g_free((gpointer)meta_data.genre);
2198 case BT_AVRCP_SET_PROPERTY: {
2202 sender = (char *)g_dbus_method_invocation_get_sender(context);
2204 __bt_service_get_parameters(in_param1,
2205 &type, sizeof(int));
2206 __bt_service_get_parameters(in_param2,
2207 &value, sizeof(unsigned int));
2209 if (value == STATUS_PLAYING) {
2210 if (current_sender_playing)
2211 g_free(current_sender_playing);
2212 current_sender_playing = g_strdup(sender);
2214 if (g_strcmp0(sender, current_sender_playing) == 0 ||
2215 current_sender_playing == NULL) {
2216 BT_INFO("Current Player Status %d type %d Sender %s", value, type, sender);
2218 BT_INFO("Current Player and this sender (%s) are different", sender);
2219 result = BLUETOOTH_ERROR_NONE;
2222 result = _bt_avrcp_set_property(type, value);
2226 case BT_AVRCP_SET_PROPERTIES: {
2227 media_player_settings_t properties;
2229 memset(&properties, 0x00, sizeof(media_player_settings_t));
2230 __bt_service_get_parameters(in_param1,
2231 &properties, sizeof(media_player_settings_t));
2233 result = _bt_avrcp_set_properties(&properties);
2237 case BT_SET_ADVERTISING_DATA: {
2240 bluetooth_advertising_data_t adv = { {0} };
2242 gboolean use_reserved_slot = FALSE;
2244 app = (char *)g_dbus_method_invocation_get_sender(context);
2245 adv_handle = g_malloc0(sizeof(int));
2247 __bt_service_get_parameters(in_param1,
2248 adv_handle, sizeof(int));
2249 __bt_service_get_parameters(in_param3,
2250 &length, sizeof(int));
2251 __bt_service_get_parameters(in_param2,
2253 __bt_service_get_parameters(in_param4,
2254 &use_reserved_slot, sizeof(gboolean));
2255 result = _bt_set_advertising_data(app, *adv_handle,
2256 &adv, length, use_reserved_slot);
2257 if (result != BLUETOOTH_ERROR_NONE) {
2258 BT_ERR("Set Advertising data failed!!");
2261 _bt_save_invocation_context(context, result, app,
2262 function_name, (gpointer)adv_handle);
2266 case BT_SET_SCAN_RESPONSE_DATA: {
2269 bluetooth_scan_resp_data_t rsp = { {0} };
2271 gboolean use_reserved_slot = FALSE;
2273 app = (char *)g_dbus_method_invocation_get_sender(context);
2274 adv_handle = g_malloc0(sizeof(int));
2276 __bt_service_get_parameters(in_param1,
2277 adv_handle, sizeof(int));
2278 __bt_service_get_parameters(in_param3,
2279 &length, sizeof(int));
2280 __bt_service_get_parameters(in_param2,
2282 __bt_service_get_parameters(in_param4,
2283 &use_reserved_slot, sizeof(gboolean));
2285 result = _bt_set_scan_response_data(app, *adv_handle,
2286 &rsp, length, use_reserved_slot);
2288 if (result != BLUETOOTH_ERROR_NONE) {
2289 BT_ERR("Set Scan Response Data failed!!");
2292 _bt_save_invocation_context(context, result, app,
2293 function_name, (gpointer)adv_handle);
2297 case BT_SET_ADVERTISING: {
2300 gboolean enable = FALSE;
2301 gboolean use_reserved_slot = FALSE;
2303 adv_handle = g_malloc0(sizeof(int));
2304 __bt_service_get_parameters(in_param1,
2305 adv_handle, sizeof(int));
2306 __bt_service_get_parameters(in_param2,
2307 &enable, sizeof(gboolean));
2308 __bt_service_get_parameters(in_param3,
2309 &use_reserved_slot, sizeof(gboolean));
2311 app = (char *)g_dbus_method_invocation_get_sender(context);
2313 result = _bt_set_advertising(app, *adv_handle,
2314 enable, use_reserved_slot);
2315 if (result != BLUETOOTH_ERROR_NONE) {
2316 BT_ERR("Start Advertising failed!!");
2319 _bt_save_invocation_context(context, result, app,
2320 function_name, (gpointer)adv_handle);
2324 case BT_SET_CUSTOM_ADVERTISING: {
2327 gboolean enable = FALSE;
2328 bluetooth_advertising_params_t adv_params;
2329 gboolean use_reserved_slot = FALSE;
2331 app = (char *)g_dbus_method_invocation_get_sender(context);
2332 adv_handle = g_malloc0(sizeof(int));
2334 __bt_service_get_parameters(in_param1, adv_handle,
2336 __bt_service_get_parameters(in_param2, &enable,
2338 __bt_service_get_parameters(in_param3, &adv_params,
2339 sizeof(bluetooth_advertising_params_t));
2340 __bt_service_get_parameters(in_param4, &use_reserved_slot,
2343 BT_DBG("bluetooth_advertising_params_t [%f %f %d %d %d]",
2344 adv_params.interval_min, adv_params.interval_max,
2345 adv_params.filter_policy, adv_params.type, adv_params.tx_power_level);
2346 result = _bt_set_custom_advertising(app, *adv_handle,
2347 enable, &adv_params, use_reserved_slot);
2348 if (result != BLUETOOTH_ERROR_NONE) {
2349 BT_ERR("Start Custom Advertising failed!!");
2352 _bt_save_invocation_context(context, result, app,
2353 function_name, (gpointer)adv_handle);
2357 case BT_GET_SCAN_RESPONSE_DATA: {
2358 bluetooth_scan_resp_data_t rsp = { {0} };
2362 app = (char *)g_dbus_method_invocation_get_sender(context);
2364 __bt_service_get_parameters(in_param1, &adv_handle,
2367 result = _bt_get_scan_response_data(app, adv_handle, &rsp, &length);
2368 if (result == BLUETOOTH_ERROR_NONE)
2369 g_array_append_vals(*out_param1, rsp.data, length);
2373 case BT_GET_ADVERTISING_DATA: {
2374 bluetooth_advertising_data_t adv = { {0} };
2378 app = (char *)g_dbus_method_invocation_get_sender(context);
2380 __bt_service_get_parameters(in_param1, &adv_handle,
2383 result = _bt_get_advertising_data(app, adv_handle, &adv, &length);
2384 if (result == BLUETOOTH_ERROR_NONE)
2385 g_array_append_vals(*out_param1, adv.data, length);
2389 case BT_GATT_REGISTER_APPLICATION: {
2390 BT_DBG("Register GATT application:Unhandled!!");
2393 case BT_GATT_SERVER_REGISTER: {
2394 BT_DBG("GATT Server instance initialization");
2397 app = (char *)g_dbus_method_invocation_get_sender(context);
2398 BT_DBG("GATT Server Unique Name [%s]", app);
2400 /* No ADV handle: Set 0 */
2401 result = _bt_register_server_instance(app, 0);
2403 if (result != BLUETOOTH_ERROR_NONE) {
2404 BT_ERR("GATT Server registration failed. result %d", result);
2406 _bt_save_invocation_context(context, result, app,
2407 function_name, NULL);
2411 case BT_GATT_SERVER_DEREGISTER: {
2413 app = (char*)g_dbus_method_invocation_get_sender(context);
2415 result = _bt_unregister_server_instance(app, 0/* Adv Handle*/);
2418 case BT_GATT_SERVER_ADD_SERVICE: {
2419 BT_DBG("GATT Server Add Service");
2425 int *tmp_inst_id = NULL;
2427 app = (char *)g_dbus_method_invocation_get_sender(context);
2429 __bt_service_get_parameters(in_param1, &service_type,
2431 __bt_service_get_parameters(in_param2, &num_handles,
2433 svc_uuid = (char *)g_variant_get_data(in_param3);
2434 __bt_service_get_parameters(in_param4, &instance_id,
2437 result = _bt_gatt_server_add_service(app, service_type, num_handles, svc_uuid, instance_id);
2438 if (result != BLUETOOTH_ERROR_NONE) {
2439 BT_ERR("GATT Server Add Service failed!!");
2441 tmp_inst_id = g_malloc0(sizeof(int));
2442 *tmp_inst_id = instance_id;
2443 _bt_save_invocation_context(context, result, app,
2444 function_name, (gpointer)tmp_inst_id);
2448 case BT_GATT_SERVER_ADD_CHARACTERISTIC: {
2449 BT_DBG("GATT Server Add Characteristic");
2452 int *tmp_inst_id = NULL;
2453 bluetooth_gatt_server_attribute_params_t param;
2454 memset(¶m, 0, sizeof(bluetooth_gatt_server_attribute_params_t));
2456 app = (char*)g_dbus_method_invocation_get_sender(context);
2458 __bt_service_get_parameters(in_param1, ¶m,
2459 sizeof(bluetooth_gatt_server_attribute_params_t));
2460 char_uuid = (char *)g_variant_get_data(in_param2);
2462 result = _bt_gatt_server_add_characteristic(app, char_uuid, ¶m);
2463 if (result != BLUETOOTH_ERROR_NONE) {
2464 BT_ERR("GATT Server Add Service failed!!");
2466 tmp_inst_id = g_malloc0(sizeof(int));
2467 *tmp_inst_id = param.instance_id;
2469 _bt_save_invocation_context(context, result, app,
2470 function_name, (gpointer)tmp_inst_id);
2474 case BT_GATT_SERVER_ADD_DESCRIPTOR: {
2475 BT_DBG("GATT Server Add Descriptor");
2479 bt_gatt_permission_t perm;
2481 int *tmp_inst_id = NULL;
2482 memset(&perm, 0, sizeof(bt_gatt_permission_t));
2484 app = (char *)g_dbus_method_invocation_get_sender(context);
2486 __bt_service_get_parameters(in_param1, &service_handle,
2488 __bt_service_get_parameters(in_param2, &instance_id,
2490 desc_uuid = (char *)g_variant_get_data(in_param4);
2491 __bt_service_get_parameters(in_param3, &perm,
2492 sizeof(bt_gatt_permission_t));
2494 result = _bt_gatt_server_add_descriptor(app, desc_uuid, &perm, service_handle, instance_id);
2495 if (result != BLUETOOTH_ERROR_NONE) {
2496 BT_ERR("GATT Server Add Service failed!!");
2498 tmp_inst_id = g_malloc0(sizeof(int));
2499 *tmp_inst_id = instance_id;
2500 _bt_save_invocation_context(context, result, app,
2501 function_name, (gpointer)tmp_inst_id);
2505 case BT_GATT_SERVER_START_SERVICE: {
2510 int *tmp_inst_id = NULL;
2511 app = (char*)g_dbus_method_invocation_get_sender(context);
2513 __bt_service_get_parameters(in_param1, &service_handle,
2515 __bt_service_get_parameters(in_param2, &instance_id,
2518 result = _bt_gatt_server_start_service(app, service_handle, instance_id);
2520 if (BLUETOOTH_ERROR_NONE == result) {
2521 tmp_inst_id = g_malloc0(sizeof(int));
2522 *tmp_inst_id = instance_id;
2523 _bt_save_invocation_context(context, result, app,
2524 function_name, (gpointer)tmp_inst_id);
2528 case BT_GATT_SERVER_STOP_SERVICE: {
2532 int *tmp_inst_id = NULL;
2533 app = (char*)g_dbus_method_invocation_get_sender(context);
2535 __bt_service_get_parameters(in_param1, &service_handle,
2537 __bt_service_get_parameters(in_param2, &instance_id,
2540 result = _bt_gatt_server_stop_service(app, service_handle, instance_id);
2542 if (BLUETOOTH_ERROR_NONE == result) {
2543 tmp_inst_id = g_malloc0(sizeof(int));
2544 *tmp_inst_id = instance_id;
2545 _bt_save_invocation_context(context, result, app,
2546 function_name, (gpointer)tmp_inst_id);
2550 case BT_GATT_SERVER_DELETE_SERVICE: {
2553 int *tmp_inst_id = NULL;
2555 app = (char*)g_dbus_method_invocation_get_sender(context);
2557 __bt_service_get_parameters(in_param1, &service_handle,
2559 __bt_service_get_parameters(in_param2, &instance_id,
2562 result = _bt_gatt_server_delete_service(app, service_handle, instance_id);
2564 if (BLUETOOTH_ERROR_NONE == result) {
2565 tmp_inst_id = g_malloc0(sizeof(int));
2566 *tmp_inst_id = instance_id;
2567 _bt_save_invocation_context(context, result, app,
2568 function_name, (gpointer)tmp_inst_id);
2572 case BT_GATT_SERVER_SEND_RESPONSE: {
2573 bluetooth_gatt_server_response_params_t param;
2574 bluetooth_gatt_att_data_t data;
2577 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_response_params_t));
2578 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2580 app = (char*)g_dbus_method_invocation_get_sender(context);
2582 __bt_service_get_parameters(in_param1, &data,
2583 sizeof(bluetooth_gatt_att_data_t));
2584 __bt_service_get_parameters(in_param2, ¶m,
2585 sizeof(bluetooth_gatt_server_response_params_t));
2587 result = _bt_gatt_server_send_response(app, &data, ¶m);
2591 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE: {
2593 bluetooth_gatt_server_acquire_response_params_t param;
2596 msg = g_dbus_method_invocation_get_message(context);
2597 GUnixFDList *fd_list;
2602 fd_list = g_dbus_message_get_unix_fd_list(msg);
2604 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2606 app = (char*)g_dbus_method_invocation_get_sender(context);
2608 __bt_service_get_parameters(in_param1, ¶m,
2609 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2611 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2612 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2613 fd = fd_list_array[0];
2616 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2620 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE: {
2622 bluetooth_gatt_server_acquire_response_params_t param;
2625 msg = g_dbus_method_invocation_get_message(context);
2626 GUnixFDList *fd_list;
2631 fd_list = g_dbus_message_get_unix_fd_list(msg);
2633 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_acquire_response_params_t));
2635 app = (char*)g_dbus_method_invocation_get_sender(context);
2637 __bt_service_get_parameters(in_param1, ¶m,
2638 sizeof(bluetooth_gatt_server_acquire_response_params_t));
2640 fd_list_array = (int *)g_unix_fd_list_peek_fds(fd_list, &len);
2641 BT_DBG("Num fds in fd_list is : %d, fd_list[0]: %d", len, fd_list_array[0]);
2642 fd = fd_list_array[0];
2645 result = _bt_gatt_server_acquire_send_response(app, ¶m, fd_list);
2649 case BT_GATT_SERVER_SEND_INDICATION: {
2650 bluetooth_gatt_server_indication_params_t param;
2651 bluetooth_gatt_att_data_t data;
2652 bluetooth_device_address_t address;
2655 app = (char*)g_dbus_method_invocation_get_sender(context);
2657 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_indication_params_t));
2658 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
2659 memset(&address, 0x00, sizeof(bluetooth_device_address_t));
2661 __bt_service_get_parameters(in_param1, &data,
2662 sizeof(bluetooth_gatt_att_data_t));
2663 __bt_service_get_parameters(in_param2, ¶m,
2664 sizeof(bluetooth_gatt_server_indication_params_t));
2665 __bt_service_get_parameters(in_param3, &address,
2666 sizeof(bluetooth_device_address_t));
2668 result = _bt_gatt_server_send_indication(app, &address, &data, ¶m);
2672 case BT_GATT_SERVER_UPDATE_VALUE: {
2673 bluetooth_gatt_server_update_value_t param;
2677 memset(¶m, 0x00, sizeof(bluetooth_gatt_server_update_value_t));
2679 app = (char*)g_dbus_method_invocation_get_sender(context);
2681 __bt_service_get_parameters(in_param1, &instance_id,
2683 __bt_service_get_parameters(in_param2, ¶m,
2684 sizeof(bluetooth_gatt_server_update_value_t));
2686 result = _bt_gatt_server_update_attribute_value(app, instance_id, ¶m);
2689 case BT_GET_ATT_MTU: {
2690 bluetooth_device_address_t address = { {0} };
2691 unsigned int mtu = 0;
2693 __bt_service_get_parameters(in_param1,
2694 &address, sizeof(bluetooth_device_address_t));
2695 result = _bt_get_att_mtu(&address, &mtu);
2696 BT_DBG("MTU: %d", mtu);
2698 if (result == BLUETOOTH_ERROR_NONE) {
2699 g_array_append_vals(*out_param1, &mtu,
2700 sizeof(unsigned int));
2704 case BT_REQ_ATT_MTU: {
2705 bluetooth_device_address_t address = { {0} };
2709 sender = (char*)g_dbus_method_invocation_get_sender(context);
2711 __bt_service_get_parameters(in_param1,
2712 &address, sizeof(bluetooth_device_address_t));
2713 __bt_service_get_parameters(in_param2,
2714 &mtu, sizeof(unsigned int));
2715 BT_DBG("BT_REQ_ATT_MTU: %d", mtu);
2716 result = _bt_request_att_mtu(&address, mtu);
2717 if (BLUETOOTH_ERROR_NONE == result) {
2718 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2720 _bt_convert_addr_type_to_string(addr, address.addr);
2722 /* Save the informations to invocation */
2723 _bt_save_invocation_context(context, result, sender,
2724 function_name, (gpointer)addr);
2726 g_array_append_vals(*out_param1, &address,
2727 sizeof(bluetooth_device_address_t));
2731 case BT_GET_DEVICE_IDA: {
2732 bluetooth_device_address_t address = { {0} };
2733 bluetooth_device_address_t id_addr = { {0} };
2735 __bt_service_get_parameters(in_param1,
2736 &address, sizeof(bluetooth_device_address_t));
2738 result = _bt_device_get_ida(&address, &id_addr);
2740 if (result == BLUETOOTH_ERROR_NONE) {
2741 g_array_append_vals(*out_param1, &id_addr,
2742 sizeof(bluetooth_device_address_t));
2746 case BT_SET_LE_STATIC_RANDOM_ADDRESS: {
2749 __bt_service_get_parameters(in_param1, &is_enable,
2752 result = _bt_set_le_static_random_address(is_enable);
2756 #ifdef TIZEN_GATT_CLIENT
2758 case BT_GATT_CLIENT_REGISTER: {
2759 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));
2767 result = _bt_register_gatt_client_instance(sender, &address);
2768 if (BLUETOOTH_ERROR_NONE == result) {
2769 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2771 _bt_convert_addr_type_to_string(addr, address.addr);
2773 /* Save the informations to invocation */
2774 _bt_save_invocation_context(context, result, sender,
2775 function_name, (gpointer)addr);
2780 case BT_GATT_CLIENT_UNREGISTER: {
2783 sender = (char*)g_dbus_method_invocation_get_sender(context);
2784 __bt_service_get_parameters(in_param1,
2785 &client_id, sizeof(int));
2787 result = _bt_unregister_gatt_client_instance(sender, client_id);
2791 /* Async: Remote Interaction */
2792 case BT_GATT_ACQUIRE_WRITE: {
2796 bluetooth_gatt_client_char_prop_info_t param;
2798 sender = (char*)g_dbus_method_invocation_get_sender(context);
2800 __bt_service_get_parameters(in_param1, ¶m,
2801 sizeof(bluetooth_gatt_client_char_prop_info_t));
2804 result = _bt_gatt_acquire_write(¶m , &fd, &mtu);
2806 g_array_append_vals(*out_param1, &mtu, sizeof(int));
2808 if (BLUETOOTH_ERROR_NONE == result)
2809 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
2811 BT_ERR("GATT Client: gatt acquire write failed");
2815 GUnixFDList *fd_list = NULL;
2816 GError *error = NULL;
2818 /* Add socket fd to unix_fd_list */
2819 fd_list = g_unix_fd_list_new();
2820 g_unix_fd_list_append(fd_list, fd, &error);
2821 g_assert_no_error(error);
2823 _bt_service_method_return_with_unix_fd_list(
2824 context, *out_param1, result, fd_list);
2827 g_object_unref(fd_list);
2831 /* Async: Remote Interaction */
2832 case BT_CONNECT_LE: {
2833 bluetooth_device_address_t address = { {0} };
2834 gboolean auto_connect;
2838 sender = (char*)g_dbus_method_invocation_get_sender(context);
2840 __bt_service_get_parameters(in_param1,
2841 &address, sizeof(bluetooth_device_address_t));
2842 __bt_service_get_parameters(in_param2,
2843 &auto_connect, sizeof(gboolean));
2844 __bt_service_get_parameters(in_param3,
2845 &client_id, sizeof(int));
2847 BT_DBG("GATT Client: client_id[%d]", client_id);
2848 result = _bt_connect_le_device(&address, auto_connect, client_id);
2849 if (BLUETOOTH_ERROR_NONE == result) {
2850 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2851 _bt_convert_addr_type_to_string(addr, address.addr);
2853 /* Save the informations to invocation */
2854 _bt_save_invocation_context(context, result, sender,
2855 function_name, (gpointer)addr);
2858 _bt_handle_invocation_context(function_name, (void *)addr);
2860 BT_ERR("GATT Client: gatt connect failed. client_id[%d]", client_id);
2861 g_array_append_vals(*out_param1, &address,
2862 sizeof(bluetooth_device_address_t));
2866 /* Async: Remote Interaction */
2867 case BT_DISCONNECT_LE: {
2868 bluetooth_device_address_t address = { {0} };
2872 sender = (char*)g_dbus_method_invocation_get_sender(context);
2874 __bt_service_get_parameters(in_param1,
2875 &address, sizeof(bluetooth_device_address_t));
2876 __bt_service_get_parameters(in_param2,
2877 &client_id, sizeof(int));
2879 BT_INFO("GATT Disconnect using client Interface [%d]", client_id);
2880 result = _bt_disconnect_le_device(&address, client_id);
2881 if (BLUETOOTH_ERROR_NONE == result) {
2882 addr = g_malloc0(BT_ADDRESS_STRING_SIZE);
2884 _bt_convert_addr_type_to_string(addr, address.addr);
2886 /* Save the informations to invocation */
2887 _bt_save_invocation_context(context, result, sender,
2888 function_name, (gpointer)addr);
2890 g_array_append_vals(*out_param1, &address,
2891 sizeof(bluetooth_device_address_t));
2896 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS: {
2897 guint available_packets = 0;
2899 result = _bt_gatt_get_data_batching_available_packets(&available_packets);
2900 BT_DBG("LE batching available packets %u", available_packets);
2901 if (result == BLUETOOTH_ERROR_NONE) {
2902 g_array_append_vals(*out_param1, &available_packets,
2909 case BT_ENABLE_GATT_DATA_BATCHING: {
2910 bluetooth_device_address_t address = { {0} };
2911 int packet_threshold;
2914 __bt_service_get_parameters(in_param1,
2915 &address, sizeof(bluetooth_device_address_t));
2916 __bt_service_get_parameters(in_param2,
2917 &packet_threshold, sizeof(int));
2918 __bt_service_get_parameters(in_param3,
2919 &timeout, sizeof(int));
2920 result = _bt_gatt_enable_data_batching(&address, packet_threshold, timeout);
2925 case BT_DISABLE_GATT_DATA_BATCHING: {
2926 bluetooth_device_address_t address = { {0} };
2928 __bt_service_get_parameters(in_param1,
2929 &address, sizeof(bluetooth_device_address_t));
2930 result = _bt_gatt_disable_data_batching(&address);
2935 case BT_GATT_GET_PRIMARY_SERVICES: {
2938 sender = (char*)g_dbus_method_invocation_get_sender(context);
2939 bluetooth_device_address_t address = { {0} };
2941 __bt_service_get_parameters(in_param1, &address,
2942 sizeof(bluetooth_device_address_t));
2944 addr = g_malloc0(sizeof(char) * BT_ADDRESS_STRING_SIZE);
2945 _bt_convert_addr_type_to_string(addr, address.addr);
2947 result = _bt_gatt_get_primary_services(addr);
2948 if (BLUETOOTH_ERROR_NONE == result) {
2949 _bt_save_invocation_context(context, result, sender,
2950 function_name, (gpointer)addr);
2956 case BT_GATT_GET_SERVICE_PROPERTIES: {
2957 bluetooth_gatt_client_svc_prop_info_t param;
2959 sender = (char*)g_dbus_method_invocation_get_sender(context);
2960 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_svc_prop_info_t));
2962 __bt_service_get_parameters(in_param1, ¶m,
2963 sizeof(bluetooth_gatt_client_svc_prop_info_t));
2965 result = _bt_gatt_get_all_characteristic(¶m);
2966 if (BLUETOOTH_ERROR_NONE == result) {
2967 /* Save the informations to invocation */
2968 _bt_save_invocation_context(context, result, sender,
2970 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_svc_prop_info_t)));
2974 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: {
2975 bluetooth_gatt_client_char_prop_info_t param;
2977 sender = (char*)g_dbus_method_invocation_get_sender(context);
2978 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
2980 __bt_service_get_parameters(in_param1, ¶m,
2981 sizeof(bluetooth_gatt_client_char_prop_info_t));
2983 result = _bt_gatt_get_all_characteristic_properties(¶m);
2984 if (BLUETOOTH_ERROR_NONE == result) {
2985 /* Save the informations to invocation */
2986 _bt_save_invocation_context(context, result, sender,
2988 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
2992 /* Async: Remote Interaction */
2993 case BT_GATT_READ_CHARACTERISTIC: {
2994 bluetooth_gatt_client_char_prop_info_t param;
2996 sender = (char*)g_dbus_method_invocation_get_sender(context);
2997 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
2999 __bt_service_get_parameters(in_param1, ¶m,
3000 sizeof(bluetooth_gatt_client_char_prop_info_t));
3002 result = _bt_gatt_read_characteristic_value(¶m);
3003 if (BLUETOOTH_ERROR_NONE == result) {
3004 /* Save the informations to invocation */
3005 _bt_save_invocation_context(context, result, sender,
3007 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3011 /* Async: Remote Interaction */
3012 case BT_GATT_READ_DESCRIPTOR_VALUE: {
3013 bluetooth_gatt_client_desc_prop_info_t param;
3015 sender = (char*)g_dbus_method_invocation_get_sender(context);
3016 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3018 __bt_service_get_parameters(in_param1, ¶m,
3019 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3021 result = _bt_gatt_read_descriptor_value(¶m);
3022 if (BLUETOOTH_ERROR_NONE == result) {
3023 /* Save the informations to invocation */
3024 _bt_save_invocation_context(context, result, sender,
3026 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3030 /* Async: Remote Interaction */
3031 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: {
3032 bluetooth_gatt_client_char_prop_info_t param;
3033 bluetooth_gatt_att_data_t data;
3034 bluetooth_gatt_write_type_e write_type;
3036 sender = (char*)g_dbus_method_invocation_get_sender(context);
3038 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3039 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3041 __bt_service_get_parameters(in_param1, ¶m,
3042 sizeof(bluetooth_gatt_client_char_prop_info_t));
3043 __bt_service_get_parameters(in_param2, &data,
3044 sizeof(bluetooth_gatt_att_data_t));
3045 __bt_service_get_parameters(in_param3, &write_type,
3046 sizeof(bluetooth_gatt_write_type_e));
3048 result = _bt_gatt_write_characteristic_value_by_type(¶m , &data, write_type);
3049 if (BLUETOOTH_ERROR_NONE == result) {
3050 /* Save the informations to invocation */
3051 _bt_save_invocation_context(context, result, sender,
3053 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3057 /* Async: Remote Interaction */
3058 case BT_GATT_WRITE_DESCRIPTOR_VALUE: {
3059 bluetooth_gatt_client_desc_prop_info_t param;
3060 bluetooth_gatt_att_data_t data;
3061 bluetooth_gatt_write_type_e write_type;
3063 sender = (char*)g_dbus_method_invocation_get_sender(context);
3064 memset(&data, 0x00, sizeof(bluetooth_gatt_att_data_t));
3065 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_desc_prop_info_t));
3067 __bt_service_get_parameters(in_param1, ¶m,
3068 sizeof(bluetooth_gatt_client_desc_prop_info_t));
3069 __bt_service_get_parameters(in_param2, &data,
3070 sizeof(bluetooth_gatt_att_data_t));
3071 __bt_service_get_parameters(in_param3, &write_type,
3072 sizeof(bluetooth_gatt_write_type_e));
3074 result = _bt_gatt_write_descriptor_value_by_type(¶m, &data, write_type);
3075 if (BLUETOOTH_ERROR_NONE == result) {
3076 /* Save the informations to invocation */
3077 _bt_save_invocation_context(context, result, sender,
3079 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
3084 case BT_GATT_WATCH_CHARACTERISTIC: {
3085 bluetooth_gatt_client_char_prop_info_t param;
3090 gboolean is_indicate;
3093 memset(¶m, 0x00, sizeof(bluetooth_gatt_client_char_prop_info_t));
3095 sender = (char*)g_dbus_method_invocation_get_sender(context);
3097 __bt_service_get_parameters(in_param1, ¶m,
3098 sizeof(bluetooth_gatt_client_char_prop_info_t));
3099 __bt_service_get_parameters(in_param2, &client_id,
3101 __bt_service_get_parameters(in_param3, &is_notify,
3103 __bt_service_get_parameters(in_param4, &is_indicate,
3106 #ifdef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
3110 if (is_indicate == false) {
3111 result = _bt_gatt_acquire_notify(¶m , &fd, &mtu);
3112 if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
3113 BT_DBG("GATT Client: Save Invocation data for characteristic props app[%s] fd[ %d]", sender, fd);
3115 GUnixFDList *fd_list = NULL;
3116 GError *error = NULL;
3118 g_array_append_vals(*out_param1, &mtu, sizeof(int));
3119 /* Add socket fd to unix_fd_list */
3120 fd_list = g_unix_fd_list_new();
3121 g_unix_fd_list_append(fd_list, fd, &error);
3122 g_assert_no_error(error);
3124 _bt_service_method_return_with_unix_fd_list(
3125 context, *out_param1, result, fd_list);
3127 g_object_unref(fd_list);
3133 result = _bt_gatt_watch_characteristic(¶m , client_id, is_notify);
3134 if (BLUETOOTH_ERROR_NONE == result) {
3135 /* Save the informations to invocation */
3136 _bt_save_invocation_context(context, result, sender, function_name,
3137 (gpointer)g_memdup(¶m, sizeof(bluetooth_gatt_client_char_prop_info_t)));
3142 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: {
3143 gboolean is_enabled;
3144 bluetooth_device_address_t address;
3146 sender = (char*)g_dbus_method_invocation_get_sender(context);
3148 __bt_service_get_parameters(in_param1,
3149 &address, sizeof(bluetooth_device_address_t));
3150 __bt_service_get_parameters(in_param2, &is_enabled,
3152 result = _bt_gatt_watch_service_changed_indication(sender, &address, is_enabled);
3153 BT_INFO("Service changed indication from app [%s]", sender);
3157 case BT_LE_CONN_UPDATE: {
3158 char *sender = NULL;
3159 bluetooth_device_address_t local_address = { {0} };
3160 bluetooth_le_connection_param_t parameters = {0};
3162 sender = (char *)g_dbus_method_invocation_get_sender(context);
3164 __bt_service_get_parameters(in_param1, &local_address,
3165 sizeof(bluetooth_device_address_t));
3166 __bt_service_get_parameters(in_param2, ¶meters,
3167 sizeof(bluetooth_le_connection_param_t));
3169 result = _bt_le_connection_update(sender,
3171 parameters.interval_min,
3172 parameters.interval_max,
3174 parameters.timeout);
3178 case BT_START_LE_DISCOVERY: {
3182 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3184 sender = (char *)g_dbus_method_invocation_get_sender(context);
3186 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3187 BT_ERR("Fail to get the sender pid");
3189 result = _bt_start_le_scan(sender, uid, pid);
3190 if (result == BLUETOOTH_ERROR_NONE) {
3191 _bt_save_invocation_context(context, result, sender,
3192 function_name, NULL);
3194 BT_DBG("Remeber pid / uid for the scan operation");
3195 _bt_bm_add_scan_app(SCAN_LE, uid, pid);
3199 case BT_STOP_LE_DISCOVERY: {
3203 __bt_service_get_parameters(in_param1, &uid, sizeof(uid_t));
3205 sender = (char *)g_dbus_method_invocation_get_sender(context);
3207 if (__bt_service_get_sender_pid(sender, &pid) != BLUETOOTH_ERROR_NONE)
3208 BT_ERR("Fail to get the sender pid");
3210 result = _bt_stop_le_scan(sender);
3211 if (result == BLUETOOTH_ERROR_NONE) {
3212 _bt_save_invocation_context(context, result, sender,
3213 function_name, NULL);
3216 BT_DBG("Remove pid / uid for the scan operation");
3217 _bt_bm_remove_scan_app(SCAN_LE, uid, pid);
3221 case BT_IS_LE_DISCOVERYING: {
3222 gboolean le_discovering = FALSE;
3224 le_discovering = _bt_is_le_scanning();
3225 g_array_append_vals(*out_param1,
3226 &le_discovering, sizeof(gboolean));
3229 case BT_SET_SCAN_PARAMETERS: {
3230 bluetooth_le_scan_params_t scan_params;
3232 __bt_service_get_parameters(in_param1, &scan_params,
3233 sizeof(bluetooth_le_scan_params_t));
3235 BT_DBG("bluetooth_le_scan_params_t [%f %f %d]",
3236 scan_params.interval, scan_params.window,
3239 result = _bt_prepare_scan_parameters(&scan_params, 0);
3242 case BT_SET_SCAN_TYPE: {
3244 __bt_service_get_parameters(in_param1, &scan_type, sizeof(int));
3246 BT_DBG("bluetooth_le_scan_type [%d]", scan_type);
3247 result = _bt_prepare_scan_parameters(NULL, scan_type);
3250 #ifdef TIZEN_FEATURE_BT_PAN_NAP
3251 case BT_NETWORK_ACTIVATE:
3252 BT_DBG("BT_NETWORK_ACTIVATE Request recieved Request Handler ");
3253 result = _bt_network_activate();
3255 case BT_NETWORK_DEACTIVATE:
3256 result = _bt_network_deactivate();
3258 case BT_NETWORK_CONNECT: {
3259 bluetooth_device_address_t address = { {0} };
3262 __bt_service_get_parameters(in_param1,
3263 &address, sizeof(bluetooth_device_address_t));
3264 __bt_service_get_parameters(in_param2,
3265 &role, sizeof(int));
3267 result = _bt_network_connect(request_id, role, &address);
3268 if (result != BLUETOOTH_ERROR_NONE) {
3269 g_array_append_vals(*out_param1, &address,
3270 sizeof(bluetooth_device_address_t));
3274 case BT_NETWORK_DISCONNECT: {
3275 bluetooth_device_address_t address = { {0} };
3277 __bt_service_get_parameters(in_param1,
3278 &address, sizeof(bluetooth_device_address_t));
3280 result = _bt_network_disconnect(request_id, &address);
3281 if (result != BLUETOOTH_ERROR_NONE) {
3282 g_array_append_vals(*out_param1, &address,
3283 sizeof(bluetooth_device_address_t));
3287 case BT_NETWORK_SERVER_DISCONNECT: {
3288 bluetooth_device_address_t address = { {0} };
3290 __bt_service_get_parameters(in_param1,
3291 &address, sizeof(bluetooth_device_address_t));
3293 result = _bt_network_server_disconnect(request_id, &address);
3294 if (result != BLUETOOTH_ERROR_NONE) {
3295 g_array_append_vals(*out_param1, &address,
3296 sizeof(bluetooth_device_address_t));
3302 #ifdef TIZEN_FEATURE_BT_IPSP
3303 case BT_LE_IPSP_INIT:
3304 result = _bt_initialize_ipsp();
3306 case BT_LE_IPSP_DEINIT:
3307 result = _bt_deinitialize_ipsp();
3309 case BT_LE_IPSP_CONNECT: {
3310 bluetooth_device_address_t address = { {0} };
3311 __bt_service_get_parameters(in_param1, &address,
3312 sizeof(bluetooth_device_address_t));
3313 result = _bt_connect_le_ipsp_device(&address);
3316 case BT_LE_IPSP_DISCONNECT: {
3317 bluetooth_device_address_t address = { {0} };
3318 __bt_service_get_parameters(in_param1, &address,
3319 sizeof(bluetooth_device_address_t));
3320 result = _bt_disconnect_le_ipsp_device(&address);
3324 case BT_IS_ADVERTISING: {
3325 gboolean advertising = FALSE;
3326 advertising = _bt_is_advertising();
3327 g_array_append_vals(*out_param1, &advertising,
3331 case BT_IS_LE_2M_PHY_SUPPORTED: {
3332 gboolean is_2m_phy_supported = FALSE;
3334 is_2m_phy_supported = _bt_is_le_2m_phy_supported();
3335 g_array_append_vals(*out_param1, &is_2m_phy_supported, sizeof(gboolean));
3338 case BT_IS_LE_CODED_PHY_SUPPORTED: {
3339 gboolean is_coded_phy_supported = FALSE;
3341 is_coded_phy_supported = _bt_is_le_coded_phy_supported();
3342 g_array_append_vals(*out_param1, &is_coded_phy_supported, sizeof(gboolean));
3345 case BT_DISCONNECT_DEVICE: {
3346 bluetooth_device_address_t address = { {0} };
3348 __bt_service_get_parameters(in_param1,
3349 &address, sizeof(bluetooth_device_address_t));
3351 result = _bt_disconnect_device(&address);
3354 case BT_REGISTER_SCAN_FILTER: {
3355 bluetooth_le_scan_filter_t scan_filter;
3357 sender = (char*)g_dbus_method_invocation_get_sender(context);
3358 __bt_service_get_parameters(in_param1, &scan_filter,
3359 sizeof(bluetooth_le_scan_filter_t));
3361 BT_DBG("bluetooth_le_scan_filter_t [features : 0x%.2x]",
3362 scan_filter.added_features);
3364 result = _bt_register_scan_filter(sender, &scan_filter);
3368 case BT_MESH_NETWORK_CREATE: {
3369 bluetooth_mesh_node_t node;
3370 GSList *model_list = NULL;
3371 int total_models = 0;
3374 const char *network_name = NULL;
3375 bluetooth_mesh_network_t *network;
3377 memset(&node, 0x00, sizeof(bluetooth_mesh_node_t));
3378 sender = (char*)g_dbus_method_invocation_get_sender(context);
3380 __bt_service_get_parameters(in_param1,
3381 &node, sizeof(bluetooth_mesh_node_t));
3382 network_name = (const char *)g_variant_get_data(in_param2);
3383 BT_INFO("MESH: Network name [%s]", network_name);
3385 param3 = g_array_new(TRUE, TRUE, sizeof(gchar));
3386 __bt_fill_garray_from_variant(in_param3, param3);
3388 total_models = (param3->len) / sizeof(bluetooth_mesh_model_t);
3389 for (i = 0; i < total_models; i++) {
3390 bluetooth_mesh_model_t *info = NULL;
3391 bluetooth_mesh_model_t *mod = NULL;
3393 info = &g_array_index(param3,
3394 bluetooth_mesh_model_t, i);
3396 mod = g_memdup(info, sizeof(bluetooth_mesh_model_t));
3399 model_list = g_slist_append(model_list,
3402 result = _bt_mesh_network_create(requester_unique_creds,
3403 sender, network_name, &node, model_list);
3405 /* Save invocation */
3406 if (result == BLUETOOTH_ERROR_NONE) {
3407 BT_INFO("Mesh: Save Invoation");
3408 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3410 /* Save Network name & UUID, Token will be received in event */
3411 _bt_mesh_util_convert_hex_to_string(
3412 (uint8_t *) node.uuid, 16,
3414 BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1);
3415 BT_INFO("Mesh: Mesh Netwok UUID [%s]", network->uuid);
3416 g_strlcpy(network->name.name, network_name,
3417 sizeof(network->name.name));
3418 g_strlcpy(network->app_cred,
3419 requester_unique_creds,
3420 sizeof(network->app_cred));
3421 sender = (char*)g_dbus_method_invocation_get_sender(context);
3422 _bt_save_invocation_context(context,
3424 function_name, (gpointer)network);
3426 g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
3427 BT_ERR("Mesh: Mesh Network creation schedule failed");
3428 g_slist_free_full(model_list, g_free);
3432 BT_INFO("Mesh: Cleanup");
3433 g_free((gpointer)requester_unique_creds);
3434 g_array_free(param3, TRUE);
3435 BT_INFO("Mesh: Cleanup Done");
3438 case BT_MESH_NETWORK_LOAD: {
3440 bluetooth_mesh_network_t *network;
3441 token = (char *)g_variant_get_data(in_param1);
3442 BT_INFO("MESH: Network Load: Token string [%s]", token);
3443 result = _bt_mesh_network_load(requester_unique_creds, sender, token);
3444 /* Save invocation */
3445 if (result == BLUETOOTH_ERROR_NONE) {
3446 network = g_malloc0(sizeof(bluetooth_mesh_network_t));
3447 g_strlcpy(network->token.token, token, strlen(token));
3448 g_strlcpy(network->app_cred, requester_unique_creds, strlen(requester_unique_creds));
3450 sender = (char*)g_dbus_method_invocation_get_sender(context);
3451 _bt_save_invocation_context(context, result, sender,
3452 function_name, (gpointer)network);
3454 g_free((gpointer)requester_unique_creds);
3457 case BT_MESH_NETWORK_SCAN: {
3458 bluetooth_mesh_network_t network;
3459 bluetooth_mesh_scan_param_t param;
3460 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3461 memset(¶m, 0x00, sizeof(bluetooth_mesh_scan_param_t));
3463 __bt_service_get_parameters(in_param1,
3464 &network, sizeof(bluetooth_mesh_network_t));
3466 __bt_service_get_parameters(in_param2,
3467 ¶m, sizeof(bluetooth_mesh_scan_param_t));
3469 result = _bt_mesh_network_scan(requester_unique_creds,
3470 sender, &network, ¶m);
3472 if (result != BLUETOOTH_ERROR_NONE) {
3473 g_array_append_vals(*out_param1,
3474 &network, sizeof(bluetooth_mesh_network_t));
3476 bluetooth_mesh_network_t *net = \
3477 g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3479 sender = (char*)g_dbus_method_invocation_get_sender(context);
3480 _bt_save_invocation_context(context, result, sender,
3481 function_name, (gpointer)net);
3485 case BT_MESH_NETWORK_CANCEL_SCAN: {
3486 bluetooth_mesh_network_t network;
3487 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3489 __bt_service_get_parameters(in_param1,
3490 &network, sizeof(bluetooth_mesh_network_t));
3492 result = _bt_mesh_network_scan_cancel(requester_unique_creds,
3495 if (result != BLUETOOTH_ERROR_NONE)
3496 g_array_append_vals(*out_param1,
3497 &network, sizeof(bluetooth_mesh_network_t));
3500 case BT_MESH_NETWORK_SET_CAPABILITIES: {
3501 bluetooth_mesh_network_t network;
3502 bluetooth_mesh_provisioner_caps_t caps;
3503 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3504 memset(&caps, 0x00, sizeof(bluetooth_mesh_provisioner_caps_t));
3506 __bt_service_get_parameters(in_param1,
3507 &network, sizeof(bluetooth_mesh_network_t));
3509 __bt_service_get_parameters(in_param2,
3510 &caps, sizeof(bluetooth_mesh_provisioner_caps_t));
3512 result = _bt_mesh_network_set_provisioner_caps(
3513 requester_unique_creds, sender, &network, &caps);
3517 case BT_MESH_NETWORK_PROVISION_DEVICE: {
3518 bluetooth_mesh_provisioning_request_t req;
3519 memset(&req, 0x00, sizeof(bluetooth_mesh_provisioning_request_t));
3521 __bt_service_get_parameters(in_param1,
3522 &req, sizeof(bluetooth_mesh_provisioning_request_t));
3524 BT_INFO("Mesh: Provision Device UUID [%s]", req.dev_uuid);
3525 BT_INFO("Mesh: Provision Device in network[%s]", req.net_uuid);
3527 result = _bt_mesh_network_provision_device(
3528 requester_unique_creds, sender, &req);
3530 /* Save invocation */
3531 if (result != BLUETOOTH_ERROR_NONE) {
3532 g_array_append_vals(*out_param1, &req,
3533 sizeof(bluetooth_mesh_provisioning_request_t));
3535 bluetooth_mesh_provisioning_request_t *param = \
3536 g_memdup(&req, sizeof(bluetooth_mesh_provisioning_request_t));
3538 sender = (char*)g_dbus_method_invocation_get_sender(context);
3539 _bt_save_invocation_context(context, result, sender,
3540 function_name, (gpointer)param);
3544 case BT_MESH_AUTHENTICATION_REPLY: {
3545 BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REPLY");
3546 const char *auth_value = NULL;
3547 gboolean authentication_reply = FALSE;
3549 auth_value = g_variant_get_data(in_param2);
3550 __bt_service_get_parameters(in_param3,
3551 &authentication_reply, sizeof(gboolean));
3552 __bt_service_get_parameters(in_param1,
3553 &auth_type, sizeof(int));
3554 BT_INFO("Mesh: Auth Reply Type [%d]", auth_type);
3555 BT_INFO("Mesh: Auth Value [%s]", auth_value);
3556 BT_INFO("Mesh: Auth Accept [%d]", authentication_reply);
3557 result = _bt_mesh_authentication_reply(auth_type,
3558 auth_value, authentication_reply);
3561 case BT_MESH_NETWORK_SET_NAME: {
3562 bluetooth_mesh_network_t network;
3563 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3565 __bt_service_get_parameters(in_param1,
3566 &network, sizeof(bluetooth_mesh_network_t));
3568 result = _bt_mesh_network_set_name(requester_unique_creds, sender, &network);
3572 case BT_MESH_NETWORK_ADD_NETKEY: {
3573 bluetooth_mesh_network_t network;
3574 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3576 __bt_service_get_parameters(in_param1,
3577 &network, sizeof(bluetooth_mesh_network_t));
3579 result = _bt_mesh_network_add_netkey(requester_unique_creds,
3582 if (result != BLUETOOTH_ERROR_NONE) {
3583 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3585 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3587 sender = (char*)g_dbus_method_invocation_get_sender(context);
3588 _bt_save_invocation_context(context, result, sender,
3589 function_name, (gpointer)net);
3593 case BT_MESH_NETWORK_DELETE_NETKEY: {
3594 bluetooth_mesh_network_t network;
3597 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3599 __bt_service_get_parameters(in_param1,
3600 &network, sizeof(bluetooth_mesh_network_t));
3601 __bt_service_get_parameters(in_param2,
3602 &index, sizeof(guint16));
3604 result = _bt_mesh_network_delete_netkey(requester_unique_creds,
3605 sender, &network, index);
3607 if (result != BLUETOOTH_ERROR_NONE) {
3608 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3610 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3612 sender = (char*)g_dbus_method_invocation_get_sender(context);
3613 _bt_save_invocation_context(context, result, sender,
3614 function_name, (gpointer)net);
3618 case BT_MESH_NETWORK_UPDATE_NETKEY: {
3619 bluetooth_mesh_network_t network;
3622 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3624 __bt_service_get_parameters(in_param1,
3625 &network, sizeof(bluetooth_mesh_network_t));
3626 __bt_service_get_parameters(in_param2,
3627 &index, sizeof(guint16));
3629 result = _bt_mesh_network_update_netkey(requester_unique_creds,
3630 sender, &network, index);
3632 if (result != BLUETOOTH_ERROR_NONE) {
3633 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3635 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3637 sender = (char*)g_dbus_method_invocation_get_sender(context);
3638 _bt_save_invocation_context(context, result, sender,
3639 function_name, (gpointer)net);
3643 case BT_MESH_NETWORK_ADD_APPKEY: {
3644 bluetooth_mesh_network_t network;
3647 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3649 __bt_service_get_parameters(in_param1,
3650 &network, sizeof(bluetooth_mesh_network_t));
3651 __bt_service_get_parameters(in_param2,
3652 &net_idx, sizeof(guint16));
3654 result = _bt_mesh_network_add_appkey(requester_unique_creds,
3655 sender, &network, net_idx);
3657 if (result != BLUETOOTH_ERROR_NONE) {
3658 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3660 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3662 sender = (char*)g_dbus_method_invocation_get_sender(context);
3663 _bt_save_invocation_context(context, result, sender,
3664 function_name, (gpointer)net);
3668 case BT_MESH_NETWORK_UPDATE_APPKEY: {
3669 bluetooth_mesh_network_t network;
3673 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3675 __bt_service_get_parameters(in_param1,
3676 &network, sizeof(bluetooth_mesh_network_t));
3677 __bt_service_get_parameters(in_param2,
3678 &net_idx, sizeof(guint16));
3679 __bt_service_get_parameters(in_param3,
3680 &app_idx, sizeof(guint16));
3682 result = _bt_mesh_network_update_appkey(requester_unique_creds,
3683 sender, &network, net_idx, app_idx);
3685 if (result != BLUETOOTH_ERROR_NONE) {
3686 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3688 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3690 sender = (char*)g_dbus_method_invocation_get_sender(context);
3691 _bt_save_invocation_context(context, result, sender,
3692 function_name, (gpointer)net);
3696 case BT_MESH_NETWORK_DELETE_APPKEY: {
3697 bluetooth_mesh_network_t network;
3701 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3703 __bt_service_get_parameters(in_param1,
3704 &network, sizeof(bluetooth_mesh_network_t));
3705 __bt_service_get_parameters(in_param2,
3706 &net_idx, sizeof(guint16));
3707 __bt_service_get_parameters(in_param3,
3708 &app_idx, sizeof(guint16));
3710 result = _bt_mesh_network_delete_appkey(requester_unique_creds,
3711 sender, &network, net_idx, app_idx);
3713 if (result != BLUETOOTH_ERROR_NONE) {
3714 g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
3716 bluetooth_mesh_network_t *net = g_memdup(&network, sizeof(bluetooth_mesh_network_t));
3718 sender = (char*)g_dbus_method_invocation_get_sender(context);
3719 _bt_save_invocation_context(context, result, sender,
3720 function_name, (gpointer)net);
3724 case BT_MESH_NETWORK_GET_NETKEYS: {
3725 bluetooth_mesh_network_t network;
3726 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3727 __bt_service_get_parameters(in_param1,
3728 &network, sizeof(bluetooth_mesh_network_t));
3729 result = _bt_mesh_network_get_netkeys(requester_unique_creds,
3730 sender, &network, out_param1);
3733 case BT_MESH_NETWORK_GET_APPKEYS: {
3734 bluetooth_mesh_network_t network;
3737 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3738 __bt_service_get_parameters(in_param1,
3739 &network, sizeof(bluetooth_mesh_network_t));
3740 __bt_service_get_parameters(in_param2,
3741 &net_idx, sizeof(guint16));
3742 result = _bt_mesh_network_get_appkeys(
3743 requester_unique_creds, sender,
3744 &network, net_idx, out_param1);
3747 case BT_MESH_NETWORK_GET_NODES: {
3748 bluetooth_mesh_network_t network;
3749 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3750 __bt_service_get_parameters(in_param1,
3751 &network, sizeof(bluetooth_mesh_network_t));
3752 result = _bt_mesh_network_get_nodes(
3753 requester_unique_creds, sender,
3754 &network, out_param1);
3757 case BT_MESH_ELEMENT_GET_MODELS: {
3758 bluetooth_mesh_network_t network;
3762 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
3763 __bt_service_get_parameters(in_param1,
3764 &network, sizeof(bluetooth_mesh_network_t));
3765 __bt_service_get_parameters(in_param2,
3766 &node_addr, sizeof(guint16));
3767 __bt_service_get_parameters(in_param3,
3768 &elem_idx, sizeof(int));
3769 result = _bt_mesh_element_get_models(requester_unique_creds, sender,
3770 &network, node_addr, elem_idx, out_param1);
3773 case BT_MESH_NODE_BROWSE: {
3774 bluetooth_mesh_node_discover_t req;
3775 memset(&req, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3777 __bt_service_get_parameters(in_param1,
3778 &req, sizeof(bluetooth_mesh_node_discover_t));
3780 result = _bt_mesh_browse_remote_node(
3781 requester_unique_creds, sender, &req);
3783 /* Save invocation */
3784 if (result != BLUETOOTH_ERROR_NONE) {
3785 g_array_append_vals(*out_param1, &req,
3786 sizeof(bluetooth_mesh_node_discover_t));
3788 bluetooth_mesh_node_discover_t *param = \
3789 g_memdup(&req, sizeof(bluetooth_mesh_node_discover_t));
3791 sender = (char*)g_dbus_method_invocation_get_sender(context);
3792 _bt_save_invocation_context(context, result, sender,
3793 function_name, (gpointer)param);
3797 case BT_MESH_NODE_GET_VENDOR_FEATURES: {
3798 bluetooth_mesh_node_features_t req;
3799 memset(&req, 0x00, sizeof(bluetooth_mesh_node_features_t));
3801 __bt_service_get_parameters(in_param1,
3802 &req, sizeof(bluetooth_mesh_node_features_t));
3804 result = _bt_mesh_node_discover_vendor_features(
3805 requester_unique_creds, sender, &req);
3807 /* Save invocation */
3808 if (result != BLUETOOTH_ERROR_NONE) {
3809 g_array_append_vals(*out_param1,
3810 &req, sizeof(bluetooth_mesh_node_features_t));
3812 bluetooth_mesh_node_features_t *param = \
3813 g_memdup(&req, sizeof(bluetooth_mesh_node_features_t));
3815 sender = (char*)g_dbus_method_invocation_get_sender(context);
3816 _bt_save_invocation_context(context, result, sender,
3817 function_name, (gpointer)param);
3821 case BT_MESH_NODE_CONFIGURE_KEY: {
3822 bluetooth_mesh_key_configure_t req;
3824 memset(&req, 0x00, sizeof(bluetooth_mesh_key_configure_t));
3826 __bt_service_get_parameters(in_param1,
3827 &req, sizeof(bluetooth_mesh_key_configure_t));
3829 result = _bt_mesh_node_configure_key(
3830 requester_unique_creds, sender, &req);
3832 /* Save invocation */
3833 if (result != BLUETOOTH_ERROR_NONE) {
3834 g_array_append_vals(*out_param1,
3835 &req, sizeof(bluetooth_mesh_key_configure_t));
3837 bluetooth_mesh_key_configure_t *param = \
3838 g_memdup(&req, sizeof(bluetooth_mesh_key_configure_t));
3840 sender = (char*)g_dbus_method_invocation_get_sender(context);
3841 _bt_save_invocation_context(context, result, sender,
3842 function_name, (gpointer)param);
3846 case BT_MESH_NODE_TTL_EXECUTE: {
3847 bluetooth_mesh_node_ttl_info_t req;
3849 memset(&req, 0x00, sizeof(bluetooth_mesh_node_ttl_info_t));
3851 __bt_service_get_parameters(in_param1,
3852 &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3854 result = _bt_mesh_ttl_execute_remote_node(
3855 requester_unique_creds, sender, &req);
3857 /* Save invocation */
3858 if (result != BLUETOOTH_ERROR_NONE) {
3859 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_node_ttl_info_t));
3861 bluetooth_mesh_node_ttl_info_t *param = \
3862 g_memdup(&req, sizeof(bluetooth_mesh_node_ttl_info_t));
3864 sender = (char*)g_dbus_method_invocation_get_sender(context);
3865 _bt_save_invocation_context(context, result, sender,
3866 function_name, (gpointer)param);
3870 case BT_MESH_MODEL_CONFIGURE_APPKEY: {
3871 bluetooth_mesh_model_configure_t req;
3873 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3875 __bt_service_get_parameters(in_param1,
3876 &req, sizeof(bluetooth_mesh_model_configure_t));
3878 result = _bt_mesh_node_model_appkey_execute(
3879 requester_unique_creds, sender, &req);
3881 /* Save invocation */
3882 if (result != BLUETOOTH_ERROR_NONE) {
3883 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3885 bluetooth_mesh_model_configure_t *param = \
3886 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3888 sender = (char*)g_dbus_method_invocation_get_sender(context);
3889 _bt_save_invocation_context(context, result, sender,
3890 function_name, (gpointer)param);
3894 case BT_MESH_NODE_GET_NETKEYS: {
3895 bluetooth_mesh_node_discover_t node;
3896 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3897 __bt_service_get_parameters(in_param1,
3898 &node, sizeof(bluetooth_mesh_node_discover_t));
3899 result = _bt_mesh_network_node_get_netkeys(
3900 requester_unique_creds, &node, out_param1);
3903 case BT_MESH_NODE_GET_APPKEYS: {
3904 bluetooth_mesh_node_discover_t node;
3905 memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
3906 __bt_service_get_parameters(in_param1,
3907 &node, sizeof(bluetooth_mesh_node_discover_t));
3908 result = _bt_mesh_network_node_get_appkeys(
3909 requester_unique_creds, sender, &node, out_param1);
3912 case BT_MESH_MODEL_GET_APPKEY_LIST: {
3913 bluetooth_mesh_model_configure_t req;
3915 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3917 __bt_service_get_parameters(in_param1,
3918 &req, sizeof(bluetooth_mesh_model_configure_t));
3920 result = _bt_mesh_node_model_get_appkey_list(
3921 requester_unique_creds, sender, &req);
3923 /* Save invocation */
3924 if (result != BLUETOOTH_ERROR_NONE) {
3925 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3927 bluetooth_mesh_model_configure_t *param = \
3928 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3930 sender = (char*)g_dbus_method_invocation_get_sender(context);
3931 _bt_save_invocation_context(context, result, sender,
3932 function_name, (gpointer)param);
3936 case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST: {
3937 bluetooth_mesh_model_configure_t req;
3939 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3941 __bt_service_get_parameters(in_param1,
3942 &req, sizeof(bluetooth_mesh_model_configure_t));
3944 result = _bt_mesh_node_model_get_subscription_list(
3945 requester_unique_creds, sender, &req);
3947 /* Save invocation */
3948 if (result != BLUETOOTH_ERROR_NONE) {
3949 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
3951 bluetooth_mesh_model_configure_t *param = \
3952 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
3954 sender = (char*)g_dbus_method_invocation_get_sender(context);
3955 _bt_save_invocation_context(context, result, sender,
3956 function_name, (gpointer)param);
3961 case BT_MESH_NETWORK_CREATE_GROUP: {
3962 bluetooth_mesh_network_t net;
3963 bluetooth_mesh_network_group_info_t res;
3964 gboolean is_virtual;
3967 memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
3968 memset(&res, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
3970 __bt_service_get_parameters(in_param1,
3971 &net, sizeof(bluetooth_mesh_network_t));
3972 __bt_service_get_parameters(in_param2,
3973 &is_virtual, sizeof(gboolean));
3974 __bt_service_get_parameters(in_param3,
3975 &grp_addr, sizeof(guint16));
3977 result = _bt_mesh_network_create_group(
3978 requester_unique_creds, sender, &net,
3979 is_virtual, grp_addr, &res);
3981 if (result == BLUETOOTH_ERROR_NONE)
3982 g_array_append_vals(*out_param1, &res,
3983 sizeof(bluetooth_mesh_network_group_info_t));
3986 case BT_MESH_MODEL_CONFIG_GROUP_SUB: {
3987 bluetooth_mesh_model_configure_t req;
3989 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
3991 __bt_service_get_parameters(in_param1,
3992 &req, sizeof(bluetooth_mesh_model_configure_t));
3994 result = _bt_mesh_model_configure_group_subscription(
3995 requester_unique_creds, sender, &req);
3997 /* Save invocation */
3998 if (result != BLUETOOTH_ERROR_NONE) {
3999 g_array_append_vals(*out_param1,
4000 &req, sizeof(bluetooth_mesh_model_configure_t));
4002 bluetooth_mesh_model_configure_t *param = \
4003 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4005 sender = (char*)g_dbus_method_invocation_get_sender(context);
4006 _bt_save_invocation_context(context, result, sender,
4007 function_name, (gpointer)param);
4011 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB: {
4012 bluetooth_mesh_model_configure_t req;
4014 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4016 __bt_service_get_parameters(in_param1,
4017 &req, sizeof(bluetooth_mesh_model_configure_t));
4019 result = _bt_mesh_model_configure_virtual_group_subscription(
4020 requester_unique_creds, sender, &req);
4022 /* Save invocation */
4023 if (result != BLUETOOTH_ERROR_NONE) {
4024 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4026 bluetooth_mesh_model_configure_t *param = \
4027 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4029 sender = (char*)g_dbus_method_invocation_get_sender(context);
4030 _bt_save_invocation_context(context, result, sender,
4031 function_name, (gpointer)param);
4035 case BT_MESH_MODEL_SET_PUBLICATION: {
4036 bluetooth_mesh_model_configure_t req;
4038 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4040 __bt_service_get_parameters(in_param1,
4041 &req, sizeof(bluetooth_mesh_model_configure_t));
4043 result = _bt_mesh_model_set_publication(
4044 requester_unique_creds, sender, &req);
4046 /* Save invocation */
4047 if (result != BLUETOOTH_ERROR_NONE) {
4048 g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
4050 bluetooth_mesh_model_configure_t *param = g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4052 sender = (char*)g_dbus_method_invocation_get_sender(context);
4053 _bt_save_invocation_context(context, result, sender,
4054 function_name, (gpointer)param);
4058 case BT_MESH_MODEL_GET_PUBLICATION: {
4059 bluetooth_mesh_model_configure_t req;
4061 memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
4063 __bt_service_get_parameters(in_param1,
4064 &req, sizeof(bluetooth_mesh_model_configure_t));
4066 result = _bt_mesh_model_get_publication(
4067 requester_unique_creds, sender, &req);
4069 /* Save invocation */
4070 if (result != BLUETOOTH_ERROR_NONE) {
4071 g_array_append_vals(*out_param1,
4072 &req, sizeof(bluetooth_mesh_model_configure_t));
4074 bluetooth_mesh_model_configure_t *param = \
4075 g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
4077 sender = (char*)g_dbus_method_invocation_get_sender(context);
4078 _bt_save_invocation_context(context, result, sender,
4079 function_name, (gpointer)param);
4083 case BT_MESH_NETWORK_GET_GROUPS: {
4084 bluetooth_mesh_network_t network;
4085 memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
4086 __bt_service_get_parameters(in_param1,
4087 &network, sizeof(bluetooth_mesh_network_t));
4088 result = _bt_mesh_network_get_groups(
4089 requester_unique_creds, sender, &network, out_param1);
4093 BT_INFO("UnSupported function [%d]", function_name);
4094 result = BLUETOOTH_ERROR_NOT_SUPPORT;
4100 #ifdef TIZEN_FEATURE_BT_OBEX
4101 /* Function definitions*/
4102 static void __bt_fill_garray_from_variant(GVariant *var, GArray *param)
4107 size = g_variant_get_size(var);
4109 data = (char *)g_variant_get_data(var);
4111 param = g_array_append_vals(param, data, size);
4117 int __bt_obexd_request(int function_name,
4120 GDBusMethodInvocation *context,
4121 GVariant *in_param1,
4122 GVariant *in_param2,
4123 GVariant *in_param3,
4124 GVariant *in_param4,
4125 GArray **out_param1)
4129 int result = BLUETOOTH_ERROR_NONE;
4131 BT_DBG("function_name : %x", function_name);
4133 switch (function_name) {
4134 case BT_OPP_PUSH_FILES: {
4135 BT_DBG("BT_OPP_PUSH_FILES");
4137 bluetooth_device_address_t address = { {0} };
4138 bt_file_path_t *path;
4143 __bt_service_get_parameters(in_param1, &address,
4144 sizeof(bluetooth_device_address_t));
4145 __bt_service_get_parameters(in_param3, &file_count,
4148 file_path = g_new0(char *, file_count + 1);
4150 param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
4151 __bt_fill_garray_from_variant(in_param2, param2);
4153 for (i = 0; i < file_count; i++) {
4154 path = &g_array_index(param2, bt_file_path_t, i);
4155 file_path[i] = g_strdup(path->path);
4157 BT_DBG("_bt_opp_client_push_files");
4158 result = _bt_opp_client_push_files(request_id, context,
4159 &address, file_path,
4162 for (i = 0; i < file_count; i++)
4163 g_free(file_path[i]);
4166 g_array_free(param2, TRUE);
4170 case BT_OPP_CANCEL_PUSH: {
4171 result = _bt_opp_client_cancel_push();
4175 case BT_OPP_IS_PUSHING_FILES: {
4176 gboolean is_sending = FALSE;
4178 result = _bt_opp_client_is_sending(&is_sending);
4180 g_array_append_vals(*out_param1, &is_sending,
4184 case BT_OPP_GET_TRANSFER_PROGRESS: {
4187 guint8 progress = 0;
4189 __bt_service_get_parameters(in_param1, &direction,
4191 __bt_service_get_parameters(in_param2, &transfer_id,
4194 result = _bt_opp_get_client_progress(&progress);
4196 result = _bt_opp_get_server_progress(transfer_id, &progress);
4198 g_array_append_vals(*out_param1, &progress,
4204 case BT_MAP_CREATE_SESSION: {
4205 BT_DBG("BT_MAP_CREATE_SESSION");
4206 char *address = (char *)g_variant_get_data(in_param1);
4207 char *session_id = NULL;
4208 result = _bt_create_session_sync(address, &session_id);
4209 if (result == BLUETOOTH_ERROR_NONE)
4210 g_array_append_vals(*out_param1, session_id, strlen(session_id)+1);
4214 case BT_MAP_DESTROY_SESSION: {
4215 BT_DBG("BT_MAP_DESTROY_SESSION");
4216 char* session_id = (char *)g_variant_get_data(in_param1);
4217 result = _bt_destroy_session_sync(session_id);
4218 if (result == BLUETOOTH_ERROR_NONE)
4219 BT_DBG("successfully destroyed session");
4223 case BT_MAP_SET_FOLDER: {
4224 BT_DBG("BT_MAP_SET_FOLDER");
4225 char *session_id = (char *)g_variant_get_data(in_param1);
4226 char *name = (char *)g_variant_get_data(in_param2);
4227 result = _bt_map_client_set_folder(session_id, name);
4231 case BT_MAP_LIST_FOLDERS: {
4232 BT_DBG("BT_MAP_LIST_FOLDERS");
4234 char* session_id = (char *)g_variant_get_data(in_param1);
4235 char* filter_serialized = (char*)g_variant_get_data(in_param2);
4237 result = _bt_map_client_list_folders(request_id, context, session_id, filter_serialized);
4238 if (result == BLUETOOTH_ERROR_NONE)
4239 BT_DBG("_bt_map_client_list_folders succeed");
4244 case BT_MAP_LIST_FILTER_FIELDS: {
4245 BT_DBG("BT_MAP_LIST_FILTER_FIELDS");
4247 char* session_id = (char *)g_variant_get_data(in_param1);
4249 result = _bt_map_client_list_filter_fields(request_id, context, session_id);
4250 if (result == BLUETOOTH_ERROR_NONE)
4251 BT_DBG("_bt_map_client_list_filter_fields succeed");
4256 case BT_MAP_LIST_MESSAGES: {
4257 BT_DBG("BT_MAP_LIST_MESSAGES");
4259 char* session_id = (char*)g_variant_get_data(in_param1);
4260 char* folder = (char*)g_variant_get_data(in_param2);
4261 char* filter_serialized = (char*)g_variant_get_data(in_param3);
4263 result = _bt_map_client_list_messages(request_id, context, session_id, folder, filter_serialized);
4264 if (result == BLUETOOTH_ERROR_NONE)
4265 BT_DBG("_bt_map_client_list_messages succeed");
4267 BT_DBG("_bt_map_client_list_messages failed");
4272 case BT_MAP_UPDATE_INBOX: {
4273 BT_DBG("BT_MAP_UPDATE_INBOX");
4274 char* session_id = (char *)g_variant_get_data(in_param1);
4275 result = _bt_map_client_update_inbox(session_id);
4279 case BT_MAP_PUSH_MESSAGE: {
4280 BT_DBG("BT_MAP_PUSH_MESSAGE");
4282 char* session_id = (char *)g_variant_get_data(in_param1);
4283 char* source_file = (char *)g_variant_get_data(in_param2);
4284 char* folder = (char *)g_variant_get_data(in_param3);
4285 char* args_serialized = (char *)g_variant_get_data(in_param4);
4287 result = _bt_map_client_push_message(
4288 request_id, context, session_id, source_file, folder, args_serialized);
4289 if (result == BLUETOOTH_ERROR_NONE)
4290 BT_DBG("_bt_map_client_push_message succeed");
4292 BT_ERR("_bt_map_client_push_message failed");
4297 case BT_MAP_GET_MESSAGE: {
4298 BT_DBG("BT_MAP_GET_MESSAGE");
4299 // TODO session currently is not used, but should be valid
4300 //char* session_id = (char *)g_variant_get_data(in_param1);
4301 char* message_object = (char *)g_variant_get_data(in_param2);
4302 char* target_file = (char *)g_variant_get_data(in_param3);
4303 bool attachment = false;
4304 __bt_service_get_parameters(in_param4, &attachment, sizeof(bool));
4306 result = _bt_map_client_get_message(request_id, context, message_object,
4307 target_file, attachment);
4308 if (result == BLUETOOTH_ERROR_NONE)
4309 BT_DBG("_bt_map_client_get_message succeed");
4314 case BT_OBEX_SERVER_ALLOCATE: {
4320 sender = (char *)g_dbus_method_invocation_get_sender(context);
4322 path = (char *)g_variant_get_data(in_param1);
4323 __bt_service_get_parameters(in_param2, &is_native,
4325 __bt_service_get_parameters(in_param3, &app_pid,
4328 result = _bt_obex_server_allocate(sender,
4329 path, app_pid, is_native);
4333 case BT_OBEX_SERVER_DEALLOCATE: {
4337 __bt_service_get_parameters(in_param1, &is_native,
4339 __bt_service_get_parameters(in_param2, &app_pid,
4342 result = _bt_obex_server_deallocate(app_pid, is_native);
4345 case BT_OBEX_SERVER_IS_ACTIVATED: {
4346 gboolean is_activated = FALSE;
4348 result = _bt_obex_server_is_activated(&is_activated);
4350 g_array_append_vals(*out_param1, &is_activated,
4355 case BT_OBEX_SERVER_ACCEPT_CONNECTION: {
4356 result = _bt_obex_server_accept_connection(request_id);
4360 case BT_OBEX_SERVER_REJECT_CONNECTION: {
4361 result = _bt_obex_server_reject_connection();
4365 case BT_OBEX_SERVER_ACCEPT_FILE: {
4368 file_name = (char *)g_variant_get_data(in_param1);
4370 result = _bt_obex_server_accept_authorize(file_name, TRUE);
4374 case BT_OBEX_SERVER_REJECT_FILE: {
4375 result = _bt_obex_server_reject_authorize();
4379 case BT_OBEX_SERVER_SET_PATH: {
4381 char *destination_path;
4383 destination_path = (char *)g_variant_get_data(in_param1);
4384 __bt_service_get_parameters(in_param2, &is_native,
4387 result = _bt_obex_server_set_destination_path(destination_path,
4392 case BT_OBEX_SERVER_SET_ROOT: {
4395 root = (char *)g_variant_get_data(in_param1);
4397 result = _bt_obex_server_set_root(root);
4401 case BT_OBEX_SERVER_CANCEL_TRANSFER: {
4404 __bt_service_get_parameters(in_param1, &transfer_id,
4407 result = _bt_obex_server_cancel_transfer(transfer_id);
4411 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS: {
4412 result = _bt_obex_server_cancel_all_transfers();
4416 case BT_OBEX_SERVER_IS_RECEIVING: {
4417 gboolean is_receiving = FALSE;
4419 result = _bt_obex_server_is_receiving(&is_receiving);
4421 g_array_append_vals(*out_param1, &is_receiving,
4425 case BT_PBAP_CONNECT: {
4426 bluetooth_device_address_t address = { {0} };
4428 __bt_service_get_parameters(in_param1, &address,
4429 sizeof(bluetooth_device_address_t));
4431 result = _bt_pbap_connect(&address);
4434 case BT_PBAP_DISCONNECT: {
4435 bluetooth_device_address_t address = { {0} };
4437 __bt_service_get_parameters(in_param1, &address,
4438 sizeof(bluetooth_device_address_t));
4440 result = _bt_pbap_disconnect(&address);
4443 case BT_PBAP_GET_PHONEBOOK_SIZE: {
4444 bluetooth_device_address_t address = { {0} };
4445 bt_pbap_folder_t folder = { 0, };
4447 __bt_service_get_parameters(in_param1, &address,
4448 sizeof(bluetooth_device_address_t));
4449 __bt_service_get_parameters(in_param2, &folder,
4450 sizeof(bt_pbap_folder_t));
4452 result = _bt_pbap_get_phonebook_size(&address,
4453 folder.addressbook, folder.folder_type);
4456 case BT_PBAP_GET_PHONEBOOK: {
4457 bluetooth_device_address_t address = { {0} };
4458 bt_pbap_folder_t folder = { 0, };
4459 bt_pbap_pull_parameters_t app_param = { 0, };
4461 __bt_service_get_parameters(in_param1, &address,
4462 sizeof(bluetooth_device_address_t));
4463 __bt_service_get_parameters(in_param2, &folder,
4464 sizeof(bt_pbap_folder_t));
4465 __bt_service_get_parameters(in_param3, &app_param,
4466 sizeof(bt_pbap_pull_parameters_t));
4468 result = _bt_pbap_get_phonebook(&address, folder.addressbook,
4469 folder.folder_type, &app_param);
4472 case BT_PBAP_GET_LIST: {
4473 bluetooth_device_address_t address = { {0} };
4474 bt_pbap_folder_t folder = { 0, };
4475 bt_pbap_list_parameters_t app_param = { 0, };
4477 __bt_service_get_parameters(in_param1, &address,
4478 sizeof(bluetooth_device_address_t));
4479 __bt_service_get_parameters(in_param2, &folder,
4480 sizeof(bt_pbap_folder_t));
4481 __bt_service_get_parameters(in_param3, &app_param,
4482 sizeof(bt_pbap_list_parameters_t));
4484 result = _bt_pbap_get_list(&address, folder.addressbook,
4485 folder.folder_type, &app_param);
4488 case BT_PBAP_PULL_VCARD: {
4489 bluetooth_device_address_t address = { {0} };
4490 bt_pbap_folder_t folder = { 0, };
4491 bt_pbap_pull_vcard_parameters_t app_param = { 0, };
4493 __bt_service_get_parameters(in_param1, &address,
4494 sizeof(bluetooth_device_address_t));
4495 __bt_service_get_parameters(in_param2, &folder,
4496 sizeof(bt_pbap_folder_t));
4497 __bt_service_get_parameters(in_param3, &app_param,
4498 sizeof(bt_pbap_pull_vcard_parameters_t));
4500 result = _bt_pbap_pull_vcard(&address, folder.addressbook,
4501 folder.folder_type, &app_param);
4504 case BT_PBAP_PHONEBOOK_SEARCH: {
4505 bluetooth_device_address_t address = { {0} };
4506 bt_pbap_folder_t folder = { 0, };
4507 bt_pbap_search_parameters_t app_param = { 0, };
4509 __bt_service_get_parameters(in_param1, &address,
4510 sizeof(bluetooth_device_address_t));
4511 __bt_service_get_parameters(in_param2, &folder,
4512 sizeof(bt_pbap_folder_t));
4513 __bt_service_get_parameters(in_param3, &app_param,
4514 sizeof(bt_pbap_search_parameters_t));
4516 result = _bt_pbap_phonebook_search(&address, folder.addressbook,
4517 folder.folder_type, &app_param);
4522 BT_ERR("Unknown function!");
4523 result = BLUETOOTH_ERROR_INTERNAL;
4532 int __bt_agent_request(int function_name,
4535 GDBusMethodInvocation *context,
4536 GVariant *in_param1,
4537 GVariant *in_param2,
4538 GVariant *in_param3,
4539 GVariant *in_param4,
4540 GArray **out_param1)
4543 switch (function_name) {
4544 case BT_SET_AUTHORIZATION: {
4551 sender = (char *)g_dbus_method_invocation_get_sender(context);
4552 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4553 uuid = (char *)g_variant_get_data(in_param2);
4554 path = (char *)g_variant_get_data(in_param3);
4555 __bt_service_get_parameters(in_param4, &fd, sizeof(int));
4557 result = _bt_register_osp_server_in_agent(sender, type, uuid, path, fd);
4560 case BT_UNSET_AUTHORIZATION: {
4564 __bt_service_get_parameters(in_param1, &type, sizeof(int));
4565 uuid = (char *)g_variant_get_data(in_param2);
4567 result = _bt_unregister_osp_server_in_agent(type, uuid);
4571 BT_ERR("Unknown function!");
4572 result = BLUETOOTH_ERROR_INTERNAL;
4579 int __bt_core_request(int function_name,
4582 GDBusMethodInvocation *context,
4583 GVariant *in_param1)
4587 switch (function_name) {
4588 case BT_ENABLE_ADAPTER:
4591 _bt_set_adapter_request_state(TRUE);
4592 status = _bt_adapter_get_status();
4594 if (status == BT_ACTIVATING) {
4595 BT_DBG("Enabling in progress");
4596 result = BLUETOOTH_ERROR_IN_PROGRESS;
4597 } else if (status == BT_ACTIVATED) {
4598 BT_DBG("Already enabled");
4599 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4601 _bt_adapter_set_status(BT_ACTIVATING);
4602 result = BLUETOOTH_ERROR_NONE;
4607 case BT_DISABLE_ADAPTER:
4611 status = _bt_adapter_get_status();
4612 if (status == BT_DEACTIVATING) {
4613 BT_DBG("Disabling in progress");
4614 result = BLUETOOTH_ERROR_IN_PROGRESS;
4615 } else if (status == BT_DEACTIVATED) {
4616 BT_DBG("Already disabled");
4617 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4619 _bt_adapter_set_status(BT_DEACTIVATING);
4620 result = BLUETOOTH_ERROR_NONE;
4625 case BT_ENABLE_ADAPTER_LE:
4627 bt_le_status_t le_status;
4628 _bt_set_le_request_state(TRUE);
4629 le_status = _bt_adapter_get_le_status();
4630 if (le_status == BT_LE_ACTIVATING) {
4631 BT_DBG("Enabling in progress");
4632 result = BLUETOOTH_ERROR_IN_PROGRESS;
4633 } else if (le_status == BT_LE_ACTIVATED) {
4634 BT_DBG("Already enabled");
4635 result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
4637 _bt_adapter_set_le_status(BT_LE_ACTIVATING);
4638 result = BLUETOOTH_ERROR_NONE;
4643 case BT_DISABLE_ADAPTER_LE:
4645 bt_le_status_t le_status;
4647 le_status = _bt_adapter_get_le_status();
4648 if (le_status == BT_LE_DEACTIVATING) {
4649 BT_DBG("Disabling in progress");
4650 result = BLUETOOTH_ERROR_IN_PROGRESS;
4651 } else if (le_status == BT_LE_DEACTIVATED) {
4652 BT_DBG("Already disabled");
4653 result = BLUETOOTH_ERROR_DEVICE_NOT_ENABLED;
4655 _bt_adapter_set_le_status(BT_LE_DEACTIVATING);
4656 result = BLUETOOTH_ERROR_NONE;
4662 BT_ERR("Unknown function!");
4663 result = BLUETOOTH_ERROR_INTERNAL;
4670 static int __bt_service_get_requester_app_id(const char *unique_name, char *app_id, int len)
4675 retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
4676 retv_if(unique_name == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
4678 ret = __bt_service_get_sender_pid(unique_name, &pid);
4679 if (ret != BLUETOOTH_ERROR_NONE) {
4680 BT_ERR("Fail to get the sender pid");
4684 ret = aul_app_get_appid_bypid(pid, app_id, len);
4685 if (ret != AUL_R_OK) {
4686 BT_ERR("app_id not found");
4687 return BLUETOOTH_ERROR_NOT_SUPPORT;
4689 BT_DBG("Sender app_id: %s", app_id);
4691 return BLUETOOTH_ERROR_NONE;
4694 gboolean __bt_service_check_privilege(int function_name,
4696 const char *unique_name)
4699 gboolean result = TRUE;
4700 char *client_creds = NULL;
4701 char *user_creds = NULL;
4702 char *client_session = "";
4703 enum cynara_client_creds client_creds_method = CLIENT_METHOD_SMACK;
4704 enum cynara_user_creds user_creds_method = USER_METHOD_UID;
4705 char err_msg[256] = {0, };
4707 retv_if(unique_name == NULL, FALSE);
4708 retv_if(bt_service_conn == NULL, FALSE);
4710 ret_val = cynara_creds_get_default_client_method(&client_creds_method);
4711 if (ret_val != CYNARA_API_SUCCESS) {
4712 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4713 BT_ERR("Fail to get default client method: %s", err_msg);
4717 ret_val = cynara_creds_get_default_user_method(&user_creds_method);
4718 if (ret_val != CYNARA_API_SUCCESS) {
4719 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4720 BT_ERR("Fail to get default user method: %s", err_msg);
4724 ret_val = cynara_creds_gdbus_get_client(bt_service_conn, unique_name, client_creds_method, &client_creds);
4725 if (ret_val != CYNARA_API_SUCCESS) {
4726 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4727 BT_ERR("Fail to get client credential: %s", err_msg);
4731 ret_val = cynara_creds_gdbus_get_user(bt_service_conn, unique_name, user_creds_method, &user_creds);
4732 if (ret_val != CYNARA_API_SUCCESS) {
4733 cynara_strerror(ret_val, err_msg, sizeof(err_msg));
4734 BT_ERR("Fail to get user credential: %s", err_msg);
4740 BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
4742 switch (function_name) {
4743 case BT_SET_LOCAL_NAME:
4744 case BT_START_DISCOVERY:
4745 case BT_START_CUSTOM_DISCOVERY:
4746 case BT_CANCEL_DISCOVERY:
4747 case BT_OOB_ADD_REMOTE_DATA:
4748 case BT_OOB_REMOVE_REMOTE_DATA:
4749 case BT_OOB_READ_LOCAL_DATA:
4750 case BT_SET_ADVERTISING:
4751 case BT_SET_CUSTOM_ADVERTISING:
4752 case BT_SET_ADVERTISING_PARAMETERS:
4753 case BT_START_LE_DISCOVERY:
4754 case BT_STOP_LE_DISCOVERY:
4755 case BT_SET_SCAN_PARAMETERS:
4756 case BT_SET_SCAN_TYPE:
4758 case BT_BOND_DEVICE:
4759 case BT_CANCEL_BONDING:
4760 case BT_UNBOND_DEVICE:
4762 case BT_SET_AUTHORIZATION:
4763 case BT_UNSET_AUTHORIZATION:
4764 case BT_SEARCH_SERVICE:
4766 case BT_RFCOMM_CLIENT_CONNECT:
4767 if (function_name == BT_RFCOMM_CLIENT_CONNECT)
4768 BT_PERMANENT_LOG("Connect socket");
4769 case BT_RFCOMM_CLIENT_CANCEL_CONNECT:
4770 case BT_RFCOMM_SOCKET_DISCONNECT:
4771 if (function_name == BT_RFCOMM_SOCKET_DISCONNECT)
4772 BT_PERMANENT_LOG("Disconnect socket");
4773 case BT_RFCOMM_SOCKET_WRITE:
4774 case BT_RFCOMM_CREATE_SOCKET:
4775 case BT_RFCOMM_REMOVE_SOCKET:
4776 case BT_RFCOMM_SEND_RX_DETAILS:
4777 case BT_RFCOMM_SEND_TX_DETAILS:
4778 case BT_RFCOMM_UPDATE_CONNECTION_INFO:
4780 case BT_OPP_PUSH_FILES:
4781 case BT_OPP_CANCEL_PUSH:
4782 /* TODO: MAP? MAP functions, see above */
4784 case BT_OBEX_SERVER_ACCEPT_CONNECTION:
4785 case BT_OBEX_SERVER_REJECT_CONNECTION:
4786 case BT_OBEX_SERVER_ACCEPT_FILE:
4787 case BT_OBEX_SERVER_REJECT_FILE:
4788 case BT_OBEX_SERVER_SET_PATH:
4789 case BT_OBEX_SERVER_SET_ROOT:
4790 case BT_OBEX_SERVER_CANCEL_TRANSFER:
4791 case BT_OBEX_SERVER_CANCEL_ALL_TRANSFERS:
4793 case BT_AUDIO_SELECT_ROLE:
4794 case BT_AUDIO_CONNECT:
4795 case BT_AUDIO_DISCONNECT:
4797 case BT_AG_DISCONNECT:
4799 case BT_AV_DISCONNECT:
4800 case BT_AV_SOURCE_CONNECT:
4801 case BT_AV_SOURCE_DISCONNECT:
4802 case BT_AVRCP_TARGET_CONNECT:
4803 case BT_AVRCP_TARGET_DISCONNECT:
4804 case BT_AVRCP_CONTROL_CONNECT:
4805 case BT_AVRCP_CONTROL_DISCONNECT:
4806 case BT_AVRCP_HANDLE_CONTROL:
4807 case BT_AVRCP_SET_TRACK_INFO:
4808 case BT_AVRCP_SET_PROPERTY:
4809 case BT_AVRCP_SET_PROPERTIES:
4810 case BT_AVRCP_CONTROL_SET_PROPERTY:
4812 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
4813 case BT_AUDIO_SET_ABSOLUTE_VOLUME:
4814 case BT_AUDIO_GET_ABSOLUTE_VOLUME:
4815 case BT_AUDIO_IS_AVC_ACTIVATED:
4819 case BT_HF_DISCONNECT:
4821 case BT_HID_CONNECT:
4822 case BT_HID_DISCONNECT:
4824 case BT_HID_DEVICE_ACTIVATE:
4825 case BT_HID_DEVICE_DEACTIVATE:
4826 case BT_HID_DEVICE_CONNECT:
4827 case BT_HID_DEVICE_DISCONNECT:
4828 case BT_HID_DEVICE_SEND_MOUSE_EVENT:
4829 case BT_HID_DEVICE_SEND_KEY_EVENT:
4830 case BT_HID_DEVICE_SEND_REPLY_TO_REPORT:
4831 case BT_HID_DEVICE_SEND_CUSTOM_EVENT:
4834 case BT_DISCONNECT_LE:
4836 case BT_SET_ADVERTISING_DATA:
4837 case BT_SET_SCAN_RESPONSE_DATA:
4839 case BT_HDP_CONNECT:
4840 case BT_HDP_DISCONNECT:
4841 case BT_HDP_SEND_DATA:
4842 case BT_HDP_REGISTER_SINK_APP:
4843 case BT_HDP_UNREGISTER_SINK_APP:
4846 case BT_DPM_SET_ALLOW_BT_MODE:
4847 case BT_DPM_GET_ALLOW_BT_MODE:
4848 case BT_DPM_SET_DEVICE_RESTRITION:
4849 case BT_DPM_GET_DEVICE_RESTRITION:
4850 case BT_DPM_SET_UUID_RESTRITION:
4851 case BT_DPM_GET_UUID_RESTRITION:
4852 case BT_DPM_ADD_DEVICES_BLACKLIST:
4853 case BT_DPM_ADD_DEVICES_WHITELIST:
4854 case BT_DPM_ADD_UUIDS_BLACKLIST:
4855 case BT_DPM_ADD_UUIDS_WHITELIST:
4856 case BT_DPM_CLEAR_DEVICES_BLACKLIST:
4857 case BT_DPM_CLEAR_DEVICES_WHITELIST:
4858 case BT_DPM_CLEAR_UUIDS_BLACKLIST:
4859 case BT_DPM_CLEAR_UUIDS_WHITELIST:
4860 case BT_DPM_REMOVE_DEVICE_BLACKLIST:
4861 case BT_DPM_REMOVE_DEVICE_WHITELIST:
4862 case BT_DPM_REMOVE_UUID_BLACKLIST:
4863 case BT_DPM_REMOVE_UUID_WHITELIST:
4864 case BT_DPM_GET_DEVICES_BLACKLIST:
4865 case BT_DPM_GET_DEVICES_WHITELIST:
4866 case BT_DPM_GET_UUIDS_BLACKLIST:
4867 case BT_DPM_GET_UUIDS_WHITELIST:
4868 case BT_DPM_SET_ALLOW_OUTGOING_CALL:
4869 case BT_DPM_GET_ALLOW_OUTGOING_CALL:
4870 case BT_DPM_SET_PAIRING_STATE:
4871 case BT_DPM_GET_PAIRING_STATE:
4872 case BT_DPM_SET_PROFILE_STATE:
4873 case BT_DPM_GET_PROFILE_STATE:
4874 case BT_DPM_SET_DESKROP_CONNECTIVITY_STATE:
4875 case BT_DPM_GET_DESKROP_CONNECTIVITY_STATE:
4876 case BT_DPM_SET_DISCOVERABLE_STATE:
4877 case BT_DPM_GET_DISCOVERABLE_STATE:
4878 case BT_DPM_SET_LIMITED_DISCOVERABLE_STATE:
4879 case BT_DPM_GET_LIMITED_DISCOVERABLE_STATE:
4880 case BT_DPM_SET_DATA_TRANSFER_STATE:
4881 case BT_DPM_GET_DATA_TRANSFER_STATE:
4883 case BT_NETWORK_ACTIVATE:
4884 case BT_NETWORK_DEACTIVATE:
4885 case BT_NETWORK_CONNECT:
4886 case BT_NETWORK_DISCONNECT:
4887 case BT_NETWORK_SERVER_DISCONNECT:
4889 case BT_GATT_GET_PRIMARY_SERVICES:
4890 #ifdef TIZEN_GATT_CLIENT
4891 case BT_GATT_GET_SERVICE_PROPERTIES: /* GATT Client */
4892 case BT_GATT_GET_CHARACTERISTIC_PROPERTIES: /* GATT Client */
4893 case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION: /* GATT Client */
4895 case BT_GATT_DISCOVER_CHARACTERISTICS:
4896 case BT_GATT_SET_PROPERTY_REQUEST:
4897 case BT_GATT_READ_CHARACTERISTIC:
4898 #ifdef TIZEN_GATT_CLIENT
4899 case BT_GATT_READ_DESCRIPTOR_VALUE: /* GATT Client */
4900 case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: /* GATT Client */
4901 case BT_GATT_ACQUIRE_WRITE:
4902 case BT_GATT_WRITE_DESCRIPTOR_VALUE: /* GATT Client */
4903 case BT_GATT_WATCH_CHARACTERISTIC: /* GATT Client */
4904 case BT_GATT_CLIENT_REGISTER: /* GATT Client */
4905 case BT_GATT_CLIENT_UNREGISTER: /* GATT Client */
4907 case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
4908 case BT_GATT_REGISTER_APPLICATION:
4909 case BT_GATT_REGISTER_SERVICE:
4910 case BT_GATT_SEND_RESPONSE:
4912 case BT_GATT_SERVER_REGISTER:
4913 case BT_GATT_SERVER_ADD_SERVICE:
4914 case BT_GATT_SERVER_ADD_CHARACTERISTIC:
4915 case BT_GATT_SERVER_ADD_DESCRIPTOR:
4916 case BT_GATT_SERVER_START_SERVICE:
4917 case BT_GATT_SERVER_STOP_SERVICE:
4918 case BT_GATT_SERVER_DELETE_SERVICE:
4919 case BT_GATT_SERVER_SEND_RESPONSE:
4920 case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE:
4921 case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE:
4922 case BT_GATT_SERVER_SEND_INDICATION:
4923 case BT_GATT_SERVER_UPDATE_VALUE:
4924 case BT_GATT_SERVER_DEREGISTER:
4926 case BT_REQ_ATT_MTU:
4927 case BT_PBAP_CONNECT:
4928 case BT_PBAP_DISCONNECT:
4929 case BT_PBAP_GET_PHONEBOOK_SIZE:
4930 case BT_PBAP_GET_PHONEBOOK:
4931 case BT_PBAP_GET_LIST:
4932 case BT_PBAP_PULL_VCARD:
4933 case BT_PBAP_PHONEBOOK_SEARCH:
4935 case BT_RFCOMM_LISTEN_AND_ACCEPT:
4936 case BT_MESH_NETWORK_CREATE:
4937 case BT_MESH_NETWORK_LOAD:
4938 case BT_MESH_NETWORK_SCAN:
4939 case BT_MESH_NETWORK_CANCEL_SCAN:
4940 case BT_MESH_NETWORK_SET_CAPABILITIES:
4941 case BT_MESH_NETWORK_PROVISION_DEVICE:
4942 case BT_MESH_AUTHENTICATION_REPLY:
4943 case BT_MESH_NETWORK_SET_NAME:
4944 case BT_MESH_NETWORK_ADD_NETKEY:
4945 case BT_MESH_NETWORK_DELETE_NETKEY:
4946 case BT_MESH_NETWORK_UPDATE_NETKEY:
4947 case BT_MESH_NETWORK_ADD_APPKEY:
4948 case BT_MESH_NETWORK_DELETE_APPKEY:
4949 case BT_MESH_NETWORK_UPDATE_APPKEY:
4950 case BT_MESH_NETWORK_GET_NETKEYS:
4951 case BT_MESH_NETWORK_GET_APPKEYS:
4952 case BT_MESH_NETWORK_GET_NODES:
4953 case BT_MESH_ELEMENT_GET_MODELS:
4954 case BT_MESH_NODE_BROWSE:
4955 case BT_MESH_NODE_GET_VENDOR_FEATURES:
4956 case BT_MESH_NODE_CONFIGURE_KEY:
4957 case BT_MESH_NODE_TTL_EXECUTE:
4958 case BT_MESH_NODE_GET_NETKEYS:
4959 case BT_MESH_NODE_GET_APPKEYS:
4960 case BT_MESH_MODEL_CONFIGURE_APPKEY:
4961 case BT_MESH_MODEL_GET_APPKEY_LIST:
4962 case BT_MESH_NETWORK_CREATE_GROUP:
4963 case BT_MESH_MODEL_CONFIG_GROUP_SUB:
4964 case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB:
4965 case BT_MESH_MODEL_SET_PUBLICATION:
4966 case BT_MESH_MODEL_GET_PUBLICATION:
4967 case BT_MESH_NETWORK_GET_GROUPS:
4969 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
4970 BT_PRIVILEGE_PUBLIC);
4972 BT_INFO("Client Credentials [%s]", client_creds);
4973 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
4974 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PUBLIC);
4978 /* Need to check mediastorage privilege */
4979 if (function_name == BT_PBAP_GET_PHONEBOOK ||
4980 function_name == BT_PBAP_PULL_VCARD) {
4981 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
4982 MEDIASTORAGE_PRIVILEGE);
4984 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
4985 BT_ERR("Fail to access: %s", MEDIASTORAGE_PRIVILEGE);
4991 case BT_ENABLE_ADAPTER:
4992 case BT_DISABLE_ADAPTER:
4993 case BT_RESET_ADAPTER:
4994 case BT_RECOVER_ADAPTER:
4995 case BT_BATTERY_READ_DATA:
4996 case BT_ENABLE_ADAPTER_LE:
4997 case BT_DISABLE_ADAPTER_LE:
4998 case BT_SET_CONNECTABLE:
4999 case BT_SET_DISCOVERABLE_MODE:
5000 case BT_ADD_WHITE_LIST:
5001 case BT_REMOVE_WHITE_LIST:
5002 case BT_CLEAR_WHITE_LIST:
5003 case BT_SET_MANUFACTURER_DATA:
5005 case BT_CANCEL_SEARCH_SERVICE:
5006 case BT_ENABLE_RSSI:
5007 case BT_DISCONNECT_DEVICE:
5009 case BT_RFCOMM_ACCEPT_CONNECTION:
5010 case BT_RFCOMM_REJECT_CONNECTION:
5011 case BT_RFCOMM_LISTEN:
5013 case BT_HID_ENABLE_BARCODE_FEATURE:
5015 case BT_AVRCP_CONTROL_GET_PROPERTY:
5016 case BT_AVRCP_GET_TRACK_INFO:
5017 case BT_AVRCP_TRANSPORT_SET_PROPERTY:
5018 case BT_AVRCP_HANDLE_CONTROL_TO_DEST:
5020 case BT_SET_CONTENT_PROTECT:
5021 case BT_BOND_DEVICE_BY_TYPE:
5022 case BT_SET_LE_PRIVACY:
5023 case BT_SET_LE_STATIC_RANDOM_ADDRESS:
5024 case BT_LE_CONN_UPDATE:
5025 case BT_UPDATE_LE_CONNECTION_MODE:
5026 case BT_GET_DEVICE_IDA:
5027 case BT_LE_READ_MAXIMUM_DATA_LENGTH:
5028 case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
5029 case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH:
5030 case BT_LE_SET_DATA_LENGTH:
5031 case BT_LE_OOB_READ_LOCAL_DATA:
5032 case BT_LE_OOB_ADD_REMOTE_DATA:
5034 case BT_GET_GATT_DATA_BATCHING_AVAILABLE_PACKETS:
5035 case BT_ENABLE_GATT_DATA_BATCHING:
5036 case BT_DISABLE_GATT_DATA_BATCHING:
5038 case BT_LE_IPSP_INIT:
5039 case BT_LE_IPSP_DEINIT:
5040 case BT_LE_IPSP_CONNECT:
5041 case BT_LE_IPSP_DISCONNECT:
5042 case BT_PXP_MONITOR_SET_PROPERTY:
5043 case BT_PXP_MONITOR_GET_PROPERTY:
5044 case BT_PXP_MONITOR_GET_SUPPORTED_SERIVCES:
5045 case BT_PXP_REPORTER_REGISTER:
5046 case BT_PXP_REPORTER_UNREGISTER:
5047 case BT_PXP_REPORTER_GET_PROPERTY:
5050 case BT_TDS_PROVIDER_REGISTER:
5051 case BT_TDS_PROVIDER_UNREGISTER:
5052 case BT_TDS_PROVIDER_SET_MANUF_DATA:
5053 case BT_TDS_PROVIDER_CREATE:
5054 case BT_TDS_PROVIDER_DESTROY:
5055 case BT_TDS_PROVIDER_SET_TRANSPORT_DATA:
5056 case BT_TDS_SEND_ACTIVATION_RESPONSE:
5057 case BT_TDS_READ_TRANSPORT_DATA:
5058 case BT_TDS_ENABLE_CONTROL_POINT:
5059 case BT_TDS_ACTIVATE_CONTROL_POINT:
5062 case BT_OTP_SERVER_INIT:
5063 case BT_OTP_SERVER_DEINIT:
5064 case BT_OTP_READ_VALUE:
5065 case BT_OTP_ENABLE_NOTIFICATION:
5066 case BT_OTP_WRITE_VALUE:
5067 case BT_LE_OTC_CONNECT:
5068 case BT_LE_OTC_DISCONNECT:
5070 case BT_MAP_CREATE_SESSION:
5071 case BT_MAP_DESTROY_SESSION:
5072 case BT_MAP_SET_FOLDER:
5073 case BT_MAP_LIST_FOLDERS:
5074 case BT_MAP_LIST_FILTER_FIELDS:
5075 case BT_MAP_LIST_MESSAGES:
5076 case BT_MAP_UPDATE_INBOX:
5077 case BT_MAP_PUSH_MESSAGE:
5078 case BT_MAP_GET_MESSAGE:
5080 ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
5081 BT_PRIVILEGE_PLATFORM);
5083 if (ret_val != CYNARA_API_ACCESS_ALLOWED) {
5084 BT_ERR("Fail to access: %s", BT_PRIVILEGE_PLATFORM);
5089 case BT_CHECK_ADAPTER:
5092 case BT_GET_LOCAL_NAME:
5093 case BT_GET_LOCAL_ADDRESS:
5094 case BT_GET_LOCAL_VERSION:
5095 case BT_IS_SERVICE_USED:
5096 case BT_GET_DISCOVERABLE_MODE:
5097 case BT_GET_DISCOVERABLE_TIME:
5098 case BT_IS_DISCOVERYING:
5099 case BT_IS_LE_DISCOVERYING:
5100 case BT_IS_CONNECTABLE:
5101 case BT_GET_CONNECTABLE:
5102 case BT_GET_BONDED_DEVICES:
5103 case BT_GET_PROFILE_CONNECTED_DEVICES:
5104 case BT_GET_BONDED_DEVICE:
5105 case BT_PASSKEY_REPLY:
5106 case BT_PASSKEY_CONFIRMATION_REPLY:
5107 case BT_GET_IS_ALIAS_SET:
5108 case BT_IS_DEVICE_CONNECTED:
5109 case BT_GET_CONNECTED_LINK_TYPE:
5110 case BT_SET_PROFILE_TRUSTED:
5111 case BT_GET_PROFILE_TRUSTED:
5112 case BT_GET_SPEAKER_GAIN:
5113 case BT_SET_SPEAKER_GAIN:
5114 case BT_RFCOMM_CLIENT_IS_CONNECTED:
5115 case BT_RFCOMM_IS_UUID_AVAILABLE:
5116 case BT_GET_ADVERTISING_DATA:
5117 case BT_GET_SCAN_RESPONSE_DATA:
5118 case BT_IS_ADVERTISING:
5119 case BT_IS_LE_2M_PHY_SUPPORTED:
5120 case BT_IS_LE_CODED_PHY_SUPPORTED:
5121 case BT_REGISTER_SCAN_FILTER:
5122 case BT_IS_SCAN_FILTER_SUPPORTED:
5123 case BT_GET_ATT_MTU:
5125 case BT_OBEX_SERVER_ALLOCATE:
5126 case BT_OBEX_SERVER_DEALLOCATE:
5127 case BT_OBEX_SERVER_IS_ACTIVATED:
5128 case BT_OPP_GET_TRANSFER_PROGRESS:
5129 /* Non-privilege control */
5132 BT_ERR("Unknown function!");
5137 if (function_name >= BT_FUNC_MESH_BASE) {
5138 BT_INFO("MESH Function called");
5139 char app_id[256] = { 0, };
5141 if (BLUETOOTH_ERROR_NONE == __bt_service_get_requester_app_id(unique_name,
5142 app_id, sizeof(app_id))) {
5143 requester_unique_creds = g_strdup(app_id);
5145 BT_DBG("Requester app_id not found, use client creds");
5146 requester_unique_creds = g_strdup(client_creds);
5148 BT_DBG("Requester unique_creds: %s", requester_unique_creds);
5150 BT_INFO("Non MESH Function called client creds [%s]", client_creds);
5162 GDBusNodeInfo *__bt_service_create_method_node_info
5163 (const gchar *introspection_data)
5166 GDBusNodeInfo *node_info = NULL;
5168 if (introspection_data == NULL) {
5169 BT_ERR("Introspection XML not present");
5173 node_info = g_dbus_node_info_new_for_xml(introspection_data, &err);
5176 BT_ERR("Unable to create node: %s", err->message);
5177 g_clear_error(&err);
5182 int __bt_service_register_object(GDBusConnection *conn,
5183 GDBusNodeInfo *node_info, gboolean reg)
5185 static guint service_id = 0;
5186 GError *error = NULL;
5189 if (node_info == NULL)
5192 service_id = g_dbus_connection_register_object(conn,
5194 node_info->interfaces[0],
5196 NULL, NULL, &error);
5197 if (service_id == 0)
5200 if (service_id > 0) {
5201 g_dbus_connection_unregister_object(conn,
5210 static void __name_owner_changed(GDBusConnection *connection,
5211 const gchar *sender_name,
5212 const gchar *object_path,
5213 const gchar *interface_name,
5214 const gchar *signal_name,
5215 GVariant *parameters,
5218 const char *name = NULL;
5219 const char *old_owner = NULL;
5220 const char *new_owner = NULL;
5222 g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner);
5223 if (*new_owner != '\0')
5226 _bt_check_hdp_app_termination(name);
5228 /* Advertising App Termination */
5229 _bt_check_adv_app_termination(name);
5231 /* Check if le_scanning app is terminated */
5232 _bt_check_le_scanner_app_termination(name);
5234 /* Check if RFCOMM app is terminated */
5235 _bt_rfcomm_check_termination(name);
5238 static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
5239 const gchar *name, gpointer user_data)
5241 GDBusNodeInfo *node_info = NULL;
5243 BT_INFO("bus acquired");
5245 ret_if(connection == NULL);
5247 node_info = __bt_service_create_method_node_info(
5248 bt_service_introspection_xml);
5249 ret_if(node_info == NULL);
5251 __bt_service_register_object(connection, node_info, TRUE);
5252 g_dbus_node_info_unref(node_info);
5254 bt_service_conn = connection;
5257 static void __bt_service_name_acquired_handler(GDBusConnection *connection,
5258 const gchar *name, gpointer user_data)
5260 BT_INFO("name acquired");
5261 name_acquired = TRUE;
5264 static void __bt_service_name_lost_handler(GDBusConnection *connection,
5265 const gchar *name, gpointer user_data)
5267 BT_INFO("name lost");
5268 name_acquired = FALSE;
5271 gboolean _is_name_acquired(void)
5273 return name_acquired;
5276 void _bt_service_unref_connection(void)
5280 if (bt_service_conn) {
5281 g_dbus_connection_flush_sync(bt_service_conn, NULL, NULL);
5282 g_object_unref(bt_service_conn);
5283 bt_service_conn = NULL;
5289 int _bt_service_register(void)
5291 GDBusConnection *conn;
5294 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
5295 retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
5296 bt_service_conn = conn;
5298 owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
5300 G_BUS_NAME_OWNER_FLAGS_NONE,
5301 __bt_service_bus_acquired_handler,
5302 __bt_service_name_acquired_handler,
5303 __bt_service_name_lost_handler,
5305 BT_DBG("owner_id is [%d]", owner_id);
5309 /* Subscribe for name owner changed signal */
5310 owner_sig_id = g_dbus_connection_signal_subscribe(conn,
5311 BT_FREEDESKTOP_SERVICE, BT_FREEDESKTOP_INTERFACE,
5312 BT_NAME_OWNER_CHANGED, NULL, NULL, G_DBUS_SIGNAL_FLAGS_NONE,
5313 __name_owner_changed, NULL, NULL);
5314 BT_INFO("owner_sig_id: %d", owner_sig_id);
5316 return BLUETOOTH_ERROR_NONE;
5319 if (bt_service_conn) {
5320 g_object_unref(bt_service_conn);
5321 bt_service_conn = NULL;
5324 return BLUETOOTH_ERROR_INTERNAL;
5327 void _bt_service_unregister(void)
5329 if (bt_service_conn) {
5330 sd_notify(0, "STOPPING=1");
5332 if (owner_sig_id > 0) {
5333 g_dbus_connection_signal_unsubscribe(
5334 bt_service_conn, owner_sig_id);
5339 g_bus_unown_name(owner_id);
5343 __bt_service_register_object(bt_service_conn, NULL, FALSE);
5347 int _bt_service_cynara_init(void)
5350 char err_msg[256] = {0, };
5352 retv_if(p_cynara != NULL, BLUETOOTH_ERROR_ALREADY_INITIALIZED);
5354 result = cynara_initialize(&p_cynara, conf);
5356 if (result != CYNARA_API_SUCCESS) {
5357 cynara_strerror(result, err_msg, sizeof(err_msg));
5358 BT_ERR("Fail to initialize cynara: [%s]", err_msg);
5359 return BLUETOOTH_ERROR_INTERNAL;
5362 return BLUETOOTH_ERROR_NONE;
5365 void _bt_service_cynara_deinit(void)
5368 char err_msg[256] = {0, };
5370 ret_if(p_cynara == NULL);
5372 result = cynara_finish(p_cynara);
5374 if (result != CYNARA_API_SUCCESS) {
5375 cynara_strerror(result, err_msg, sizeof(err_msg));
5376 BT_ERR("Fail to finish cynara: [%s]", err_msg);
5384 void _bt_service_method_return(GDBusMethodInvocation *invocation,
5385 GArray *out_param, int result)
5389 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5390 out_param->data, out_param->len, TRUE, NULL, NULL);
5392 g_dbus_method_invocation_return_value(invocation,
5393 g_variant_new("(iv)", result, out_var));
5396 void _bt_service_method_return_with_unix_fd_list(GDBusMethodInvocation *invocation,
5397 GArray *out_param, int result, GUnixFDList *fd_list)
5401 out_var = g_variant_new_from_data((const GVariantType *)"ay",
5402 out_param->data, out_param->len, TRUE, NULL, NULL);
5404 g_dbus_method_invocation_return_value_with_unix_fd_list(invocation,
5405 g_variant_new("(iv)", result, out_var), fd_list);