Correct the privilege check for BT_UPDATE_LE_CONNECTION_MODE
[platform/core/connectivity/bluetooth-frwk.git] / bt-service / services / bt-request-handler.c
index c61e140..318aa25 100644 (file)
@@ -24,6 +24,7 @@
 #include <cynara-client.h>
 #include <cynara-creds-gdbus.h>
 #include <systemd/sd-daemon.h>
+#include <aul.h>
 
 #include "bluetooth-api.h"
 #include "bluetooth-audio-api.h"
 #include "bt-service-avrcp-tg.h"
 #include "bt-service-avrcp-ctrl.h"
 #include "bt-service-gatt.h"
+#include "bt-service-mesh-main.h"
 #include "bt-service-mesh-util.h"
 #include "bt-service-mesh-network.h"
-
-#ifdef TIZEN_FEATURE_BT_DPM
+#include "bt-service-mesh-config-client.h"
+#include "bt-service-mesh-model.h"
 #include "bt-service-dpm.h"
-#endif
 #include "bt-service-hidhost.h"
 #include "bt-service-rfcomm.h"
 #include "bt-service-hdp.h"
+#include "bt-service-tds.h"
 
 /*Obex*/
 #include "bt-service-obex-server.h"
@@ -68,7 +70,7 @@
 #include "bt-service-ipsp.h"
 #endif
 /* For maintaining Application Sync API call requests */
-GSList *invocation_list = NULL;
+static GSList *invocation_list = NULL;
 
 static GDBusConnection *bt_service_conn;
 static guint owner_id = 0;
@@ -77,7 +79,7 @@ static gboolean is_le_intended = FALSE;
 
 static cynara *p_cynara;
 static cynara_configuration *conf;
-const char *requester_unique_creds = NULL;
+static const char *requester_unique_creds = NULL;
 
 static const gchar bt_service_introspection_xml[] =
 "<node name='/org/projectx/bt_service'>"
@@ -96,12 +98,10 @@ static const gchar bt_service_introspection_xml[] =
 "                      <arg type='i' name='output_param1' direction='out' />"
 "                      <arg type='v' name='output_param2' direction='out' />"
 "              </method>"
-#ifdef TIZEN_FEATURE_BT_AVC_TARGET
 "              <method name='get_avc_mode'>"
                        /* Out Parameters */
 "                      <arg type='u' name='avc_mode' direction='out' />"
 "              </method>"
-#endif
 "      </interface>"
 "</node>";
 
@@ -220,7 +220,6 @@ static gboolean __bt_is_sync_function(int service_function)
                        || service_function == BT_START_LE_DISCOVERY
                        || service_function == BT_STOP_LE_DISCOVERY
                        || service_function == BT_GET_CONNECTABLE
-#ifdef TIZEN_GATT_CLIENT
                        || service_function == BT_GATT_CLIENT_REGISTER
                        || service_function == BT_GATT_GET_PRIMARY_SERVICES
                        || service_function == BT_GATT_GET_SERVICE_PROPERTIES
@@ -228,10 +227,12 @@ static gboolean __bt_is_sync_function(int service_function)
                        || service_function == BT_GATT_GET_CHARACTERISTIC_PROPERTIES
                        || service_function == BT_GATT_WATCH_CHARACTERISTIC
                        || service_function == BT_GATT_ACQUIRE_WRITE
-#endif
                        || service_function == BT_AUDIO_SELECT_ROLE
                        /* Mesh API's */
+                       || service_function == BT_MESH_INIT
                        || service_function == BT_MESH_NETWORK_CREATE
+                       || service_function == BT_MESH_NETWORK_DESTROY
+                       || service_function == BT_MESH_NETWORK_LOAD
                        || service_function == BT_MESH_NETWORK_SCAN
                        || service_function == BT_MESH_NETWORK_ADD_NETKEY
                        || service_function == BT_MESH_NETWORK_DELETE_NETKEY
@@ -435,7 +436,6 @@ fail:
                g_variant_unref(param4);
                g_variant_unref(param5);
        }
-#ifdef TIZEN_FEATURE_BT_AVC_TARGET
        else if (g_strcmp0(method_name, "get_avc_mode") == 0) {
                unsigned int mode = 0;
 
@@ -447,7 +447,6 @@ fail:
                g_dbus_method_invocation_return_value(invocation,
                        g_variant_new("(u)", mode));
        }
-#endif
 
        FN_END;
        return;
@@ -1150,7 +1149,6 @@ int __bt_bluez_request(int function_name,
                }
                break;
        }
