~aleteoryx/muditaos

702287ea0c589583b111f3d8a947d4d939fe28c9 — Piotr Tański 4 years ago 53fe43c
[EGD-7748] Fixed lazy auto lock setting refresh

The auto lock value refresh was visible to a user.
M module-apps/application-settings/ApplicationSettings.cpp => module-apps/application-settings/ApplicationSettings.cpp +4 -9
@@ 309,13 309,6 @@ namespace app
            return sys::MessageNone{};
        });

        connect(typeid(manager::GetAutoLockTimeoutResponse), [&](sys::Message *msg) {
            auto response = static_cast<manager::GetAutoLockTimeoutResponse *>(msg);
            auto data     = std::make_unique<gui::AutoLockData>(response->getValue());
            updateCurrentWindow(std::move(data));
            return sys::MessageNone{};
        });

        connect(typeid(AudioStopNotification), [&](sys::Message *msg) -> sys::MessagePointer {
            auto notification = static_cast<AudioStopNotification *>(msg);
            return handleAudioStop(notification);


@@ 736,9 729,11 @@ namespace app
        CellularServiceAPI::SetConnectionFrequency(this, val);
    }

    void ApplicationSettings::getAutoLockTime()
    auto ApplicationSettings::getAutoLockTime() -> std::chrono::seconds
    {
        bus.sendUnicast(std::make_shared<app::manager::GetAutoLockTimeoutRequest>(), service::name::appmgr);
        auto intervalValue =
            settings->getValue(::settings::SystemProperties::autoLockTimeInSec, ::settings::SettingsScope::Global);
        return std::chrono::seconds{utils::getNumericValue<unsigned int>(intervalValue)};
    }

    auto ApplicationSettings::getCurrentPhoneMode() const noexcept -> sys::phone_modes::PhoneMode

M module-apps/application-settings/include/application-settings/ApplicationSettings.hpp => module-apps/application-settings/include/application-settings/ApplicationSettings.hpp +2 -2
@@ 94,7 94,7 @@ namespace app
        class AutoLockSettings
        {
          public:
            virtual void getAutoLockTime()                              = 0;
            virtual auto getAutoLockTime() -> std::chrono::seconds      = 0;
            virtual void setAutoLockTime(std::chrono::seconds lockTime) = 0;
        };



@@ 166,7 166,7 @@ namespace app
        auto getConnectionFrequency() const noexcept -> uint8_t override;
        void setConnectionFrequency(uint8_t val) noexcept override;

        void getAutoLockTime() override;
        auto getAutoLockTime() -> std::chrono::seconds override;
        void setAutoLockTime(std::chrono::seconds lockTime) override;

        auto getCurrentPhoneMode() const noexcept -> sys::phone_modes::PhoneMode override;

M module-apps/application-settings/windows/security/AutolockWindow.cpp => module-apps/application-settings/windows/security/AutolockWindow.cpp +8 -14
@@ 15,13 15,13 @@ namespace gui
    namespace
    {
        const std::vector<std::pair<std::string, std::chrono::seconds>> autoLockTimes = {
            {"15s", std::chrono::seconds{15}},
            {"30s", std::chrono::seconds{30}},
            {"1m", std::chrono::minutes{1}},
            {"2m", std::chrono::minutes{2}},
            {"5m", std::chrono::minutes{5}},
            {"10m", std::chrono::minutes{10}},
            {"20m", std::chrono::minutes{20}}};
            {"15 s", std::chrono::seconds{15}},
            {"30 s", std::chrono::seconds{30}},
            {"1 m", std::chrono::minutes{1}},
            {"2 m", std::chrono::minutes{2}},
            {"5 m", std::chrono::minutes{5}},
            {"10 m", std::chrono::minutes{10}},
            {"20 m", std::chrono::minutes{20}}};
    } // namespace

    AutolockWindow::AutolockWindow(app::ApplicationCommon *app,


@@ 59,13 59,7 @@ namespace gui

    void AutolockWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        if (auto autoLockData = dynamic_cast<const AutoLockData *>(data); data != nullptr) {
            currentAutoLockTimeout = autoLockData->getValue();
        }
        else if (mode == ShowMode::GUI_SHOW_INIT) {
            autoLockSettings->getAutoLockTime();
        }

        currentAutoLockTimeout = autoLockSettings->getAutoLockTime();
        auto it = std::find_if(
            autoLockTimes.begin(), autoLockTimes.end(), [&](const std::pair<std::string, std::chrono::seconds> &elem) {
                return elem.second == currentAutoLockTimeout;

M module-services/service-appmgr/include/service-appmgr/messages/AutoLockRequests.hpp => module-services/service-appmgr/include/service-appmgr/messages/AutoLockRequests.hpp +0 -21
@@ 7,26 7,6 @@

namespace app::manager
{

    class GetAutoLockTimeoutRequest : public BaseMessage
    {
      public:
    };

    class GetAutoLockTimeoutResponse : public sys::ResponseMessage
    {
        std::chrono::seconds value;

      public:
        explicit GetAutoLockTimeoutResponse(std::chrono::seconds value) : value{value}
        {}

        [[nodiscard]] auto getValue() const noexcept
        {
            return value;
        }
    };

    class SetAutoLockTimeoutRequest : public BaseMessage
    {
        std::chrono::seconds value;


@@ 40,5 20,4 @@ namespace app::manager
            return value;
        }
    };

} // namespace app::manager

M module-services/service-appmgr/include/service-appmgr/model/ApplicationManagerCommon.hpp => module-services/service-appmgr/include/service-appmgr/model/ApplicationManagerCommon.hpp +0 -5
@@ 35,11 35,6 @@
namespace app
{
    class ApplicationLauncher;
    namespace manager
    {
        class GetAutoLockTimeoutRequest;
        class SetAutoLockTimeoutRequest;
    } // namespace manager
} // namespace app

namespace app::manager

M products/PurePhone/services/appmgr/ApplicationManager.cpp => products/PurePhone/services/appmgr/ApplicationManager.cpp +0 -13
@@ 206,10 206,6 @@ namespace app::manager
            notificationProvider.handle(req);
            return sys::msgHandled();
        });
        connect(typeid(GetAutoLockTimeoutRequest), [&](sys::Message *request) -> sys::MessagePointer {
            auto req = static_cast<GetAutoLockTimeoutRequest *>(request);
            return handleAutoLockGetRequest(req);
        });
        connect(typeid(SetAutoLockTimeoutRequest), [&](sys::Message *request) -> sys::MessagePointer {
            auto req = static_cast<SetAutoLockTimeoutRequest *>(request);
            return handleAutoLockSetRequest(req);


@@ 431,15 427,6 @@ namespace app::manager
        notificationProvider.handleSnooze(snoozeCount);
    }

    auto ApplicationManager::handleAutoLockGetRequest([[maybe_unused]] GetAutoLockTimeoutRequest *request)
        -> std::shared_ptr<sys::ResponseMessage>
    {
        auto intervalValue =
            settings->getValue(settings::SystemProperties::autoLockTimeInSec, settings::SettingsScope::Global);
        const auto interval = std::chrono::seconds{utils::getNumericValue<unsigned int>(intervalValue)};
        return std::make_shared<GetAutoLockTimeoutResponse>(interval);
    }

    auto ApplicationManager::handleAutoLockSetRequest(SetAutoLockTimeoutRequest *request)
        -> std::shared_ptr<sys::ResponseMessage>
    {

M products/PurePhone/services/appmgr/include/appmgr/ApplicationManager.hpp => products/PurePhone/services/appmgr/include/appmgr/ApplicationManager.hpp +2 -2
@@ 11,6 11,8 @@

namespace app::manager
{
    class SetAutoLockTimeoutRequest;

    class ApplicationManager : public ApplicationManagerCommon
    {
      public:


@@ 22,7 24,6 @@ namespace app::manager
        auto InitHandler() -> sys::ReturnCodes override;
        void changePhoneMode(sys::phone_modes::PhoneMode phoneMode, const ApplicationHandle *app);
        void handlePhoneModeChanged(sys::phone_modes::PhoneMode phoneMode);
        auto handleBluetoothModeChangedAction(ActionEntry &action) -> ActionProcessStatus;
        void handleBluetoothModeChanged(sys::bluetooth::BluetoothMode mode);
        void handleAlarmClockStatusChanged(bool status);
        void changeBluetoothMode(const ApplicationHandle *app);


@@ 32,7 33,6 @@ namespace app::manager
        void processKeypadBacklightState(bsp::keypad_backlight::State keypadLightState);
        void registerMessageHandlers() override;
        void startBackgroundApplications();
        auto handleAutoLockGetRequest(GetAutoLockTimeoutRequest *request) -> std::shared_ptr<sys::ResponseMessage>;
        auto handleAutoLockSetRequest(SetAutoLockTimeoutRequest *request) -> std::shared_ptr<sys::ResponseMessage>;
        auto handleDeveloperModeRequest(sys::Message *request) -> sys::MessagePointer override;
        void lockTimeChanged(std::string value);