~aleteoryx/muditaos

b7330da36cb842a913ac82d9d97ab8f5c83708e6 — Dawid Wojtas 3 years ago 829b9b2
[MOS-662][MOS-301] Fix E-ink shutdown while restoring data

While restoring system data the timer can turn off power of E-ink
to save the power. To avoid this situation we need to power on
the E-ink before wiping out the display. The restore procedure
also performs reversing services list to close. In this case
we do it twice so the order is wrong.
M module-services/service-eink/ServiceEink.cpp => module-services/service-eink/ServiceEink.cpp +2 -0
@@ 111,6 111,8 @@ namespace service::eink

    sys::ReturnCodes ServiceEink::DeinitHandler()
    {
        // Eink must be turn on before wiping out the display
        display->powerOn();
        if (exitAction == ExitAction::WipeOut) {
            display->wipeOut();
        }

M module-sys/SystemManager/SystemManagerCommon.cpp => module-sys/SystemManager/SystemManagerCommon.cpp +14 -8
@@ 67,11 67,12 @@ namespace sys
    {
        namespace restore
        {
            static constexpr std::array whitelist = {service::name::service_desktop,
                                                     service::name::evt_manager,
                                                     service::name::eink,
                                                     service::name::appmgr,
                                                     service::name::cellular};
            static constexpr std::array whitelist = {
                service::name::service_desktop, // Handle restore procedure
                service::name::evt_manager, // Workaround for charging battery after shutting down and turn on the phone
                service::name::appmgr,
                service::name::cellular,
            };
        }

        namespace regularClose


@@ 704,7 705,10 @@ namespace sys

        // We are going to remove services in reversed order of creation
        CriticalSection::Enter();
        std::reverse(servicesList.begin(), servicesList.end());
        if (not serviceListReversed) {
            std::reverse(servicesList.begin(), servicesList.end());
            serviceListReversed = true;
        }
        CriticalSection::Exit();

        InitiateSystemCloseSequence(closeReason);


@@ 741,10 745,12 @@ namespace sys
    void SystemManagerCommon::RestoreSystemHandler()
    {
        LOG_INFO("Entering restore system state");

        // We are going to remove services in reversed order of creation
        CriticalSection::Enter();
        std::reverse(servicesList.begin(), servicesList.end());
        if (not serviceListReversed) {
            std::reverse(servicesList.begin(), servicesList.end());
            serviceListReversed = true;
        }
        CriticalSection::Exit();

        DestroyServices(sys::state::restore::whitelist);

M module-sys/SystemManager/include/SystemManager/SystemManagerCommon.hpp => module-sys/SystemManager/include/SystemManager/SystemManagerCommon.hpp +1 -0
@@ 193,6 193,7 @@ namespace sys
        void UpdateResourcesAfterCpuFrequencyChange(bsp::CpuFrequencyMHz newFrequency);

        bool cpuStatisticsTimerInit{false};
        bool serviceListReversed{false};

        CloseReason closeReason{CloseReason::RegularPowerDown};
        UpdateReason updateReason{UpdateReason::Update};

M pure_changelog.md => pure_changelog.md +2 -0
@@ 7,6 7,8 @@
* Separated system volume from Bluetooth device volume for A2DP

### Fixed
* Fixed order of the services while closing system
* Fixed crash of the E-ink service while restoring system data
* Fixed removing wrong sentinels
* Fixed music player behaviour when connecting/disconnecting audio devices
* Fixed dropping the call during the DND mode