-#ifdef TIZEN_FEATURE_BT_DPM
        case BT_DPM_SET_ALLOW_BT_MODE: {
                dpm_bt_allow_t value = DPM_BT_ERROR;
 
@@ -1426,7 +1424,6 @@ int __bt_bluez_request(int function_name,
                g_array_append_vals(*out_param1, &value, sizeof(int));
                break;
        }
-#endif
        case BT_RFCOMM_CLIENT_CONNECT: {
                bluetooth_device_address_t address = { {0} };
                char *input_string;
@@ -1596,7 +1593,6 @@ int __bt_bluez_request(int function_name,
                }
                break;
        }
-#ifdef TIZEN_FEATURE_BT_AVC_TARGET
        case BT_AUDIO_SET_ABSOLUTE_VOLUME: {
                unsigned int volume = 0;
 
@@ -1620,15 +1616,18 @@ int __bt_bluez_request(int function_name,
                g_array_append_vals(*out_param1, &activated, sizeof(bool));
                break;
        }
-#endif
        case BT_AV_CONNECT: {
                bluetooth_device_address_t address = { {0} };
                __bt_service_get_parameters(in_param1,
                                &address, sizeof(bluetooth_device_address_t));
 
-               result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
+               result = _bt_audio_is_profile_connection_in_progress(BT_AV_CONNECT, &address);
+
+               if (result == BLUETOOTH_ERROR_NONE)
+                       result = _bt_audio_connect(BT_AUDIO_A2DP, &address);
 
                if (result != BLUETOOTH_ERROR_NONE) {
+                       BT_ERR("AV Connect Request has failed to execute");
                        char addr[BT_ADDRESS_STRING_SIZE];
                        _bt_convert_addr_type_to_string(addr, address.addr);
                        g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
@@ -1646,9 +1645,13 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param1,
                                &address, sizeof(bluetooth_device_address_t));
 
-               result = _bt_audio_connect(BT_AUDIO_ALL, &address);
+               result = _bt_audio_is_profile_connection_in_progress(BT_AUDIO_CONNECT, &address);
+
+               if (result == BLUETOOTH_ERROR_NONE)
+                       result = _bt_audio_connect(BT_AUDIO_ALL, &address);
 
                if (result != BLUETOOTH_ERROR_NONE) {
+                       BT_ERR("Audio All Connect Request has failed to execute");
                        char addr[BT_ADDRESS_STRING_SIZE];
                        _bt_convert_addr_type_to_string(addr, address.addr);
                        g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
@@ -1706,9 +1709,13 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param1,
                                &address, sizeof(bluetooth_device_address_t));
 
-               result = _bt_audio_connect(BT_AUDIO_HSP, &address);
+               result = _bt_audio_is_profile_connection_in_progress(BT_AG_CONNECT, &address);
+
+               if (result == BLUETOOTH_ERROR_NONE)
+                       result = _bt_audio_connect(BT_AUDIO_HSP, &address);
 
                if (result != BLUETOOTH_ERROR_NONE) {
+                       BT_ERR("AG Connect Request has failed to execute");
                        char addr[BT_ADDRESS_STRING_SIZE];
                        _bt_convert_addr_type_to_string(addr, address.addr);
                        g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
@@ -1748,8 +1755,14 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param1,
                                &address, sizeof(bluetooth_device_address_t));
 
-               result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
+               result = _bt_audio_is_profile_connection_in_progress(BT_AV_SOURCE_CONNECT,
+                               &address);
+
+               if (result == BLUETOOTH_ERROR_NONE)
+                       result = _bt_audio_connect(BT_AUDIO_A2DP_SOURCE, &address);
+
                if (result != BLUETOOTH_ERROR_NONE) {
+                       BT_ERR("A2DP Source Connect Request has failed to execute");
                        char addr[BT_ADDRESS_STRING_SIZE];
                        _bt_convert_addr_type_to_string(addr, address.addr);
                        g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
@@ -1788,8 +1801,14 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param1,
                                &address, sizeof(bluetooth_device_address_t));
 
-               result = _bt_hf_connect(&address);
+               result = _bt_audio_is_profile_connection_in_progress(BT_HF_CONNECT,
+                               &address);
+
+               if (result == BLUETOOTH_ERROR_NONE)
+                       result = _bt_hf_connect(&address);
+
                if (result != BLUETOOTH_ERROR_NONE) {
+                       BT_ERR("HF Connect Request has failed to execute");
                        char addr[BT_ADDRESS_STRING_SIZE];
                        _bt_convert_addr_type_to_string(addr, address.addr);
                        g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
@@ -1828,8 +1847,14 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param1,
                                &address, sizeof(bluetooth_device_address_t));
 
-               result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
+               result = _bt_audio_is_profile_connection_in_progress(BT_AVRCP_TARGET_CONNECT,
+                               &address);
+
+               if (result == BLUETOOTH_ERROR_NONE)
+                       result = _bt_audio_connect(BT_AVRCP_TARGET, &address);
+
                if (result != BLUETOOTH_ERROR_NONE) {
+                       BT_ERR("AVRCP Target Connect Request has failed to execute");
                        char addr[BT_ADDRESS_STRING_SIZE];
                        _bt_convert_addr_type_to_string(addr, address.addr);
                        g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
@@ -1868,8 +1893,14 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param1,
                                &address, sizeof(bluetooth_device_address_t));
 
-               result = _bt_audio_connect(BT_AVRCP, &address);
+               result = _bt_audio_is_profile_connection_in_progress(BT_AVRCP_CONTROL_CONNECT,
+                               &address);
+
+               if (result == BLUETOOTH_ERROR_NONE)
+                       result = _bt_audio_connect(BT_AVRCP, &address);
+
                if (result != BLUETOOTH_ERROR_NONE) {
+                       BT_ERR("AVRCP Control Connect Request has failed to execute");
                        char addr[BT_ADDRESS_STRING_SIZE];
                        _bt_convert_addr_type_to_string(addr, address.addr);
                        g_array_append_vals(*out_param1, addr, BT_ADDRESS_STRING_SIZE);
@@ -2337,7 +2368,7 @@ int __bt_bluez_request(int function_name,
                __bt_service_get_parameters(in_param4, &use_reserved_slot,
                                sizeof(gboolean));
 
-               BT_DBG("bluetooth_advertising_params_t [%f %f %d %d %d]",
+               BT_DBG("bluetooth_advertising_params_t [%d %d %d %d %d]",
                                adv_params.interval_min, adv_params.interval_max,
                                adv_params.filter_policy, adv_params.type, adv_params.tx_power_level);
                result = _bt_set_custom_advertising(app, *adv_handle,
@@ -2750,7 +2781,6 @@ int __bt_bluez_request(int function_name,
 
                break;
        }
-#ifdef TIZEN_GATT_CLIENT
        /* Local Async */
        case BT_GATT_CLIENT_REGISTER: {
                bluetooth_device_address_t address = { {0} };
@@ -3171,7 +3201,6 @@ normal:
                                        parameters.timeout);
                break;
        }
-#endif
        case BT_START_LE_DISCOVERY: {
                uid_t uid = 0;
                pid_t pid = 0;
@@ -3362,6 +3391,128 @@ normal:
 
                break;
        }
+
+       case BT_TDS_PROVIDER_REGISTER: {
+               char *sender = NULL;
+
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+               result = _bt_tds_provider_register(sender);
+
+               break;
+       }
+
+       case BT_TDS_PROVIDER_UNREGISTER: {
+               char *sender = NULL;
+
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+               result = _bt_tds_provider_unregister(sender);
+
+               break;
+       }
+
+       case BT_TDS_PROVIDER_SET_MANUF_DATA: {
+               char *sender = NULL;
+               unsigned int length = 0;
+               bluetooth_advertising_data_t manuf_data;
+
+               __bt_service_get_parameters(in_param1,
+                               &length, sizeof(unsigned int));
+               __bt_service_get_parameters(in_param2,
+                               &manuf_data, sizeof(bluetooth_advertising_data_t));
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+               result = _bt_tds_provider_set_manuf_data(sender, manuf_data.data, length);
+               break;
+       }
+
+       case BT_TDS_PROVIDER_CREATE: {
+               char *sender = NULL;
+               unsigned int tds_handle = 0;
+               int transport;
+
+               __bt_service_get_parameters(in_param1,
+                               &tds_handle, sizeof(unsigned int));
+               __bt_service_get_parameters(in_param2,
+                               &transport, sizeof(int));
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+               result = _bt_tds_provider_transport_create(sender, transport, tds_handle);
+
+               break;
+       }
+
+       case BT_TDS_PROVIDER_DESTROY: {
+               char *sender = NULL;
+               unsigned int tds_handle = 0;
+
+               __bt_service_get_parameters(in_param1,
+                               &tds_handle, sizeof(unsigned int));
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+               result = _bt_tds_provider_transport_remove(sender, tds_handle);
+
+               break;
+       }
+
+       case BT_TDS_PROVIDER_SET_TRANSPORT_DATA: {
+               char *sender = NULL;
+               unsigned int tds_handle = 0;
+               int transport_state = 0;
+               bluetooth_tds_data_t tds_data;
+
+               __bt_service_get_parameters(in_param1,
+                               &tds_handle, sizeof(unsigned int));
+               __bt_service_get_parameters(in_param2,
+                               &transport_state, sizeof(int));
+               __bt_service_get_parameters(in_param3,
+                               &tds_data, sizeof(bluetooth_tds_data_t));
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+               result = _bt_tds_provider_set_transport_data(sender, tds_handle,
+                               transport_state, tds_data.data, tds_data.length);
+               break;
+       }
+
+       case BT_TDS_SEND_ACTIVATION_RESPONSE: {
+               bluetooth_device_address_t address = { {0} };
+               bluetooth_tds_data_t tds_data;
+               char *sender = NULL;
+               unsigned int tds_handle = 0;
+               int response;
+
+               __bt_service_get_parameters(in_param1,
+                               &tds_handle, sizeof(unsigned int));
+               __bt_service_get_parameters(in_param2,
+                               &response, sizeof(int));
+               __bt_service_get_parameters(in_param3, &address,
+                       sizeof(bluetooth_device_address_t));
+               __bt_service_get_parameters(in_param4,
+                               &tds_data, sizeof(bluetooth_tds_data_t));
+               sender = (char *)g_dbus_method_invocation_get_sender(context);
+
+               result = _bt_tds_provider_send_activation_response(sender, tds_handle,
+                               &address, response, tds_data.data, tds_data.length);
+               break;
+       }
+
+       case BT_MESH_INIT:
+               sender = (char*)g_dbus_method_invocation_get_sender(context);
+               BT_INFO("Mesh: Init by [%s]", sender);
+               result = _bt_mesh_init(sender);
+               /* Save invocation */
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       BT_INFO("Mesh: Save Invoation");
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context,
+                                       result, sender,
+                                       function_name, NULL);
+               }
+               break;
+
+       case BT_MESH_DEINIT:
+               sender = (char*)g_dbus_method_invocation_get_sender(context);
+               BT_INFO("Mesh: De-Init by [%s]", sender);
+               result = _bt_mesh_deinit(sender);
+               break;
+
        case BT_MESH_NETWORK_CREATE: {
                bluetooth_mesh_node_t node;
                GSList *model_list = NULL;
@@ -3377,6 +3528,7 @@ normal:
                __bt_service_get_parameters(in_param1,
                                &node, sizeof(bluetooth_mesh_node_t));
                network_name = (const char *)g_variant_get_data(in_param2);
+
                BT_INFO("MESH: Network name [%s]", network_name);
 
                param3 = g_array_new(TRUE, TRUE, sizeof(gchar));
@@ -3416,10 +3568,12 @@ normal:
                                requester_unique_creds,
                                sizeof(network->app_cred));
                        sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       BT_INFO("Mesh: Network Create by [%s]", sender);
                        _bt_save_invocation_context(context,
                                        result, sender,
                                        function_name, (gpointer)network);
                } else {
+                       g_array_append_vals(*out_param1, &node, sizeof(bluetooth_mesh_node_t));
                        BT_ERR("Mesh: Mesh Network creation schedule failed");
                        g_slist_free_full(model_list, g_free);
                }
@@ -3431,6 +3585,122 @@ normal:
                BT_INFO("Mesh: Cleanup Done");
                break;
        }
+       case BT_MESH_NETWORK_DESTROY: {
+               bluetooth_mesh_network_t network;
+               memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &network, sizeof(bluetooth_mesh_network_t));
+
+               BT_INFO("Mesh: Destroy Network");
+               result = _bt_mesh_network_destroy(requester_unique_creds,
+                               sender, &network);
+
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1,
+                               &network, sizeof(bluetooth_mesh_network_t));
+               } else {
+                       BT_INFO("Mesh: Destroy Network scheduled: add invocation");
+                       bluetooth_mesh_network_t *net =  \
+                                       g_memdup(&network, sizeof(bluetooth_mesh_network_t));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)net);
+               }
+               break;
+       }
+       case BT_MESH_NETWORK_LOAD: {
+               char *token = NULL;
+               bluetooth_mesh_network_t *network;
+               token = (char *)g_variant_get_data(in_param1);
+               BT_INFO("MESH: Network Load: Token string [%s]", token);
+               result = _bt_mesh_network_load(requester_unique_creds, sender, token);
+               /* Save invocation */
+               if (result == BLUETOOTH_ERROR_NONE) {
+                       network =  g_malloc0(sizeof(bluetooth_mesh_network_t));
+                       g_strlcpy(network->token.token, token,
+                                       BLUETOOTH_MESH_NETWORK_TOKEN_STRING_LENGTH + 1);
+                       g_strlcpy(network->app_cred, requester_unique_creds,
+                                       sizeof(network->app_cred));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)network);
+               }
+               g_free((gpointer)requester_unique_creds);
+               break;
+       }
+       case BT_MESH_NETWORK_UNLOAD: {
+               bluetooth_mesh_network_t network;
+               memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &network, sizeof(bluetooth_mesh_network_t));
+
+               BT_INFO("MESH: Network Unload: Network UUID [%s]", network.uuid);
+               result = _bt_mesh_network_unload(requester_unique_creds,
+                               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_memdup(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;
@@ -3498,6 +3768,9 @@ normal:
                __bt_service_get_parameters(in_param1,
                                &req, sizeof(bluetooth_mesh_provisioning_request_t));
 
+               BT_INFO("Mesh: Provision Device UUID [%s]", req.dev_uuid);
+               BT_INFO("Mesh: Provision Device in network[%s]", req.net_uuid);
+
                result = _bt_mesh_network_provision_device(
                                requester_unique_creds, sender, &req);
 
@@ -3516,6 +3789,7 @@ normal:
                break;
        }
        case BT_MESH_AUTHENTICATION_REPLY: {
+               BT_INFO("Mesh: BT_MESH_AUTHENTICATION_REPLY");
                const char *auth_value = NULL;
                gboolean authentication_reply = FALSE;
                int auth_type;
@@ -3524,6 +3798,9 @@ normal:
                                &authentication_reply, sizeof(gboolean));
                __bt_service_get_parameters(in_param1,
                                &auth_type, sizeof(int));
+               BT_INFO("Mesh: Auth Reply Type [%d]", auth_type);
+               BT_INFO("Mesh: Auth Value [%s]", auth_value);
+               BT_INFO("Mesh: Auth Accept [%d]", authentication_reply);
                result = _bt_mesh_authentication_reply(auth_type,
                                auth_value, authentication_reply);
                break;
@@ -3709,8 +3986,409 @@ normal:
                                &network, sizeof(bluetooth_mesh_network_t));
                __bt_service_get_parameters(in_param2,
                                &net_idx, sizeof(guint16));
