~aleteoryx/muditaos

3b68d92572cf3755c1412f7ac79c4d0bf3e80edc — lblach 5 years ago dfcf981
[EGD-6009] Test and repair Update process

Fixes to improve Update process.
M image/assets/lang/Deutsch.json => image/assets/lang/Deutsch.json +1 -1
@@ 90,7 90,7 @@
  "app_desktop_tools_antenna": "ANTENNA TEST",
  "app_desktop_poweroff_title": "Turn off",
  "app_desktop_poweroff_question": "Turn off the phone?",
  "app_desktop_update_success": "MuditaOS has been updated succesfully.",
  "app_desktop_update_success": "MuditaOS has been updated to ver. $VERSION succesfully.",
  "app_call_call": "CALL",
  "app_call_clear": "CLEAR",
  "app_call_reject": "REJECT",

M image/assets/lang/English.json => image/assets/lang/English.json +1 -1
@@ 550,6 550,6 @@
  "app_desktop_update_muditaos": "MuditaOS update",
  "app_desktop_update_in_progress": "Update in progress...",
  "app_desktop_update_ready_for_reset": "Ready for reset...",
  "app_desktop_update_success": "MuditaOS has been updated to $VERSION succesfully.",
  "app_desktop_update_success": "MuditaOS has been updated to ver. $VERSION succesfully.",
  "app_call_private_number": "Private number"
}

M image/assets/lang/Espanol.json => image/assets/lang/Espanol.json +1 -1
@@ 91,7 91,7 @@
  "app_desktop_tools_antenna": "ANTENNA TEST",
  "app_desktop_poweroff_title": "Turn off",
  "app_desktop_poweroff_question": "Turn off the phone?",
  "app_desktop_update_success": "MuditaOS has been updated succesfully.",
  "app_desktop_update_success": "MuditaOS has been updated to ver. $VERSION succesfully.",
  "app_call_call": "CALL",
  "app_call_clear": "CLEAR",
  "app_call_reject": "REJECT",

M image/assets/lang/Francais.json => image/assets/lang/Francais.json +1 -1
@@ 90,7 90,7 @@
  "app_desktop_tools_antenna": "ANTENNA TEST",
  "app_desktop_poweroff_title": "Turn off",
  "app_desktop_poweroff_question": "Turn off the phone?",
  "app_desktop_update_success": "MuditaOS has been updated succesfully.",
  "app_desktop_update_success": "MuditaOS has been updated to ver. $VERSION succesfully.",
  "app_call_call": "CALL",
  "app_call_clear": "CLEAR",
  "app_call_reject": "REJECT",

M image/assets/lang/Polski.json => image/assets/lang/Polski.json +1 -1
@@ 92,7 92,7 @@
  "app_desktop_tools_antenna": "ANTENNA TEST",
  "app_desktop_poweroff_title": "Wyłączanie",
  "app_desktop_poweroff_question": "Czy wyłączyć telefon?",
  "app_desktop_update_success": "MuditaOS został zaktualizowany.",
  "app_desktop_update_success": "MuditaOS został zaktualizowany do wersji $VERSION.",
  "app_call_call": "DZWOŃ",
  "app_call_clear": "WYCZYŚĆ",
  "app_call_reject": "ODRZUĆ",

M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +2 -3
@@ 515,7 515,7 @@ namespace app
        if (value.empty()) {
            return;
        }
        osCurrentVersion = std::move(value);
        osCurrentVersion = value;
    }
    void ApplicationDesktop::setOsUpdateVersion(const std::string &value)
    {


@@ 524,7 524,6 @@ namespace app
            return;
        }
        osUpdateVersion = value;
        settings->setValue(
            settings::SystemProperties::osUpdateVersion, std::move(value), settings::SettingsScope::Global);
        settings->setValue(settings::SystemProperties::osUpdateVersion, value, settings::SettingsScope::Global);
    }
} // namespace app

M module-apps/application-desktop/CMakeLists.txt => module-apps/application-desktop/CMakeLists.txt +1 -0
@@ 79,5 79,6 @@ target_link_libraries(${PROJECT_NAME}
        service-db
        service-desktop
        service-time
        service-appmgr
        utils-bootconfig
    )

M module-apps/application-desktop/data/LockPhoneData.hpp => module-apps/application-desktop/data/LockPhoneData.hpp +17 -1
@@ 1,4 1,4 @@
// Copyright (c) 2017-2020, 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

#ifndef MODULE_APPS_APPLICATION_DESKTOP_DATA_LOCKPHONEDATA_HPP_


