Porting flight mode logic to tizen5.5
[platform/core/connectivity/bluetooth-frwk.git] / bt-service-adaptation / services / bt-request-handler.c
index a5ad048..a6a05e2 100644 (file)
@@ -203,6 +203,7 @@ static gboolean __bt_is_sync_function(int service_function)
                        || service_function == BT_GET_IS_ALIAS_SET
                        || service_function == BT_GET_CONNECTED_LINK_TYPE
                        || service_function == BT_IS_SERVICE_USED
+                       || service_function == BT_RFCOMM_LISTEN_AND_ACCEPT
                        || service_function == BT_RFCOMM_LISTEN
                        || service_function == BT_HDP_REGISTER_SINK_APP
                        || service_function == BT_HDP_UNREGISTER_SINK_APP
@@ -231,8 +232,7 @@ static gboolean __bt_is_sync_function(int service_function)
                        || service_function == BT_GATT_WATCH_CHARACTERISTIC
                        || service_function == BT_GATT_ACQUIRE_WRITE
 #endif
-                       || service_function == BT_AUDIO_SELECT_ROLE
-                       || service_function == BT_OBEX_SERVER_ACCEPT_CONNECTION)
+                       || service_function == BT_AUDIO_SELECT_ROLE)
                return TRUE;
        else
                return FALSE;
@@ -1312,6 +1312,25 @@ int __bt_bluez_request(int function_name,
                result = BLUETOOTH_ERROR_NONE;
                break;
        }
