From 6c8d0daa55b382737786809bad0ae341e2222283 Mon Sep 17 00:00:00 2001 From: "yying.jin" Date: Tue, 10 Feb 2026 14:27:54 +0800 Subject: [PATCH 1/2] replace eldbus with gdbus --- flutter/shell/platform/tizen/BUILD.gn | 5 +- .../tizen/channels/accessibility_channel.cc | 104 ++++++++++++------ .../tizen/channels/accessibility_channel.h | 8 +- tools/generate_sysroot.py | 3 +- 4 files changed, 77 insertions(+), 43 deletions(-) diff --git a/flutter/shell/platform/tizen/BUILD.gn b/flutter/shell/platform/tizen/BUILD.gn index f12a9c4b..3d9dfd0b 100644 --- a/flutter/shell/platform/tizen/BUILD.gn +++ b/flutter/shell/platform/tizen/BUILD.gn @@ -25,13 +25,14 @@ config("flutter_tizen_config") { "${sysroot_path}/usr/include/efl-1", "${sysroot_path}/usr/include/eina-1", "${sysroot_path}/usr/include/eina-1/eina", - "${sysroot_path}/usr/include/eldbus-1", "${sysroot_path}/usr/include/eo-1", "${sysroot_path}/usr/include/feedback", "${sysroot_path}/usr/include/system", "${sysroot_path}/usr/include/tzsh", "${sysroot_path}/usr/include/vconf", "${sysroot_path}/usr/include/wayland-extension", + "${sysroot_path}/usr/include/glib-2.0", + "${sysroot_path}/usr/lib/glib-2.0/include", ] cflags_cc = [ @@ -117,7 +118,7 @@ template("embedder") { "ecore_input", "ecore_wl2", "eina", - "eldbus", + "gio-2.0", "feedback", "flutter_engine", "tbm", diff --git a/flutter/shell/platform/tizen/channels/accessibility_channel.cc b/flutter/shell/platform/tizen/channels/accessibility_channel.cc index 8e2a50d6..409a8222 100644 --- a/flutter/shell/platform/tizen/channels/accessibility_channel.cc +++ b/flutter/shell/platform/tizen/channels/accessibility_channel.cc @@ -22,27 +22,44 @@ constexpr char kAtspiDirectReadInterface[] = "org.tizen.DirectReading"; } // namespace -static void _accessibilityBusAddressGet(void* data, - const Eldbus_Message* message, - Eldbus_Pending* pending) { - Eldbus_Connection** accessibility_bus = - static_cast(data); - const char* error_name = nullptr; - const char* error_message = nullptr; - const char* socket_address = nullptr; - - if (eldbus_message_error_get(message, &error_name, &error_message)) { - FT_LOG(Error) << "Eldbus message error. (" << error_name << " : " - << error_message << ")"; +static void _accessibilityBusAddressGet(GObject* source_object, + GAsyncResult* res, + gpointer user_data) { + GError* error = nullptr; + GVariant* result = nullptr; + GDBusConnection** accessibility_bus = + static_cast(user_data); + + GDBusProxy* proxy = G_DBUS_PROXY(source_object); + result = g_dbus_proxy_call_finish(proxy, res, &error); + + if (error) { + FT_LOG(Error) << "GDBus message error. (" << error->message << ")"; + g_error_free(error); return; } - if (!eldbus_message_arguments_get(message, "s", &socket_address) || - !socket_address) { + const gchar* socket_address = nullptr; + if (g_variant_is_of_type(result, G_VARIANT_TYPE("(s)"))) { + g_variant_get(result, "(&s)", &socket_address); + } + + if (!socket_address) { FT_LOG(Error) << "Could not get A11Y Bus socket address."; + g_variant_unref(result); return; } - *accessibility_bus = eldbus_private_address_connection_get(socket_address); + + *accessibility_bus = g_dbus_connection_new_for_address_sync( + socket_address, G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, nullptr, + nullptr, &error); + + if (error) { + FT_LOG(Error) << "Failed to connect to A11Y Bus: " << error->message; + g_error_free(error); + } + + g_variant_unref(result); } AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger) @@ -50,16 +67,27 @@ AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger) messenger, kChannelName, &StandardMessageCodec::GetInstance())) { - eldbus_init(); + GError* error = nullptr; + session_bus_ = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error); + if (error) { + FT_LOG(Error) << "Failed to get session bus: " << error->message; + g_error_free(error); + return; + } - session_bus_ = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); - bus_ = eldbus_object_get(session_bus_, kAccessibilityDbus, - kAccessibilityDbusPath); + bus_ = g_dbus_proxy_new_sync(session_bus_, G_DBUS_PROXY_FLAGS_NONE, nullptr, + kAccessibilityDbus, kAccessibilityDbusPath, + kAccessibilityDbusInterface, nullptr, &error); - Eldbus_Message* method = eldbus_object_method_call_new( - bus_, kAccessibilityDbusInterface, "GetAddress"); - eldbus_object_send(bus_, method, _accessibilityBusAddressGet, - &accessibility_bus_, 100); + if (error) { + FT_LOG(Error) << "Failed to create proxy: " << error->message; + g_error_free(error); + return; + } + + g_dbus_proxy_call(bus_, "GetAddress", nullptr, G_DBUS_CALL_FLAGS_NONE, -1, + nullptr, (GAsyncReadyCallback)_accessibilityBusAddressGet, + &accessibility_bus_); channel_->SetMessageHandler([&](const auto& message, auto reply) { if (std::holds_alternative(message)) { @@ -72,14 +100,11 @@ AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger) if (*type == "announce" && data) { EncodableValueHolder msg(data.value, "message"); if (msg && accessibility_bus_) { - Eldbus_Message* eldbus_message = eldbus_message_method_call_new( - kAtspiDirectReadBus, kAtspiDirectReadPath, - kAtspiDirectReadInterface, "ReadCommand"); - Eldbus_Message_Iter* iter = eldbus_message_iter_get(eldbus_message); - eldbus_message_iter_arguments_append(iter, "sb", msg->c_str(), - true); - eldbus_connection_send(accessibility_bus_, eldbus_message, nullptr, - nullptr, -1); + GVariant* params = g_variant_new("(sb)", msg->c_str(), TRUE); + g_dbus_connection_call( + accessibility_bus_, kAtspiDirectReadBus, kAtspiDirectReadPath, + kAtspiDirectReadInterface, "ReadCommand", params, nullptr, + G_DBUS_CALL_FLAGS_NONE, -1, nullptr, nullptr, nullptr); } } } @@ -91,11 +116,20 @@ AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger) AccessibilityChannel::~AccessibilityChannel() { channel_->SetMessageHandler(nullptr); - eldbus_connection_unref(accessibility_bus_); - eldbus_connection_unref(session_bus_); - eldbus_object_unref(bus_); + if (accessibility_bus_) { + g_object_unref(accessibility_bus_); + accessibility_bus_ = nullptr; + } - eldbus_shutdown(); + if (session_bus_) { + g_object_unref(session_bus_); + session_bus_ = nullptr; + } + + if (bus_) { + g_object_unref(bus_); + bus_ = nullptr; + } } } // namespace flutter diff --git a/flutter/shell/platform/tizen/channels/accessibility_channel.h b/flutter/shell/platform/tizen/channels/accessibility_channel.h index da112f72..86656c00 100644 --- a/flutter/shell/platform/tizen/channels/accessibility_channel.h +++ b/flutter/shell/platform/tizen/channels/accessibility_channel.h @@ -5,7 +5,7 @@ #ifndef EMBEDDER_ACCESSIBILITY_CHANNEL_H_ #define EMBEDDER_ACCESSIBILITY_CHANNEL_H_ -#include +#include #include #include @@ -23,9 +23,9 @@ class AccessibilityChannel { private: std::unique_ptr> channel_; - Eldbus_Connection* session_bus_ = nullptr; - Eldbus_Connection* accessibility_bus_ = nullptr; - Eldbus_Object* bus_ = nullptr; + GDBusConnection* session_bus_ = nullptr; + GDBusConnection* accessibility_bus_ = nullptr; + GDBusProxy* bus_ = nullptr; }; } // namespace flutter diff --git a/tools/generate_sysroot.py b/tools/generate_sysroot.py index 2116b6d5..d160a266 100755 --- a/tools/generate_sysroot.py +++ b/tools/generate_sysroot.py @@ -59,10 +59,9 @@ 'eina', 'eina-devel', 'eina-tools', - 'eldbus', - 'eldbus-devel', 'eo-devel', 'glib2-devel', + 'libgio', 'jsoncpp', 'jsoncpp-devel', 'libatk', From 60318b2c90d55260a08ebf2382aa2971bfa1d437 Mon Sep 17 00:00:00 2001 From: "yying.jin" Date: Wed, 11 Feb 2026 15:07:45 +0800 Subject: [PATCH 2/2] use g_autoptr for automatically free --- .../tizen/channels/accessibility_channel.cc | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/flutter/shell/platform/tizen/channels/accessibility_channel.cc b/flutter/shell/platform/tizen/channels/accessibility_channel.cc index 409a8222..25aac3e0 100644 --- a/flutter/shell/platform/tizen/channels/accessibility_channel.cc +++ b/flutter/shell/platform/tizen/channels/accessibility_channel.cc @@ -25,8 +25,8 @@ constexpr char kAtspiDirectReadInterface[] = "org.tizen.DirectReading"; static void _accessibilityBusAddressGet(GObject* source_object, GAsyncResult* res, gpointer user_data) { - GError* error = nullptr; - GVariant* result = nullptr; + g_autoptr(GError) error = nullptr; + g_autoptr(GVariant) result = nullptr; GDBusConnection** accessibility_bus = static_cast(user_data); @@ -34,8 +34,7 @@ static void _accessibilityBusAddressGet(GObject* source_object, result = g_dbus_proxy_call_finish(proxy, res, &error); if (error) { - FT_LOG(Error) << "GDBus message error. (" << error->message << ")"; - g_error_free(error); + FT_LOG(Error) << "GDBus message error: " << error->message; return; } @@ -46,7 +45,6 @@ static void _accessibilityBusAddressGet(GObject* source_object, if (!socket_address) { FT_LOG(Error) << "Could not get A11Y Bus socket address."; - g_variant_unref(result); return; } @@ -56,10 +54,7 @@ static void _accessibilityBusAddressGet(GObject* source_object, if (error) { FT_LOG(Error) << "Failed to connect to A11Y Bus: " << error->message; - g_error_free(error); } - - g_variant_unref(result); } AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger) @@ -67,11 +62,10 @@ AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger) messenger, kChannelName, &StandardMessageCodec::GetInstance())) { - GError* error = nullptr; + g_autoptr(GError) error = nullptr; session_bus_ = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, &error); if (error) { FT_LOG(Error) << "Failed to get session bus: " << error->message; - g_error_free(error); return; } @@ -81,7 +75,6 @@ AccessibilityChannel::AccessibilityChannel(BinaryMessenger* messenger) if (error) { FT_LOG(Error) << "Failed to create proxy: " << error->message; - g_error_free(error); return; }