Modify the log level
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / services / bt-request-handler.c
index ad3562b..5a2f90a 100644 (file)
@@ -62,6 +62,8 @@
 
 #include "bt-service-battery-monitor.h"
 
+#include "bt-service-l2cap-le.h"
+
 #ifdef TIZEN_FEATURE_BT_PAN_NAP
 #include "bt-service-network.h"
 #endif
 /* For maintaining Application Sync API call requests */
 static GSList *invocation_list = NULL;
 
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+struct nspid_t {
+       char *unique_name;
+       gboolean is_container;
+};
+static GSList *nspid_list = NULL;
+#endif
+
 static GDBusConnection *bt_service_conn;
 static guint owner_id = 0;
 static guint owner_sig_id = 0;
@@ -239,7 +249,10 @@ static gboolean __bt_is_sync_function(int service_function)
                        || service_function == BT_MESH_NETWORK_UPDATE_NETKEY
                        || service_function == BT_MESH_NETWORK_ADD_APPKEY
                        || service_function == BT_MESH_NETWORK_DELETE_APPKEY
-                       || service_function == BT_MESH_NETWORK_UPDATE_APPKEY)
+                       || service_function == BT_MESH_NETWORK_UPDATE_APPKEY
+                       || service_function == BT_L2CAP_LE_LISTEN_AND_ACCEPT
+                       || service_function == BT_L2CAP_LE_LISTEN
+                       || service_function == BT_REQ_ATT_MTU)
                return TRUE;
        else
                return FALSE;