-               result = _bt_mesh_network_get_appkeys(requester_unique_creds,
-                               sender, &network, net_idx, out_param1);
+               result = _bt_mesh_network_get_appkeys(
+                               requester_unique_creds, sender,
+                                       &network, net_idx, out_param1);
+               break;
+       }
+       case BT_MESH_NETWORK_GET_NODES: {
+               bluetooth_mesh_network_t network;
+               memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
+               __bt_service_get_parameters(in_param1,
+                               &network, sizeof(bluetooth_mesh_network_t));
+               result = _bt_mesh_network_get_nodes(
+                               requester_unique_creds, sender,
+                                       &network, out_param1);
+               break;
+       }
+       case BT_MESH_ELEMENT_GET_MODELS: {
+               bluetooth_mesh_network_t network;
+               uint16_t node_addr;
+               int elem_idx;
+
+               memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
+               __bt_service_get_parameters(in_param1,
+                               &network, sizeof(bluetooth_mesh_network_t));
+               __bt_service_get_parameters(in_param2,
+                               &node_addr, sizeof(guint16));
+               __bt_service_get_parameters(in_param3,
+                               &elem_idx, sizeof(int));
+               result = _bt_mesh_element_get_models(requester_unique_creds, sender,
+                               &network, node_addr, elem_idx, out_param1);
+               break;
+       }
+       case BT_MESH_NODE_BROWSE: {
+               bluetooth_mesh_node_discover_t req;
+               memset(&req, 0x00, sizeof(bluetooth_mesh_node_discover_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_node_discover_t));
+
+               result = _bt_mesh_browse_remote_node(
+                               requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1, &req,
+                               sizeof(bluetooth_mesh_node_discover_t));
+               } else {
+                       bluetooth_mesh_node_discover_t *param = \
+                               g_memdup(&req, sizeof(bluetooth_mesh_node_discover_t));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_NODE_GET_VENDOR_FEATURES: {
+               bluetooth_mesh_node_features_t req;
+               memset(&req, 0x00, sizeof(bluetooth_mesh_node_features_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_node_features_t));
+
+               result = _bt_mesh_node_discover_vendor_features(
+                               requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1,
+                               &req, sizeof(bluetooth_mesh_node_features_t));
+               } else {
+                       bluetooth_mesh_node_features_t *param =  \
+                               g_memdup(&req, sizeof(bluetooth_mesh_node_features_t));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_NODE_CONFIGURE_KEY: {
+               bluetooth_mesh_key_configure_t req;
+
+               memset(&req, 0x00, sizeof(bluetooth_mesh_key_configure_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_key_configure_t));
+
+               result = _bt_mesh_node_configure_key(
+                               requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       g_array_append_vals(*out_param1,
+                               &req, sizeof(bluetooth_mesh_key_configure_t));
+               } else {
+                       bluetooth_mesh_key_configure_t *param = \
+                               g_memdup(&req, sizeof(bluetooth_mesh_key_configure_t));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_NODE_TTL_EXECUTE: {
+               bluetooth_mesh_node_ttl_info_t req;
+
+               memset(&req, 0x00, sizeof(bluetooth_mesh_node_ttl_info_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_node_ttl_info_t));
+
+               result = _bt_mesh_ttl_execute_remote_node(
+                               requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       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));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_MODEL_CONFIGURE_APPKEY: {
+               bluetooth_mesh_model_configure_t req;
+
+               memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_model_configure_t));
+
+               result = _bt_mesh_node_model_appkey_execute(
+                               requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               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));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_MODEL_EXECUTE_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_execute_msg(
+                               requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               if (result != BLUETOOTH_ERROR_NONE) {
+                       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));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_NODE_GET_NETKEYS: {
+               bluetooth_mesh_node_discover_t node;
+               memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
+               __bt_service_get_parameters(in_param1,
+                               &node, sizeof(bluetooth_mesh_node_discover_t));
+               result = _bt_mesh_network_node_get_netkeys(
+                               requester_unique_creds, &node, out_param1);
+               break;
+       }
+       case BT_MESH_NODE_GET_APPKEYS: {
+               bluetooth_mesh_node_discover_t node;
+               memset(&node, 0x00, sizeof(bluetooth_mesh_node_discover_t));
+               __bt_service_get_parameters(in_param1,
+                               &node, sizeof(bluetooth_mesh_node_discover_t));
+               result = _bt_mesh_network_node_get_appkeys(
+                               requester_unique_creds, sender, &node, out_param1);
+               break;
+       }
+       case BT_MESH_NODE_RESET: {
+               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: Reset the Node");
+               result = _bt_mesh_network_reset_node(requester_unique_creds,
+                               sender, &node);
+
+               break;
+       }
+       case BT_MESH_MODEL_GET_APPKEY_LIST: {
+               bluetooth_mesh_model_configure_t req;
+
+               memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_model_configure_t));
+
+               result = _bt_mesh_node_model_get_appkey_list(
+                                       requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               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));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST: {
+               bluetooth_mesh_model_configure_t req;
+
+               memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_model_configure_t));
+
+               result = _bt_mesh_node_model_get_subscription_list(
+                               requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               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));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+
+               break;
+       }
+       case BT_MESH_NETWORK_CREATE_GROUP: {
+               bluetooth_mesh_network_t net;
+               bluetooth_mesh_network_group_info_t res;
+               gboolean is_virtual;
+               uint16_t grp_addr;
+
+               memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
+               memset(&res, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &net, sizeof(bluetooth_mesh_network_t));
+               __bt_service_get_parameters(in_param2,
+                               &is_virtual, sizeof(gboolean));
+               __bt_service_get_parameters(in_param3,
+                               &grp_addr, sizeof(guint16));
+
+               result = _bt_mesh_network_create_group(
+                               requester_unique_creds, sender, &net,
+                                       is_virtual, grp_addr, &res);
+
+               if (result == BLUETOOTH_ERROR_NONE)
+                       g_array_append_vals(*out_param1, &res,
+                               sizeof(bluetooth_mesh_network_group_info_t));
+               break;
+       }
+       case BT_MESH_NETWORK_REMOVE_GROUP: {
+               bluetooth_mesh_network_t net;
+               bluetooth_mesh_network_group_info_t req;
+
+               memset(&net, 0x00, sizeof(bluetooth_mesh_network_t));
+               memset(&req, 0x00, sizeof(bluetooth_mesh_network_group_info_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &net, sizeof(bluetooth_mesh_network_t));
+               __bt_service_get_parameters(in_param2,
+                               &req, sizeof(bluetooth_mesh_network_group_info_t));
+
+               result = _bt_mesh_network_remove_group(
+                               requester_unique_creds, sender, &net, &req);
+
+               break;
+       }
+       case BT_MESH_MODEL_CONFIG_GROUP_SUB: {
+               bluetooth_mesh_model_configure_t req;
+
+               memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_model_configure_t));
+
+               result = _bt_mesh_model_configure_group_subscription(
+                               requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               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));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB: {
+               bluetooth_mesh_model_configure_t req;
+
+               memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_model_configure_t));
+
+               result = _bt_mesh_model_configure_virtual_group_subscription(
+                               requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               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));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_MODEL_SET_PUBLICATION: {
+               bluetooth_mesh_model_configure_t req;
+
+               memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_model_configure_t));
+
+               result = _bt_mesh_model_set_publication(
+                               requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               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));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_MODEL_GET_PUBLICATION: {
+               bluetooth_mesh_model_configure_t req;
+
+               memset(&req, 0x00, sizeof(bluetooth_mesh_model_configure_t));
+
+               __bt_service_get_parameters(in_param1,
+                               &req, sizeof(bluetooth_mesh_model_configure_t));
+
+               result = _bt_mesh_model_get_publication(
+                                       requester_unique_creds, sender, &req);
+
+               /* Save invocation */
+               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));
+
+                       sender = (char*)g_dbus_method_invocation_get_sender(context);
+                       _bt_save_invocation_context(context, result, sender,
+                                       function_name, (gpointer)param);
+               }
+               break;
+       }
+       case BT_MESH_NETWORK_GET_GROUPS: {
+               bluetooth_mesh_network_t network;
+               memset(&network, 0x00, sizeof(bluetooth_mesh_network_t));
+               __bt_service_get_parameters(in_param1,
+                               &network, sizeof(bluetooth_mesh_network_t));
+               BT_INFO("Mesh: Request:: Get Groups");
+               result = _bt_mesh_network_get_groups(
+                               requester_unique_creds, sender, &network, out_param1);
                break;
        }
        default:
