~aleteoryx/muditaos

5d1b9bbb0de99de7f24d8bbd2fb5fab55050be8f — Dawid Wojtas 3 years ago 2aa7629
[BH-1615] Crash after entering alarm settings

If there is no value in the database use the default one.
M products/BellHybrid/apps/application-bell-settings/models/alarm_settings/AlarmSettingsModel.cpp => products/BellHybrid/apps/application-bell-settings/models/alarm_settings/AlarmSettingsModel.cpp +9 -1
@@ 8,6 8,11 @@

namespace app::bell_settings
{
    namespace
    {
        static constexpr std::string_view DefaultBrightness{"50.0"};
    }

    void AlarmToneModel::setValue(UTF8 value)
    {
        settings.setValue(bell::settings::Alarm::tone, value, settings::SettingsScope::Global);


@@ 56,7 61,10 @@ namespace app::bell_settings

    frontlight_utils::Brightness AlarmFrontlightModel::getValue() const
    {
        const auto str = settings.getValue(bell::settings::Alarm::brightness, settings::SettingsScope::Global);
        auto str = settings.getValue(bell::settings::Alarm::brightness, settings::SettingsScope::Global);
        if (str.empty()) {
            str = DefaultBrightness;
        }
        return frontlight_utils::percentageToFixedVal(std::stoi(str));
    }
} // namespace app::bell_settings

M products/BellHybrid/apps/application-bell-settings/models/alarm_settings/PrewakeUpSettingsModel.cpp => products/BellHybrid/apps/application-bell-settings/models/alarm_settings/PrewakeUpSettingsModel.cpp +9 -1
@@ 8,6 8,11 @@

namespace app::bell_settings
{
    namespace
    {
        static constexpr std::string_view DefaultBrightness{"50.0"};
    }

    void PrewakeUpChimeDurationModel::setValue(std::uint8_t value)
    {
        const auto valStr = std::to_string(value);


@@ 68,7 73,10 @@ namespace app::bell_settings

    frontlight_utils::Brightness PrewakeUpFrontlightModel::getValue() const
    {
        const auto str = settings.getValue(bell::settings::PrewakeUp::brightness, settings::SettingsScope::Global);
        auto str = settings.getValue(bell::settings::PrewakeUp::brightness, settings::SettingsScope::Global);
        if (str.empty()) {
            str = DefaultBrightness;
        }
        return frontlight_utils::percentageToFixedVal(std::stoi(str));
    }
} // namespace app::bell_settings