@@ -27,6 +27,7 @@
#include "src/shared/queue.h"
#define ADMIN_POLICY_SET_INTERFACE "org.bluez.AdminPolicySet1"
+#define ADMIN_POLICY_STATUS_INTERFACE "org.bluez.AdminPolicyStatus1"
static DBusConnection *dbus_conn;
@@ -151,6 +152,11 @@ static DBusMessage *set_service_allowlist(DBusConnection *conn,
return btd_error_failed(msg, "service_allowlist_set failed");
}
+ g_dbus_emit_property_changed(dbus_conn,
+ adapter_get_path(policy_data->adapter),
+ ADMIN_POLICY_STATUS_INTERFACE,
+ "ServiceAllowList");
+
return dbus_message_new_method_return(msg);
}
@@ -160,6 +166,43 @@ static const GDBusMethodTable admin_policy_adapter_methods[] = {
{ }
};
+void append_service_uuid(void *data, void *user_data)
+{
+ bt_uuid_t *uuid = data;
+ DBusMessageIter *entry = user_data;
+ char uuid_str[MAX_LEN_UUID_STR];
+ const char *uuid_str_ptr = uuid_str;
+
+ if (!uuid) {
+ error("Unexpected NULL uuid data in service_allowlist");
+ return;
+ }
+
+ bt_uuid_to_string(uuid, uuid_str, MAX_LEN_UUID_STR);
+ dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &uuid_str_ptr);
+}
+
+static gboolean property_get_service_allowlist(
+ const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct btd_admin_policy *admin_policy = user_data;
+ DBusMessageIter entry;
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING, &entry);
+ queue_foreach(admin_policy->service_allowlist, append_service_uuid,
+ &entry);
+ dbus_message_iter_close_container(iter, &entry);
+
+ return TRUE;
+}
+
+static const GDBusPropertyTable admin_policy_adapter_properties[] = {
+ { "ServiceAllowList", "as", property_get_service_allowlist },
+ { }
+};
+
static int admin_policy_adapter_probe(struct btd_adapter *adapter)
{
const char *adapter_path;
@@ -189,6 +232,21 @@ static int admin_policy_adapter_probe(struct btd_adapter *adapter)
btd_info(policy_data->adapter_id,
"Admin Policy Set interface registered");
+
+ if (!g_dbus_register_interface(dbus_conn, adapter_path,
+ ADMIN_POLICY_STATUS_INTERFACE,
+ NULL, NULL,
+ admin_policy_adapter_properties,
+ policy_data, admin_policy_free)) {
+ btd_error(policy_data->adapter_id,
+ "Admin Policy Status interface init failed on path %s",
+ adapter_path);
+ return -EINVAL;
+ }
+
+ btd_info(policy_data->adapter_id,
+ "Admin Policy Status interface registered");
+
return 0;
}
@@ -27,6 +27,7 @@
#include "src/shared/queue.h"
#define ADMIN_POLICY_SET_INTERFACE "org.bluez.AdminPolicySet1"
+#define ADMIN_POLICY_STATUS_INTERFACE "org.bluez.AdminPolicyStatus1"
static DBusConnection *dbus_conn;
@@ -151,6 +152,11 @@ static DBusMessage *set_service_allowlist(DBusConnection *conn,
return btd_error_failed(msg, "service_allowlist_set failed");
}
+ g_dbus_emit_property_changed(dbus_conn,
+ adapter_get_path(policy_data->adapter),
+ ADMIN_POLICY_STATUS_INTERFACE,
+ "ServiceAllowList");
+
return dbus_message_new_method_return(msg);
}
@@ -160,6 +166,43 @@ static const GDBusMethodTable admin_policy_adapter_methods[] = {
{ }
};
+void append_service_uuid(void *data, void *user_data)
+{
+ bt_uuid_t *uuid = data;
+ DBusMessageIter *entry = user_data;
+ char uuid_str[MAX_LEN_UUID_STR];
+ const char *uuid_str_ptr = uuid_str;
+
+ if (!uuid) {
+ error("Unexpected NULL uuid data in service_allowlist");
+ return;
+ }
+
+ bt_uuid_to_string(uuid, uuid_str, MAX_LEN_UUID_STR);
+ dbus_message_iter_append_basic(entry, DBUS_TYPE_STRING, &uuid_str_ptr);
+}
+
+static gboolean property_get_service_allowlist(
+ const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *user_data)
+{
+ struct btd_admin_policy *admin_policy = user_data;
+ DBusMessageIter entry;
+
+ dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+ DBUS_TYPE_STRING_AS_STRING, &entry);
+ queue_foreach(admin_policy->service_allowlist, append_service_uuid,
+ &entry);
+ dbus_message_iter_close_container(iter, &entry);
+
+ return TRUE;
+}
+
+static const GDBusPropertyTable admin_policy_adapter_properties[] = {
+ { "ServiceAllowList", "as", property_get_service_allowlist },
+ { }
+};
+
static int admin_policy_adapter_probe(struct btd_adapter *adapter)
{
if (policy_data) {
@@ -185,6 +228,21 @@ static int admin_policy_adapter_probe(struct btd_adapter *adapter)
btd_info(policy_data->adapter_id,
"Admin Policy Set interface registered");
+
+ if (!g_dbus_register_interface(dbus_conn, adapter_get_path(adapter),
+ ADMIN_POLICY_STATUS_INTERFACE,
+ NULL, NULL,
+ admin_policy_adapter_properties,
+ policy_data, admin_policy_free)) {
+ btd_error(policy_data->adapter_id,
+ "Admin Policy Status interface init failed on path %s",
+ adapter_get_path(adapter));
+ return -EINVAL;
+ }
+
+ btd_info(policy_data->adapter_id,
+ "Admin Policy Status interface registered");
+
return 0;
}