#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"
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)
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);