@@ -329,6 +342,7 @@ static void __bt_service_method(GDBusConnection *connection,
                GVariant *temp = NULL;
                int result = 0;
                int request_id = -1;
+               const char *unique_name = NULL;
 
                g_variant_get(parameters, "(iii@ay@ay@ay@ay@ay)", &service_type,
                                &service_function, &request_type,
@@ -336,10 +350,22 @@ static void __bt_service_method(GDBusConnection *connection,
 
                out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
 
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+               /* In case of the bt-service in container, only privilege check request is coming
+                * from the bt-service in host. At this time, the original sender's privilege
+                * should be checked not bt-service's privilege */
+               if (_bt_service_is_container() == TRUE)
+                       unique_name = (const char *)g_variant_get_data(param1);
+               else
+                       unique_name = sender;
+#else
+               unique_name = sender;
+#endif
+
                if (service_type == BT_CORE_SERVICE) {
                        BT_DBG("No need to check privilege from bt-core");
                } else if (__bt_service_check_privilege(service_function,
-                                       service_type, (const char *)sender) == FALSE) {
+                                       service_type, unique_name) == FALSE) {
                        BT_ERR("Client don't have the privilege to excute this function");
                        result = BLUETOOTH_ERROR_PERMISSION_DEINED;
                        goto fail;
@@ -932,7 +958,7 @@ int __bt_bluez_request(int function_name,
               result = _bt_set_le_privacy(set_privacy);
               break;
        }
-       case BT_ADD_WHITE_LIST: {
+       case BT_ADD_ALLOW_LIST: {
                bluetooth_device_address_t address = { {0} };
                int address_type = 0;
                bool is_add = true;
@@ -940,10 +966,10 @@ int __bt_bluez_request(int function_name,
                                &address, sizeof(bluetooth_device_address_t));
                __bt_service_get_parameters(in_param2,
                                &address_type, sizeof(int));
-               result = _bt_set_white_list(&address, address_type, is_add);
+               result = _bt_set_allow_list(&address, address_type, is_add);
                break;
        }
-       case BT_REMOVE_WHITE_LIST: {
+       case BT_REMOVE_ALLOW_LIST: {
                bluetooth_device_address_t address = { {0} };
                int address_type = 0;
                bool is_add = false;
@@ -951,7 +977,7 @@ int __bt_bluez_request(int function_name,
                                &address, sizeof(bluetooth_device_address_t));
                __bt_service_get_parameters(in_param2,
                                &address_type, sizeof(int));
-               result = _bt_set_white_list(&address, address_type, is_add);
+               result = _bt_set_allow_list(&address, address_type, is_add);
                break;
         }
        case BT_UPDATE_LE_CONNECTION_MODE: {
@@ -1197,105 +1223,106 @@ int __bt_bluez_request(int function_name,
                g_array_append_vals(*out_param1, &value, sizeof(int));
                break;
        }
-       case BT_DPM_ADD_DEVICES_BLACKLIST: {
+       case BT_DPM_ADD_DEVICES_BLOCKLIST: {
                bluetooth_device_address_t address = { {0} };
 
                __bt_service_get_parameters(in_param1, &address,
                        sizeof(bluetooth_device_address_t));
 
-               result = _bt_dpm_add_bluetooth_devices_to_blacklist(&address);
+               result = _bt_dpm_add_bluetooth_devices_to_blocklist(&address);
                break;
        }
-       case BT_DPM_ADD_DEVICES_WHITELIST: {
+       case BT_DPM_ADD_DEVICES_ALLOWLIST: {
                bluetooth_device_address_t address = { {0} };
 
                __bt_service_get_parameters(in_param1, &address,
                        sizeof(bluetooth_device_address_t));
 
-               result = _bt_dpm_add_bluetooth_devices_to_whitelist(&address);
+               result = _bt_dpm_add_bluetooth_devices_to_allowlist(&address);
                break;
        }
-       case BT_DPM_ADD_UUIDS_BLACKLIST: {
+       case BT_DPM_ADD_UUIDS_BLOCKLIST: {
                const char *uuid = NULL;
 
                uuid = g_variant_get_data(in_param1);
 
-               result = _bt_dpm_add_bluetooth_uuids_to_blacklist(uuid);
+               result = _bt_dpm_add_bluetooth_uuids_to_blocklist(uuid);
                break;
        }
-       case BT_DPM_ADD_UUIDS_WHITELIST: {
+       case BT_DPM_ADD_UUIDS_ALLOWLIST: {
                const char *uuid = NULL;
 
                uuid = g_variant_get_data(in_param1);
 
-               result = _bt_dpm_add_bluetooth_uuids_to_whitelist(uuid);
+               result = _bt_dpm_add_bluetooth_uuids_to_allowlist(uuid);
                break;
        }
-       case BT_DPM_CLEAR_DEVICES_BLACKLIST: {
-               result = _bt_dpm_clear_bluetooth_devices_from_blacklist();
+       case BT_DPM_CLEAR_DEVICES_BLOCKLIST: {
+               result = _bt_dpm_clear_bluetooth_devices_from_blocklist();
                break;
        }
-       case BT_DPM_CLEAR_DEVICES_WHITELIST: {
-               result = _bt_dpm_clear_bluetooth_devices_from_whitelist();
+       case BT_DPM_CLEAR_DEVICES_ALLOWLIST: {
+               result = _bt_dpm_clear_bluetooth_devices_from_allowlist();
                break;
        }
-       case BT_DPM_CLEAR_UUIDS_BLACKLIST: {
-               result = _bt_dpm_clear_bluetooth_uuids_from_blacklist();
+       case BT_DPM_CLEAR_UUIDS_BLOCKLIST: {
+               result = _bt_dpm_clear_bluetooth_uuids_from_blocklist();
                break;
        }
-       case BT_DPM_CLEAR_UUIDS_WHITELIST: {
-               result = _bt_dpm_clear_bluetooth_uuids_from_whitelist();
+       case BT_DPM_CLEAR_UUIDS_ALLOWLIST: {
+               result = _bt_dpm_clear_bluetooth_uuids_from_allowlist();
                break;
        }
-       case BT_DPM_REMOVE_DEVICE_BLACKLIST: {
+       case BT_DPM_REMOVE_DEVICE_BLOCKLIST: {
                bluetooth_device_address_t address = { {0} };
 
                __bt_service_get_parameters(in_param1, &address,
                        sizeof(bluetooth_device_address_t));
 
-               result = _bt_dpm_remove_bluetooth_devices_from_blacklist(&address);
+               result = _bt_dpm_remove_bluetooth_devices_from_blocklist(&address);
                break;
        }
-       case BT_DPM_REMOVE_DEVICE_WHITELIST: {
+       case BT_DPM_REMOVE_DEVICE_ALLOWLIST: {
                bluetooth_device_address_t address = { {0} };
 
                __bt_service_get_parameters(in_param1, &address,
                        sizeof(bluetooth_device_address_t));
 
-               result = _bt_dpm_remove_bluetooth_devices_from_whitelist(&address);
+               result = _bt_dpm_remove_bluetooth_devices_from_allowlist(&address);
                break;
        }
-       case BT_DPM_REMOVE_UUID_BLACKLIST: {
+       case BT_DPM_REMOVE_UUID_BLOCKLIST: {
                const char *uuid = NULL;
 
                uuid = g_variant_get_data(in_param1);
 
-               result = _bt_dpm_remove_bluetooth_uuids_from_blacklist(uuid);
+               result = _bt_dpm_remove_bluetooth_uuids_from_blocklist(uuid);
                break;
        }
-       case BT_DPM_REMOVE_UUID_WHITELIST: {
+       case BT_DPM_REMOVE_UUID_ALLOWLIST: {
                const char *uuid = NULL;
 
                uuid = g_variant_get_data(in_param1);
 
-               result = _bt_dpm_remove_bluetooth_uuids_from_whitelist(uuid);
+               result = _bt_dpm_remove_bluetooth_uuids_from_allowlist(uuid);
 
                break;
        }
-       case BT_DPM_GET_DEVICES_BLACKLIST: {
-               result = _bt_dpm_get_bluetooth_devices_from_blacklist(out_param1);
+       case BT_DPM_GET_DEVICES_BLOCKLIST: {
+               result = _bt_dpm_get_bluetooth_devices_from_blocklist(out_param1);
                break;
        }
-       case BT_DPM_GET_DEVICES_WHITELIST: {
-               result = _bt_dpm_get_bluetooth_devices_from_whitelist(out_param1);
+       case BT_DPM_GET_DEVICES_ALLOWLIST: {
+               result = _bt_dpm_get_bluetooth_devices_from_allowlist(out_param1);
+
                break;
        }
-       case BT_DPM_GET_UUIDS_BLACKLIST: {
-               result = _bt_dpm_get_bluetooth_uuids_from_blacklist(out_param1);
+       case BT_DPM_GET_UUIDS_BLOCKLIST: {
+               result = _bt_dpm_get_bluetooth_uuids_from_blocklist(out_param1);
                break;
        }
-       case BT_DPM_GET_UUIDS_WHITELIST: {
-               result = _bt_dpm_get_bluetooth_uuids_from_whitelist(out_param1);
+       case BT_DPM_GET_UUIDS_ALLOWLIST: {
+               result = _bt_dpm_get_bluetooth_uuids_from_allowlist(out_param1);
                break;
        }
        case BT_DPM_SET_ALLOW_OUTGOING_CALL: {
@@ -1451,6 +1478,7 @@ int __bt_bluez_request(int function_name,
 
                        conn_info.device_role = RFCOMM_ROLE_CLIENT;
                        conn_info.socket_fd = -1;
+                       memcpy(&conn_info.device_addr, &address, sizeof(bluetooth_device_address_t));
                        g_array_append_vals(*out_param1, &conn_info,
                                        sizeof(bluetooth_rfcomm_connection_t));
                } else {
@@ -1523,14 +1551,14 @@ int __bt_bluez_request(int function_name,
                char *address;
 
                address = (char *)g_variant_get_data(in_param1);
-               result = _bt_rfcomm_reply_conn_authorization(address, TRUE);
+               result = _bt_socket_reply_conn_authorization(address, TRUE);
                break;
        }
        case BT_RFCOMM_REJECT_CONNECTION: {
                char *address;
 
                address = (char *)g_variant_get_data(in_param1);
-               result = _bt_rfcomm_reply_conn_authorization(address, FALSE);
+               result = _bt_socket_reply_conn_authorization(address, FALSE);
                break;
        }
        case BT_RFCOMM_REMOVE_SOCKET: {
@@ -1986,7 +2014,7 @@ int __bt_bluez_request(int function_name,
                if (result == BLUETOOTH_ERROR_NONE) {
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
-                                       function_name, g_memdup(&type, sizeof(int)));
+                                       function_name, g_memdup2(&type, sizeof(int)));
                }
                break;
        }
@@ -2267,7 +2295,9 @@ int __bt_bluez_request(int function_name,
                int *adv_handle;
                bluetooth_advertising_data_t adv = { {0} };
                int length;
-               gboolean use_reserved_slot = FALSE;
+               bluetooth_le_slot_and_adv_type_t rs_at;
+               rs_at.is_legacy = TRUE;
+               rs_at.use_reserved_slot = FALSE;
 
                app = (char *)g_dbus_method_invocation_get_sender(context);
                adv_handle = g_malloc0(sizeof(int));
@@ -2279,9 +2309,9 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param2,
                                &adv, length);
                __bt_service_get_parameters(in_param4,
-                               &use_reserved_slot, sizeof(gboolean));
+                               &rs_at, sizeof(bluetooth_le_slot_and_adv_type_t));
                result = _bt_set_advertising_data(app, *adv_handle,
-                               &adv, length, use_reserved_slot);
+                               &adv, length, &rs_at);
                if (result != BLUETOOTH_ERROR_NONE) {
                        BT_ERR("Set Advertising data failed!!");
                        g_free(adv_handle);
@@ -2597,6 +2627,18 @@ int __bt_bluez_request(int function_name,
                }
                break;
        }
+       case BT_GATT_SERVER_SET_SERVICE_PERSISTENCE: {
+               char *uuid;
+               uuid = (char *)g_variant_get_data(in_param1);
+               result = _bt_gatt_server_set_service_persistence(uuid);
+               break;
+       }
+       case BT_GATT_SERVER_UNSET_SERVICE_PERSISTENCE: {
+               char *uuid;
+               uuid = (char *)g_variant_get_data(in_param1);
+               result = _bt_gatt_server_unset_service_persistence(uuid);
+               break;
+       }
        case BT_GATT_SERVER_SEND_RESPONSE: {
                bluetooth_gatt_server_response_params_t param;
                bluetooth_gatt_att_data_t data;
@@ -2714,6 +2756,68 @@ int __bt_bluez_request(int function_name,
                result = _bt_gatt_server_update_attribute_value(app, instance_id, &param);
                break;
        }
+       case BT_GATT_SERVER_READ_PHY: {
+               bluetooth_device_address_t address = { {0} };
+
+               sender = (char*)g_dbus_method_invocation_get_sender(context);
+
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+
+               result = _bt_gatt_server_read_phy(&address);
+               break;
+       }
+       case BT_GATT_SERVER_SET_PHY: {
+               bluetooth_device_address_t address = { {0} };
+               int tx_phy;
+               int rx_phy;
+               int phy_options;
+
+               sender = (char*)g_dbus_method_invocation_get_sender(context);
+
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &tx_phy, sizeof(int));
+               __bt_service_get_parameters(in_param3,
+                               &rx_phy, sizeof(int));
+               __bt_service_get_parameters(in_param4,
+                               &phy_options, sizeof(int));
+
+               result = _bt_gatt_server_set_phy(&address, tx_phy, rx_phy, phy_options);
+               break;
+       }
+       case BT_GATT_CLIENT_READ_PHY: {
+               bluetooth_device_address_t address = { {0} };
+
+               sender = (char*)g_dbus_method_invocation_get_sender(context);
+
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+
+               result = _bt_gatt_client_read_phy(&address);
+               break;
+       }
+       case BT_GATT_CLIENT_SET_PHY: {
+               bluetooth_device_address_t address = { {0} };
+               int tx_phy;
+               int rx_phy;
+               int phy_options;
+
+               sender = (char*)g_dbus_method_invocation_get_sender(context);
+
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param2,
+                               &tx_phy, sizeof(int));
+               __bt_service_get_parameters(in_param3,
+                               &rx_phy, sizeof(int));
+               __bt_service_get_parameters(in_param4,
+                               &phy_options, sizeof(int));
+
+               result = _bt_gatt_client_set_phy(&address, tx_phy, rx_phy, phy_options);
+               break;
+       }
        case BT_GET_ATT_MTU: {
                bluetooth_device_address_t address = { {0} };
                unsigned int mtu = 0;
@@ -2994,7 +3098,7 @@ int __bt_bluez_request(int function_name,
                        /* Save the informations to invocation */
                        _bt_save_invocation_context(context, result, sender,
                                        function_name,
-                                       (gpointer)g_memdup(&param, sizeof(bluetooth_gatt_client_svc_prop_info_t)));
+                                       (gpointer)g_memdup2(&param, sizeof(bluetooth_gatt_client_svc_prop_info_t)));
                }
                break;
        }
@@ -3012,7 +3116,7 @@ int __bt_bluez_request(int function_name,
                        /* Save the informations to invocation */
                        _bt_save_invocation_context(context, result, sender,
                                        function_name,
-                                       (gpointer)g_memdup(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
+                                       (gpointer)g_memdup2(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
                }
                break;
        }
@@ -3031,7 +3135,7 @@ int __bt_bluez_request(int function_name,
                        /* Save the informations to invocation */
                        _bt_save_invocation_context(context, result, sender,
                                        function_name,
-                                       (gpointer)g_memdup(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
+                                       (gpointer)g_memdup2(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
                }
                break;
        }
@@ -3050,7 +3154,7 @@ int __bt_bluez_request(int function_name,
                        /* Save the informations to invocation */
                        _bt_save_invocation_context(context, result, sender,
                                        function_name,
-                                       (gpointer)g_memdup(&param, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
+                                       (gpointer)g_memdup2(&param, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
                }
                break;
        }
@@ -3077,7 +3181,7 @@ int __bt_bluez_request(int function_name,
                        /* Save the informations to invocation */
                        _bt_save_invocation_context(context, result, sender,
                                        function_name,
-                                       (gpointer)g_memdup(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
+                                       (gpointer)g_memdup2(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
                }
                break;
        }
@@ -3103,7 +3207,7 @@ int __bt_bluez_request(int function_name,
                        /* Save the informations to invocation */
                        _bt_save_invocation_context(context, result, sender,
                                        function_name,
-                                       (gpointer)g_memdup(&param, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
+                                       (gpointer)g_memdup2(&param, sizeof(bluetooth_gatt_client_desc_prop_info_t)));
                }
                break;
        }
@@ -3161,7 +3265,7 @@ normal:
                        if (BLUETOOTH_ERROR_NONE == result) {
                                /* Save the informations to invocation */
                                _bt_save_invocation_context(context, result, sender, function_name,
-                                        (gpointer)g_memdup(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
+                                        (gpointer)g_memdup2(&param, sizeof(bluetooth_gatt_client_char_prop_info_t)));
                        }
                }
                break;
@@ -3368,6 +3472,28 @@ normal:
                g_array_append_vals(*out_param1, &is_coded_phy_supported, sizeof(gboolean));
                break;
        }
+       case BT_IS_LE_EXTENDED_ADVERTISING_SUPPORTED: {
+               gboolean is_extended_advertising_supported = FALSE;
+
+               is_extended_advertising_supported = _bt_is_le_extended_advertising_supported();
+               g_array_append_vals(*out_param1, &is_extended_advertising_supported,
+                       sizeof(gboolean));
+               break;
+       }
+       case BT_IS_LE_EXTENDED_SCAN_SUPPORTED: {
+               gboolean is_extended_scan_supported = FALSE;
+
+               is_extended_scan_supported = _bt_is_le_extended_scan_supported();
+               g_array_append_vals(*out_param1, &is_extended_scan_supported, sizeof(gboolean));
+               break;
+       }
+       case BT_LE_MAX_ADVERTISING_DATA_LEN: {
+               gint max_advertising_len = 0;
+
+               max_advertising_len = _bt_le_get_maximum_advertising_len();
+               g_array_append_vals(*out_param1, &max_advertising_len, sizeof(gint));
+               break;
+       }
        case BT_DISCONNECT_DEVICE: {
                bluetooth_device_address_t address = { {0} };
 
@@ -3377,6 +3503,24 @@ normal:
                result = _bt_disconnect_device(&address);
                break;
        }
+       case BT_SET_SCANNING_PHY: {
+               int phy = 0;
+               sender = (char*)g_dbus_method_invocation_get_sender(context);
+               __bt_service_get_parameters(in_param1, &phy, sizeof(int));
+
+               result = _bt_set_scan_phy(sender, phy);
+
+               break;
+       }
+       case BT_SET_SCANNING_ROLE: {
+               int role = 0;
+               sender = (char*)g_dbus_method_invocation_get_sender(context);
+               __bt_service_get_parameters(in_param1, &role, sizeof(int));
+
+               result = _bt_set_scan_role(sender, role);
+
+               break;
+       }
        case BT_REGISTER_SCAN_FILTER: {
                bluetooth_le_scan_filter_t scan_filter;
 
@@ -3542,7 +3686,7 @@ normal:
                        info = &g_array_index(param3,
                                        bluetooth_mesh_model_t, i);
 
-                       mod = g_memdup(info, sizeof(bluetooth_mesh_model_t));
+                       mod = g_memdup2(info, sizeof(bluetooth_mesh_model_t));
 
                        if (mod)
                                model_list = g_slist_append(model_list,
@@ -3602,7 +3746,7 @@ normal:
                } else {
                        BT_INFO("Mesh: Destroy Network scheduled: add invocation");
                        bluetooth_mesh_network_t *net =  \
-                                       g_memdup(&network, sizeof(bluetooth_mesh_network_t));
+                                       g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -3643,6 +3787,64 @@ normal:
                                sender, &network);
                break;
        }
+       case BT_MESH_NETWORK_JOIN: {
+               bluetooth_mesh_node_t node;
+               GSList *model_list = NULL;
+               int total_models = 0;
+               GArray *param2;
+               int i = 0;
+
+               memset(&node, 0x00, sizeof(bluetooth_mesh_node_t));
+               sender = (char*)g_dbus_method_invocation_get_sender(context);
+
+               __bt_service_get_parameters(in_param1,
+                               &node, sizeof(bluetooth_mesh_node_t));
+
+               param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
+               __bt_fill_garray_from_variant(in_param2, param2);
+
+               total_models = (param2->len) / sizeof(bluetooth_mesh_model_t);
+               for (i = 0; i < total_models; i++) {
+                       bluetooth_mesh_model_t *info = NULL;
+                       bluetooth_mesh_model_t *mod = NULL;
+                       info = &g_array_index(param2,
+                               bluetooth_mesh_model_t, i);
+                       mod = g_memdup2(info, sizeof(bluetooth_mesh_model_t));
+
+                       if (mod)
+                               model_list = g_slist_append(model_list,
+                                       (gpointer)mod);
+               }
+
+               BT_INFO("MESH: Network Join bt-service");
+               //result = BLUETOOTH_ERROR_NONE;
+               result = _bt_mesh_network_join(requester_unique_creds,
+                               sender, &node, model_list);
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
+                       BT_ERR("Mesh: Mesh Join Network schedule failed");
+                       g_slist_free_full(model_list, g_free);
+               }
+
+               BT_INFO("return of _bt_mesh_network_join : [%d]", result);
+               break;
+       }
+       case BT_MESH_CANCEL_JOIN: {
+               bluetooth_mesh_node_info_t node;
+               memset(&node, 0x00, sizeof(bluetooth_mesh_node_info_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &node, sizeof(bluetooth_mesh_node_info_t));
+
+               BT_INFO("Mesh: Cancel Join request");
+               result = _bt_mesh_cancel_join(requester_unique_creds,
+                               sender, &node);
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1,
+                                       &node, sizeof(bluetooth_mesh_node_t));
+               }
+               break;
+       }
        case BT_MESH_NETWORK_SCAN: {
                bluetooth_mesh_network_t network;
                bluetooth_mesh_scan_param_t param;
@@ -3663,7 +3865,7 @@ normal:
                                &network, sizeof(bluetooth_mesh_network_t));
                } else {
                        bluetooth_mesh_network_t *net =  \
-                                       g_memdup(&network, sizeof(bluetooth_mesh_network_t));
+                                       g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -3722,7 +3924,7 @@ normal:
                                sizeof(bluetooth_mesh_provisioning_request_t));
                } else {
                        bluetooth_mesh_provisioning_request_t *param =  \
-                               g_memdup(&req, sizeof(bluetooth_mesh_provisioning_request_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_provisioning_request_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -3771,7 +3973,7 @@ normal:
                if (result != BLUETOOTH_ERROR_NONE) {
                        g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
                } else {
-                       bluetooth_mesh_network_t *net =  g_memdup(&network, sizeof(bluetooth_mesh_network_t));
+                       bluetooth_mesh_network_t *net =  g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -3796,7 +3998,7 @@ normal:
                if (result != BLUETOOTH_ERROR_NONE) {
                        g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
                } else {
-                       bluetooth_mesh_network_t *net =  g_memdup(&network, sizeof(bluetooth_mesh_network_t));
+                       bluetooth_mesh_network_t *net =  g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -3821,7 +4023,7 @@ normal:
                if (result != BLUETOOTH_ERROR_NONE) {
                        g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
                } else {
-                       bluetooth_mesh_network_t *net =  g_memdup(&network, sizeof(bluetooth_mesh_network_t));
+                       bluetooth_mesh_network_t *net =  g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -3846,7 +4048,7 @@ normal:
                if (result != BLUETOOTH_ERROR_NONE) {
                        g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
                } else {
-                       bluetooth_mesh_network_t *net =  g_memdup(&network, sizeof(bluetooth_mesh_network_t));
+                       bluetooth_mesh_network_t *net =  g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -3874,7 +4076,7 @@ normal:
                if (result != BLUETOOTH_ERROR_NONE) {
                        g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
                } else {
-                       bluetooth_mesh_network_t *net =  g_memdup(&network, sizeof(bluetooth_mesh_network_t));
+                       bluetooth_mesh_network_t *net =  g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -3902,7 +4104,7 @@ normal:
                if (result != BLUETOOTH_ERROR_NONE) {
                        g_array_append_vals(*out_param1, &network, sizeof(bluetooth_mesh_network_t));
                } else {
-                       bluetooth_mesh_network_t *net =  g_memdup(&network, sizeof(bluetooth_mesh_network_t));
+                       bluetooth_mesh_network_t *net =  g_memdup2(&network, sizeof(bluetooth_mesh_network_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -3975,7 +4177,7 @@ normal:
                                sizeof(bluetooth_mesh_node_discover_t));
                } else {
                        bluetooth_mesh_node_discover_t *param = \
-                               g_memdup(&req, sizeof(bluetooth_mesh_node_discover_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_node_discover_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -3999,7 +4201,7 @@ normal:
                                &req, sizeof(bluetooth_mesh_node_features_t));
                } else {
                        bluetooth_mesh_node_features_t *param =  \
-                               g_memdup(&req, sizeof(bluetooth_mesh_node_features_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_node_features_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4024,7 +4226,7 @@ normal:
                                &req, sizeof(bluetooth_mesh_key_configure_t));
                } else {
                        bluetooth_mesh_key_configure_t *param = \
-                               g_memdup(&req, sizeof(bluetooth_mesh_key_configure_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_key_configure_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4048,7 +4250,7 @@ normal:
                        g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_node_ttl_info_t));
                } else {
                        bluetooth_mesh_node_ttl_info_t *param =  \
-                               g_memdup(&req, sizeof(bluetooth_mesh_node_ttl_info_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_node_ttl_info_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4072,7 +4274,7 @@ normal:
                        g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
                } else {
                        bluetooth_mesh_model_configure_t *param =  \
-                               g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4096,7 +4298,7 @@ normal:
                        g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_msg_t));
                } else {
                        bluetooth_mesh_model_msg_t *param =  \
-                               g_memdup(&req, sizeof(bluetooth_mesh_model_msg_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_model_msg_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4104,6 +4306,18 @@ normal:
                }
                break;
        }
+       case BT_MESH_MODEL_RESPONSE_MSG: {
+               bluetooth_mesh_model_msg_t req;
+               memset(&req, 0x00, sizeof(bluetooth_mesh_model_msg_t));
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_model_msg_t));
+
+               result = _bt_mesh_model_send_response(
+                               requester_unique_creds, sender, &req);
+               if (result != BLUETOOTH_ERROR_NONE)
+                       g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_msg_t));
+               break;
+       }
        case BT_MESH_NODE_GET_NETKEYS: {
                bluetooth_mesh_node_discover_t node;
                memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
@@ -4151,7 +4365,7 @@ normal:
                        g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
                } else {
                        bluetooth_mesh_model_configure_t *param = \
-                               g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4175,7 +4389,7 @@ normal:
                        g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
                } else {
                        bluetooth_mesh_model_configure_t *param =  \
-                               g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4243,7 +4457,7 @@ normal:
                                &req, sizeof(bluetooth_mesh_model_configure_t));
                } else {
                        bluetooth_mesh_model_configure_t *param =  \
-                               g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4267,7 +4481,7 @@ normal:
                        g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
                } else {
                        bluetooth_mesh_model_configure_t *param =  \
-                               g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4290,7 +4504,7 @@ normal:
                if (result != BLUETOOTH_ERROR_NONE) {
                        g_array_append_vals(*out_param1, &req, sizeof(bluetooth_mesh_model_configure_t));
                } else {
-                       bluetooth_mesh_model_configure_t *param = g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
+                       bluetooth_mesh_model_configure_t *param = g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4315,7 +4529,7 @@ normal:
                                &req, sizeof(bluetooth_mesh_model_configure_t));
                } else {
                        bluetooth_mesh_model_configure_t *param =  \
-                               g_memdup(&req, sizeof(bluetooth_mesh_model_configure_t));
+                               g_memdup2(&req, sizeof(bluetooth_mesh_model_configure_t));
 
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
                        _bt_save_invocation_context(context, result, sender,
@@ -4333,6 +4547,124 @@ normal:
                                requester_unique_creds, sender, &network, out_param1);
                break;
        }
+       case BT_L2CAP_LE_CLIENT_CONNECT: {
+               bluetooth_device_address_t address = { {0} };
+               int psm;
+
+               __bt_service_get_parameters(in_param1,
+                               &address, sizeof(bluetooth_device_address_t));
+
+               __bt_service_get_parameters(in_param2, &psm, sizeof(int));
+
+               result = _bt_l2cap_le_connect_using_psm(&address, psm);
+
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       bluetooth_l2cap_le_connection_t conn_info;
+
+                       BT_ERR("BT_L2CAP_LE_CLIENT_CONNECT failed, send error errcode %d", result);
+                       memset(&conn_info, 0x00, sizeof(bluetooth_l2cap_le_connection_t));
+                       conn_info.device_role = L2CAP_LE_ROLE_CLIENT;
+                       conn_info.socket_fd = -1;
+                       conn_info.psm = psm;
+                       memcpy(&conn_info.device_addr, &address, sizeof(bluetooth_device_address_t));
+                       g_array_append_vals(*out_param1, &conn_info,
+                                       sizeof(bluetooth_l2cap_le_connection_t));
+               } else {
+                       bluetooth_l2cap_le_connection_t *conn_info;
+
+                       BT_INFO("BT_L2CAP_LE_CLIENT_CONNECT success, save context");
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       conn_info = g_malloc0(sizeof(bluetooth_l2cap_le_connection_t));
+                       conn_info->socket_fd = -1;
+                       conn_info->device_role = L2CAP_LE_ROLE_CLIENT;
+                       conn_info->psm = psm;
+
+                       memcpy(&conn_info->device_addr, &address, sizeof(bluetooth_device_address_t));
+
+                       _bt_save_invocation_context(context, result, sender, function_name, (gpointer)conn_info);
+               }
+               break;
+       }
+       case BT_L2CAP_LE_SOCKET_DISCONNECT: {
+               /*
+                * Bluetooth L2CAP_LE socket disconnection will be done from bt-api, call to bt-service
+                * is only used for privilege check, so return BLUETOOTH_ERROR_NONE from here.
+                */
+               result = BLUETOOTH_ERROR_NONE;
+               break;
+       }
+       case BT_L2CAP_LE_SOCKET_WRITE: {
+               /*
+                * This call to bt-service is only used for privilege check, so return
+                * BLUETOOTH_ERROR_NONE from here.
+                */
+               result = BLUETOOTH_ERROR_NONE;
+               break;
+       }
+       case BT_L2CAP_LE_CREATE_SOCKET: {
+               /*
+                * This call to bt-service is only used for privilege check, so return
+                * BLUETOOTH_ERROR_NONE from here.
+                */
+               result = BLUETOOTH_ERROR_NONE;
+               break;
+       }
+       case BT_L2CAP_LE_LISTEN_AND_ACCEPT: {
+               int socket_fd = -1;
+               int psm;
+
+               __bt_service_get_parameters(in_param1, &psm, sizeof(int));
+
+               socket_fd = _bt_l2cap_le_socket_listen(psm, true);
+               if (socket_fd > 0) {
+                       result = BLUETOOTH_ERROR_NONE;
+                       sender = (char *)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context,
+                                       result, sender, function_name, NULL);
+               } else {
+                       g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
+               }
+               break;
+       }
+       case BT_L2CAP_LE_LISTEN: {
+               int socket_fd = -1;
+               int psm;
+
+               __bt_service_get_parameters(in_param1, &psm, sizeof(int));
+
+               socket_fd = _bt_l2cap_le_socket_listen(psm, false);
+               if (socket_fd > 0) {
+                       result = BLUETOOTH_ERROR_NONE;
+                       sender = (char *)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result,
+                                       sender, function_name, NULL);
+               } else {
+                       g_array_append_vals(*out_param1, &socket_fd, sizeof(int));
+               }
+               break;
+       }
+       case BT_L2CAP_LE_ACCEPT_CONNECTION: {
+               char *address;
+
+               address = (char *)g_variant_get_data(in_param1);
+               result = _bt_socket_reply_conn_authorization(address, TRUE);
+               break;
+       }
+       case BT_L2CAP_LE_REJECT_CONNECTION: {
+               char *address;
+
+               address = (char *)g_variant_get_data(in_param1);
+               result = _bt_socket_reply_conn_authorization(address, FALSE);
+               break;
+       }
+       case BT_L2CAP_LE_REMOVE_SOCKET: {
+               /*
+                * This call to bt-service is only used for privilege check, so return
+                * BLUETOOTH_ERROR_NONE from here.
+                */
+               result = BLUETOOTH_ERROR_NONE;
+               break;
+       }
        default:
                BT_INFO("UnSupported function [%d]", function_name);
                result = BLUETOOTH_ERROR_NOT_SUPPORT;
@@ -4935,6 +5267,156 @@ static int __bt_service_get_requester_app_id(const char *unique_name, char *app_
        return BLUETOOTH_ERROR_NONE;
 }
 
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+static void __bt_service_free_nspid(struct nspid_t *nspid)
+{
+       g_free(nspid->unique_name);
+       g_free(nspid);
+}
+
+static void __bt_service_cleanup_nspid_list(const char *unique_name)
+{
+       GSList *l;
+       struct nspid_t *nspid;
+
+       ret_if(unique_name == NULL);
+
+       for (l = nspid_list; l; l = g_slist_next(l)) {
+               nspid = l->data;
+               if (!nspid)
+                       continue;
+               if (!g_strcmp0(nspid->unique_name, unique_name)) {
+                       nspid_list = g_slist_remove(nspid_list, nspid);
+                       __bt_service_free_nspid(nspid);
+                       return;
+               }
+       }
+}
+
+static gboolean __bt_service_is_container_request(const char *unique_name)
+{
+       int ret;
+       pid_t pid;
+       char path[1024], buf[1024];
+       FILE *fp;
+       gboolean is_container = FALSE;
+       GSList *l;
+       struct nspid_t *nspid;
+
+       for (l = nspid_list; l; l = g_slist_next(l)) {
+               nspid = l->data;
+               if (!nspid)
+                       continue;
+               if (!g_strcmp0(nspid->unique_name, unique_name))
+                       return nspid->is_container;
+       }
+
+       ret = __bt_service_get_sender_pid(unique_name, &pid);
+       if (ret != BLUETOOTH_ERROR_NONE)
+               return FALSE;
+
+       sprintf(path, "/proc/%d/status", pid);
+       fp = fopen(path, "r");
+       if (fp == NULL) {
+               BT_ERR("fopen() failed. %d(%s)", errno, strerror(errno));
+               return FALSE;
+       }
+
+       while (fgets(buf, sizeof(buf), fp)) {
+               if (strstr(buf, "NSpid:")) {
+                       char *p = strchr(buf + 7, '\t'); /* find 2nd '\t' */
+                       if (p) {
+                               BT_DBG("caller is container process");
+                               is_container = TRUE;
+                               goto out;
+                       }
+                       break;
+               }
+       }
+
+out:
+       nspid = g_malloc0(sizeof(struct nspid_t));
+       nspid->unique_name = g_strdup(unique_name);
+       nspid->is_container = is_container;
+       nspid_list = g_slist_append(nspid_list, nspid);
+       fclose(fp);
+       return is_container;
+}
+#endif
+
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+static gboolean __bt_service_check_privilege_in_container(int function_name,
+               const char *unique_name)
+{
+       int result = BLUETOOTH_ERROR_NONE;
+       GError *error = NULL;
+       GDBusProxy *proxy;
+       GArray *in_param1, *in_param2, *in_param3, *in_param4, *in_param5;
+       GVariant *param1, *param2, *param3, *param4, *param5, *out_param;
+
+       proxy = _bt_get_container_proxy();
+       if (proxy == NULL) {
+               BT_ERR("container proxy is NULL");
+               return FALSE;
+       }
+
+       in_param1 = g_array_new(TRUE, TRUE, sizeof(gchar));
+       in_param2 = g_array_new(TRUE, TRUE, sizeof(gchar));
+       in_param3 = g_array_new(TRUE, TRUE, sizeof(gchar));
+       in_param4 = g_array_new(TRUE, TRUE, sizeof(gchar));
+       in_param5 = g_array_new(TRUE, TRUE, sizeof(gchar));
+
+       /* The sender's privilege should be checked not bt-service in container */
+       g_array_append_vals(in_param1, unique_name, strlen(unique_name));
+
+       param1 = g_variant_new_from_data((const GVariantType *)"ay",
+                       in_param1->data, in_param1->len, TRUE, NULL, NULL);
+       param2 = g_variant_new_from_data((const GVariantType *)"ay",
+                       in_param2->data, in_param2->len, TRUE, NULL, NULL);
+       param3 = g_variant_new_from_data((const GVariantType *)"ay",
+                       in_param3->data, in_param3->len, TRUE, NULL, NULL);
+       param4 = g_variant_new_from_data((const GVariantType *)"ay",
+                       in_param4->data, in_param4->len, TRUE, NULL, NULL);
+       param5 = g_variant_new_from_data((const GVariantType *)"ay",
+                       in_param5->data, in_param5->len, TRUE, NULL, NULL);
+
+       BT_DBG("This request is from container. Privilege will be checked in container. unique_name: %s", unique_name);
+
+       GVariant *ret = g_dbus_proxy_call_sync(proxy, "service_request",
+                       g_variant_new("(iii@ay@ay@ay@ay@ay)",
+                                       BT_CHECK_PRIVILEGE, function_name,
+                                       BT_SYNC_REQ, param1, param2,
+                                       param3, param4, param5),
+                       G_DBUS_CALL_FLAGS_NONE, -1,
+                       NULL, &error);
+       if (ret == NULL) {
+               BT_ERR("dBUS-RPC is failed");
+
+               if (error != NULL) {
+                       BT_ERR("D-Bus API failure: errCode[%x], message[%s]",
+                                       error->code, error->message);
+                       g_clear_error(&error);
+               } else {
+                       BT_ERR("error returned was NULL");
+               }
+
+               result = BLUETOOTH_ERROR_INTERNAL;
+       } else {
+               g_variant_get(ret, "(iv)", &result, &out_param);
+               g_variant_unref(out_param);
+               g_variant_unref(ret);
+       }
+
+       g_array_free(in_param1, TRUE);
+       g_array_free(in_param2, TRUE);
+       g_array_free(in_param3, TRUE);
+       g_array_free(in_param4, TRUE);
+       g_array_free(in_param5, TRUE);
+
+       return (result == BLUETOOTH_ERROR_NONE) ? TRUE : FALSE;
+}
+#endif
+
 gboolean __bt_service_check_privilege(int function_name,
                                        int service_type,
                                        const char *unique_name)
@@ -4951,6 +5433,12 @@ gboolean __bt_service_check_privilege(int function_name,
        retv_if(unique_name == NULL, FALSE);
        retv_if(bt_service_conn == NULL, FALSE);
 
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+       if (_bt_service_is_container() == FALSE)
+               if (__bt_service_is_container_request(unique_name) == TRUE)
+                       return __bt_service_check_privilege_in_container(function_name, unique_name);
+#endif
+
        ret_val = cynara_creds_get_default_client_method(&client_creds_method);
        if (ret_val != CYNARA_API_SUCCESS) {
                cynara_strerror(ret_val, err_msg, sizeof(err_msg));
@@ -4981,7 +5469,7 @@ gboolean __bt_service_check_privilege(int function_name,
                return FALSE;
        }
 
-       BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
+       BT_INFO("%s, %s, %s", unique_name, client_creds, user_creds);
 
        switch (function_name) {
        case BT_SET_LOCAL_NAME:
@@ -4998,6 +5486,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_STOP_LE_DISCOVERY:
        case BT_SET_SCAN_PARAMETERS:
        case BT_SET_SCAN_TYPE:
+       case BT_UPDATE_LE_CONNECTION_MODE:
 
        case BT_BOND_DEVICE:
        case BT_CANCEL_BONDING:
@@ -5091,22 +5580,22 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_DPM_GET_DEVICE_RESTRITION:
        case BT_DPM_SET_UUID_RESTRITION:
        case BT_DPM_GET_UUID_RESTRITION:
-       case BT_DPM_ADD_DEVICES_BLACKLIST:
-       case BT_DPM_ADD_DEVICES_WHITELIST:
-       case BT_DPM_ADD_UUIDS_BLACKLIST:
-       case BT_DPM_ADD_UUIDS_WHITELIST:
-       case BT_DPM_CLEAR_DEVICES_BLACKLIST:
-       case BT_DPM_CLEAR_DEVICES_WHITELIST:
-       case BT_DPM_CLEAR_UUIDS_BLACKLIST:
-       case BT_DPM_CLEAR_UUIDS_WHITELIST:
-       case BT_DPM_REMOVE_DEVICE_BLACKLIST:
-       case BT_DPM_REMOVE_DEVICE_WHITELIST:
-       case BT_DPM_REMOVE_UUID_BLACKLIST:
-       case BT_DPM_REMOVE_UUID_WHITELIST:
-       case BT_DPM_GET_DEVICES_BLACKLIST:
-       case BT_DPM_GET_DEVICES_WHITELIST:
-       case BT_DPM_GET_UUIDS_BLACKLIST:
-       case BT_DPM_GET_UUIDS_WHITELIST:
+       case BT_DPM_ADD_DEVICES_BLOCKLIST:
+       case BT_DPM_ADD_DEVICES_ALLOWLIST:
+       case BT_DPM_ADD_UUIDS_BLOCKLIST:
+       case BT_DPM_ADD_UUIDS_ALLOWLIST:
+       case BT_DPM_CLEAR_DEVICES_BLOCKLIST:
+       case BT_DPM_CLEAR_DEVICES_ALLOWLIST:
+       case BT_DPM_CLEAR_UUIDS_BLOCKLIST:
+       case BT_DPM_CLEAR_UUIDS_ALLOWLIST:
+       case BT_DPM_REMOVE_DEVICE_BLOCKLIST:
+       case BT_DPM_REMOVE_DEVICE_ALLOWLIST:
+       case BT_DPM_REMOVE_UUID_BLOCKLIST:
+       case BT_DPM_REMOVE_UUID_ALLOWLIST:
+       case BT_DPM_GET_DEVICES_BLOCKLIST:
+       case BT_DPM_GET_DEVICES_ALLOWLIST:
+       case BT_DPM_GET_UUIDS_BLOCKLIST:
+       case BT_DPM_GET_UUIDS_ALLOWLIST:
        case BT_DPM_SET_ALLOW_OUTGOING_CALL:
        case BT_DPM_GET_ALLOW_OUTGOING_CALL:
        case BT_DPM_SET_PAIRING_STATE:
@@ -5154,6 +5643,8 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GATT_SERVER_START_SERVICE:
        case BT_GATT_SERVER_STOP_SERVICE:
        case BT_GATT_SERVER_DELETE_SERVICE:
+       case BT_GATT_SERVER_SET_SERVICE_PERSISTENCE:
+       case BT_GATT_SERVER_UNSET_SERVICE_PERSISTENCE:
        case BT_GATT_SERVER_SEND_RESPONSE:
        case BT_GATT_SERVER_ACQURE_WRITE_RESPONSE:
        case BT_GATT_SERVER_ACQUIRE_NOTIFY_RESPONSE:
@@ -5161,6 +5652,10 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GATT_SERVER_UPDATE_VALUE:
        case BT_GATT_SERVER_DEREGISTER:
 #endif
+       case BT_GATT_SERVER_READ_PHY:
+       case BT_GATT_SERVER_SET_PHY:
+       case BT_GATT_CLIENT_READ_PHY:
+       case BT_GATT_CLIENT_SET_PHY:
        case BT_REQ_ATT_MTU:
        case BT_PBAP_CONNECT:
        case BT_PBAP_DISCONNECT:
@@ -5172,6 +5667,17 @@ gboolean __bt_service_check_privilege(int function_name,
 
        case BT_RFCOMM_LISTEN_AND_ACCEPT:
 
+       case BT_L2CAP_LE_CLIENT_CONNECT:
+       case BT_L2CAP_LE_CLIENT_CANCEL_CONNECT:
+       case BT_L2CAP_LE_SOCKET_DISCONNECT:
+       case BT_L2CAP_LE_SOCKET_WRITE:
+       case BT_L2CAP_LE_CREATE_SOCKET:
+       case BT_L2CAP_LE_REMOVE_SOCKET:
+       case BT_L2CAP_LE_LISTEN_AND_ACCEPT:
+       case BT_L2CAP_LE_ACCEPT_CONNECTION:
+       case BT_L2CAP_LE_REJECT_CONNECTION:
+       case BT_L2CAP_LE_LISTEN:
+
        ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
                                                BT_PRIVILEGE_PUBLIC);
 
@@ -5203,9 +5709,9 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_DISABLE_ADAPTER_LE:
        case BT_SET_CONNECTABLE:
        case BT_SET_DISCOVERABLE_MODE:
-       case BT_ADD_WHITE_LIST:
-       case BT_REMOVE_WHITE_LIST:
-       case BT_CLEAR_WHITE_LIST:
+       case BT_ADD_ALLOW_LIST:
+       case BT_REMOVE_ALLOW_LIST:
+       case BT_CLEAR_ALLOW_LIST:
        case BT_SET_MANUFACTURER_DATA:
 
        case BT_CANCEL_SEARCH_SERVICE:
@@ -5226,7 +5732,6 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_SET_LE_PRIVACY:
        case BT_SET_LE_STATIC_RANDOM_ADDRESS:
        case BT_LE_CONN_UPDATE:
-       case BT_UPDATE_LE_CONNECTION_MODE:
        case BT_GET_DEVICE_IDA:
        case BT_LE_READ_MAXIMUM_DATA_LENGTH:
        case BT_LE_WRITE_HOST_SUGGESTED_DATA_LENGTH:
@@ -5287,6 +5792,8 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_MESH_NETWORK_DESTROY:
        case BT_MESH_NETWORK_LOAD:
        case BT_MESH_NETWORK_UNLOAD:
+       case BT_MESH_NETWORK_JOIN:
+       case BT_MESH_CANCEL_JOIN:
        case BT_MESH_NETWORK_SCAN:
        case BT_MESH_NETWORK_CANCEL_SCAN:
        case BT_MESH_NETWORK_SET_CAPABILITIES:
@@ -5313,6 +5820,7 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_MESH_MODEL_CONFIGURE_APPKEY:
        case BT_MESH_MODEL_GET_APPKEY_LIST:
        case BT_MESH_MODEL_EXECUTE_MSG:
+       case BT_MESH_MODEL_RESPONSE_MSG:
        case BT_MESH_NETWORK_CREATE_GROUP:
        case BT_MESH_NETWORK_REMOVE_GROUP:
        case BT_MESH_MODEL_CONFIG_GROUP_SUB:
@@ -5363,6 +5871,11 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_IS_ADVERTISING:
        case BT_IS_LE_2M_PHY_SUPPORTED:
        case BT_IS_LE_CODED_PHY_SUPPORTED:
+       case BT_SET_SCANNING_ROLE:
+       case BT_SET_SCANNING_PHY:
+       case BT_IS_LE_EXTENDED_ADVERTISING_SUPPORTED:
+       case BT_IS_LE_EXTENDED_SCAN_SUPPORTED:
+       case BT_LE_MAX_ADVERTISING_DATA_LEN:
        case BT_REGISTER_SCAN_FILTER:
        case BT_IS_SCAN_FILTER_SUPPORTED:
        case BT_GET_ATT_MTU:
@@ -5373,6 +5886,8 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_OPP_GET_TRANSFER_PROGRESS:
        case BT_AVRCP_CONTROL_GET_PROPERTY:
        case BT_AVRCP_GET_TRACK_INFO:
+
+       case BT_L2CAP_LE_IS_PSM_AVAILABLE:
                /* Non-privilege control */
                break;
        default:
@@ -5467,7 +5982,7 @@ static void __name_owner_changed(GDBusConnection *connection,
        const char *new_owner = NULL;
 
        g_variant_get(parameters, "(&s&s&s)", &name, &old_owner, &new_owner);
-       if (*new_owner != '\0')
+       if (new_owner && *new_owner != '\0')
                return;
 
        _bt_check_hdp_app_termination(name);
@@ -5486,6 +6001,11 @@ static void __name_owner_changed(GDBusConnection *connection,
 
        /* Stop the Transport Discovery service */
        _bt_tds_stop_by_terminated_process(name);
+
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+       /* Cleanup the NSpid list */
+       __bt_service_cleanup_nspid_list(name);
+#endif
 }
 
 static void __bt_service_bus_acquired_handler(GDBusConnection *connection,
@@ -5512,6 +6032,11 @@ static void __bt_service_name_acquired_handler(GDBusConnection *connection,
 {
        BT_INFO("name acquired");
        name_acquired = TRUE;
+
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+       if (_bt_service_is_container() == TRUE)
+               __bt_service_bus_acquired_handler(connection, name, user_data);
+#endif
 }
 
 static void __bt_service_name_lost_handler(GDBusConnection *connection,
@@ -5577,6 +6102,56 @@ fail:
        return BLUETOOTH_ERROR_INTERNAL;
 }
 
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+int _bt_service_register_in_container(void)
+{
+       GDBusConnection *conn;
+       GError *err = NULL;
+
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+
+       /* Register dbus name because systemd will down bt-service
+        * if we don't reigster the dbus name in container */
+       owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM,
+                               BT_SERVICE_NAME,
+                               G_BUS_NAME_OWNER_FLAGS_NONE,
+                               NULL, NULL, NULL, NULL, NULL);
+       BT_DBG("owner_id is [%d]", owner_id);
+       if (owner_id == 0)
+               goto fail;
+
+       conn = g_dbus_connection_new_for_address_sync(
+                       DBUS_HOST_SYSTEM_BUS_ADDRESS,
+                       G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
+                       NULL, NULL, &err);
+       retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+       bt_service_conn = conn;
+
+       /* Register to host dbus connection to call
+        * the method toward container in host bt-service */
+       owner_id = g_bus_own_name_on_connection(conn,
+                               BT_SERVICE_CONTAINER_NAME,
+                               G_BUS_NAME_OWNER_FLAGS_NONE,
+                               __bt_service_name_acquired_handler,
+                               __bt_service_name_lost_handler,
+                               NULL, NULL);
+       BT_DBG("owner_id is [%d]", owner_id);
+       if (owner_id == 0)
+               goto fail;
+
+       return BLUETOOTH_ERROR_NONE;
+
+fail:
+       if (bt_service_conn) {
+               g_object_unref(bt_service_conn);
+               bt_service_conn = NULL;
+       }
+
+       return BLUETOOTH_ERROR_INTERNAL;
+}
+#endif
+
 void _bt_service_unregister(void)
 {
        if (bt_service_conn) {
@@ -5595,6 +6170,13 @@ void _bt_service_unregister(void)
 
                __bt_service_register_object(bt_service_conn, NULL, FALSE);
        }
+
+#ifdef TIZEN_FEATURE_BT_CONTAINER
+       if (nspid_list) {
+               g_slist_free_full(nspid_list, (GDestroyNotify)__bt_service_free_nspid);
+               nspid_list = NULL;
+       }
+#endif
 }
 
 int _bt_service_cynara_init(void)