@@ -4291,6 +4969,30 @@ int __bt_core_request(int function_name,
        return result;
 }
 
+static int __bt_service_get_requester_app_id(const char *unique_name, char *app_id, int len)
+{
+       int ret;
+       pid_t pid = 0;
+
+       retv_if(bt_service_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
+       retv_if(unique_name == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
+
+       ret = __bt_service_get_sender_pid(unique_name, &pid);
+       if (ret != BLUETOOTH_ERROR_NONE) {
+               BT_ERR("Fail to get the sender pid");
+               return ret;
+       }
+
+       ret = aul_app_get_appid_bypid(pid, app_id, len);
+       if (ret != AUL_R_OK) {
+               BT_ERR("app_id not found");
+               return BLUETOOTH_ERROR_NOT_SUPPORT;
+       }
+       BT_DBG("Sender app_id: %s", app_id);
+
+       return BLUETOOTH_ERROR_NONE;
+}
+
 gboolean __bt_service_check_privilege(int function_name,
                                        int service_type,
                                        const char *unique_name)
@@ -4337,7 +5039,7 @@ gboolean __bt_service_check_privilege(int function_name,
                return FALSE;
        }
 
-//     BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
+       BT_DBG("%s, %s, %s", unique_name, client_creds, user_creds);
 
        switch (function_name) {
        case BT_SET_LOCAL_NAME:
@@ -4354,6 +5056,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:
@@ -4409,11 +5112,9 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_AVRCP_SET_PROPERTIES:
        case BT_AVRCP_CONTROL_SET_PROPERTY:
 
-#ifdef TIZEN_FEATURE_BT_AVC_TARGET
        case BT_AUDIO_SET_ABSOLUTE_VOLUME:
        case BT_AUDIO_GET_ABSOLUTE_VOLUME:
        case BT_AUDIO_IS_AVC_ACTIVATED:
-#endif
 
        case BT_HF_CONNECT:
        case BT_HF_DISCONNECT:
@@ -4487,15 +5188,12 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_NETWORK_SERVER_DISCONNECT:
 
        case BT_GATT_GET_PRIMARY_SERVICES:
-#ifdef TIZEN_GATT_CLIENT
        case BT_GATT_GET_SERVICE_PROPERTIES:             /* GATT Client */
        case BT_GATT_GET_CHARACTERISTIC_PROPERTIES:      /* GATT Client */
        case BT_GATT_WATCH_SERVICE_CHANGED_INDICATION:   /* GATT Client */
-#endif
        case BT_GATT_DISCOVER_CHARACTERISTICS:
        case BT_GATT_SET_PROPERTY_REQUEST:
        case BT_GATT_READ_CHARACTERISTIC:
-#ifdef TIZEN_GATT_CLIENT
        case BT_GATT_READ_DESCRIPTOR_VALUE:              /* GATT Client */
        case BT_GATT_WRITE_CHARACTERISTIC_VALUE_BY_TYPE: /* GATT Client */
        case BT_GATT_ACQUIRE_WRITE:
@@ -4503,7 +5201,6 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_GATT_WATCH_CHARACTERISTIC:               /* GATT Client */
        case BT_GATT_CLIENT_REGISTER:                    /* GATT Client */
        case BT_GATT_CLIENT_UNREGISTER:                   /* GATT Client */
-#endif
        case BT_GATT_DISCOVER_CHARACTERISTICS_DESCRIPTOR:
        case BT_GATT_REGISTER_APPLICATION:
        case BT_GATT_REGISTER_SERVICE:
@@ -4533,21 +5230,6 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_PBAP_PHONEBOOK_SEARCH:
 
        case BT_RFCOMM_LISTEN_AND_ACCEPT:
-       case BT_MESH_NETWORK_CREATE:
-       case BT_MESH_NETWORK_SCAN:
-       case BT_MESH_NETWORK_CANCEL_SCAN:
-       case BT_MESH_NETWORK_SET_CAPABILITIES:
-       case BT_MESH_NETWORK_PROVISION_DEVICE:
-       case BT_MESH_AUTHENTICATION_REPLY:
-       case BT_MESH_NETWORK_SET_NAME:
-       case BT_MESH_NETWORK_ADD_NETKEY:
-       case BT_MESH_NETWORK_DELETE_NETKEY:
-       case BT_MESH_NETWORK_UPDATE_NETKEY:
-       case BT_MESH_NETWORK_ADD_APPKEY:
-       case BT_MESH_NETWORK_DELETE_APPKEY:
-       case BT_MESH_NETWORK_UPDATE_APPKEY:
-       case BT_MESH_NETWORK_GET_NETKEYS:
-       case BT_MESH_NETWORK_GET_APPKEYS:
 
        ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
                                                BT_PRIVILEGE_PUBLIC);
@@ -4595,8 +5277,6 @@ gboolean __bt_service_check_privilege(int function_name,
 
        case BT_HID_ENABLE_BARCODE_FEATURE:
 
-       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:
 
@@ -4605,7 +5285,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:
@@ -4660,6 +5339,49 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_MAP_PUSH_MESSAGE:
        case BT_MAP_GET_MESSAGE:
 
+       case BT_MESH_INIT:
+       case BT_MESH_DEINIT:
+       case BT_MESH_NETWORK_CREATE:
+       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:
+       case BT_MESH_NETWORK_PROVISION_DEVICE:
+       case BT_MESH_AUTHENTICATION_REPLY:
+       case BT_MESH_NETWORK_SET_NAME:
+       case BT_MESH_NETWORK_ADD_NETKEY:
+       case BT_MESH_NETWORK_DELETE_NETKEY:
+       case BT_MESH_NETWORK_UPDATE_NETKEY:
+       case BT_MESH_NETWORK_ADD_APPKEY:
+       case BT_MESH_NETWORK_DELETE_APPKEY:
+       case BT_MESH_NETWORK_UPDATE_APPKEY:
+       case BT_MESH_NETWORK_GET_NETKEYS:
+       case BT_MESH_NETWORK_GET_APPKEYS:
+       case BT_MESH_NETWORK_GET_NODES:
+       case BT_MESH_ELEMENT_GET_MODELS:
+       case BT_MESH_NODE_BROWSE:
+       case BT_MESH_NODE_GET_VENDOR_FEATURES:
+       case BT_MESH_NODE_CONFIGURE_KEY:
+       case BT_MESH_NODE_TTL_EXECUTE:
+       case BT_MESH_NODE_GET_NETKEYS:
+       case BT_MESH_NODE_GET_APPKEYS:
+       case BT_MESH_NODE_RESET:
+       case BT_MESH_MODEL_CONFIGURE_APPKEY:
+       case BT_MESH_MODEL_GET_APPKEY_LIST:
+       case BT_MESH_MODEL_EXECUTE_MSG:
+       case BT_MESH_NETWORK_CREATE_GROUP:
+       case BT_MESH_NETWORK_REMOVE_GROUP:
+       case BT_MESH_MODEL_CONFIG_GROUP_SUB:
+       case BT_MESH_MODEL_CONFIG_VIRTUAL_GROUP_SUB:
+       case BT_MESH_MODEL_GET_SUBSCRIPTION_LIST:
+       case BT_MESH_MODEL_SET_PUBLICATION:
+       case BT_MESH_MODEL_GET_PUBLICATION:
+       case BT_MESH_NETWORK_GET_GROUPS:
+
        ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds,
                                BT_PRIVILEGE_PLATFORM);
 
@@ -4709,6 +5431,8 @@ gboolean __bt_service_check_privilege(int function_name,
        case BT_OBEX_SERVER_DEALLOCATE:
        case BT_OBEX_SERVER_IS_ACTIVATED:
        case BT_OPP_GET_TRANSFER_PROGRESS:
+       case BT_AVRCP_CONTROL_GET_PROPERTY:
+       case BT_AVRCP_GET_TRACK_INFO:
                /* Non-privilege control */
                break;
        default:
@@ -4717,13 +5441,24 @@ gboolean __bt_service_check_privilege(int function_name,
                break;
        }
 
-       if (client_creds && function_name >= BT_FUNC_MESH_BASE) {
-               BT_INFO("MESH Function called creds [%s]", client_creds);
-               requester_unique_creds = g_strdup(client_creds);
-               free(client_creds);
+       if (function_name >= BT_FUNC_MESH_BASE) {
+               BT_INFO("MESH Function called");
+               char app_id[256] = { 0, };
 
-       } else
+               if (BLUETOOTH_ERROR_NONE == __bt_service_get_requester_app_id(unique_name,
+                                       app_id, sizeof(app_id))) {
+                       requester_unique_creds = g_strdup(app_id);
+               } else {
+                       BT_DBG("Requester app_id not found, use client creds");
+                       requester_unique_creds = g_strdup(client_creds);
+               }
+               BT_DBG("Requester unique_creds: %s", requester_unique_creds);
+       } else {
                BT_INFO("Non MESH Function called client creds [%s]", client_creds);
+       }
+
+       if (client_creds)
+               free(client_creds);
 
        if (user_creds)
                free(user_creds);
@@ -4805,6 +5540,12 @@ static void __name_owner_changed(GDBusConnection *connection,
 
        /* Check if RFCOMM app is terminated */
        _bt_rfcomm_check_termination(name);
+
+       /* Mesh App Termination */
+       _bt_check_mesh_app_termination(name);
+
+       /* Stop the Transport Discovery service */
+       _bt_tds_stop_by_terminated_process(name);
 }
 
 static void __bt_service_bus_acquired_handler(GDBusConnection *connection,