@@ 58,6 58,22 @@ namespace gui
        sdesktop::UpdateOsMessage updateOsMessage;
    };

    class CurrentOsVersion : public gui::SwitchData
    {
        std::string osVersion;

      public:
        [[nodiscard]] std::string getCurrentOsVersion() const
        {
            return osVersion;
        }

        void setData(std::string version)
        {
            osVersion = version;
        }
    };

} // namespace gui

#endif /* MODULE_APPS_APPLICATION_DESKTOP_DATA_LOCKPHONEDATA_HPP_ */

M module-apps/application-desktop/data/Style.hpp => module-apps/application-desktop/data/Style.hpp +41 -16
@@ 1,4 1,4 @@
// Copyright (c) 2017-2020, 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

#pragma once


@@ 8,33 8,58 @@ namespace style::desktop

    namespace notifications
    {
        constexpr auto SpanSize     = 8;
        constexpr auto DigitSize    = 16;
        constexpr auto IconWidth    = 35;
        constexpr auto TextMaxWidth = 250;
        inline constexpr auto SpanSize     = 8;
        inline constexpr auto DigitSize    = 16;
        inline constexpr auto IconWidth    = 35;
        inline constexpr auto TextMaxWidth = 250;

        constexpr auto X     = 0;
        constexpr auto Y     = 284;
        constexpr auto Width = style::window_width;
        inline constexpr auto X     = 0;
        inline constexpr auto Y     = 284;
        inline constexpr auto Width = style::window_width;

    }; // namespace notifications

    namespace timeLabel
    {
        constexpr auto X     = 0;
        constexpr auto Y     = 106;
        constexpr auto Width = style::window_width;
        constexpr auto Height = 96;
        inline constexpr auto X      = 0;
        inline constexpr auto Y      = 106;
        inline constexpr auto Width  = style::window_width;
        inline constexpr auto Height = 96;

    } // namespace timeLabel

    namespace dayLabel
    {
        constexpr auto X     = 0;
        constexpr auto Y     = 204;
        constexpr auto Width = style::window_width;
        constexpr auto Height = 51;
        inline constexpr auto X      = 0;
        inline constexpr auto Y      = 204;
        inline constexpr auto Width  = style::window_width;
        inline constexpr auto Height = 51;

    } // namespace dayLabel

    namespace image
    {
        inline constexpr uint32_t x = 176;
        inline constexpr uint32_t y = 132;

    } // namespace image

    namespace textupdate
    {
        inline constexpr uint32_t x = 120;
        inline constexpr uint32_t y = 250;
        inline constexpr uint32_t w = 250;
        inline constexpr uint32_t h = 100;

    } // namespace textupdate

    namespace percentlabel
    {
        inline constexpr uint32_t x = 0;
        inline constexpr uint32_t y = 450;
        inline constexpr uint32_t w = 500;
        inline constexpr uint32_t h = 100;

    } // namespace percentlabel

} // namespace style::desktop

M module-apps/application-desktop/windows/DesktopMainWindow.cpp => module-apps/application-desktop/windows/DesktopMainWindow.cpp +6 -4
@@ 80,6 80,9 @@ namespace gui

    DesktopMainWindow::DesktopMainWindow(app::Application *app) : AppWindow(app, app::window::name::desktop_main_window)
    {
        osUpdateVer  = getAppDesktop()->getOsUpdateVersion();
        osCurrentVer = getAppDesktop()->getOsCurrentVersion();

        buildInterface();

        preBuildDrawListHook = [this](std::list<Command> &cmd) { updateTime(); };


@@ 110,12 113,11 @@ namespace gui
            }
            setActiveState(app);

            auto osUpdateVer  = getAppDesktop()->getOsUpdateVersion();
            auto osCurrentVer = getAppDesktop()->getOsCurrentVersion();

            if (osUpdateVer == osCurrentVer && osUpdateVer != updateos::initSysVer &&
                osCurrentVer != updateos::initSysVer) {
                application->switchWindow(app::window::name::desktop_post_update_window);
                auto data = std::make_unique<CurrentOsVersion>();
                data->setData(osCurrentVer);
                application->switchWindow(app::window::name::desktop_post_update_window, std::move(data));
                getAppDesktop()->setOsUpdateVersion(updateos::initSysVer);
            }


M module-apps/application-desktop/windows/DesktopMainWindow.hpp => module-apps/application-desktop/windows/DesktopMainWindow.hpp +2 -0
@@ 87,6 87,8 @@ namespace gui

      private:
        void invalidate() noexcept;
        std::string osUpdateVer;
        std::string osCurrentVer;

        gui::KeyInputMappedTranslation translator;
    };

