M module-services/service-cellular/ServiceCellular.cpp => module-services/service-cellular/ServiceCellular.cpp +14 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "endpoints/developerMode/event/ATRequest.hpp"
@@ 165,14 165,16 @@ State::ST State::get() const
return this->state;
}
-ServiceCellular::ServiceCellular() : sys::Service(serviceName, "", cellularStack, sys::ServicePriority::Idle)
+ServiceCellular::ServiceCellular()
+ : sys::Service(serviceName, "", cellularStack, sys::ServicePriority::Idle),
+ phoneModeObserver{std::make_unique<sys::phone_modes::Observer>()}
{
-
LOG_INFO("[ServiceCellular] Initializing");
bus.channels.push_back(sys::BusChannel::ServiceCellularNotifications);
bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
bus.channels.push_back(sys::BusChannel::ServiceEvtmgrNotifications);
+ bus.channels.push_back(sys::BusChannel::PhoneModeChanges);
callStateTimer = std::make_unique<sys::Timer>("call_state", this, 1000);
callStateTimer->connect([&](sys::Timer &) { CallStateTimerHandler(); });
@@ 304,6 306,15 @@ void handleCellularSimNewPinDataMessage(CellularSimNewPinDataMessage *msg)
void ServiceCellular::registerMessageHandlers()
{
+ phoneModeObserver->connect(this);
+ phoneModeObserver->subscribe(
+ []([[maybe_unused]] sys::phone_modes::PhoneMode mode, sys::phone_modes::Tethering tethering) {
+ using bsp::cellular::USB::setPassthrough;
+ using bsp::cellular::USB::PassthroughState;
+ setPassthrough(tethering == sys::phone_modes::Tethering::On ? PassthroughState::ENABLED
+ : PassthroughState::DISABLED);
+ });
+
connect(typeid(CellularSimNewPinDataMessage), [&](sys::Message *request) -> sys::MessagePointer {
auto msg = static_cast<CellularSimNewPinDataMessage *>(request);
return std::make_shared<CellularResponseMessage>(
M module-services/service-cellular/service-cellular/ServiceCellular.hpp => module-services/service-cellular/service-cellular/ServiceCellular.hpp +2 -0
@@ 29,6 29,7 @@
#include <vector> // for vector
#include <service-db/Settings.hpp>
#include <module-services/service-db/agents/settings/SystemSettings.hpp>
+#include <module-sys/PhoneModes/Observer.hpp>
#include <service-db/DBServiceName.hpp>
#include <service-db/DBNotificationMessage.hpp>
@@ 176,6 177,7 @@ class ServiceCellular : public sys::Service
DLC_channel::Callback_t notificationCallback = nullptr;
std::unique_ptr<packet_data::PacketData> packetData;
+ std::unique_ptr<sys::phone_modes::Observer> phoneModeObserver;
cellular::State state;
bsp::Board board = bsp::Board::none;
M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +4 -0
@@ 25,6 25,8 @@
#include <filesystem>
#include <module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp>
#include <module-services/service-db/agents/settings/SystemSettings.hpp>
+#include <module-sys/SystemManager/Constants.hpp>
+#include <module-sys/SystemManager/messages/TetheringStateRequest.hpp>
#include <purefs/filesystem_paths.hpp>
#include <sys/mount.h>
@@ 206,6 208,8 @@ sys::ReturnCodes ServiceDesktop::InitHandler()
LOG_INFO("USB disconnected. Enabling secured endpoints.");
bus.sendUnicast(std::make_shared<sdesktop::passcode::ScreenPasscodeRequest>(true),
app::manager::ApplicationManager::ServiceName);
+ bus.sendUnicast(std::make_shared<sys::TetheringStateRequest>(sys::phone_modes::Tethering::Off),
+ service::name::system_manager);
return sys::MessageNone{};
});