From 81f5b7047177a45759585796578eadb2383e1b71 Mon Sep 17 00:00:00 2001 From: Eduardo Gonzalez Date: Thu, 14 May 2026 09:49:28 +0200 Subject: [PATCH 1/2] gconnman_technology.cpp: Use int32 for freq variant Signed-off-by: Eduardo Gonzalez --- src/dbus/gconnman_technology.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/dbus/gconnman_technology.cpp b/src/dbus/gconnman_technology.cpp index e2a5cbc..f5a492b 100644 --- a/src/dbus/gconnman_technology.cpp +++ b/src/dbus/gconnman_technology.cpp @@ -60,7 +60,7 @@ void Technology::setTetheringPassphrase(const std::string& passphrase, void Technology::setTetheringFreq(const uint32_t frequency, PropertiesSetCallback callback) { auto data = prepareCallback(std::move(callback)); - setProperty(TETHERINGFREQ_STR, g_variant_new_uint32(frequency), nullptr, + setProperty(TETHERINGFREQ_STR, g_variant_new_int32(frequency), nullptr, &Technology::finishAsyncCall, data.release()); } @@ -75,7 +75,6 @@ void TechProperties::update(const gchar* key, GVariant* value) { name_ = g_variant_get_string(value, nullptr); } else if (g_strcmp0(key, TYPE_STR) == 0U) { type_ = TYPE_MAP.fromString(g_variant_get_string(value, nullptr)); - } else if (g_strcmp0(key, POWERED_STR) == 0U) { powered_ = g_variant_get_boolean(value) == 1U; } else if (g_strcmp0(key, CONNECTED_STR) == 0U) { From 18aabe1294e79e2f6d5290cb46ae591dd56b651b Mon Sep 17 00:00:00 2001 From: Eduardo Gonzalez Date: Thu, 14 May 2026 09:50:02 +0200 Subject: [PATCH 2/2] gconnman_tech_test.cpp: Add tethering tests Signed-off-by: Eduardo Gonzalez --- tests/gconnman_tech_test.cpp | 109 +++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/tests/gconnman_tech_test.cpp b/tests/gconnman_tech_test.cpp index 419e486..d09989b 100644 --- a/tests/gconnman_tech_test.cpp +++ b/tests/gconnman_tech_test.cpp @@ -8,6 +8,8 @@ using Amarula::DBus::G::Connman::Connman; using Type = Amarula::DBus::G::Connman::TechProperties::Type; +constexpr uint32_t WIFI_FREQ_2412_MHZ = 2412; + TEST(Connman, getTechs) { bool called = false; { @@ -125,6 +127,113 @@ TEST(Connman, ScanWifiTechnology) { ASSERT_TRUE(called) << "TechnologiesChanged callback was never called"; } +TEST(Connman, SetTetheringOn) { + bool called = false; + { + const ThreadBundle thread_bundle; + Connman connman; + const auto manager = connman.manager(); + + manager->onTechnologiesChanged( + [&called, main_tid = thread_bundle.main_tid, + loop_tid = thread_bundle.loop_tid](const auto& technologies) { + ASSERT_FALSE(technologies.empty()) + << "No technologies returned"; + + for (const auto& tech : technologies) { + const auto props = tech->properties(); + const auto name = props.getName(); + + if (props.getType() == Type::Wifi) { // test only wifi + std::cout << "Setting tethering properties for " << name + << "\n"; + tech->setTetheringIdentifier( + "AmarulaTestSSID", + [name, main_tid, loop_tid](bool success) { + const auto callback_tid = + std::this_thread::get_id(); + EXPECT_NE(callback_tid, main_tid); + EXPECT_NE(callback_tid, loop_tid); + EXPECT_TRUE(success) + << "Failed to set tethering identifier for " + << name; + }); + tech->setTetheringPassphrase( + "AmarulaTestPassphrase", + [name, main_tid, loop_tid](bool success) { + const auto callback_tid = + std::this_thread::get_id(); + EXPECT_NE(callback_tid, main_tid); + EXPECT_NE(callback_tid, loop_tid); + EXPECT_TRUE(success) + << "Failed to set tethering passphrase for " + << name; + }); + + tech->setTetheringFreq( + WIFI_FREQ_2412_MHZ, + [name, main_tid, loop_tid](bool success) { + const auto callback_tid = + std::this_thread::get_id(); + EXPECT_NE(callback_tid, main_tid); + EXPECT_NE(callback_tid, loop_tid); + EXPECT_TRUE(success) + << "Failed to set tethering frequency for " + << name; + }); + tech->setTethering(true, [&called, name, main_tid, + loop_tid](bool success) { + const auto callback_tid = + std::this_thread::get_id(); + EXPECT_NE(callback_tid, main_tid); + EXPECT_NE(callback_tid, loop_tid); + EXPECT_TRUE(success) + << "Failed to set tethering for " << name; + called = true; + }); + } + } + }); + } + ASSERT_TRUE(called) << "setTethering callback was never called"; +} + +TEST(Connman, SetTetheringOff) { + bool called = false; + { + const ThreadBundle thread_bundle; + Connman connman; + const auto manager = connman.manager(); + + manager->onTechnologiesChanged( + [&called, main_tid = thread_bundle.main_tid, + loop_tid = thread_bundle.loop_tid](const auto& technologies) { + ASSERT_FALSE(technologies.empty()) + << "No technologies returned"; + + for (const auto& tech : technologies) { + const auto props = tech->properties(); + const auto name = props.getName(); + + if (props.getType() == Type::Wifi) { // test only wifi + std::cout << "Disable tethering for " << name << "\n"; + tech->setTethering(false, [&called, name, main_tid, + loop_tid](bool success) { + const auto callback_tid = + std::this_thread::get_id(); + EXPECT_NE(callback_tid, main_tid); + EXPECT_NE(callback_tid, loop_tid); + EXPECT_TRUE(success) + << "Failed to unset tethering for " << name; + called = true; + }); + } + } + }); + } + ASSERT_TRUE(called) << "setTethering callback was never called"; +} + TEST(Connman, PowerOffAllTechnologies) { bool called = false; {