M module-apps/application-desktop/windows/PostUpdateWindow.cpp => module-apps/application-desktop/windows/PostUpdateWindow.cpp +19 -5
@@ 6,11 6,15 @@
#include "service-appmgr/Controller.hpp"
#include "gui/widgets/BottomBar.hpp"
#include "gui/widgets/TopBar.hpp"
#include "RichTextParser.hpp"
#include "FontManager.hpp"

#include "application-desktop/data/AppDesktopStyle.hpp"
#include "Names.hpp"
#include <module-gui/gui/widgets/BottomBar.hpp>
#include <module-gui/gui/widgets/TopBar.hpp>
#include <module-gui/gui/core/FontManager.hpp>

#include <module-apps/application-desktop/data/AppDesktopStyle.hpp>
#include <module-apps/application-desktop/data/LockPhoneData.hpp>
#include <module-apps/application-desktop/windows/Names.hpp>

#include <application-phonebook/ApplicationPhonebook.hpp>
#include <i18n/i18n.hpp>


@@ 25,6 29,18 @@ PostUpdateWindow::PostUpdateWindow(app::Application *app)

void PostUpdateWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
    if (data == nullptr) {
        LOG_ERROR("Received null pointer");
    }
    else {
        auto *item = dynamic_cast<CurrentOsVersion *>(data);
        if (item != nullptr) {
            currentOsVersion = item->getCurrentOsVersion();
            auto info        = utils::localize.get("app_desktop_update_success");
            utils::findAndReplaceAll(info, "$VERSION", currentOsVersion);
            infoText->setText(info);
        }
    }
    setVisibleState();
}



@@ 78,8 94,6 @@ void PostUpdateWindow::buildInterface()
                        post_update_style::primary_text::y,
                        post_update_style::primary_text::w,
                        post_update_style::primary_text::h);

    infoText->setText(utils::localize.get("app_desktop_update_success"));
    infoText->setAlignment(Alignment::Horizontal::Center);
}


M module-apps/application-desktop/windows/PostUpdateWindow.hpp => module-apps/application-desktop/windows/PostUpdateWindow.hpp +6 -4
@@ 1,11 1,11 @@
// Copyright (c) 2017-2020, 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

#pragma once

#include "AppWindow.hpp"
#include "Text.hpp"
#include "gui/widgets/Image.hpp"
#include <module-apps/windows/AppWindow.hpp>
#include <module-gui/gui/widgets/Text.hpp>
#include <module-gui/gui/widgets/Image.hpp>

namespace gui
{


@@ 17,6 17,8 @@ namespace gui
        void setVisibleState();
        void invalidate() noexcept;

        std::string currentOsVersion;

      public:
        explicit PostUpdateWindow(app::Application *app);
        void onBeforeShow(ShowMode mode, SwitchData *data) override;

M module-apps/application-desktop/windows/UpdateProgress.cpp => module-apps/application-desktop/windows/UpdateProgress.cpp +76 -80
@@ 11,117 11,125 @@
#include <i18n/i18n.hpp>

#include <application-desktop/ApplicationDesktop.hpp>
#include <application-desktop/data/Style.hpp>

// services
#include <service-appmgr/model/ApplicationManager.hpp>

#include <Style.hpp>
#include <DialogMetadataMessage.hpp>

#include "UpdateProgress.hpp"

namespace style
{
    namespace image
    {
        constexpr uint32_t x = 176;
        constexpr uint32_t y = 132;
    } // namespace image

    namespace text
    {
        constexpr uint32_t x = 120;
        constexpr uint32_t y = 250;
        constexpr uint32_t w = 250;
        constexpr uint32_t h = 100;
    } // namespace text

    namespace percentlabel
    {
        constexpr uint32_t x = 0;
        constexpr uint32_t y = 450;
        constexpr uint32_t w = 500;
        constexpr uint32_t h = 100;
    } // namespace percentlabel

    namespace progressbar
    {
        constexpr uint32_t x = 100;
        constexpr uint32_t y = 400;
    } // namespace progressbar

} // namespace style
namespace gui
{

    UpdateProgressWindow::UpdateProgressWindow(app::Application *app)
        : AppWindow(app, app::window::name::desktop_update_progress)
    {
        buildInterface();
    }