+       case BT_RFCOMM_LISTEN_AND_ACCEPT: {
+               char *uuid;
+               int socket_fd = -1;
+
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+               uuid = (char *)g_variant_get_data(in_param1);
+
+               result = _bt_rfcomm_socket_listen(sender, uuid, true);
+               if (result > 0) {
+                       BT_ERR("BT_RFCOMM_LISTEN_AND_ACCEPT success, save context");
+
+                       result = BLUETOOTH_ERROR_NONE;
+                       _bt_save_invocation_context(context,
+                                       result, sender, function_name, NULL);
+               } else {
+                       g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
+               }
+               break;
+       }
        case BT_RFCOMM_LISTEN: {
                char *uuid;
                int socket_fd = -1;
@@ -1319,7 +1338,7 @@ int __bt_bluez_request(int function_name,
                sender = (char *)g_dbus_method_invocation_get_sender(context);
                uuid = (char *)g_variant_get_data(in_param1);
 
-               result = _bt_rfcomm_socket_listen(sender, uuid);
+               result = _bt_rfcomm_socket_listen(sender, uuid, false);
                if (result > 0) {
                        BT_ERR("BT_RFCOMM_LISTEN success, save context");
 
@@ -1614,6 +1633,17 @@ int __bt_bluez_request(int function_name,
                result = _bt_avrcp_control_cmd(key_code);
                break;
        }
+       case BT_AVRCP_HANDLE_CONTROL_TO_DEST: {
+               int key_code;
+               bluetooth_device_address_t address = { { 0 } };
+
+               __bt_service_get_parameters(in_param1, &key_code, sizeof(int));
+               __bt_service_get_parameters(in_param2,
+                                               &address, sizeof(bluetooth_device_address_t));
+
+               result = _bt_avrcp_control_cmd_to_dest(key_code, &address);
+               break;
+       }
        case BT_AVRCP_CONTROL_SET_PROPERTY: {
                int type;
                unsigned int value;
@@ -2446,6 +2476,7 @@ int __bt_bluez_request(int function_name,
                /* Add socket fd to unix_fd_list */
                fd_list = g_unix_fd_list_new();
                g_unix_fd_list_append(fd_list, fd, &error);
+               g_assert_no_error(error);
 
                _bt_service_method_return_with_unix_fd_list(
                                context, *out_param1, result, fd_list);
@@ -2705,6 +2736,10 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param4, &is_indicate,
                                sizeof(gboolean));
 
+#ifdef TIZEN_FEATURE_BT_GATT_CLIENT_FD_DISABLE
+               goto normal;
+#endif
+
                if (is_indicate == false) {
                        result   = _bt_gatt_acquire_notify(&param , &fd, &mtu);
                        if (BLUETOOTH_ERROR_NONE == result && fd > -1) {
@@ -2953,7 +2988,7 @@ int __bt_obexd_request(int function_name,
                BT_DBG("BT_OPP_PUSH_FILES");
                int i;
                bluetooth_device_address_t address = { {0} };
-               bt_file_path_t path;
+               bt_file_path_t *path;
                char **file_path;
                int file_count;
                GArray *param2;
@@ -2969,8 +3004,8 @@ int __bt_obexd_request(int function_name,
                __bt_fill_garray_from_variant(in_param2, param2);
 
                for (i = 0; i < file_count; i++) {
-                       path = g_array_index(param2, bt_file_path_t, i);
-                       file_path[i] = g_strdup(path.path);
+                       path = &g_array_index(param2, bt_file_path_t, i);
+                       file_path[i] = g_strdup(path->path);
                }
                BT_DBG("_bt_opp_client_push_files");
                result = _bt_opp_client_push_files(request_id, context,
@@ -3414,11 +3449,10 @@ int __bt_core_request(int function_name,
                        BT_DBG("Already enabled");
                        result = BLUETOOTH_ERROR_DEVICE_ALREADY_ENABLED;
                } else {
+                       BT_INFO("Start Enabling Adapter");
                        _bt_adapter_set_status(BT_ACTIVATING);
-
-#if TODO_40 /* Need to add this function */
                        _bt_adapter_start_enable_timer();
-#endif
+                       BT_INFO("Returning with no error");
                        result = BLUETOOTH_ERROR_NONE;
                }
 
@@ -3456,9 +3490,8 @@ int __bt_core_request(int function_name,
                } else {
                        _bt_adapter_set_le_status(BT_LE_ACTIVATING);
 
-#if TODO_40 /* Need to add this function */
                        _bt_adapter_start_le_enable_timer();
-#endif
+
                        result = BLUETOOTH_ERROR_NONE;
                }
 
@@ -3546,6 +3579,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_CANCEL_DISCOVERY:
        case BT_OOB_ADD_REMOTE_DATA:
        case BT_OOB_REMOVE_REMOTE_DATA:
+       case BT_OOB_READ_LOCAL_DATA:
        case BT_SET_ADVERTISING:
        case BT_SET_CUSTOM_ADVERTISING:
        case BT_SET_ADVERTISING_PARAMETERS:
@@ -3708,6 +3742,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GATT_SERVER_UPDATE_VALUE:
        case BT_GATT_SERVER_DEREGISTER:
 #endif
+       case BT_REQ_ATT_MTU:
        case BT_PBAP_CONNECT:
        case BT_PBAP_DISCONNECT:
        case BT_PBAP_GET_PHONEBOOK_SIZE:
@@ -3716,6 +3751,8 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_PBAP_PULL_VCARD:
        case BT_PBAP_PHONEBOOK_SEARCH:
 
+       case BT_RFCOMM_LISTEN_AND_ACCEPT:
+
        ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
                                                BT_PRIVILEGE_PUBLIC);
 
@@ -3762,7 +3799,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_AVRCP_CONTROL_GET_PROPERTY:
        case BT_AVRCP_GET_TRACK_INFO:
        case BT_AVRCP_TRANSPORT_SET_PROPERTY:
-
+       case BT_AVRCP_HANDLE_CONTROL_TO_DEST:
 
        case BT_SET_CONTENT_PROTECT:
        case BT_BOND_DEVICE_BY_TYPE:
@@ -3770,15 +3807,12 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_SET_LE_STATIC_RANDOM_ADDRESS:
        case BT_LE_CONN_UPDATE:
        case BT_UPDATE_LE_CONNECTION_MODE:
-       case BT_REQ_ATT_MTU:
        case BT_GET_DEVICE_IDA:
        case BT_LE_READ_MAXIMUM_DATA_LENGTH:
        case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
        case BT_LE_READ_HOST_SUGGESTED_DATA_LENGTH:
        case BT_LE_SET_DATA_LENGTH:
 
-       case BT_GET_ATT_MTU:
-
        case BT_LE_IPSP_INIT:
        case BT_LE_IPSP_DEINIT:
        case BT_LE_IPSP_CONNECT:
@@ -3854,7 +3888,6 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GET_PROFILE_TRUSTED:
        case BT_GET_SPEAKER_GAIN:
        case BT_SET_SPEAKER_GAIN:
-       case BT_OOB_READ_LOCAL_DATA:
        case BT_RFCOMM_CLIENT_IS_CONNECTED:
        case BT_RFCOMM_IS_UUID_AVAILABLE:
        case BT_GET_ADVERTISING_DATA:
@@ -3866,6 +3899,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_UNREGISTER_SCAN_FILTER:
        case BT_UNREGISTER_ALL_SCAN_FILTERS:
        case BT_IS_SCAN_FILTER_SUPPORTED:
+       case BT_GET_ATT_MTU:
 
        case BT_OBEX_SERVER_ALLOCATE:
        case BT_OBEX_SERVER_DEALLOCATE: