~aleteoryx/muditaos

decc1ec262760a6e6f992ce3763e6dd61dfcb6bc — Tigran Soghbatyan 4 years ago 1b16cab
[BH-1270] Fix idle timeout in applications

Implement correct idle timeout handling in applications
M products/BellHybrid/apps/Application.cpp => products/BellHybrid/apps/Application.cpp +14 -1
@@ 133,7 133,9 @@ namespace app

    void Application::restartIdleTimer()
    {
        bus.sendUnicast(std::make_shared<RestartIdleTimerMessage>(), service::name::appmgr);
        if (idleTimerActiveFlag) {
            bus.sendUnicast(std::make_shared<RestartIdleTimerMessage>(), service::name::appmgr);
        }
    }

    void Application::stopIdleTimer()


@@ 143,4 145,15 @@ namespace app

    void Application::updateStatuses(gui::AppWindow *window) const
    {}

    void Application::resumeIdleTimer()
    {
        startIdleTimer();
        idleTimerActiveFlag = true;
    }
    void Application::suspendIdleTimer()
    {
        stopIdleTimer();
        idleTimerActiveFlag = false;
    }
} // namespace app

M products/BellHybrid/apps/application-bell-meditation-timer/ApplicationBellMeditationTimer.cpp => products/BellHybrid/apps/application-bell-meditation-timer/ApplicationBellMeditationTimer.cpp +0 -4
@@ 83,8 83,4 @@ namespace app

        return handleAsyncResponse(resp);
    }

    // Empty: do not start idleTimer on application run
    void ApplicationBellMeditationTimer::onStart()
    {}
} // namespace app

M products/BellHybrid/apps/application-bell-meditation-timer/include/application-bell-meditation-timer/ApplicationBellMeditationTimer.hpp => products/BellHybrid/apps/application-bell-meditation-timer/include/application-bell-meditation-timer/ApplicationBellMeditationTimer.hpp +0 -3
@@ 41,9 41,6 @@ namespace app
        {
            return sys::ReturnCodes::Success;
        }

      private:
        void onStart() override;
    };

    template <> struct ManifestTraits<ApplicationBellMeditationTimer>

M products/BellHybrid/apps/application-bell-meditation-timer/presenter/IntervalChimePresenter.cpp => products/BellHybrid/apps/application-bell-meditation-timer/presenter/IntervalChimePresenter.cpp +2 -0
@@ 62,6 62,7 @@ namespace app::meditation
            if (option.second == value) {
                settings->setValue(
                    intervalDBRecordName, utils::to_string(option.first.count()), settings::SettingsScope::AppLocal);
                reinterpret_cast<app::Application *>(app)->suspendIdleTimer();
                app->switchWindow(gui::name::window::readyGoing);
                break;
            }


@@ 76,6 77,7 @@ namespace app::meditation
            utils::getNumericValue<int>(settings->getValue(meditationDBRecordName, settings::SettingsScope::AppLocal));
        if (duration == 1) {
            settings->setValue(intervalDBRecordName, utils::to_string(0), settings::SettingsScope::AppLocal);
            reinterpret_cast<app::Application *>(app)->suspendIdleTimer();
            app->switchWindow(gui::name::window::readyGoing);
            return;
        }

M products/BellHybrid/apps/application-bell-meditation-timer/presenter/MeditationProgressPresenter.cpp => products/BellHybrid/apps/application-bell-meditation-timer/presenter/MeditationProgressPresenter.cpp +1 -0
@@ 44,6 44,7 @@ namespace app::meditation

    void MeditationProgressPresenter::start()
    {
        reinterpret_cast<app::Application *>(app)->suspendIdleTimer();
        timer->reset(std::chrono::seconds(duration), std::chrono::seconds(interval));
        timer->start();
    }

M products/BellHybrid/apps/application-bell-meditation-timer/windows/MeditationRunningWindow.cpp => products/BellHybrid/apps/application-bell-meditation-timer/windows/MeditationRunningWindow.cpp +1 -0
@@ 126,6 126,7 @@ namespace gui
            return true;
        }
        if (inputEvent.isShortRelease(gui::KeyCode::KEY_RF)) {
            reinterpret_cast<app::Application *>(application)->resumeIdleTimer();
            presenter->abandon();
            return true;
        }

M products/BellHybrid/apps/application-bell-powernap/ApplicationBellPowerNap.cpp => products/BellHybrid/apps/application-bell-powernap/ApplicationBellPowerNap.cpp +0 -4
@@ 73,8 73,4 @@ namespace app

        return handleAsyncResponse(resp);
    }

    // Empty: do not start idleTimer on application run
    void ApplicationBellPowerNap::onStart()
    {}
} // namespace app

M products/BellHybrid/apps/application-bell-powernap/include/application-bell-powernap/ApplicationBellPowerNap.hpp => products/BellHybrid/apps/application-bell-powernap/include/application-bell-powernap/ApplicationBellPowerNap.hpp +0 -3
@@ 44,9 44,6 @@ namespace app
        {
            return sys::ReturnCodes::Success;
        }

      private:
        void onStart() override;
    };

    template <> struct ManifestTraits<ApplicationBellPowerNap>

M products/BellHybrid/apps/application-bell-powernap/presenter/PowerNapMainWindowPresenter.cpp => products/BellHybrid/apps/application-bell-powernap/presenter/PowerNapMainWindowPresenter.cpp +1 -0
@@ 32,6 32,7 @@ namespace app::powernap
        const auto currentValue = model->getCurrentValue();
        settings->setValue(
            powernapDBRecordName, utils::to_string(currentValue.count()), settings::SettingsScope::AppLocal);
        reinterpret_cast<app::Application *>(app)->suspendIdleTimer();
        app->switchWindow(gui::window::name::powernapProgress);
    }
} // namespace app::powernap

M products/BellHybrid/apps/application-bell-powernap/windows/PowerNapProgressWindow.cpp => products/BellHybrid/apps/application-bell-powernap/windows/PowerNapProgressWindow.cpp +1 -0
@@ 109,6 109,7 @@ namespace gui
                return true;
            }
            else if (not presenter->isNapFinished() && key == KeyMap::Back) {
                reinterpret_cast<app::Application *>(application)->resumeIdleTimer();
                presenter->endNap();
                application->returnToPreviousWindow();
                return true;

M products/BellHybrid/apps/include/Application.hpp => products/BellHybrid/apps/include/Application.hpp +3 -0
@@ 11,6 11,8 @@ namespace app
    {
      public:
        using ApplicationCommon::ApplicationCommon;
        void resumeIdleTimer();
        void suspendIdleTimer();

      protected:
        void attachPopups(const std::vector<gui::popup::ID> &popupsList) override;


@@ 30,5 32,6 @@ namespace app
        virtual void onKeyPressed();
        virtual void onStart();
        virtual void onStop();
        bool idleTimerActiveFlag = true;
    };
} // namespace app