    void UpdateProgressWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    {
        if (data == nullptr) {
            LOG_ERROR("Received null pointer");
        }
        else {
            auto *item = dynamic_cast<gui::UpdateSwitchData *>(data);
            if (item != nullptr) {
                auto msg   = item->getUpdateOsMessage();
                updateFile = msg.updateStats.updateFile;
                auto updateVersion =
                    msg.updateStats.versionInformation[boot::json::os_version][boot::json::version_string]
                        .string_value();
                if (text->getText().empty()) {
                    text->setText(utils::localize.get("app_desktop_update_preparing") + " " + updateVersion);
                }
                else {
                    text->setText(textInfo);
                }
            }
            percentLabel->setText(std::to_string(progressPercent) + " %");
            updateProgress->setValue(progressPercent);
        }
        setVisibleState();
    }

    void UpdateProgressWindow::setVisibleState()
    {
        percentLabel->setVisible(true);
        updateProgress->setVisible(true);
        updateProgress->setVisible(true);
        text->setVisible(true);
    }

    void UpdateProgressWindow::rebuild()
    {
        destroyInterface();
        buildInterface();
    }

    top_bar::Configuration UpdateProgressWindow::configureTopBar(top_bar::Configuration appConfiguration)
    {
        appConfiguration.enable(top_bar::Indicator::Time);
        appConfiguration.disable(top_bar::Indicator::Lock);
        appConfiguration.disable(top_bar::Indicator::Battery);
        appConfiguration.disable(top_bar::Indicator::NetworkAccessTechnology);
        appConfiguration.disable(top_bar::Indicator::Signal);
        appConfiguration.disable(top_bar::Indicator::SimCard);
        return appConfiguration;
    }

    void UpdateProgressWindow::buildInterface()
    {
        AppWindow::buildInterface();

        setTitle(utils::localize.get("app_desktop_update_muditaos"));

        icon = new Image(this, style::image::x, style::image::y, "circle_update");
        icon = new Image(this, style::desktop::image::x, style::desktop::image::y, "circle_update");

        text = new Text(this, style::text::x, style::text::y, style::text::w, style::text::h);
        text = new Text(this,
                        style::desktop::textupdate::x,
                        style::desktop::textupdate::y,
                        style::desktop::textupdate::w,
                        style::desktop::textupdate::h);
        text->setTextType(TextType::MultiLine);
        text->setEditMode(EditMode::Browse);
        text->setEdges(RectangleEdge::None);
        text->setFont(style::window::font::biglight);
        text->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));

        percentLabel = new gui::Label(
            this, style::percentlabel::x, style::percentlabel::y, style::percentlabel::w, style::percentlabel::h);
        percentLabel = new gui::Label(this,
                                      style::desktop::percentlabel::x,
                                      style::desktop::percentlabel::y,
                                      style::desktop::percentlabel::w,
                                      style::desktop::percentlabel::h);
        percentLabel->setFilled(false);
        percentLabel->setBorderColor(gui::ColorNoColor);
        percentLabel->setFont(style::window::font::biglight);
        percentLabel->setAlignment(
            gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
        percentLabel->setVisible(true);

        updateProgress = new ProgressBar(this,
                                         style::progressbar::x,
                                         style::progressbar::y,
                                         style::window_width - 2 * style::progressbar::x,
                                         style::window::label::default_h);
                                         style::window::progressBar::x,
                                         style::window::progressBar::y,
                                         style::window::progressBar::width,
                                         style::window::progressBar::h);
        updateProgress->setMaximum(100);
        updateProgress->setValue(0);
        updateProgress->setVisible(true);
    }

    void UpdateProgressWindow::destroyInterface()
    {
        erase();
        invalidate();
    }

    void UpdateProgressWindow::onBeforeShow(ShowMode mode, SwitchData *data)
    void UpdateProgressWindow::invalidate() noexcept
    {
        if (data == nullptr) {
            LOG_ERROR("Received null pointer");
        }
        else {
            auto *item = dynamic_cast<gui::UpdateSwitchData *>(data);
            if (item != nullptr) {
                auto msg   = item->getUpdateOsMessage();
                updateFile = msg.updateStats.updateFile;
                auto updateVersion =
                    msg.updateStats.versionInformation[boot::json::os_version][boot::json::version_string]
                        .string_value();
                text->setRichText(utils::localize.get("app_desktop_update_preparing") + " " + updateVersion);
            }
        }
        state = State::Return;
        percentLabel   = nullptr;
        updateProgress = nullptr;
        text           = nullptr;
        icon           = nullptr;
    }

    bool UpdateProgressWindow::handleSwitchData(SwitchData *data)


