// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved. // For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace { constexpr auto applicationSettingsStackSize = 1024 * 6; } namespace app { namespace settings { constexpr inline auto operators_on = "operators_on"; } // namespace settings ApplicationSettings::ApplicationSettings(std::string name, std::string parent, StatusIndicators statusIndicators, StartInBackground startInBackground) : Application( std::move(name), std::move(parent), statusIndicators, startInBackground, applicationSettingsStackSize), AsyncCallbackReceiver{this}, soundsPlayer{std::make_shared(this)} { bus.channels.push_back(sys::BusChannel::ServiceAudioNotifications); bus.channels.push_back(sys::BusChannel::BluetoothNotifications); bus.channels.push_back(sys::BusChannel::BluetoothModeChanges); bus.channels.push_back(sys::BusChannel::ServiceCellularNotifications); CellularServiceAPI::SubscribeForOwnNumber(this, [&](const std::string &number) { selectedSimNumber = number; LOG_DEBUG("Sim number changed"); }); if ((Store::GSM::SIM::SIM1 == simState || Store::GSM::SIM::SIM2 == simState) && Store::GSM::get()->sim == simState) { CellularServiceAPI::RequestForOwnNumber(this); } bluetoothSettingsModel = std::make_shared(this); } ApplicationSettings::~ApplicationSettings() {} // Invoked upon receiving data message auto ApplicationSettings::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp) -> sys::MessagePointer { auto retMsg = Application::DataReceivedHandler(msgl); // if message was handled by application's template there is no need to process further. auto rm = dynamic_cast(retMsg.get()); if (nullptr != rm && sys::ReturnCodes::Success == rm->retCode) { return retMsg; } if (auto phoneMsg = dynamic_cast(msgl); nullptr != phoneMsg) { auto currentWindow = getCurrentWindow(); if (gui::window::name::network == currentWindow->getName()) { updateCurrentWindow(); } } return handleAsyncResponse(resp); } // Invoked during initialization auto ApplicationSettings::InitHandler() -> sys::ReturnCodes { auto ret = Application::InitHandler(); if (ret != sys::ReturnCodes::Success) { return ret; } connect(typeid(cellular::msg::notification::SimReady), [&](sys::Message *) { CellularServiceAPI::RequestForOwnNumber(this); return handleSimNotification(); }); connect(typeid(cellular::msg::notification::SimBlocked), [&](sys::Message *) { return handleSimNotification(); }); connect(typeid(cellular::msg::notification::SimNeedPin), [&](sys::Message *) { return handleSimNotification(); }); connect(typeid(cellular::msg::notification::SimNeedPuk), [&](sys::Message *) { return handleSimNotification(); }); connect(typeid(::sys::bluetooth::BluetoothModeChanged), [&](sys::Message *msg) { const auto message = static_cast<::sys::bluetooth::BluetoothModeChanged *>(msg); const auto newState = message->getBluetoothMode(); const auto oldStatus = bluetoothSettingsModel->getStatus(); const auto oldState = oldStatus.state; if (newState == sys::bluetooth::BluetoothMode::Disabled && oldState == BluetoothStatus::State::On) { const auto isVisible = oldStatus.visibility; bluetoothSettingsModel->updateStatus(false, isVisible); if (getCurrentWindow()->getName() == gui::window::name::bluetooth) { updateCurrentWindow(); } } return sys::MessageNone{}; }); connect(typeid(::message::bluetooth::ResponseStatus), [&](sys::Message *msg) { auto responseStatusMsg = static_cast<::message::bluetooth::ResponseStatus *>(msg); const auto status = responseStatusMsg->getStatus(); const auto bluetoothState = status.state == BluetoothStatus::State::On; bluetoothSettingsModel->setStatus(bluetoothState, status.visibility); return sys::MessageNone{}; }); connect(typeid(::message::bluetooth::ResponseDeviceName), [&](sys::Message *msg) { auto responseDeviceNameMsg = static_cast<::message::bluetooth::ResponseDeviceName *>(msg); if (gui::window::name::phone_name == getCurrentWindow()->getName()) { auto phoneNameData = std::make_unique(responseDeviceNameMsg->getName()); switchWindow(gui::window::name::phone_name, std::move(phoneNameData)); } return sys::MessageNone{}; }); connect(typeid(::message::bluetooth::SyncDevices), [&](sys::Message *msg) { auto message = static_cast<::message::bluetooth::SyncDevices *>(msg); bluetoothSettingsModel->replaceDevicesList(message->getDevices()); if (gui::window::name::all_devices == getCurrentWindow()->getName()) { switchWindow(gui::window::name::all_devices); } return sys::MessageNone{}; }); connect(typeid(::message::bluetooth::ResponseBondedDevices), [&](sys::Message *msg) { auto message = static_cast<::message::bluetooth::ResponseBondedDevices *>(msg); bluetoothSettingsModel->replaceDevicesList(message->getDevices()); if (gui::window::name::all_devices == getCurrentWindow()->getName()) { switchWindow(gui::window::name::all_devices); } return sys::MessageNone{}; }); connect(typeid(::message::bluetooth::ResponseVisibleDevices), [&](sys::Message *msg) { auto responseVisibleDevicesMsg = static_cast<::message::bluetooth::ResponseVisibleDevices *>(msg); if (gui::window::name::add_device == getCurrentWindow()->getName() || gui::window::name::dialog_settings == getCurrentWindow()->getName()) { auto visibleDevicesData = std::make_unique(responseVisibleDevicesMsg->getDevices()); if (gui::window::name::dialog_settings == getCurrentWindow()->getName()) { visibleDevicesData->ignoreCurrentWindowOnStack = true; } switchWindow(gui::window::name::add_device, std::move(visibleDevicesData)); } return sys::MessageNone{}; }); connect(typeid(::message::bluetooth::ProfileStatus), [&](sys::Message *msg) { return sys::MessageNone{}; }); connect(typeid(::message::bluetooth::UnpairResult), [&](sys::Message *msg) { auto unpairResultMsg = static_cast<::message::bluetooth::UnpairResult *>(msg); if (unpairResultMsg->isSucceed()) { return sys::MessageNone{}; } auto device = unpairResultMsg->getDevice(); auto message = std::make_shared(device); switchToAllDevicesViaBtErrorPrompt(std::move(message), "app_settings_bluetooth_unpairing_error_message"); return sys::MessageNone{}; }); connect(typeid(::message::bluetooth::ConnectResult), [&](sys::Message *msg) { auto connectResultMsg = static_cast<::message::bluetooth::ConnectResult *>(msg); auto device = connectResultMsg->getDevice(); using message::bluetooth::ConnectResult; if (connectResultMsg->getResult() == ConnectResult::Result::Success) { return sys::MessageNone{}; } auto message = std::make_shared(device); switchToAllDevicesViaBtErrorPrompt(std::move(message), "app_settings_bluetooth_connecting_error_message"); return sys::MessageNone{}; }); connect(typeid(::message::bluetooth::DisconnectResult), [&](sys::Message *msg) { if (gui::window::name::all_devices == getCurrentWindow()->getName()) { switchWindow(gui::window::name::all_devices); } return sys::MessageNone{}; }); connect(typeid(::message::bluetooth::InitializationResult), [&](sys::Message *msg) { auto initializationResultMsg = static_cast<::message::bluetooth::InitializationResult *>(msg); if (initializationResultMsg->isSucceed()) { return sys::MessageNone{}; } switchWindow(gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::make_unique( gui::DialogMetadata{utils::translate("app_settings_bt"), "fail_128px_W_G", utils::translate("app_settings_bluetooth_init_error_message"), "", [=]() -> bool { switchWindow(gui::window::name::bluetooth); return true; }})); return sys::MessageNone{}; }); connect(typeid(cellular::GetAPNResponse), [&](sys::Message *msg) { if (gui::window::name::apn_settings == getCurrentWindow()->getName()) { auto apns = dynamic_cast(msg); if (apns != nullptr) { auto apnsData = std::make_unique(apns->getAPNs()); switchWindow(gui::window::name::apn_settings, std::move(apnsData)); } } return sys::MessageNone{}; }); connect(typeid(cellular::msg::request::sim::GetPinSettings::Response), [&](sys::Message *msg) { auto simCardPinSettings = static_cast(msg); auto simCardPinSettingsData = std::make_unique(simCardPinSettings->locked); updateCurrentWindow(std::move(simCardPinSettingsData)); return sys::MessageNone{}; }); connect(typeid(manager::GetCurrentDisplayLanguageResponse), [&](sys::Message *msg) { if (gui::window::name::languages == getCurrentWindow()->getName()) { auto response = dynamic_cast(msg); if (response != nullptr) { auto languagesData = std::make_unique(response->getLanguage()); switchWindow(gui::window::name::languages, std::move(languagesData)); } } return sys::MessageNone{}; }); connect(typeid(AudioStopNotification), [&](sys::Message *msg) -> sys::MessagePointer { auto notification = static_cast(msg); return handleAudioStop(notification); }); connect(typeid(AudioEOFNotification), [&](sys::Message *msg) -> sys::MessagePointer { auto notification = static_cast(msg); return handleAudioStop(notification); }); connect(typeid(cellular::GetVolteStateResponse), [&](sys::Message *msg) -> sys::MessagePointer { return handleVolteState(msg); }); connect(typeid(cellular::VolteStateNotification), [&](sys::Message *msg) -> sys::MessagePointer { return handleVolteState(msg); }); addActionReceiver(app::manager::actions::DisplayFactoryResetInProgressScreen, [this](auto &&data) { requestShutdownWindow(gui::window::name::factory_reset_in_progress); return actionHandled(); }); createUserInterface(); settings->registerValueChange(settings::operators_on, [this](const std::string &value) { operatorOnChanged(value); }); settings->registerValueChange( ::settings::Cellular::offlineMode, [this](const std::string &value) { flightModeOn = utils::getNumericValue(value); }, ::settings::SettingsScope::Global); settings->registerValueChange( ::settings::Offline::callsFromFavorites, [this](const std::string &value) { callsFromFavorites = utils::getNumericValue(value); }, ::settings::SettingsScope::Global); settings->registerValueChange( ::settings::Offline::connectionFrequency, [this](const std::string &value) { utils::toNumeric(value, connectionFrequency); }, ::settings::SettingsScope::Global); settings->registerValueChange( ::settings::Offline::notificationsWhenLocked, [this](const std::string &value) { notificationsWhenLocked = utils::getNumericValue(value); }, ::settings::SettingsScope::Global); bluetoothSettingsModel->requestBondedDevices(); bluetoothSettingsModel->requestStatus(); bus.sendUnicast(std::make_shared(), service::name::cellular); return ret; } void ApplicationSettings::createUserInterface() { windowsFactory.attach(gui::name::window::main_window, [](ApplicationCommon *app, const std::string &name) { return std::make_unique( app, name, mainWindowOptionsNew(app), utils::translate("app_settings_title_main")); }); // Advanced windowsFactory.attach(gui::window::name::advanced, [](ApplicationCommon *app, const std::string &name) { return std::make_unique( app, name, advancedOptions(app), utils::translate("app_settings_advanced")); }); windowsFactory.attach(gui::window::name::information, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::ui_test, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::cpu_test_window, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::color_test_window, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::status_bar_img_type, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::text_image_color, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); // Bluetooth windowsFactory.attach(gui::window::name::bluetooth, [this](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, bluetoothSettingsModel); }); windowsFactory.attach(gui::window::name::add_device, [this](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, bluetoothSettingsModel); }); windowsFactory.attach(gui::window::name::all_devices, [this](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, bluetoothSettingsModel); }); windowsFactory.attach(gui::window::name::phone_name, [this](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, bluetoothSettingsModel); }); // Network windowsFactory.attach(gui::window::name::network, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); windowsFactory.attach(gui::window::name::sim_cards, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); windowsFactory.attach(gui::window::name::sim_pin_settings, [&](ApplicationCommon *app, const std::string &name) { auto presenter = std::make_unique(this); return std::make_unique(app, std::move(presenter)); }); windowsFactory.attach(gui::window::name::import_contacts, [&](ApplicationCommon *app, const std::string &name) { auto repository = std::make_unique(this); auto model = std::make_unique(this, std::move(repository)); auto presenter = std::make_unique(this, std::move(model)); return std::make_unique(app, std::move(presenter)); }); windowsFactory.attach(gui::window::name::new_apn, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::apn_settings, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::apn_options, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); // Display and keypad windowsFactory.attach(gui::window::name::display_and_keypad, [](ApplicationCommon *app, const std::string &name) { auto model = std::make_unique(app); return std::make_unique(app, std::move(model)); }); windowsFactory.attach(gui::window::name::display_light, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); windowsFactory.attach(gui::window::name::wallpaper, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); windowsFactory.attach(gui::window::name::quotes, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::new_quote, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::options_quote, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::edit_quotes, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::quote_categories, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::quotes_dialog_yes_no, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, name); }); windowsFactory.attach(gui::window::name::keypad_light, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); windowsFactory.attach(gui::window::name::input_language, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); // Phone modes windowsFactory.attach(gui::window::name::phone_modes, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); windowsFactory.attach(gui::window::name::do_not_disturb, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); windowsFactory.attach(gui::window::name::offline, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); windowsFactory.attach( gui::window::name::connection_frequency, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); // Apps windowsFactory.attach(gui::window::name::apps, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::phone, [](ApplicationCommon *app, const std::string &name) { auto audioModel = std::make_unique(app, audio_settings::PlaybackType::CallRingtone); return std::make_unique(app, std::move(audioModel)); }); windowsFactory.attach(gui::window::name::messages, [](ApplicationCommon *app, const std::string &name) { auto audioModel = std::make_unique( app, audio_settings::PlaybackType::TextMessageRingtone); return std::make_unique(app, std::move(audioModel)); }); windowsFactory.attach(gui::window::name::alarm_clock, [](ApplicationCommon *app, const std::string &name) { auto audioModel = std::make_unique(app, audio_settings::PlaybackType::Alarm); return std::make_unique(app, std::move(audioModel)); }); windowsFactory.attach(gui::window::name::sound_select, [this](ApplicationCommon *app, const std::string &name) { auto model = std::make_shared(soundsPlayer); return std::make_unique(app, name, std::move(model)); }); // Security windowsFactory.attach(gui::window::name::security, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::autolock, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, static_cast(app)); }); // System windowsFactory.attach(gui::window::name::system, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::languages, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::date_and_time, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, gui::window::name::date_and_time); }); windowsFactory.attach(gui::window::name::change_time_zone, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::change_date_and_time, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach( gui::window::name::technical_information, [&](ApplicationCommon *app, const std::string &name) { auto factoryData = std::make_unique(*settings); auto repository = std::make_unique(this); auto model = std::make_unique(std::move(factoryData), std::move(repository)); auto presenter = std::make_unique(this, std::move(model)); return std::make_unique(app, std::move(presenter)); }); windowsFactory.attach(gui::window::name::certification, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); windowsFactory.attach(gui::window::name::sar, [&](ApplicationCommon *app, const std::string &name) { const auto path = purefs::dir::getSystemDataDirPath() / "certification_info"; const auto filename = "sar.txt"; auto sarInfoRepository = std::make_unique(path, filename); auto presenter = std::make_unique(std::move(sarInfoRepository)); return std::make_unique(app, std::move(presenter)); }); windowsFactory.attach(gui::window::name::factory_reset, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, name); }); windowsFactory.attach(gui::window::name::dialog_settings, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, name); }); windowsFactory.attach(gui::window::name::dialog_confirm, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, gui::window::name::dialog_confirm); }); windowsFactory.attach(gui::window::name::dialog_retry, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app, name); }); windowsFactory.attach(gui::window::name::factory_reset_in_progress, [](ApplicationCommon *app, const std::string &name) { return std::make_unique(app); }); attachPopups({gui::popup::ID::Volume, gui::popup::ID::Tethering, gui::popup::ID::BluetoothAuthenticate, gui::popup::ID::PhoneModes, gui::popup::ID::PhoneLock, gui::popup::ID::SimLock, gui::popup::ID::Alarm}); } void ApplicationSettings::destroyUserInterface() {} std::string ApplicationSettings::getNumber() { return selectedSimNumber; } void ApplicationSettings::returnToPreviousWindow() { using namespace gui::popup::window; using namespace gui::window::name; if (!windowsStack().isWindowOnStack(sim_cards)) { return ApplicationCommon::returnToPreviousWindow(); } auto previousWindowName = getPreviousWindow(); if (!previousWindowName.has_value()) { return ApplicationCommon::returnToPreviousWindow(); } auto backToSimCards = [this]() { switchWindow(sim_cards); }; if (previousWindowName == sim_pin_settings || previousWindowName == import_contacts || previousWindowName == sim_unlock_window || previousWindowName == sim_info_window) { return backToSimCards(); } if (getCurrentWindow()->getName() == sim_info_window) { return backToSimCards(); } ApplicationCommon::returnToPreviousWindow(); } void ApplicationSettings::setSelectedSim(Store::GSM::SelectedSIM sim) { auto arg = (sim == Store::GSM::SelectedSIM::SIM2) ? cellular::api::SimSlot::SIM2 : cellular::api::SimSlot::SIM1; getSimLockSubject().setSim(arg); } void ApplicationSettings::updateSimParam() { selectedSim = Store::GSM::get()->selected; simState = Store::GSM::get()->sim; } Store::GSM::SelectedSIM ApplicationSettings::getSelectedSim() { return selectedSim; } Store::GSM::SIM ApplicationSettings::getSimState() { return simState; } void ApplicationSettings::operatorOnChanged(const std::string &value) { LOG_DEBUG("OperatorOn changed: %s", value.c_str()); if (!value.empty()) { operatorsOn = utils::getNumericValue(value); } } bool ApplicationSettings::getOperatorsOn() const noexcept { LOG_DEBUG("OperatorOn: %d", operatorsOn); return operatorsOn; } void ApplicationSettings::setOperatorsOn(bool value) { operatorsOn = value; LOG_DEBUG("New OperatorOn: %d", operatorsOn); settings->setValue(settings::operators_on, std::to_string(static_cast(value))); } void ApplicationSettings::setOsUpdateVersion(const std::string &value) { LOG_DEBUG("New OS version: %s", value.c_str()); settings->setValue(::settings::SystemProperties::osUpdateVersion, value, ::settings::SettingsScope::Global); } auto ApplicationSettings::getCurrentValues() -> settingsInterface::ScreenLightSettings::Values { constexpr int timeout = pdMS_TO_TICKS(1500); auto response = bus.sendUnicastSync( std::make_shared(), service::name::evt_manager, timeout); if (response.first == sys::ReturnCodes::Success) { auto msgState = dynamic_cast(response.second.get()); if (msgState == nullptr) { return {}; } return {msgState->isLightOn(), msgState->getMode(), msgState->getParams()}; } return {}; } void ApplicationSettings::setBrightness(bsp::eink_frontlight::BrightnessPercentage value) { screen_light_control::ManualModeParameters parameters{value}; bus.sendUnicast(std::make_shared(parameters), service::name::evt_manager); } void ApplicationSettings::setMode(bool isAutoLightSwitchOn) { bus.sendUnicast(std::make_shared( isAutoLightSwitchOn ? screen_light_control::Action::enableAutomaticMode : screen_light_control::Action::disableAutomaticMode), service::name::evt_manager); } void ApplicationSettings::setStatus(bool isDisplayLightSwitchOn) { bus.sendUnicast(std::make_shared(isDisplayLightSwitchOn ? screen_light_control::Action::turnOn : screen_light_control::Action::turnOff), service::name::evt_manager); } auto ApplicationSettings::getKeypadBacklightState() -> bsp::keypad_backlight::State { return static_cast(utils::getNumericValue( settings->getValue(::settings::KeypadLight::state, ::settings::SettingsScope::Global))); } void ApplicationSettings::setKeypadBacklightState(bsp::keypad_backlight::State keypadLightState) { settings->setValue(::settings::KeypadLight::state, std::to_string(static_cast(keypadLightState)), ::settings::SettingsScope::Global); } auto ApplicationSettings::getWallpaperOption() -> gui::WallpaperOption { return static_cast(utils::getNumericValue( settings->getValue(::settings::Wallpaper::option, ::settings::SettingsScope::Global))); } void ApplicationSettings::setWallpaperOption(gui::WallpaperOption option) { settings->setValue( ::settings::Wallpaper::option, std::to_string(static_cast(option)), ::settings::SettingsScope::Global); } auto ApplicationSettings::getNotificationsWhenLocked() const noexcept -> bool { return notificationsWhenLocked; } void ApplicationSettings::setNotificationsWhenLocked(bool on) noexcept { notificationsWhenLocked = on; settings->setValue( ::settings::Offline::notificationsWhenLocked, std::to_string(on), ::settings::SettingsScope::Global); } auto ApplicationSettings::getCallsFromFavourite() const noexcept -> bool { return callsFromFavorites; } void ApplicationSettings::setCallsFromFavourite(bool on) noexcept { callsFromFavorites = on; settings->setValue( ::settings::Offline::callsFromFavorites, std::to_string(on), ::settings::SettingsScope::Global); } auto ApplicationSettings::isFlightMode() const noexcept -> bool { return flightModeOn; } void ApplicationSettings::setFlightMode(bool flightModeOn) noexcept { this->flightModeOn = flightModeOn; CellularServiceAPI::SetFlightMode(this, flightModeOn); } auto ApplicationSettings::getConnectionFrequency() const noexcept -> uint8_t { return connectionFrequency; } void ApplicationSettings::setConnectionFrequency(uint8_t val) noexcept { connectionFrequency = val; CellularServiceAPI::SetConnectionFrequency(this, val); } auto ApplicationSettings::getAutoLockTime() -> std::chrono::seconds { auto intervalValue = settings->getValue(::settings::SystemProperties::autoLockTimeInSec, ::settings::SettingsScope::Global); return std::chrono::seconds{utils::getNumericValue(intervalValue)}; } auto ApplicationSettings::getCurrentPhoneMode() const noexcept -> sys::phone_modes::PhoneMode { return statusIndicators.phoneMode; } auto ApplicationSettings::getVolteState() const noexcept -> cellular::VolteState { return volteState; } void ApplicationSettings::setAutoLockTime(std::chrono::seconds lockTime) { bus.sendUnicast(std::make_shared(lockTime), service::name::appmgr); } void ApplicationSettings::switchToAllDevicesViaBtErrorPrompt(std::shared_ptr msg, const std::string &errorMsg) { switchWindow(gui::window::name::dialog_retry, gui::ShowMode::GUI_SHOW_INIT, std::make_unique( gui::DialogMetadata{utils::translate("app_settings_bt"), "fail_128px_W_G", utils::translate(errorMsg), "", [this, message{std::move(msg)}]() -> bool { bus.sendUnicast(message, service::name::bluetooth); switchWindow(gui::window::name::all_devices); return true; }})); } auto ApplicationSettings::handleAudioStop(AudioStopNotification *notification) -> sys::MessagePointer { soundsPlayer->stop(notification->token); return sys::MessageNone{}; } auto ApplicationSettings::handleSimNotification() -> sys::MessagePointer { auto currentWindow = getCurrentWindow(); if (gui::window::name::sim_cards == currentWindow->getName()) { updateCurrentWindow(); } return sys::MessageNone{}; } auto ApplicationSettings::handleVolteState(sys::Message *msg) -> sys::MessagePointer { auto *volteStateMessage = static_cast(msg); volteState = volteStateMessage->volteState; if (isCurrentWindow(gui::window::name::network)) { // refreshWindow() would be insufficient because wouldn't trigger list rebuild switchWindow(gui::window::name::network); } return sys::MessageNone{}; } void ApplicationSettings::sendVolteChangeRequest(bool enable) { auto message = std::make_shared(enable); bus.sendUnicast(std::move(message), service::name::cellular); }; } /* namespace app */