~aleteoryx/muditaos

409b9b77e5c46b3f9212e2060b6c5288f56debd5 — Adam Dobrowolski 3 years ago bdcec85
[MOS-516] FIX: tethering while call disabled

We discard tethering while call now
M module-services/service-cellular/ServiceCellular.cpp => module-services/service-cellular/ServiceCellular.cpp +4 -0
@@ 613,6 613,10 @@ void ServiceCellular::registerMessageHandlers()
        return sys::MessageNone{};
    });

    connect(typeid(CellularIsCallActive), [&](sys::Message * /*request*/) -> sys::MessagePointer {
        return std::make_shared<CellularIsCallActiveResponse>(ongoingCall && ongoingCall->active());
    });

    handle_CellularGetChannelMessage();
}


M module-services/service-cellular/service-cellular/CellularMessage.hpp => module-services/service-cellular/service-cellular/CellularMessage.hpp +10 -0
@@ 1070,4 1070,14 @@ namespace cellular
        time_t callDuration;
    };

    class CellularIsCallActive : public sys::DataMessage
    {};
    struct CellularIsCallActiveResponse : public sys::ResponseMessage
    {
        explicit CellularIsCallActiveResponse(bool active) : active{active}
        {}

        const bool active = false;
    };

} // namespace cellular

M module-sys/PhoneModes/Subject.cpp => module-sys/PhoneModes/Subject.cpp +5 -3
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <PhoneModes/Subject.hpp>


@@ 13,7 13,8 @@

namespace sys::phone_modes
{
    Subject::Subject(Service *owner, std::function<bool()> simSelect) : owner{owner}, simSelected{simSelect}
    Subject::Subject(Service *owner, std::function<bool()> simSelect, std::function<bool()> isCallOngoing)
        : owner{owner}, simSelected{simSelect}, isCallOngoing{isCallOngoing}
    {
        if (owner == nullptr) {
            throw std::invalid_argument{"Subject's owner is invalid"};


@@ 81,6 82,7 @@ namespace sys::phone_modes

    bool Subject::isTetheringPossible() const noexcept
    {
        return (phoneMode != PhoneMode::Offline) && (simSelected && simSelected());
        return (phoneMode != PhoneMode::Offline) && (simSelected && simSelected()) &&
               (isCallOngoing && !isCallOngoing());
    }
} // namespace sys::phone_modes

M module-sys/PhoneModes/include/PhoneModes/Subject.hpp => module-sys/PhoneModes/include/PhoneModes/Subject.hpp +3 -2
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 16,7 16,7 @@ namespace sys::phone_modes
    class Subject
    {
      public:
        Subject(Service *owner, std::function<bool()> simSelect);
        Subject(Service *owner, std::function<bool()> simSelect, std::function<bool()> isCallOngoing);

        /**
         * Sets phone and tethering modes


@@ 54,5 54,6 @@ namespace sys::phone_modes
        PhoneMode phoneMode     = PhoneMode::Connected;
        Tethering tetheringMode = Tethering::Off;
        const std::function<bool()> simSelected;
        const std::function<bool()> isCallOngoing;
    };
} // namespace sys::phone_modes

M products/PurePhone/sys/SystemManager.cpp => products/PurePhone/sys/SystemManager.cpp +7 -1
@@ 36,7 36,13 @@ namespace sys
            return (Store::GSM::get()->selected == Store::GSM::SIM::SIM1 ||
                    Store::GSM::get()->selected == Store::GSM::SIM::SIM2);
        };
        phoneModeSubject = std::make_unique<phone_modes::Subject>(this, simSelected);
        auto isCallOngoing = [this]() {
            auto request = async_call<cellular::CellularIsCallActive, cellular::CellularIsCallActiveResponse>(
                cellular::service::name);
            sync(request);
            return request.getResult().active;
        };
        phoneModeSubject = std::make_unique<phone_modes::Subject>(this, simSelected, isCallOngoing);
        SystemManagerCommon::StartSystem(std::move(sysInit), std::move(appSpaceInit), std::move(sysDeinit));
    }