@@ 129,52 137,40 @@ namespace gui
        auto *item = dynamic_cast<gui::UpdateSwitchData *>(data);
        if (item != nullptr) {
            auto status = static_cast<updateos::UpdateState>(item->getUpdateOsMessage().updateStats.status);

            switch (status) {
            case updateos::UpdateState::Initial:
                text->setRichText(text->getText());
                textInfo        = text->getText();
                progressPercent = 10;
                break;
            case updateos::UpdateState::UpdateFileSet:
                text->setRichText(text->getText());
                textInfo        = text->getText();
                progressPercent = 20;
                break;
            case updateos::UpdateState::CreatingDirectories:
                text->setRichText(text->getText());
                textInfo        = text->getText();
                progressPercent = 30;
                break;
            case updateos::UpdateState::ExtractingFiles:
                text->setRichText(utils::localize.get("app_desktop_update_in_progress"));
                textInfo        = utils::localize.get("app_desktop_update_in_progress");
                progressPercent = 40;
                break;
            case updateos::UpdateState::ChecksumVerification:
                text->setRichText(text->getText());
                textInfo        = text->getText();
                progressPercent = 70;
                break;
            case updateos::UpdateState::VersionVerificiation:
                text->setRichText(text->getText());
                progressPercent = 90;
                textInfo        = text->getText();
                progressPercent = 80;
                break;
            case updateos::UpdateState::UpdatingBootloader:
                text->setRichText(text->getText());
                textInfo        = utils::localize.get("app_desktop_update_ready_for_reset");
                progressPercent = 99;
                break;
            case updateos::UpdateState::ReadyForReset:
                text->setRichText(utils::localize.get("app_desktop_update_ready_for_reset"));
                textInfo        = text->getText();
                progressPercent = 100;
                break;
            default:
                if (item->getUpdateOsMessage().updateStats.messageText != "") {
                    percentLabel->setText(item->getUpdateOsMessage().updateStats.messageText);
                }
            }

            percentLabel->setVisible(true);
            percentLabel->setText(std::to_string(progressPercent) + " %");
            updateProgress->setVisible(true);
            updateProgress->setFocus(true);
            updateProgress->setValue(progressPercent);
            text->setVisible(true);
        }
        return true;
    }

M module-apps/application-desktop/windows/UpdateProgress.hpp => module-apps/application-desktop/windows/UpdateProgress.hpp +12 -16
@@ 4,37 4,32 @@
#pragma once

#include <vector>
#include "AppWindow.hpp"
#include "Dialog.hpp"
#include "gui/widgets/Label.hpp"
#include "gui/widgets/TextFixedSize.hpp"
#include "gui/widgets/Image.hpp"
#include "gui/widgets/BottomBar.hpp"
#include "gui/widgets/ProgressBar.hpp"
#include <module-apps/windows/AppWindow.hpp>
#include <module-apps/windows/Dialog.hpp>
#include <module-gui/gui/widgets/Label.hpp>
#include <module-gui/gui/widgets/TextFixedSize.hpp>
#include <module-gui/gui/widgets/Image.hpp>
#include <module-gui/gui/widgets/BottomBar.hpp>
#include <module-gui/gui/widgets/ProgressBar.hpp>
namespace gui
{

    class UpdateProgressWindow : public AppWindow
    {

        enum class State
        {
            UpdateNow,
            Return,
        };

        unsigned int progressPercent = 0;
        std::string textInfo;

        gui::Label *percentLabel    = nullptr;
        ProgressBar *updateProgress = nullptr;

        State state = State::Return;
        fs::path updateFile;

      protected:
        Text *text  = nullptr;
        Image *icon = nullptr;

        void setVisibleState();
        void invalidate() noexcept;

      public:
        UpdateProgressWindow(app::Application *app);
        void onBeforeShow(ShowMode mode, SwitchData *data) override;


@@ 42,6 37,7 @@ namespace gui
        void rebuild() override;
        void buildInterface() override;
        void destroyInterface() override;
        top_bar::Configuration configureTopBar(top_bar::Configuration appConfiguration) override;
    };

} /* namespace gui */

M module-gui/gui/widgets/Style.hpp => module-gui/gui/widgets/Style.hpp +8 -0
@@ 95,6 95,14 @@ namespace style
            inline constexpr auto h = 54U;
            inline constexpr auto w = window_width;
        } // namespace bottomBar

        namespace progressBar
        {
            inline constexpr auto x     = 100U;
            inline constexpr auto y     = 400U;
            inline constexpr auto width = 280U;
            inline constexpr auto h     = 50U;
        }; // namespace progressBar
    };    // namespace window

    namespace settings