Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Linux] Optimize generated glib D-Bus integration stubs #37492

Merged
merged 6 commits into from
Feb 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/controller/python/chip/ble/LinuxImpl.cpp
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
#include <platform/Linux/bluez/AdapterIterator.h>
#include <platform/Linux/bluez/BluezObjectManager.h>
#include <platform/Linux/bluez/ChipDeviceScanner.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>
#include <platform/PlatformManager.h>
#include <system/SystemClock.h>
#include <system/SystemLayer.h>
177 changes: 88 additions & 89 deletions src/platform/Linux/ConnectivityManagerImpl.cpp

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions src/platform/Linux/ConnectivityManagerImpl.h
Original file line number Diff line number Diff line change
@@ -86,13 +86,13 @@ struct GDBusWpaSupplicant
SCANNING,
};

WpaState state = WpaState::INIT;
WpaScanningState scanState = WpaScanningState::IDLE;
WpaFiW1Wpa_supplicant1 * proxy = nullptr;
WpaFiW1Wpa_supplicant1Interface * iface = nullptr;
WpaFiW1Wpa_supplicant1BSS * bss = nullptr;
gchar * interfacePath = nullptr;
gchar * networkPath = nullptr;
WpaState state = WpaState::INIT;
WpaScanningState scanState = WpaScanningState::IDLE;
WpaSupplicant1 * proxy = nullptr;
WpaSupplicant1Interface * iface = nullptr;
WpaSupplicant1BSS * bss = nullptr;
gchar * interfacePath = nullptr;
gchar * networkPath = nullptr;
};
#endif

@@ -222,10 +222,10 @@ class ConnectivityManagerImpl final : public ConnectivityManager,
CHIP_ERROR StopAutoScan();

void _OnWpaProxyReady(GObject * sourceObject, GAsyncResult * res);
void _OnWpaInterfaceRemoved(WpaFiW1Wpa_supplicant1 * proxy, const char * path, GVariant * properties);
void _OnWpaInterfaceAdded(WpaFiW1Wpa_supplicant1 * proxy, const char * path, GVariant * properties);
void _OnWpaPropertiesChanged(WpaFiW1Wpa_supplicant1Interface * proxy, GVariant * properties);
void _OnWpaInterfaceScanDone(WpaFiW1Wpa_supplicant1Interface * proxy, gboolean success);
void _OnWpaInterfaceRemoved(WpaSupplicant1 * proxy, const char * path, GVariant * properties);
void _OnWpaInterfaceAdded(WpaSupplicant1 * proxy, const char * path, GVariant * properties);
void _OnWpaPropertiesChanged(WpaSupplicant1Interface * proxy, GVariant * properties);
void _OnWpaInterfaceScanDone(WpaSupplicant1Interface * proxy, gboolean success);
void _OnWpaInterfaceReady(GObject * sourceObject, GAsyncResult * res);
void _OnWpaInterfaceProxyReady(GObject * sourceObject, GAsyncResult * res);
void _OnWpaBssProxyReady(GObject * sourceObject, GAsyncResult * res);
36 changes: 18 additions & 18 deletions src/platform/Linux/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ namespace {

struct SetActiveDatasetContext
{
OpenthreadIoOpenthreadBorderRouter * proxy;
OpenthreadBorderRouter * proxy;
ByteSpan netInfo;
};

@@ -67,7 +67,7 @@ CHIP_ERROR GLibMatterContextSetActiveDataset(SetActiveDatasetContext * context)
GAutoPtr<GVariant> value(g_variant_new_from_bytes(G_VARIANT_TYPE_BYTESTRING, bytes.release(), true));
if (!value)
return CHIP_ERROR_NO_MEMORY;
openthread_io_openthread_border_router_set_active_dataset_tlvs(context->proxy, value.release());
openthread_border_router_set_active_dataset_tlvs(context->proxy, value.release());
return CHIP_NO_ERROR;
}

@@ -82,9 +82,9 @@ CHIP_ERROR ThreadStackManagerImpl::GLibMatterContextInitThreadStack(ThreadStackM
VerifyOrDie(g_main_context_get_thread_default() != nullptr);

GAutoPtr<GError> err;
self->mProxy.reset(openthread_io_openthread_border_router_proxy_new_for_bus_sync(
G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kDBusOpenThreadService, kDBusOpenThreadObjectPath, nullptr,
&err.GetReceiver()));
self->mProxy.reset(openthread_border_router_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE,
kDBusOpenThreadService, kDBusOpenThreadObjectPath, nullptr,
&err.GetReceiver()));
VerifyOrReturnError(
self->mProxy != nullptr, CHIP_ERROR_INTERNAL,
ChipLogError(DeviceLayer, "openthread: failed to create openthread dbus proxy %s", err ? err->message : "unknown error"));
@@ -103,7 +103,7 @@ CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack()

// If get property is called inside dbus thread (we are going to make it so), XXX_get_XXX can be used instead of XXX_dup_XXX
// which is a little bit faster and the returned object doesn't need to be freed. Same for all following get properties.
GAutoPtr<char> role(openthread_io_openthread_border_router_dup_device_role(mProxy.get()));
GAutoPtr<char> role(openthread_border_router_dup_device_role(mProxy.get()));
if (role)
{
ThreadDeviceRoleChangedHandler(role.get());
@@ -112,7 +112,7 @@ CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack()
return CHIP_NO_ERROR;
}

void ThreadStackManagerImpl::OnDbusPropertiesChanged(OpenthreadIoOpenthreadBorderRouter * proxy, GVariant * changed_properties,
void ThreadStackManagerImpl::OnDbusPropertiesChanged(OpenthreadBorderRouter * proxy, GVariant * changed_properties,
const gchar * const * invalidated_properties, gpointer user_data)
{
ThreadStackManagerImpl * me = reinterpret_cast<ThreadStackManagerImpl *>(user_data);
@@ -182,7 +182,7 @@ bool ThreadStackManagerImpl::_HaveRouteToAddress(const Inet::IPAddress & destAdd
return true;
}

GAutoPtr<GVariant> routes(openthread_io_openthread_border_router_dup_external_routes(mProxy.get()));
GAutoPtr<GVariant> routes(openthread_border_router_dup_external_routes(mProxy.get()));
if (!routes)
return false;

@@ -368,7 +368,7 @@ bool ThreadStackManagerImpl::_IsThreadAttached() const
CHIP_ERROR ThreadStackManagerImpl::GLibMatterContextCallAttach(ThreadStackManagerImpl * self)
{
VerifyOrDie(g_main_context_get_thread_default() != nullptr);
openthread_io_openthread_border_router_call_attach(self->mProxy.get(), nullptr, _OnThreadBrAttachFinished, self);
openthread_border_router_call_attach(self->mProxy.get(), nullptr, _OnThreadBrAttachFinished, self);
return CHIP_NO_ERROR;
}

@@ -383,7 +383,7 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadEnabled(bool val)
else
{
GAutoPtr<GError> err;
gboolean result = openthread_io_openthread_border_router_call_reset_sync(mProxy.get(), nullptr, &err.GetReceiver());
gboolean result = openthread_border_router_call_reset_sync(mProxy.get(), nullptr, &err.GetReceiver());
if (err)
{
ChipLogError(DeviceLayer, "openthread: _SetThreadEnabled calling %s failed: %s", "Reset", err->message);
@@ -405,7 +405,7 @@ void ThreadStackManagerImpl::_OnThreadBrAttachFinished(GObject * source_object,
GAutoPtr<GVariant> attachRes;
GAutoPtr<GError> err;
{
gboolean result = openthread_io_openthread_border_router_call_attach_finish(this_->mProxy.get(), res, &err.GetReceiver());
gboolean result = openthread_border_router_call_attach_finish(this_->mProxy.get(), res, &err.GetReceiver());
if (!result)
{
ChipLogError(DeviceLayer, "Failed to perform finish Thread network scan: %s",
@@ -442,7 +442,7 @@ ConnectivityManager::ThreadDeviceType ThreadStackManagerImpl::_GetThreadDeviceTy
return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported;
}

GAutoPtr<char> role(openthread_io_openthread_border_router_dup_device_role(mProxy.get()));
GAutoPtr<char> role(openthread_border_router_dup_device_role(mProxy.get()));
if (!role)
return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported;
if (strcmp(role.get(), kOpenthreadDeviceRoleDetached) == 0 || strcmp(role.get(), kOpenthreadDeviceRoleDisabled) == 0)
@@ -451,7 +451,7 @@ ConnectivityManager::ThreadDeviceType ThreadStackManagerImpl::_GetThreadDeviceTy
}
if (strcmp(role.get(), kOpenthreadDeviceRoleChild) == 0)
{
GAutoPtr<GVariant> linkMode(openthread_io_openthread_border_router_dup_link_mode(mProxy.get()));
GAutoPtr<GVariant> linkMode(openthread_border_router_dup_link_mode(mProxy.get()));
if (!linkMode)
return ConnectivityManager::ThreadDeviceType::kThreadDeviceType_NotSupported;
gboolean rx_on_when_idle;
@@ -499,7 +499,7 @@ CHIP_ERROR ThreadStackManagerImpl::_SetThreadDeviceType(ConnectivityManager::Thr
GAutoPtr<GVariant> linkMode(g_variant_new("(bbb)", rx_on_when_idle, device_type, network_data));
if (!linkMode)
return CHIP_ERROR_NO_MEMORY;
openthread_io_openthread_border_router_set_link_mode(mProxy.get(), linkMode.release());
openthread_border_router_set_link_mode(mProxy.get(), linkMode.release());
}

return CHIP_NO_ERROR;
@@ -546,7 +546,7 @@ CHIP_ERROR ThreadStackManagerImpl::_GetAndLogThreadTopologyFull()
CHIP_ERROR ThreadStackManagerImpl::_GetPrimary802154MACAddress(uint8_t * buf)
{
VerifyOrReturnError(mProxy, CHIP_ERROR_INCORRECT_STATE);
guint64 extAddr = openthread_io_openthread_border_router_get_extended_address(mProxy.get());
guint64 extAddr = openthread_border_router_get_extended_address(mProxy.get());

for (size_t i = 0; i < sizeof(extAddr); i++)
{
@@ -579,7 +579,7 @@ CHIP_ERROR ThreadStackManagerImpl::_GetPollPeriod(uint32_t & buf)
CHIP_ERROR ThreadStackManagerImpl::GLibMatterContextCallScan(ThreadStackManagerImpl * self)
{
VerifyOrDie(g_main_context_get_thread_default() != nullptr);
openthread_io_openthread_border_router_call_scan(self->mProxy.get(), nullptr, _OnNetworkScanFinished, self);
openthread_border_router_call_scan(self->mProxy.get(), nullptr, _OnNetworkScanFinished, self);
return CHIP_NO_ERROR;
}

@@ -604,8 +604,8 @@ void ThreadStackManagerImpl::_OnNetworkScanFinished(GAsyncResult * res)
GAutoPtr<GVariant> scan_result;
GAutoPtr<GError> err;
{
gboolean result = openthread_io_openthread_border_router_call_scan_finish(mProxy.get(), &scan_result.GetReceiver(), res,
&err.GetReceiver());
gboolean result =
openthread_border_router_call_scan_finish(mProxy.get(), &scan_result.GetReceiver(), res, &err.GetReceiver());
if (!result)
{
ChipLogError(DeviceLayer, "Failed to perform finish Thread network scan: %s",
8 changes: 4 additions & 4 deletions src/platform/Linux/ThreadStackManagerImpl.h
Original file line number Diff line number Diff line change
@@ -23,15 +23,15 @@
#include <app/icd/server/ICDServerConfig.h>
#include <lib/support/ThreadOperationalDataset.h>
#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/openthread/introspect.h>
#include <platform/Linux/dbus/openthread/DBusOpenthread.h>
#include <platform/NetworkCommissioning.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>
#include <platform/internal/DeviceNetworkInfo.h>

namespace chip {

template <>
struct GAutoPtrDeleter<OpenthreadIoOpenthreadBorderRouter>
struct GAutoPtrDeleter<OpenthreadBorderRouter>
{
using deleter = GObjectDeleter;
};
@@ -149,12 +149,12 @@ class ThreadStackManagerImpl : public ThreadStackManager
uint8_t lqi;
};

GAutoPtr<OpenthreadIoOpenthreadBorderRouter> mProxy;
GAutoPtr<OpenthreadBorderRouter> mProxy;

static CHIP_ERROR GLibMatterContextInitThreadStack(ThreadStackManagerImpl * self);
static CHIP_ERROR GLibMatterContextCallAttach(ThreadStackManagerImpl * self);
static CHIP_ERROR GLibMatterContextCallScan(ThreadStackManagerImpl * self);
static void OnDbusPropertiesChanged(OpenthreadIoOpenthreadBorderRouter * proxy, GVariant * changed_properties,
static void OnDbusPropertiesChanged(OpenthreadBorderRouter * proxy, GVariant * changed_properties,
const gchar * const * invalidated_properties, gpointer user_data);
void ThreadDeviceRoleChangedHandler(const gchar * role);

2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/AdapterIterator.cpp
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>

#include "BluezObjectIterator.h"
#include "BluezObjectList.h"
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/AdapterIterator.h
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
#include <cstdint>

#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>

#include "BluezObjectIterator.h"
#include "BluezObjectManager.h"
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezAdvertisement.cpp
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
#include <lib/support/logging/CHIPLogging.h>
#include <platform/ConfigurationManager.h>
#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>
#include <platform/PlatformManager.h>

#include "BluezEndpoint.h"
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezAdvertisement.h
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@
#include <ble/Ble.h>
#include <lib/core/CHIPError.h>
#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>

#include "BluezEndpoint.h"
#include "Types.h"
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezConnection.cpp
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@
#include <lib/support/CodeUtils.h>
#include <platform/ConnectivityManager.h>
#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>
#include <platform/PlatformManager.h>
#include <platform/internal/BLEManager.h>
#include <system/SystemPacketBuffer.h>
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezConnection.h
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@

#include <lib/core/CHIPError.h>
#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>
#include <system/SystemPacketBuffer.h>

#include "Types.h"
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezEndpoint.cpp
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@
#include <platform/ConnectivityManager.h>
#include <platform/DeviceInstanceInfoProvider.h>
#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>
#include <platform/PlatformManager.h>
#include <platform/internal/BLEManager.h>
#include <setup_payload/AdditionalDataPayloadGenerator.h>
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezEndpoint.h
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@
#include <ble/Ble.h>
#include <lib/core/CHIPError.h>
#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>

#include "BluezConnection.h"
#include "BluezObjectManager.h"
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezObjectIterator.h
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
#include <glib.h>

#include <platform/CHIPDeviceConfig.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>

namespace chip {
namespace DeviceLayer {
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezObjectList.h
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@

#include <lib/support/logging/CHIPLogging.h>
#include <platform/CHIPDeviceConfig.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>

#include "BluezObjectIterator.h"

2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/BluezObjectManager.cpp
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
#include <lib/support/logging/CHIPLogging.h>
#include <platform/ConfigurationManager.h>
#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>
#include <platform/PlatformManager.h>

#include "Types.h"
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/ChipDeviceScanner.h
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@
#include <ble/Ble.h>
#include <lib/core/CHIPError.h>
#include <platform/GLibTypeDeleter.h>
#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>
#include <system/SystemLayer.h>

#include "BluezObjectManager.h"
2 changes: 1 addition & 1 deletion src/platform/Linux/bluez/Types.h
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@

#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE

#include <platform/Linux/dbus/bluez/DbusBluez.h>
#include <platform/Linux/dbus/bluez/DBusBluez.h>

namespace chip {

2 changes: 1 addition & 1 deletion src/platform/Linux/dbus/bluez/BUILD.gn
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ import("//build_overrides/chip.gni")
import("${chip_root}/build/chip/linux/gdbus_library.gni")

gdbus_library("bluez") {
sources = [ "DbusBluez.xml" ]
sources = [ "DBusBluez.xml" ]

c_namespace = "Bluez"
interface_prefix = "org.bluez"
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
# Copyright (c) 2020 Project CHIP Authors
#
@@ -21,8 +20,10 @@
# relevant for the Matter GATT service and advertisement management. Also,
# some properties and methods not used by Matter are omitted in order to
# decrease the size of Matter SDK library.
#
-->
<!DOCTYPE node PUBLIC
"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">

<node>

@@ -158,9 +159,9 @@
<property name="Discoverable" type="b" access="read"/>
<!--
Do not expose discoverable timeout property, so BlueZ will set it
internally to zero, effectively disabling the timeout. Becase of BlueZ
internally to zero, effectively disabling the timeout. Because of BlueZ
bug, which is not fixed until BlueZ 5.73, exposing discoverable timeout
as zero will timout the advertisement immediately.
as zero will timeout the advertisement immediately.

<property name="DiscoverableTimeout" type="q" access="read"/>
-->
3 changes: 2 additions & 1 deletion src/platform/Linux/dbus/openthread/BUILD.gn
Original file line number Diff line number Diff line change
@@ -17,9 +17,10 @@ import("//build_overrides/chip.gni")
import("${chip_root}/build/chip/linux/gdbus_library.gni")

gdbus_library("openthread") {
sources = [ "introspect.xml" ]
sources = [ "DBusOpenthread.xml" ]

c_namespace = "Openthread"
interface_prefix = "io.openthread"
c_generate_object_manager = false
dbus_out_dir = "platform/Linux/dbus/openthread"
}
Loading
Loading