M image/assets/lang/English.json => image/assets/lang/English.json +17 -17
@@ 245,11 245,6 @@
"app_desktop_sim_setup_wrong_puk_last_attempt_warning": "<text>If the code is wrong this time, the<br></br>SIM card will be blocked and you'll<br></br>have to contact the operator.</text>",
"app_desktop_sim_card_unlocked": "SIM card unlocked",
"app_desktop_sim_card_locked": "SIM card locked",
- "app_desktop_screen_enter_passcode_to_unlock": "<text>Enter the passcode<br></br>to unlock:</text>",
- "app_desktop_screen_wrong_passcode_last_attempt": "<text>Wrong passcode.<br></br>You have 1 attempt left.</text>",
- "app_desktop_screen_wrong_passcode_last_attempt_warning": "<text>If the passcode is wrong this time,<br></br>you'll have to wait <token>$MINUTES</token> minutes<br></br>before trying again.</text>",
- "app_desktop_screen_wrong_passcode": "<text>Wrong passcode.<br></br>You have <token>$ATTEMPTS</token> attempts left.</text>",
- "app_desktop_screen_blocked_info": "Sorry, phone blocked",
"app_desktop_press_to_unlock": "<text font='gt_pressura' size='27'>Press <b>Unlock</b> and then <b>#</b></text>",
"app_desktop_unread_messages": "<text>Unread <b>messages</b></text>",
"app_desktop_missed_calls": "<text>Missed <b>calls</b></text>",
@@ 321,10 316,6 @@
"app_onboarding_configuration_successful": "<text>Your Pure was configured</text><br></br><text>successfully.</text>",
"app_onboarding_no_configuration": "<text>Your Pure is not configured.</text><br></br><text>You can go to Settings to.</text><br></br><text>configure it.</text>",
"app_onboarding_update_info": "<text>New Mudita OS version is available.</text><br></br><text>To update your Pure Phone, please</text><br></br><text>visit: </text><text font='gt_pressura' weight='bold' size='27'>www.mudita.com/updateos</text><br></br><text>and follow the instructions.</text>",
- "app_onboarding_set_password": "Set passcode that unlocks the phone",
- "app_onboarding_confirm_password": "Confirm the passcode",
- "app_onboarding_wrong_password": "Wrong passcode. Configure passcode again.",
- "app_onboarding_passcode_configuration": "Configure passcode",
"app_settings_title_main": "Advanced",
"app_settings_title_main_new": "Settings",
"app_settings_bt": "Bluetooth",
@@ 440,14 431,23 @@
"app_settings_network_apn_settings": "APN settings",
"app_settings_toggle_on": "ON",
"app_settings_toggle_off": "OFF",
- "app_settings_security_lock_screen_passcode": "Lock screen passcode",
- "app_settings_security_change_passcode": "Change passcode",
- "app_settings_security_type_current_passcode": "Type current passcode",
- "app_settings_security_enter_new_passcode": "Enter new passcode",
- "app_settings_security_confirm_new_passcode": "Confirm new passcode",
- "app_settings_security_wrong_passcode": "Wrong passcode!",
- "app_settings_security_passcode_changed_successfully": "Passcode changed successfully!",
- "app_settings_security_passcode_disabled": "Passcode disabled!",
+ "app_settings_security_phone_lock": "Lock screen passcode",
+ "app_settings_security_change_phone_lock": "Change passcode",
+ "phone_lock_unlock": "<text>Enter the passcode<br></br>to unlock:</text>",
+ "phone_lock_unlock_last_attempt": "<text>Wrong passcode.<br></br>You have 1 attempt left.</text>",
+ "phone_lock_unlock_last_attempt_warning": "<text>If the passcode is wrong this time,<br></br>you'll have to wait <token>$MINUTES</token> minutes<br></br>before trying again.</text>",
+ "phone_lock_unlock_invalid": "<text>Wrong passcode.<br></br>You have <token>$ATTEMPTS</token> attempts left.</text>",
+ "phone_lock_blocked": "Sorry, phone blocked",
+ "phone_lock_current": "Type current passcode",
+ "phone_lock_enter_new": "Enter new passcode",
+ "phone_lock_confirm_new": "Confirm new passcode",
+ "phone_lock_invalid": "Wrong passcode!",
+ "phone_lock_changed_successfully": "Passcode changed successfully!",
+ "phone_lock_disabled": "Passcode disabled!",
+ "phone_lock_set": "<text>Set passcode that unlocks <br></br> the phone</text>",
+ "phone_lock_confirm": "Confirm the passcode",
+ "phone_lock_invalid_retry": "<text>Wrong passcode. <br></br> Configure passcode again.</text>",
+ "phone_lock_configure": "Configure passcode",
"app_settings_security_usb_passcode": "USB security",
"app_settings_apn_settings_no_apns": "<text align='center' color='9'>No APNs yet.<p>Press <b>left arrow</b> to add new.</p></text>",
"app_settings_apn_options": "Options",
M image/assets/lang/Svenska.json => image/assets/lang/Svenska.json +13 -13
@@ 229,11 229,6 @@
"app_desktop_sim_setup_wrong_puk": "<text>Fel PUK-kod.<br></br>Du har <token>$ATTEMPTS</token> försök kvar.</text>",
"app_desktop_sim_setup_wrong_puk_last_attempt": "<text>Fel PUK-kod.<br></br>Du har 1 försök kvar.</text>",
"app_desktop_sim_setup_wrong_puk_last_attempt_warning": "<text>Om koden är fel den här gången<br></br>kommer SIM-kortet låsas och du kommer<br></br>behöva kontakta operatören.</text>",
- "app_desktop_screen_enter_passcode_to_unlock": "<text>Lösenord:</text>",
- "app_desktop_screen_wrong_passcode_last_attempt": "<text>Fel lösenord.<br></br>Du har 1 försök kvar.</text>",
- "app_desktop_screen_wrong_passcode_last_attempt_warning": "<text>Om lösenordet är fel den här gången,<br></br>måste du vänta <token>$MINUTES</token> minuter<br></br>innan nästa försök.</text>",
- "app_desktop_screen_wrong_passcode": "<text>Fel lösenord.<br></br>Du har <token>$ATTEMPTS</token> försök kvar.</text>",
- "app_desktop_screen_blocked_info": "Tyvärr, telefonen blockerad.",
"app_desktop_press_to_unlock": "<text font='gt_pressura' size='27'>Tryck <b>Lås upp</b> följt av <b>#</b></text>",
"app_desktop_unread_messages": "<text>Olästa <b>meddelanden</b></text>",
"app_desktop_missed_calls": "<text>Missade <b>samtal</b></text>",
@@ 379,14 374,19 @@
"app_settings_network_apn_settings": "APN-inställningar",
"app_settings_toggle_on": "PÅ",
"app_settings_toggle_off": "AV",
- "app_settings_security_lock_screen_passcode": "Lösenord för att låsa telefonen",
- "app_settings_security_change_passcode": "Byt lösenord",
- "app_settings_security_type_current_passcode": "Det förra lösenordet",
- "app_settings_security_enter_new_passcode": "Det nya lösenordet",
- "app_settings_security_confirm_new_passcode": "Bekräfta nytt löserord",
- "app_settings_security_wrong_passcode": "Fel lösenord!",
- "app_settings_security_passcode_changed_successfully": "Lösenordet bytt!",
- "app_settings_security_passcode_disabled": "Lösenordet avstängt!",
+ "app_settings_security_phone_lock": "Lösenord för att låsa telefonen",
+ "app_settings_security_change_phone_lock": "Byt lösenord",
+ "phone_lock_unlock": "<text>Lösenord:</text>",
+ "phone_lock_unlock_last_attempt": "<text>Fel lösenord.<br></br>Du har 1 försök kvar.</text>",
+ "phone_lock_unlock_last_attempt_warning": "<text>Om lösenordet är fel den här gången,<br></br>måste du vänta <token>$MINUTES</token> minuter<br></br>innan nästa försök.</text>",
+ "phone_lock_unlock_invalid": "<text>Fel lösenord.<br></br>Du har <token>$ATTEMPTS</token> försök kvar.</text>",
+ "phone_lock_blocked": "Tyvärr, telefonen blockerad.",
+ "phone_lock_current": "Det förra lösenordet",
+ "phone_lock_enter_new": "Det nya lösenordet",
+ "phone_lock_confirm_new": "Bekräfta nytt löserord",
+ "phone_lock_invalid": "Fel lösenord!",
+ "phone_lock_changed_successfully": "Lösenordet bytt!",
+ "phone_lock_disabled": "Lösenordet avstängt!",
"app_settings_apn_settings_no_apns": "<text align='center' color='9'>Inga APN-inställningar än.<p>Tryck <b>vänsterpil</b> för att lägga till.</p></text>",
"app_settings_apn_options": "Alternativ",
"app_settings_apn_options_delete": "Radera",
M module-apps/Application.cpp => module-apps/Application.cpp +20 -34
@@ 47,7 47,8 @@
#include <popups/presenter/PowerOffPresenter.hpp>
#include <popups/lock-popups/PhoneLockedWindow.hpp>
#include <popups/lock-popups/PhoneLockedInfoWindow.hpp>
-#include <popups/lock-popups/PhoneUnLockWindow.hpp>
+#include <popups/lock-popups/PhoneLockInputWindow.hpp>
+#include <popups/lock-popups/PhoneLockChangeInfoWindow.hpp>
#include <popups/data/PopupData.hpp>
#include <popups/data/PopupRequestParams.hpp>
#include <popups/data/PhoneModeParams.hpp>
@@ 627,12 628,6 @@ namespace app
setState(State::ACTIVE_BACKGROUND);
}
- lockScreenPasscodeIsOn = utils::getNumericValue<bool>(
- settings->getValue(settings::SystemProperties::lockScreenPasscodeIsOn, settings::SettingsScope::Global));
- settings->registerValueChange(
- settings::SystemProperties::lockScreenPasscodeIsOn,
- [this](const std::string &value) { lockScreenPasscodeIsOn = utils::getNumericValue<bool>(value); },
- settings::SettingsScope::Global);
return sys::ReturnCodes::Success;
}
@@ 774,16 769,22 @@ namespace app
case ID::Brightness:
break;
case ID::PhoneLock:
- case ID::InputLock:
+ case ID::PhoneLockInput:
+ case ID::PhoneLockChangeInfo:
windowsFactory.attach(window::phone_lock_window, [](Application *app, const std::string &name) {
return std::make_unique<gui::PhoneLockedWindow>(app, window::phone_lock_window);
});
windowsFactory.attach(window::phone_lock_info_window, [](Application *app, const std::string &name) {
return std::make_unique<gui::PhoneLockedInfoWindow>(app, window::phone_lock_info_window);
});
- windowsFactory.attach(window::input_lock_window, [](Application *app, const std::string &name) {
- return std::make_unique<gui::PhoneUnlockWindow>(app, window::input_lock_window);
+ windowsFactory.attach(window::phone_lock_input_window, [](Application *app, const std::string &name) {
+ return std::make_unique<gui::PhoneLockInputWindow>(app, window::phone_lock_input_window);
});
+ windowsFactory.attach(window::phone_lock_change_info_window,
+ [](Application *app, const std::string &name) {
+ return std::make_unique<gui::PhoneLockChangeInfoWindow>(
+ app, window::phone_lock_change_info_window);
+ });
windowsFactory.attach(window::power_off_window, [](Application *app, const std::string &name) {
auto presenter = std::make_unique<gui::PowerOffPresenter>(app);
return std::make_unique<gui::PowerOffWindow>(app, std::move(presenter));
@@ 807,10 808,12 @@ namespace app
std::to_string(volumeParams->getVolume()).c_str());
handleVolumeChanged(volumeParams->getVolume(), volumeParams->getAudioContext());
}
- else if (id == ID::InputLock) {
+ else if (id == ID::PhoneLockInput || id == ID::PhoneLockChangeInfo) {
auto popupParams = static_cast<const gui::PhoneUnlockInputRequestParams *>(params);
- switchWindow(gui::popup::resolveWindowName(id), std::make_unique<locks::LockData>(popupParams->getLock()));
+ switchWindow(
+ gui::popup::resolveWindowName(id),
+ std::make_unique<locks::LockData>(popupParams->getLock(), popupParams->getPhoneLockInputTypeAction()));
}
else {
switchWindow(gui::popup::resolveWindowName(id));
@@ 933,31 936,14 @@ namespace app
callbackStorage->removeAll(receiver);
}
- void Application::handlePhoneLock()
- {
- phoneLockSubject.lock();
- }
-
- void Application::handlePhoneUnLock()
- {
- phoneLockSubject.unlock();
- }
-
- void Application::verifyPhoneLockInput(const std::vector<unsigned int> &inputData)
- {
- phoneLockSubject.verifyInput(inputData);
- }
-
- void Application::setLockScreenPasscodeOn(bool screenPasscodeOn) noexcept
+ auto Application::getPhoneLockSubject() noexcept -> locks::PhoneLockSubject &
{
- lockScreenPasscodeIsOn = screenPasscodeOn;
- settings->setValue(settings::SystemProperties::lockScreenPasscodeIsOn,
- std::to_string(lockScreenPasscodeIsOn),
- settings::SettingsScope::Global);
+ return phoneLockSubject;
}
- bool Application::isLockScreenPasscodeOn() const noexcept
+ bool Application::isPhoneLockEnabled() const noexcept
{
- return lockScreenPasscodeIsOn;
+ return (utils::getNumericValue<bool>(
+ settings->getValue(settings::SystemProperties::lockScreenPasscodeIsOn, settings::SettingsScope::Global)));
}
} /* namespace app */
M module-apps/Application.hpp => module-apps/Application.hpp +2 -6
@@ 157,7 157,6 @@ namespace app
private:
std::string default_window;
State state = State::DEACTIVATED;
- bool lockScreenPasscodeIsOn;
sys::MessagePointer handleSignalStrengthUpdate(sys::Message *msgl);
sys::MessagePointer handleNetworkAccessTechnologyUpdate(sys::Message *msgl);
@@ 403,12 402,9 @@ namespace app
locks::PhoneLockSubject phoneLockSubject;
public:
- void handlePhoneLock();
- void handlePhoneUnLock();
- void verifyPhoneLockInput(const std::vector<unsigned int> &inputData);
+ [[nodiscard]] auto getPhoneLockSubject() noexcept -> locks::PhoneLockSubject &;
- void setLockScreenPasscodeOn(bool screenPasscodeOn) noexcept;
- bool isLockScreenPasscodeOn() const noexcept;
+ [[nodiscard]] bool isPhoneLockEnabled() const noexcept;
const gui::top_bar::Configuration &getTopBarConfiguration() const noexcept;
};
M module-apps/application-calendar/windows/CalendarEventsOptionsWindow.cpp => module-apps/application-calendar/windows/CalendarEventsOptionsWindow.cpp +1 -3
@@ 15,9 15,7 @@ namespace gui
CalendarEventsOptions::CalendarEventsOptions(app::Application *app)
: OptionWindow(app, style::window::calendar::name::events_options)
- {
- buildInterface();
- }
+ {}
auto CalendarEventsOptions::eventsOptionsList() -> std::list<gui::Option>
{
M module-apps/application-desktop/ApplicationDesktop.cpp => module-apps/application-desktop/ApplicationDesktop.cpp +0 -34
@@ 165,11 165,6 @@ namespace app
if (auto msg = dynamic_cast<cellular::StateChange *>(msgl)) {
handled = handle(msg);
}
- else if (auto msg = dynamic_cast<sdesktop::developerMode::DeveloperModeRequest *>(msgl)) {
- if (auto event = dynamic_cast<sdesktop::developerMode::ScreenlockCheckEvent *>(msg->event.get())) {
- handled = handle(event);
- }
- }
else if (auto msg = dynamic_cast<sdesktop::UpdateOsMessage *>(msgl)) {
handled = handle(msg);
}
@@ 205,17 200,6 @@ namespace app
return true;
}
- auto ApplicationDesktop::handle(sdesktop::developerMode::ScreenlockCheckEvent *event) -> bool
- {
- if (event != nullptr) {
- auto event = std::make_unique<sdesktop::developerMode::ScreenlockCheckEvent>(lockHandler.isScreenLocked());
- auto msg = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(std::move(event));
- bus.sendUnicast(std::move(msg), service::name::service_desktop);
- }
-
- return true;
- }
-
void ApplicationDesktop::handleNotificationsChanged(std::unique_ptr<gui::SwitchData> notificationsParams)
{
if (auto window = getCurrentWindow()->getName();
@@ 252,9 236,6 @@ namespace app
return ret;
}
- lockPassHashChanged(
- settings->getValue(settings::SystemProperties::lockPassHash, settings::SettingsScope::Global));
-
createUserInterface();
connect(sdesktop::UpdateOsMessage(), [&](sys::Message *msg) {
@@ 362,11 343,6 @@ namespace app
settings::SettingsScope::Global);
settings->registerValueChange(
- settings::SystemProperties::lockPassHash,
- [this](const std::string &value) { lockPassHashChanged(value); },
- settings::SettingsScope::Global);
-
- settings->registerValueChange(
settings::SystemProperties::osCurrentVersion,
[this](const std::string &value) { osCurrentVersionChanged(value); },
settings::SettingsScope::Global);
@@ 467,16 443,6 @@ namespace app
}
}
- void ApplicationDesktop::lockPassHashChanged(std::string value)
- {
- if (!value.empty()) {
- lockPassHash = utils::getNumericValue<unsigned int>(value);
- }
- else {
- lockPassHash = 0;
- }
- }
-
void ApplicationDesktop::handleLowBatteryNotification(manager::actions::ActionParamsPtr &&data)
{
auto lowBatteryState = static_cast<manager::actions::LowBatteryNotificationParams *>(data.get());
M module-apps/application-desktop/ApplicationDesktop.hpp => module-apps/application-desktop/ApplicationDesktop.hpp +0 -7
@@ 49,13 49,8 @@ namespace app
// done
bool handle(cellular::StateChange *msg);
auto handle(sdesktop::UpdateOsMessage *msg) -> bool;
- auto handle(sdesktop::developerMode::ScreenlockCheckEvent *event) -> bool;
void handleNotificationsChanged(std::unique_ptr<gui::SwitchData> notificationsParams) override;
- unsigned int getLockPassHash() const noexcept
- {
- return lockPassHash;
- }
std::string getOsUpdateVersion() const
{
return osUpdateVersion;
@@ 69,9 64,7 @@ namespace app
private:
bool refreshMenuWindow();
void activeSimChanged(std::string value);
- void lockPassHashChanged(std::string value);
void handleLowBatteryNotification(manager::actions::ActionParamsPtr &&data);
- unsigned int lockPassHash = 0;
void osUpdateVersionChanged(const std::string &value);
void osCurrentVersionChanged(const std::string &value);
std::string osUpdateVersion{updateos::initSysVer};
M module-apps/application-onboarding/ApplicationOnBoarding.cpp => module-apps/application-onboarding/ApplicationOnBoarding.cpp +12 -17
@@ 20,7 20,7 @@
#include <module-apps/application-settings-new/data/LanguagesData.hpp>
#include <module-services/service-db/agents/settings/SystemSettings.hpp>
#include <module-apps/application-settings-new/windows/ChangeTimeZone.hpp>
-#include <module-apps/application-onboarding/windows/ConfigurePasscodeWindow.hpp>
+#include <module-apps/locks/data/PhoneLockMessages.hpp>
namespace app
{
@@ 43,6 43,7 @@ namespace app
Indicator::NetworkAccessTechnology});
bus.channels.push_back(sys::BusChannel::ServiceDBNotifications);
+ bus.channels.push_back(sys::BusChannel::PhoneLockChanges);
}
// Invoked upon receiving data message
@@ 76,6 77,16 @@ namespace app
}
});
+ connect(typeid(locks::SetConfirmedPhoneLock), [&](sys::Message *msg) {
+ switchWindow(gui::window::name::onBoarding_date_and_time);
+ return sys::msgHandled();
+ });
+
+ connect(typeid(locks::SkippedSetPhoneLock), [&](sys::Message *msg) {
+ switchWindow(gui::window::name::onBoarding_date_and_time);
+ return sys::msgHandled();
+ });
+
return ret;
}
@@ 84,18 95,6 @@ namespace app
settings->setValue(settings::SystemProperties::eulaAccepted, "1", settings::SettingsScope::Global);
}
- void ApplicationOnBoarding::setLockPassHash(unsigned int value)
- {
- lockPassHash = value;
- settings->setValue(
- ::settings::SystemProperties::lockPassHash, std::to_string(value), ::settings::SettingsScope::Global);
- }
-
- auto ApplicationOnBoarding::getLockPassHash() const noexcept -> unsigned int
- {
- return lockPassHash;
- }
-
sys::ReturnCodes ApplicationOnBoarding::DeinitHandler()
{
return sys::ReturnCodes::Success;
@@ 150,10 149,6 @@ namespace app
windowsFactory.attach(gui::window::name::change_time_zone, [](Application *app, const std::string &name) {
return std::make_unique<gui::ChangeTimeZone>(app);
});
- windowsFactory.attach(gui::window::name::onBoarding_configure_passcode,
- [](Application *app, const std::string &name) {
- return std::make_unique<gui::ConfigurePasscodeWindow>(app);
- });
windowsFactory.attach(gui::window::name::dialog_confirm, [](Application *app, const std::string &name) {
return std::make_unique<gui::DialogConfirm>(app, gui::window::name::dialog_confirm);
});
M module-apps/application-onboarding/ApplicationOnBoarding.hpp => module-apps/application-onboarding/ApplicationOnBoarding.hpp +0 -7
@@ 16,7 16,6 @@ namespace gui::window::name
inline constexpr auto onBoarding_skip = "OnBoardingSkipConfirm";
inline constexpr auto onBoarding_date_and_time = "OnBoardingDateAndTime";
inline constexpr auto onBoarding_change_date_and_time = "OnBoardingChangeDateAndTime";
- inline constexpr auto onBoarding_configure_passcode = "OnBoardingConfigurePasscode";
} // namespace gui::window::name
namespace app
@@ 40,12 39,6 @@ namespace app
void createUserInterface() override;
void destroyUserInterface() override;
-
- void setLockPassHash(unsigned int value);
- [[nodiscard]] auto getLockPassHash() const noexcept -> unsigned int;
-
- private:
- unsigned int lockPassHash = 0;
};
template <> struct ManifestTraits<ApplicationOnBoarding>
M module-apps/application-onboarding/CMakeLists.txt => module-apps/application-onboarding/CMakeLists.txt +2 -3
@@ 10,7 10,7 @@ include_directories( ${PROJECT_NAME}
target_sources(${PROJECT_NAME}
- PRIVATE
+ PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/ApplicationOnBoarding.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/OnBoardingMainWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/StartConfigurationWindow.cpp"
@@ 24,8 24,7 @@ target_sources(${PROJECT_NAME}
"${CMAKE_CURRENT_LIST_DIR}/windows/SkipDialogWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/OnBoardingDateAndTimeWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/OnBoardingChangeDateAndTimeWindow.cpp"
- "${CMAKE_CURRENT_LIST_DIR}/windows/ConfigurePasscodeWindow.cpp"
- PUBLIC
+ PUBLIC
"${CMAKE_CURRENT_LIST_DIR}/ApplicationOnBoarding.hpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/OnBoardingMainWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/windows/StartConfigurationWindow.hpp"
D module-apps/application-onboarding/windows/ConfigurePasscodeWindow.cpp => module-apps/application-onboarding/windows/ConfigurePasscodeWindow.cpp +0 -106
@@ 1,106 0,0 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
-// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-#include "ConfigurePasscodeWindow.hpp"
-#include "locks/data/LockStyle.hpp"
-
-#include <application-onboarding/ApplicationOnBoarding.hpp>
-#include <application-onboarding/data/OnBoardingSwitchData.hpp>
-#include <application-settings-new/ApplicationSettings.hpp>
-#include <application-settings-new/windows/ChangePasscodeWindow.hpp>
-
-#include <DialogMetadata.hpp>
-#include <DialogMetadataMessage.hpp>
-#include <windows/Dialog.hpp>
-
-namespace lock_style = style::window::pin_lock;
-namespace screen_lock_style = style::window::screen_pin_lock;
-
-namespace gui
-{
- ConfigurePasscodeWindow::ConfigurePasscodeWindow(app::Application *app) : ChangePasscodeWindow(app)
- {
- lockState = Lock::LockState::NewInputRequired;
-
- textForEnterNewPassword = "app_onboarding_set_password";
- testForConfirmPassword = "app_onboarding_confirm_password";
- textForWrongPassword = "app_onboarding_worng_password";
- }
-
- auto ConfigurePasscodeWindow::onInput(const InputEvent &inputEvent) -> bool
- {
- if (inputEvent.isShortRelease(KeyCode::KEY_LF)) {
- application->setLockScreenPasscodeOn(false);
- application->switchWindow(gui::window::name::onBoarding_date_and_time,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<app::onBoarding::OnBoardingSwitchData>());
- }
-
- return ChangePasscodeWindow::onInput(inputEvent);
- }
-
- void ConfigurePasscodeWindow::buildBottomBar()
- {
- bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::confirm));
- bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));
- bottomBar->setText(BottomBar::Side::LEFT, utils::translate(style::strings::common::skip));
- }
-
- void ConfigurePasscodeWindow::buildTitleBar()
- {
- setTitle(utils::translate("app_onboarding_passcode_configuration"));
- }
-
- void ConfigurePasscodeWindow::processPasscode()
- {
- switch (lockState) {
- case Lock::LockState::NewInputConfirmRequired:
- case Lock::LockState::NewInputInvalid: {
- lockState = lockHandler.newPasscodeConfirmed();
- if (lockState == Lock::LockState::Unlocked) {
- auto app = static_cast<app::ApplicationOnBoarding *>(application);
- app->setLockPassHash(lockHandler.getNewPasscodeHash());
- }
- break;
- }
- default:
- return ChangePasscodeWindow::processPasscode();
- }
- }
-
- void ConfigurePasscodeWindow::setVisibleState()
- {
- switch (lockState) {
- case Lock::LockState::NewInputInvalid: {
-
- auto metaData = std::make_unique<gui::DialogMetadataMessage>(
- gui::DialogMetadata{utils::translate("app_onboarding_passcode_configuration"),
- "info_big_circle_W_G",
- utils::translate("app_onboarding_wrong_password"),
- "",
- [this]() {
- application->switchWindow(gui::window::name::onBoarding_configure_passcode,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<ChangePasscodeData>(
- ChangePasscodeAction::OnlyProvideNewPasscode));
- return true;
- }});
-
- application->switchWindow(
- gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
-
- break;
- }
- case Lock::LockState::Unlocked: {
- application->setLockScreenPasscodeOn(true);
- application->switchWindow(gui::window::name::onBoarding_date_and_time,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<app::onBoarding::OnBoardingSwitchData>());
- break;
- }
- default:
- ChangePasscodeWindow::setVisibleState();
- break;
- }
- }
-} // namespace gui
D module-apps/application-onboarding/windows/ConfigurePasscodeWindow.hpp => module-apps/application-onboarding/windows/ConfigurePasscodeWindow.hpp +0 -26
@@ 1,26 0,0 @@
-// 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 <locks/widgets/PhoneLockBaseBox.hpp>
-#include <locks/windows/LockWindow.hpp>
-#include <application-settings-new/windows/ChangePasscodeWindow.hpp>
-#include <application-settings-new/data/ChangePasscodeData.hpp>
-#include <application-settings-new/widgets/ChangePasscodeLockHandler.hpp>
-
-namespace gui
-{
- class ConfigurePasscodeWindow : public ChangePasscodeWindow
- {
- public:
- explicit ConfigurePasscodeWindow(app::Application *app);
- bool onInput(const InputEvent &inputEvent) override;
-
- protected:
- void buildBottomBar() override;
- void buildTitleBar() override;
- void processPasscode() override;
- void setVisibleState() override;
- };
-} /* namespace gui */
M module-apps/application-onboarding/windows/OnBoardingDateAndTimeWindow.cpp => module-apps/application-onboarding/windows/OnBoardingDateAndTimeWindow.cpp +1 -8
@@ 31,14 31,7 @@ namespace app::onBoarding
bool OnBoardingDateAndTimeWindow::onInput(const gui::InputEvent &inputEvent)
{
- if (inputEvent.isShortRelease(gui::KeyCode::KEY_RF)) {
- application->switchWindow(
- gui::window::name::onBoarding_configure_passcode,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<ChangePasscodeData>(ChangePasscodeAction::OnlyProvideNewPasscode));
- return true;
- }
- else if (inputEvent.isShortRelease(gui::KeyCode::KEY_LF)) {
+ if (inputEvent.isShortRelease(gui::KeyCode::KEY_LF)) {
return getFocusItem()->onActivated(nullptr);
}
else if (inputEvent.isShortRelease(gui::KeyCode::KEY_ENTER)) {
M module-apps/application-onboarding/windows/StartConfigurationWindow.cpp => module-apps/application-onboarding/windows/StartConfigurationWindow.cpp +1 -3
@@ 51,9 51,7 @@ namespace app::onBoarding
std::make_unique<OnBoardingSwitchData>());
}
if (inputEvent.is(gui::KeyCode::KEY_ENTER)) {
- application->switchWindow(gui::window::name::onBoarding_configure_passcode,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<OnBoardingSwitchData>());
+ application->getPhoneLockSubject().setPhoneLock();
}
if (inputEvent.is(gui::KeyCode::KEY_LF)) {
M module-apps/application-phonebook/windows/PhonebookContactOptions.cpp => module-apps/application-phonebook/windows/PhonebookContactOptions.cpp +1 -3
@@ 16,9 16,7 @@ namespace gui
PhonebookContactOptions::PhonebookContactOptions(app::Application *app)
: OptionWindow(app, gui::window::name::contact_options)
- {
- buildInterface();
- }
+ {}
auto PhonebookContactOptions::handleSwitchData(SwitchData *data) -> bool
{
M module-apps/application-phonebook/windows/PhonebookNamecardOptions.cpp => module-apps/application-phonebook/windows/PhonebookNamecardOptions.cpp +0 -1
@@ 14,7 14,6 @@ namespace gui
PhonebookNamecardOptions::PhonebookNamecardOptions(app::Application *app)
: OptionWindow(app, gui::window::name::namecard_options)
{
- buildInterface();
addOptions(namecardOptionsList());
}
M module-apps/application-settings-new/ApplicationSettings.cpp => module-apps/application-settings-new/ApplicationSettings.cpp +0 -16
@@ 34,7 34,6 @@
#include <application-settings-new/windows/SecurityMainWindow.hpp>
#include <application-settings-new/windows/QuotesOptionsWindow.hpp>
#include <application-settings-new/windows/SARInfoWindow.hpp>
-#include <application-settings-new/windows/ChangePasscodeWindow.hpp>
#include <application-settings-new/windows/SystemMainWindow.hpp>
#include <application-settings-new/windows/NewApnWindow.hpp>
#include <application-settings-new/windows/LanguagesWindow.hpp>
@@ 301,11 300,6 @@ namespace app
::settings::Cellular::volte_on,
[this](const std::string &value) { volteChanged(value); },
::settings::SettingsScope::Global);
- settings->registerValueChange(
- ::settings::SystemProperties::lockPassHash,
- [this](const std::string &value) { lockPassHash = utils::getNumericValue<unsigned int>(value); },
- ::settings::SettingsScope::Global);
-
/*
settings->registerValueChange(
::settings::SystemProperties::usbSecurity,
@@ 429,9 423,6 @@ namespace app
windowsFactory.attach(app::window::name::desktop_pin_lock, [&](Application *app, const std::string newname) {
return std::make_unique<gui::PinLockWindow>(app, app::window::name::desktop_pin_lock);
});
- windowsFactory.attach(gui::window::name::change_passcode, [](Application *app, const std::string &name) {
- return std::make_unique<gui::ChangePasscodeWindow>(app);
- });
windowsFactory.attach(gui::window::name::dialog_confirm, [](Application *app, const std::string &name) {
return std::make_unique<gui::DialogConfirm>(app, gui::window::name::dialog_confirm);
});
@@ 571,13 562,6 @@ namespace app
settings->setValue(::settings::SystemProperties::osUpdateVersion, value, ::settings::SettingsScope::Global);
}
- void ApplicationSettingsNew::setLockPassHash(unsigned int value)
- {
- lockPassHash = value;
- settings->setValue(
- ::settings::SystemProperties::lockPassHash, std::to_string(value), ::settings::SettingsScope::Global);
- }
-
auto ApplicationSettingsNew::getCurrentValues() -> settingsInterface::ScreenLightSettings::Values
{
constexpr int timeout = pdMS_TO_TICKS(1500);
M module-apps/application-settings-new/ApplicationSettings.hpp => module-apps/application-settings-new/ApplicationSettings.hpp +0 -10
@@ 204,11 204,6 @@ namespace app
bool getVoLTEOn() const noexcept override;
void volteChanged(const std::string &value);
void setOsUpdateVersion(const std::string &value);
- [[nodiscard]] auto getLockPassHash() const noexcept -> unsigned int
- {
- return lockPassHash;
- }
- void setLockPassHash(unsigned int value);
ScreenLightSettings::Values getCurrentValues() override;
void setBrightness(float brigtnessValue) override;
@@ 222,9 217,6 @@ namespace app
auto isUSBSecured() const -> bool override;
void setUSBSecurity(bool security) override;
- void setLockScreenPasscodeOn(bool passcodeOn);
- auto isLockScreenPasscodeOn() const -> bool;
-
auto getNotificationsWhenLocked() const noexcept -> bool override;
void setNotificationsWhenLocked(bool on) noexcept override;
auto getCallsFromFavourite() const noexcept -> bool override;
@@ 246,8 238,6 @@ namespace app
bool operatorsOn = false;
bool voLteStateOn = false;
bool usbSecured = true;
- bool lockScreenPasscodeOn = true;
- unsigned int lockPassHash = 0;
bool notificationsWhenLocked = true;
bool callsFromFavorites = false;
int connectionFrequency = 0;
M module-apps/application-settings-new/CMakeLists.txt => module-apps/application-settings-new/CMakeLists.txt +0 -4
@@ 28,7 28,6 @@ target_sources( ${PROJECT_NAME}
models/SoundsModel.cpp
presenter/SARInfoWindowPresenter.cpp
presenter/TechnicalWindowPresenter.cpp
- widgets/ChangePasscodeLockHandler.cpp
widgets/QuoteWidget.cpp
widgets/CategoryWidget.cpp
widgets/ApnInputWidget.cpp
@@ 66,7 65,6 @@ target_sources( ${PROJECT_NAME}
windows/QuotesOptionsWindow.cpp
windows/SARInfoWindow.cpp
windows/SecurityMainWindow.cpp
- windows/ChangePasscodeWindow.cpp
windows/NewApnWindow.cpp
widgets/SpinBox.cpp
widgets/SpinBoxOptionSettings.cpp
@@ 89,7 87,6 @@ target_sources( ${PROJECT_NAME}
PUBLIC
ApplicationSettings.hpp
- widgets/ChangePasscodeLockHandler.hpp
widgets/ApnInputWidget.hpp
widgets/CategoryWidget.hpp
windows/NewApnWindow.hpp
@@ 106,7 103,6 @@ target_sources( ${PROJECT_NAME}
widgets/SettingsStyle.hpp
windows/AutolockWindow.hpp
windows/WallpaperWindow.hpp
- windows/ChangePasscodeWindow.hpp
windows/SystemMainWindow.hpp
windows/LanguagesWindow.hpp
windows/DateAndTimeMainWindow.hpp
D module-apps/application-settings-new/widgets/ChangePasscodeLockHandler.cpp => module-apps/application-settings-new/widgets/ChangePasscodeLockHandler.cpp +0 -57
@@ 1,57 0,0 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
-// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-#include "ChangePasscodeLockHandler.hpp"
-#include "locks/widgets/LockHash.hpp"
-
-namespace gui
-{
- ChangePasscodeLockHandler::ChangePasscodeLockHandler()
- : lock(Store::GSM::SIM::NONE, Lock::LockState::InputRequired, Lock::LockType::Screen)
- {}
-
- Lock::LockState ChangePasscodeLockHandler::checkPasscode(unsigned int currentLockPassHash)
- {
- return activateLock([this, currentLockPassHash](Lock::LockType, const std::vector<unsigned int> &pin) {
- const auto hash = getHash(pin);
- if (hash == currentLockPassHash) {
- lock.lockState = Lock::LockState::NewInputRequired;
- }
- else {
- lock.lockState = Lock::LockState::InputInvalidRetryRequired;
- }
- });
- }
-
- Lock::LockState ChangePasscodeLockHandler::newPasscodeConfirmed()
- {
- return activateLock([this](Lock::LockType, const std::vector<unsigned int> &pin) {
- const auto newPasscodeConfirmedHash = getHash(pin);
- if (newPasscodeHash == newPasscodeConfirmedHash) {
- lock.lockState = Lock::LockState::Unlocked;
- }
- else {
- lock.lockState = Lock::LockState::NewInputInvalid;
- }
- });
- }
-
- Lock::LockState ChangePasscodeLockHandler::newPasscodeProvided()
- {
- return activateLock([this](Lock::LockType, const std::vector<unsigned int> &pin) {
- if (pin.size() < lock.getMaxInputSize()) {
- lock.lockState = Lock::LockState::NewInputInvalidRetryRequired;
- return;
- }
- newPasscodeHash = getHash(pin);
- lock.lockState = Lock::LockState::NewInputConfirmRequired;
- });
- }
-
- Lock::LockState ChangePasscodeLockHandler::activateLock(OnActivatedCallback onActivatedCallback)
- {
- lock.onActivatedCallback = onActivatedCallback;
- lock.activate();
- return lock.lockState;
- }
-} // namespace gui
D module-apps/application-settings-new/widgets/ChangePasscodeLockHandler.hpp => module-apps/application-settings-new/widgets/ChangePasscodeLockHandler.hpp +0 -36
@@ 1,36 0,0 @@
-// 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 "locks/widgets/Lock.hpp"
-
-namespace gui
-{
- using namespace locks;
-
- class ChangePasscodeLockHandler
- {
- public:
- ChangePasscodeLockHandler();
-
- auto checkPasscode(unsigned int currentLockPassHash) -> Lock::LockState;
- [[nodiscard]] auto getLock() -> Lock &
- {
- return lock;
- }
- [[nodiscard]] auto getNewPasscodeHash() const noexcept -> unsigned int
- {
- return newPasscodeHash;
- }
- auto newPasscodeConfirmed() -> Lock::LockState;
- auto newPasscodeProvided() -> Lock::LockState;
-
- private:
- using OnActivatedCallback = std::function<void(Lock::LockType type, const std::vector<unsigned int> &)>;
- auto activateLock(OnActivatedCallback onActivatedCallback) -> Lock::LockState;
-
- Lock lock;
- unsigned int newPasscodeHash;
- };
-} // namespace gui
D module-apps/application-settings-new/windows/ChangePasscodeWindow.cpp => module-apps/application-settings-new/windows/ChangePasscodeWindow.cpp +0 -189
@@ 1,189 0,0 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
-// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
-
-#include "application-settings-new/ApplicationSettings.hpp"
-#include "locks/data/LockStyle.hpp"
-#include "ChangePasscodeWindow.hpp"
-#include "DialogMetadata.hpp"
-#include "DialogMetadataMessage.hpp"
-#include "windows/Dialog.hpp"
-
-namespace lock_style = style::window::pin_lock;
-namespace screen_lock_style = style::window::screen_pin_lock;
-
-namespace gui
-{
- ChangePasscodeWindow::ChangePasscodeWindow(app::Application *app)
- : LockWindow(app, gui::window::name::change_passcode)
- {
- buildInterface();
- }
-
- auto ChangePasscodeWindow::onInput(const InputEvent &inputEvent) -> bool
- {
- auto &lock = lockHandler.getLock();
- if (lock.isState(Lock::LockState::Unlocked) && inputEvent.isShortRelease()) {
- application->returnToPreviousWindow();
- }
- if (!inputEvent.isShortRelease()) {
- return AppWindow::onInput(inputEvent);
- }
-
- if (inputEvent.isDigit() && lock.canPut()) {
- lockBox->putChar(lock.getCharCount());
- lock.putNextChar(inputEvent.numericValue());
- return true;
- }
- else if (inputEvent.is(KeyCode::KEY_PND)) {
- lock.popChar();
- lockBox->popChar(lock.getCharCount());
- return true;
- }
- else if (inputEvent.is(KeyCode::KEY_ENTER)) {
- processPasscode();
- setVisibleState();
- return true;
- }
- return AppWindow::onInput(inputEvent);
- }
-
- void ChangePasscodeWindow::rebuild()
- {
- destroyInterface();
- buildInterface();
- }
-
- void ChangePasscodeWindow::buildBottomBar()
- {
- LockWindow::buildBottomBar();
- setBottomBarWidgetsActive(false, true, true);
- }
-
- void ChangePasscodeWindow::buildInterface()
- {
- AppWindow::buildInterface();
- LockWindow::build();
-
- lockBox = std::make_unique<PhoneLockBaseBox>(this);
- lockBox->buildLockBox(lockHandler.getLock().getMaxInputSize());
-
- lockImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, "pin_lock");
-
- primaryText->setPosition(lockImage->getHeight() + screen_lock_style::primary_text::y, gui::Axis::Y);
- pinLabelsBox->setPosition(lockImage->getHeight() + screen_lock_style::pin_label::y, gui::Axis::Y);
- }
-
- void ChangePasscodeWindow::buildTitleBar()
- {
- setTitle(utils::translate("app_settings_security_change_passcode"));
- }
-
- void ChangePasscodeWindow::destroyInterface()
- {
- erase();
- }
-
- void ChangePasscodeWindow::onBeforeShow(ShowMode mode, SwitchData *data)
- {
- if (data != nullptr) {
- auto changePasscodeData = static_cast<ChangePasscodeData *>(data);
- changePasscodeAction = changePasscodeData->changePasscodeAction;
- if (ChangePasscodeAction::OnlyProvideNewPasscode == changePasscodeAction) {
- lockState = Lock::LockState::NewInputRequired;
- }
- }
- setVisibleState();
- }
-
- void ChangePasscodeWindow::processPasscode()
- {
- switch (lockState) {
- case Lock::LockState::InputRequired:
- case Lock::LockState::InputInvalidRetryRequired: {
- auto app = static_cast<app::ApplicationSettingsNew *>(application);
- lockState = lockHandler.checkPasscode(app->getLockPassHash());
- if (ChangePasscodeAction::OnlyCheckCurrentPasscode == changePasscodeAction &&
- lockState == Lock::LockState::NewInputRequired) {
- application->setLockScreenPasscodeOn(false);
-
- auto metaData = std::make_unique<gui::DialogMetadataMessage>(
- gui::DialogMetadata{utils::translate("app_settings_security_change_passcode"),
- "success_icon_W_G",
- utils::translate("app_settings_security_passcode_disabled"),
- "",
- [this]() {
- application->switchWindow(gui::window::name::security);
- return true;
- }});
- application->switchWindow(
- gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
- return;
- }
- break;
- }
- case Lock::LockState::NewInputRequired:
- case Lock::LockState::NewInputInvalidRetryRequired: {
- lockState = lockHandler.newPasscodeProvided();
- break;
- }
- case Lock::LockState::NewInputConfirmRequired:
- case Lock::LockState::NewInputInvalid: {
- lockState = lockHandler.newPasscodeConfirmed();
- if (lockState == Lock::LockState::Unlocked) {
- auto app = static_cast<app::ApplicationSettingsNew *>(application);
- app->setLockPassHash(lockHandler.getNewPasscodeHash());
- }
- break;
- }
- default:
- break;
- }
- }
-
- void ChangePasscodeWindow::setVisibleState()
- {
- lockBox->clear();
- switch (lockState) {
- case Lock::LockState::InputRequired: {
- setText("app_settings_security_type_current_passcode", LockWindow::TextType::Primary);
- secondaryText->setVisible(false);
- break;
- }
- case Lock::LockState::NewInputRequired: {
- setText("app_settings_security_enter_new_passcode", LockWindow::TextType::Primary);
- secondaryText->setVisible(false);
- break;
- }
- case Lock::LockState::NewInputConfirmRequired: {
- setText("app_settings_security_confirm_new_passcode", LockWindow::TextType::Primary);
- secondaryText->setVisible(false);
- break;
- }
- case Lock::LockState::InputInvalidRetryRequired:
- case Lock::LockState::NewInputInvalidRetryRequired:
- case Lock::LockState::NewInputInvalid: {
- setText("app_settings_security_wrong_passcode", LockWindow::TextType::Secondary);
- break;
- }
- case Lock::LockState::Unlocked: {
- application->setLockScreenPasscodeOn(true);
-
- auto metaData = std::make_unique<gui::DialogMetadataMessage>(
- gui::DialogMetadata{utils::translate("app_settings_security_change_passcode"),
- "success_icon_W_G",
- utils::translate("app_settings_security_passcode_changed_successfully"),
- "",
- [this]() {
- application->switchWindow(gui::window::name::security);
- return true;
- }});
- application->switchWindow(
- gui::window::name::dialog_confirm, gui::ShowMode::GUI_SHOW_INIT, std::move(metaData));
- break;
- }
- default: {
- break;
- }
- }
- }
-} // namespace gui
D module-apps/application-settings-new/windows/ChangePasscodeWindow.hpp => module-apps/application-settings-new/windows/ChangePasscodeWindow.hpp +0 -41
@@ 1,41 0,0 @@
-// 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 "locks/windows/LockWindow.hpp"
-#include "locks/widgets/PhoneLockBaseBox.hpp"
-#include "application-settings-new/data/ChangePasscodeData.hpp"
-#include "application-settings-new/widgets/ChangePasscodeLockHandler.hpp"
-
-namespace gui
-{
- class ChangePasscodeWindow : public LockWindow
- {
- public:
- explicit ChangePasscodeWindow(app::Application *app);
- bool onInput(const InputEvent &inputEvent) override;
- void rebuild() override;
-
- protected:
- void buildBottomBar() override;
- void buildInterface() override;
- void buildTitleBar() override;
- void destroyInterface() override;
- void onBeforeShow(ShowMode mode, SwitchData *data) override;
-
- virtual void processPasscode();
- virtual void setVisibleState();
-
- ChangePasscodeAction changePasscodeAction;
- std::unique_ptr<PhoneLockBaseBox> lockBox = nullptr;
- gui::Image *lockImage = nullptr;
- Lock::LockState lockState{Lock::LockState::InputRequired};
- ChangePasscodeLockHandler lockHandler;
-
- std::string textForEnterCurrentPassword = "app_settings_security_type_current_passcode";
- std::string textForEnterNewPassword = "app_settings_security_enter_new_passcode";
- std::string testForConfirmPassword = "app_settings_security_confirm_new_passcode";
- std::string textForWrongPassword = "app_settings_security_wrong_passcode";
- };
-} /* namespace gui */
M module-apps/application-settings-new/windows/SecurityMainWindow.cpp => module-apps/application-settings-new/windows/SecurityMainWindow.cpp +18 -19
@@ 12,23 12,24 @@
namespace gui
{
SecurityMainWindow::SecurityMainWindow(app::Application *app, app::settingsInterface::SecuritySettings *settings)
- : BaseSettingsWindow(app, window::name::security), lockScreenPasscodeIsOn(app->isLockScreenPasscodeOn()),
- securitySettings(settings)
+ : BaseSettingsWindow(app, window::name::security), securitySettings(settings)
{}
+ void SecurityMainWindow::onBeforeShow(ShowMode mode, SwitchData *data)
+ {
+ isPhoneLockEnabled = application->isPhoneLockEnabled();
+ BaseSettingsWindow::onBeforeShow(mode, data);
+ }
+
auto SecurityMainWindow::buildOptionsList() -> std::list<Option>
{
std::list<Option> optionList;
optionList.emplace_back(std::make_unique<option::OptionSettings>(
- utils::translate("app_settings_security_lock_screen_passcode"),
+ utils::translate("app_settings_security_phone_lock"),
[=](Item &item) {
- lockScreenPasscodeIsOn = !lockScreenPasscodeIsOn;
- LOG_INFO("switching to %s page", window::name::change_passcode);
- auto data = lockScreenPasscodeIsOn
- ? std::make_unique<ChangePasscodeData>(ChangePasscodeAction::OnlyProvideNewPasscode)
- : std::make_unique<ChangePasscodeData>(ChangePasscodeAction::OnlyCheckCurrentPasscode);
- application->switchWindow(window::name::change_passcode, std::move(data));
+ isPhoneLockEnabled ? application->getPhoneLockSubject().disablePhoneLock()
+ : application->getPhoneLockSubject().enablePhoneLock();
return true;
},
[=](Item &item) {
@@ 41,7 42,7 @@ namespace gui
return true;
},
nullptr,
- lockScreenPasscodeIsOn ? option::SettingRightItem::On : option::SettingRightItem::Off));
+ isPhoneLockEnabled ? option::SettingRightItem::On : option::SettingRightItem::Off));
optionList.emplace_back(std::make_unique<option::OptionSettings>(
utils::translate("app_settings_security_usb_passcode"),
@@ 52,9 53,10 @@ namespace gui
securitySettings->setUSBSecurity(!securitySettings->isUSBSecured());
application->returnToPreviousWindow();
};
- application->switchWindow(app::window::name::desktop_pin_lock,
- gui::ShowMode::GUI_SHOW_INIT,
- std::make_unique<locks::LockData>(*lock));
+ application->switchWindow(
+ app::window::name::desktop_pin_lock,
+ gui::ShowMode::GUI_SHOW_INIT,
+ std::make_unique<locks::LockData>(*lock, locks::PhoneLockInputTypeAction::Change));
return true;
},
[=](Item &item) {
@@ 69,14 71,11 @@ namespace gui
nullptr,
securitySettings->isUSBSecured() ? option::SettingRightItem::On : option::SettingRightItem::Off));
- if (lockScreenPasscodeIsOn) {
+ if (isPhoneLockEnabled) {
optionList.emplace_back(std::make_unique<option::OptionSettings>(
- utils::translate("app_settings_security_change_passcode"),
+ utils::translate("app_settings_security_change_phone_lock"),
[=](Item &item) {
- LOG_INFO("switching to %s page", window::name::change_passcode);
- application->switchWindow(
- window::name::change_passcode,
- std::make_unique<ChangePasscodeData>(ChangePasscodeAction::ChangeCurrentPasscode));
+ application->getPhoneLockSubject().changePhoneLock();
return true;
},
nullptr,
M module-apps/application-settings-new/windows/SecurityMainWindow.hpp => module-apps/application-settings-new/windows/SecurityMainWindow.hpp +2 -1
@@ 14,8 14,9 @@ namespace gui
private:
auto buildOptionsList() -> std::list<Option> override;
+ void onBeforeShow(ShowMode mode, SwitchData *data) override;
- bool lockScreenPasscodeIsOn;
+ bool isPhoneLockEnabled;
app::settingsInterface::SecuritySettings *securitySettings;
};
} // namespace gui
M module-apps/locks/CMakeLists.txt => module-apps/locks/CMakeLists.txt +1 -1
@@ 29,7 29,7 @@ target_sources( ${PROJECT_NAME}
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/data/LockData.hpp"
"${CMAKE_CURRENT_LIST_DIR}/data/LockStyle.hpp"
- "${CMAKE_CURRENT_LIST_DIR}/data/LockMessages.hpp"
+ "${CMAKE_CURRENT_LIST_DIR}/data/PhoneLockMessages.hpp"
"${CMAKE_CURRENT_LIST_DIR}/handlers/PinLockHandler.hpp"
"${CMAKE_CURRENT_LIST_DIR}/handlers/PhoneLockHandler.hpp"
"${CMAKE_CURRENT_LIST_DIR}/handlers/PhoneLockSubject.hpp"
M module-apps/locks/data/LockData.hpp => module-apps/locks/data/LockData.hpp +21 -3
@@ 4,27 4,45 @@
#pragma once
#include <memory>
+#include <utility>
#include "gui/SwitchData.hpp"
#include "locks/widgets/Lock.hpp"
namespace locks
{
+ enum class PhoneLockInputTypeAction
+ {
+ Unlock,
+ Enable,
+ Disable,
+ ConfirmCurrent,
+ Change,
+ Set
+ };
// class template that stores information that was sent along with switch message
class LockData : public gui::SwitchData
{
Lock lock;
+ PhoneLockInputTypeAction phoneLockInputTypeAction;
public:
- explicit LockData(Lock lock) : SwitchData(), lock(std::move(lock))
+ explicit LockData(Lock lock,
+ PhoneLockInputTypeAction phoneLockInputTypeAction = PhoneLockInputTypeAction::Unlock)
+ : SwitchData(), lock(std::move(lock)), phoneLockInputTypeAction(phoneLockInputTypeAction)
{
description = "LockPhoneData";
}
- [[nodiscard]] const Lock &getLock() const noexcept
+ [[nodiscard]] auto getLock() const noexcept
{
return lock;
}
+
+ [[nodiscard]] auto getPhoneLockInputTypeAction() const noexcept
+ {
+ return phoneLockInputTypeAction;
+ }
};
-} // namespace lock
+} // namespace locks
R module-apps/locks/data/LockMessages.hpp => module-apps/locks/data/PhoneLockMessages.hpp +21 -0
@@ 22,6 22,27 @@ namespace locks
class LockedPhone : public sys::DataMessage
{};
+ class EnablePhoneLock : public sys::DataMessage
+ {};
+
+ class DisablePhoneLock : public sys::DataMessage
+ {};
+
+ class ChangePhoneLock : public sys::DataMessage
+ {};
+
+ class SetPhoneLock : public sys::DataMessage
+ {};
+
+ class SetConfirmedPhoneLock : public sys::DataMessage
+ {};
+
+ class SkipSetPhoneLock : public sys::DataMessage
+ {};
+
+ class SkippedSetPhoneLock : public sys::DataMessage
+ {};
+
class UnLockPhoneInput : public sys::DataMessage
{
private:
M module-apps/locks/handlers/PhoneLockHandler.cpp => module-apps/locks/handlers/PhoneLockHandler.cpp +216 -27
@@ 9,13 9,14 @@
#include <memory>
#include <module-apps/popups/data/PopupRequestParams.hpp>
+#include <module-services/service-db/agents/settings/SystemSettings.hpp>
namespace locks
{
constexpr unsigned int default_attempts = 4;
- PhoneLockHandler::PhoneLockHandler(sys::Service *owner)
- : owner(owner), lock(Lock::LockState::InputRequired, default_attempts)
+ PhoneLockHandler::PhoneLockHandler(sys::Service *owner, std::shared_ptr<settings::Settings> settings)
+ : owner(owner), lock(Lock::LockState::InputRequired, default_attempts), settings(std::move(settings))
{}
void PhoneLockHandler::enablePhoneLock(bool _phoneLockEnabled)
@@ 33,19 34,34 @@ namespace locks
}
}
- void PhoneLockHandler::PhoneLockAction()
+ void PhoneLockHandler::setPhoneLockInputTypeAction(PhoneLockInputTypeAction _phoneLockInputTypeAction)
{
+ if (phoneLockInputTypeAction != _phoneLockInputTypeAction) {
+ phoneLockInputTypeAction = _phoneLockInputTypeAction;
+ lock.attemptsLeft = default_attempts;
+ storedInputData.clear();
+ }
+ }
+
+ bool PhoneLockHandler::checkPhoneLockInputTypeAction(PhoneLockInputTypeAction _phoneLockInputTypeAction)
+ {
+ return phoneLockInputTypeAction == _phoneLockInputTypeAction;
+ }
+
+ void PhoneLockHandler::phoneLockAction()
+ {
+ phoneState = PhoneState::Locked;
app::manager::Controller::sendAction(owner,
app::manager::actions::ShowPopup,
std::make_unique<gui::PopupRequestParams>(gui::popup::ID::PhoneLock));
owner->bus.sendMulticast(std::make_shared<locks::LockedPhone>(), sys::BusChannel::PhoneLockChanges);
}
- void PhoneLockHandler::PhoneUnlockPopupsCloseAction()
+ void PhoneLockHandler::phoneUnlockPopupsCloseAction()
{
app::manager::Controller::sendAction(owner,
app::manager::actions::AbortPopup,
- std::make_unique<gui::PopupRequestParams>(gui::popup::ID::InputLock));
+ std::make_unique<gui::PopupRequestParams>(gui::popup::ID::PhoneLockInput));
if (!isPhoneLocked()) {
app::manager::Controller::sendAction(owner,
app::manager::actions::AbortPopup,
@@ 53,38 69,89 @@ namespace locks
}
}
- void PhoneLockHandler::PhoneUnlockAction()
+ void PhoneLockHandler::phoneUnlockAction()
{
- PhoneUnlockPopupsCloseAction();
+ phoneState = PhoneState::Unlocked;
+ phoneUnlockPopupsCloseAction();
owner->bus.sendMulticast(std::make_shared<locks::UnlockedPhone>(), sys::BusChannel::PhoneLockChanges);
}
- void PhoneLockHandler::PhoneInputRequiredAction()
+ void PhoneLockHandler::phoneInputRequiredAction()
+ {
+ app::manager::Controller::sendAction(owner,
+ app::manager::actions::ShowPopup,
+ std::make_unique<gui::PhoneUnlockInputRequestParams>(
+ gui::popup::ID::PhoneLockInput, lock, phoneLockInputTypeAction));
+ }
+
+ void PhoneLockHandler::phoneLockEnableAction()
{
- app::manager::Controller::sendAction(
- owner,
- app::manager::actions::ShowPopup,
- std::make_unique<gui::PhoneUnlockInputRequestParams>(gui::popup::ID::InputLock, lock));
+ setPhoneLockAvailabilityInSettings(true);
+ phoneLockChangeAction();
+ }
+
+ void PhoneLockHandler::phoneLockDisableAction()
+ {
+ setPhoneLockAvailabilityInSettings(false);
+ phoneLockChangeInfoAction();
+ phoneUnlockPopupsCloseAction();
+ }
+
+ void PhoneLockHandler::phoneLockChangeAction()
+ {
+ setPhoneLockInSettings();
+ phoneLockChangeInfoAction();
+ phoneUnlockPopupsCloseAction();
+ }
+
+ void PhoneLockHandler::phoneLockSetAction()
+ {
+ setPhoneLockAvailabilityInSettings(true);
+ setPhoneLockInSettings();
+
+ lock.lockState = Lock::LockState::NewInputRequired;
+ owner->bus.sendMulticast(std::make_shared<locks::SetConfirmedPhoneLock>(), sys::BusChannel::PhoneLockChanges);
+ }
+
+ void PhoneLockHandler::phoneLockChangeInfoAction()
+ {
+ app::manager::Controller::sendAction(owner,
+ app::manager::actions::ShowPopup,
+ std::make_unique<gui::PhoneUnlockInputRequestParams>(
+ gui::popup::ID::PhoneLockChangeInfo, lock, phoneLockInputTypeAction));
+ }
+
+ void PhoneLockHandler::setPhoneLockInSettings()
+ {
+ phoneLockHash = getHash(storedInputData);
+ settings->setValue(::settings::SystemProperties::lockPassHash,
+ std::to_string(phoneLockHash),
+ ::settings::SettingsScope::Global);
+ }
+
+ void PhoneLockHandler::setPhoneLockAvailabilityInSettings(bool value)
+ {
+ phoneLockEnabled = value;
+ settings->setValue(settings::SystemProperties::lockScreenPasscodeIsOn,
+ std::to_string(phoneLockEnabled),
+ settings::SettingsScope::Global);
}
sys::MessagePointer PhoneLockHandler::handleUnlockRequest()
{
+ setPhoneLockInputTypeAction(PhoneLockInputTypeAction::Unlock);
+
// Check if phoneLock has not been disabled by setting
if (!phoneLockEnabled) {
- PhoneUnlockAction();
+ phoneUnlockAction();
return sys::msgHandled();
}
-
- if (lock.isState(Lock::LockState::Unlocked)) {
- PhoneUnlockAction();
- }
- else if (lock.isState(Lock::LockState::Blocked)) {
- PhoneInputRequiredAction();
+ if (lock.isState(Lock::LockState::Blocked)) {
+ phoneInputRequiredAction();
}
else if (!lock.isState(Lock::LockState::Unlocked)) {
-
lock.lockState = Lock::LockState::InputRequired;
- PhoneInputRequiredAction();
+ phoneInputRequiredAction();
}
return sys::msgHandled();
@@ 93,42 160,164 @@ namespace locks
sys::MessagePointer PhoneLockHandler::handleLockRequest()
{
lock.lockState = Lock::LockState::InputRequired;
- PhoneLockAction();
+ phoneLockAction();
return sys::msgHandled();
}
+ sys::MessagePointer PhoneLockHandler::handleEnablePhoneLock()
+ {
+ setPhoneLockInputTypeAction(PhoneLockInputTypeAction::Enable);
+
+ lock.lockState = Lock::LockState::NewInputRequired;
+ lock.attemptsLeft = Lock::unlimitedNumOfAttempts;
+
+ phoneInputRequiredAction();
+
+ return sys::msgHandled();
+ }
+
+ sys::MessagePointer PhoneLockHandler::handleDisablePhoneLock()
+ {
+ setPhoneLockInputTypeAction(PhoneLockInputTypeAction::Disable);
+
+ lock.lockState = Lock::LockState::InputRequired;
+ lock.attemptsLeft = Lock::unlimitedNumOfAttempts;
+
+ phoneInputRequiredAction();
+
+ return sys::msgHandled();
+ }
+
+ sys::MessagePointer PhoneLockHandler::handleChangePhoneLock()
+ {
+ setPhoneLockInputTypeAction(PhoneLockInputTypeAction::ConfirmCurrent);
+
+ lock.lockState = Lock::LockState::InputRequired;
+ lock.attemptsLeft = Lock::unlimitedNumOfAttempts;
+
+ phoneInputRequiredAction();
+
+ return sys::msgHandled();
+ }
+
+ sys::MessagePointer PhoneLockHandler::handleSetPhoneLock()
+ {
+ setPhoneLockInputTypeAction(PhoneLockInputTypeAction::Set);
+
+ lock.lockState = Lock::LockState::NewInputRequired;
+ lock.attemptsLeft = Lock::unlimitedNumOfAttempts;
+
+ phoneInputRequiredAction();
+
+ return sys::msgHandled();
+ }
+
+ sys::MessagePointer PhoneLockHandler::handleSkipSetPhoneLock()
+ {
+ setPhoneLockInputTypeAction(PhoneLockInputTypeAction::Set);
+
+ lock.lockState = Lock::LockState::NewInputRequired;
+ lock.attemptsLeft = Lock::unlimitedNumOfAttempts;
+
+ owner->bus.sendMulticast(std::make_shared<locks::SkippedSetPhoneLock>(), sys::BusChannel::PhoneLockChanges);
+ return sys::msgHandled();
+ }
+
+ void PhoneLockHandler::checkNewPhoneLock()
+ {
+ setPhoneLockInputTypeAction(PhoneLockInputTypeAction::Change);
+
+ lock.lockState = Lock::LockState::NewInputRequired;
+ lock.attemptsLeft = Lock::unlimitedNumOfAttempts;
+
+ phoneInputRequiredAction();
+ }
+
sys::MessagePointer PhoneLockHandler::verifyPhoneLockInput(const std::vector<unsigned int> &inputData)
{
+ if (checkPhoneLockInputTypeAction(PhoneLockInputTypeAction::Enable) ||
+ checkPhoneLockInputTypeAction(PhoneLockInputTypeAction::Change) ||
+ checkPhoneLockInputTypeAction(PhoneLockInputTypeAction::Set)) {
+ return verifyPhoneLockChangeInput(inputData);
+ }
+ else {
+ return verifyPhoneUnlockInput(inputData);
+ }
+ }
+
+ sys::MessagePointer PhoneLockHandler::verifyPhoneUnlockInput(const std::vector<unsigned int> &inputData)
+ {
const uint32_t hash = getHash(inputData);
lock.attemptsLeft--;
if (phoneLockHash == hash) {
lock.lockState = Lock::LockState::Unlocked;
lock.attemptsLeft = default_attempts;
- PhoneUnlockAction();
+ resolvePhoneLockAction();
return sys::msgHandled();
}
else if (lock.attemptsLeft > 0) {
- lock.lockState = Lock::LockState::InputInvalidRetryRequired;
+ lock.lockState = Lock::LockState::InputInvalid;
}
else {
lock.lockState = Lock::LockState::Blocked;
}
- PhoneInputRequiredAction();
+ phoneInputRequiredAction();
return sys::msgHandled();
}
+ sys::MessagePointer PhoneLockHandler::verifyPhoneLockChangeInput(const std::vector<unsigned int> &inputData)
+ {
+ if (lock.isState(Lock::LockState::NewInputRequired) || lock.isState(Lock::LockState::NewInputInvalid)) {
+ storedInputData = inputData;
+ lock.lockState = Lock::LockState::NewInputConfirmRequired;
+ }
+ else if (lock.isState(Lock::LockState::NewInputConfirmRequired)) {
+ if (storedInputData == inputData) {
+ resolvePhoneLockAction();
+ return sys::msgHandled();
+ }
+ else {
+ lock.lockState = Lock::LockState::NewInputInvalid;
+ }
+ }
+
+ phoneInputRequiredAction();
+
+ return sys::MessagePointer();
+ }
+
+ void PhoneLockHandler::resolvePhoneLockAction()
+ {
+ switch (phoneLockInputTypeAction) {
+ case PhoneLockInputTypeAction::Unlock:
+ return phoneUnlockAction();
+ case PhoneLockInputTypeAction::Enable:
+ return phoneLockEnableAction();
+ case PhoneLockInputTypeAction::Disable:
+ return phoneLockDisableAction();
+ case PhoneLockInputTypeAction::ConfirmCurrent:
+ return checkNewPhoneLock();
+ case PhoneLockInputTypeAction::Change:
+ return phoneLockChangeAction();
+ case PhoneLockInputTypeAction::Set:
+ return phoneLockSetAction();
+ default:
+ return;
+ }
+ }
+
sys::MessagePointer PhoneLockHandler::handleUnlockCancelRequest()
{
- PhoneUnlockPopupsCloseAction();
+ phoneUnlockPopupsCloseAction();
return sys::msgHandled();
}
bool PhoneLockHandler::isPhoneLocked() const noexcept
{
- return !lock.isState(Lock::LockState::Unlocked);
+ return phoneState == PhoneState::Locked;
}
} // namespace locks
M module-apps/locks/handlers/PhoneLockHandler.hpp => module-apps/locks/handlers/PhoneLockHandler.hpp +42 -8
@@ 4,8 4,10 @@
#pragma once
#include <locks/widgets/Lock.hpp>
-#include <locks/data/LockMessages.hpp>
+#include <locks/data/PhoneLockMessages.hpp>
+#include <locks/data/LockData.hpp>
+#include <service-db/service-db/Settings.hpp>
#include <module-sys/Service/Service.hpp>
namespace locks
@@ 13,22 15,54 @@ namespace locks
class PhoneLockHandler
{
private:
+ enum class PhoneState
+ {
+ Locked,
+ Unlocked,
+ };
+
sys::Service *owner;
Lock lock;
- bool phoneLockEnabled = true;
- unsigned int phoneLockHash = std::numeric_limits<unsigned>::max();
+ bool phoneLockEnabled = true;
+ unsigned int phoneLockHash = std::numeric_limits<unsigned>::max();
+ PhoneState phoneState = PhoneState::Locked;
+ PhoneLockInputTypeAction phoneLockInputTypeAction = PhoneLockInputTypeAction::Unlock;
+ std::shared_ptr<settings::Settings> settings;
+ std::vector<unsigned int> storedInputData;
+
+ void setPhoneLockInputTypeAction(PhoneLockInputTypeAction _phoneLockInputTypeAction);
+ bool checkPhoneLockInputTypeAction(PhoneLockInputTypeAction _phoneLockInputTypeAction);
+
+ void setPhoneLockInSettings();
+ void setPhoneLockAvailabilityInSettings(bool value);
+
+ void phoneLockAction();
+ void phoneUnlockAction();
+ void phoneLockEnableAction();
+ void phoneLockDisableAction();
+ void phoneLockChangeAction();
+ void phoneLockSetAction();
+ void phoneInputRequiredAction();
+ void phoneUnlockPopupsCloseAction();
+ void phoneLockChangeInfoAction();
+
+ void checkNewPhoneLock();
+ void resolvePhoneLockAction();
- void PhoneLockAction();
- void PhoneUnlockAction();
- void PhoneInputRequiredAction();
- void PhoneUnlockPopupsCloseAction();
+ sys::MessagePointer verifyPhoneUnlockInput(const std::vector<unsigned int> &inputData);
+ sys::MessagePointer verifyPhoneLockChangeInput(const std::vector<unsigned int> &inputData);
public:
- explicit PhoneLockHandler(sys::Service *owner);
+ explicit PhoneLockHandler(sys::Service *owner, std::shared_ptr<settings::Settings> settings);
sys::MessagePointer handleLockRequest();
sys::MessagePointer handleUnlockRequest();
sys::MessagePointer handleUnlockCancelRequest();
+ sys::MessagePointer handleEnablePhoneLock();
+ sys::MessagePointer handleDisablePhoneLock();
+ sys::MessagePointer handleChangePhoneLock();
+ sys::MessagePointer handleSetPhoneLock();
+ sys::MessagePointer handleSkipSetPhoneLock();
sys::MessagePointer verifyPhoneLockInput(const std::vector<unsigned int> &inputData);
void enablePhoneLock(bool _phoneLockEnabled);
M module-apps/locks/handlers/PhoneLockSubject.cpp => module-apps/locks/handlers/PhoneLockSubject.cpp +26 -1
@@ 4,7 4,7 @@
#include "PhoneLockSubject.hpp"
#include <service-appmgr/service-appmgr/model/ApplicationManager.hpp>
-#include <locks/data/LockMessages.hpp>
+#include <locks/data/PhoneLockMessages.hpp>
namespace locks
{
@@ 25,6 25,31 @@ namespace locks
owner->bus.sendUnicast(std::make_shared<LockPhone>(), app::manager::ApplicationManager::ServiceName);
}
+ void PhoneLockSubject::enablePhoneLock()
+ {
+ owner->bus.sendUnicast(std::make_shared<EnablePhoneLock>(), app::manager::ApplicationManager::ServiceName);
+ }
+
+ void PhoneLockSubject::disablePhoneLock()
+ {
+ owner->bus.sendUnicast(std::make_shared<DisablePhoneLock>(), app::manager::ApplicationManager::ServiceName);
+ }
+
+ void PhoneLockSubject::changePhoneLock()
+ {
+ owner->bus.sendUnicast(std::make_shared<ChangePhoneLock>(), app::manager::ApplicationManager::ServiceName);
+ }
+
+ void PhoneLockSubject::setPhoneLock()
+ {
+ owner->bus.sendUnicast(std::make_shared<SetPhoneLock>(), app::manager::ApplicationManager::ServiceName);
+ }
+
+ void PhoneLockSubject::skipSetPhoneLock()
+ {
+ owner->bus.sendUnicast(std::make_shared<SkipSetPhoneLock>(), app::manager::ApplicationManager::ServiceName);
+ }
+
void PhoneLockSubject::verifyInput(const std::vector<unsigned int> &inputData)
{
owner->bus.sendUnicast(std::make_shared<UnLockPhoneInput>(inputData),
M module-apps/locks/handlers/PhoneLockSubject.hpp => module-apps/locks/handlers/PhoneLockSubject.hpp +6 -1
@@ 17,7 17,12 @@ namespace locks
void unlock();
void lock();
+ void enablePhoneLock();
+ void disablePhoneLock();
+ void changePhoneLock();
+ void setPhoneLock();
+ void skipSetPhoneLock();
void verifyInput(const std::vector<unsigned int> &inputData);
};
-} // namespace lock
+} // namespace locks
M module-apps/locks/handlers/PinLockHandler.cpp => module-apps/locks/handlers/PinLockHandler.cpp +6 -26
@@ 34,23 34,6 @@ namespace gui
screenLock.setAutoActivate(true);
}
- void PinLockHandler::handleScreenPin(const std::vector<unsigned int> &pin)
- {
- const uint32_t hash = getHash(pin);
- screenLock.attemptsLeft--;
- if (hash == app->getLockPassHash()) {
- screenLock.lockState = gui::Lock::LockState::Unlocked;
- screenLock.attemptsLeft = default_attempts;
- }
- else if (screenLock.attemptsLeft > 0) {
- screenLock.lockState = gui::Lock::LockState::InputInvalidRetryRequired;
- }
- else {
- screenLock.lockState = gui::Lock::LockState::Blocked;
- }
- unlock();
- }
-
void PinLockHandler::handlePasscodeParams(Lock::LockType type,
Lock::LockState state,
app::manager::actions::ActionParamsPtr &&data)
@@ 58,7 41,7 @@ namespace gui
auto passcodeData = static_cast<app::manager::actions::PasscodeParams *>(data.get());
if (simLock.isSim(passcodeData->getSim()) && simLock.isType(type) && simLock.isState(state) &&
simLock.getAttemptsLeft() > passcodeData->getAttempts()) {
- simLock.lockState = Lock::LockState::InputInvalidRetryRequired;
+ simLock.lockState = Lock::LockState::InputInvalid;
}
else {
simLock.lockState = state;
@@ 117,13 100,13 @@ namespace gui
LOG_ERROR("Number of attempts left is equal to zero before decrementation!");
}
if (simLock.attemptsLeft > 0) {
- simLock.lockState = Lock::LockState::InputInvalidRetryRequired;
+ simLock.lockState = Lock::LockState::InputInvalid;
auto onActivatedCallback = [this, simCardLock](Lock::LockType type, const std::vector<unsigned int> &data) {
auto params = std::make_unique<PasscodeParams>(
Store::GSM::get()->selected, simLock.attemptsLeft, PasscodeParams::pinName);
handlePinEnableRequest(std::move(params), simCardLock);
};
- switchToPinLockWindow(Lock::LockState::InputInvalidRetryRequired, onActivatedCallback);
+ switchToPinLockWindow(Lock::LockState::InputInvalid, onActivatedCallback);
}
else {
auto params = std::make_unique<PasscodeParams>(
@@ 143,13 126,13 @@ namespace gui
LOG_ERROR("Number of attempts left is equal to zero before decrementation!");
}
if (simLock.attemptsLeft > 0) {
- simLock.lockState = Lock::LockState::InputInvalidRetryRequired;
+ simLock.lockState = Lock::LockState::InputInvalid;
auto onActivatedCallback = [this](Lock::LockType type, const std::vector<unsigned int> &data) {
auto params = std::make_unique<PasscodeParams>(
Store::GSM::get()->selected, simLock.attemptsLeft, PasscodeParams::pinName);
handlePinChangeRequest(std::move(params));
};
- switchToPinLockWindow(Lock::LockState::InputInvalidRetryRequired, onActivatedCallback);
+ switchToPinLockWindow(Lock::LockState::InputInvalid, onActivatedCallback);
}
else {
auto params = std::make_unique<PasscodeParams>(
@@ 197,7 180,7 @@ namespace gui
std::function<void(Lock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback)
{
auto lock = std::make_unique<gui::Lock>(getStrongestLock());
- if (lock->isState(Lock::LockState::InputInvalidRetryRequired)) {
+ if (lock->isState(Lock::LockState::InputInvalid)) {
getStrongestLock().consumeState();
lock->onActivatedCallback = [this, onLockActivatedCallback](Lock::LockType,
const std::vector<unsigned int> &) {
@@ 242,9 225,6 @@ namespace gui
else if (type == Lock::LockType::SimPuk) {
handlePasscodeChange(passcode);
}
- else if (type == Lock::LockType::Screen) {
- handleScreenPin(passcode);
- }
}
void PinLockHandler::handlePasscodeChange(const std::vector<unsigned int> passcode)
M module-apps/locks/handlers/PinLockHandler.hpp => module-apps/locks/handlers/PinLockHandler.hpp +0 -1
@@ 25,7 25,6 @@ namespace gui
Lock simLock;
bool promptSimLockWindow = true;
- void handleScreenPin(const std::vector<unsigned int> &pin);
void handlePasscode(Lock::LockType type, const std::vector<unsigned int> passcode);
void handlePasscodeChange(const std::vector<unsigned int> passcode);
void handleNewPasscodeUnconfirmed(const std::vector<unsigned int> &passcode,
M module-apps/locks/widgets/Lock.cpp => module-apps/locks/widgets/Lock.cpp +5 -2
@@ 8,12 8,15 @@ namespace locks
{
void Lock::consumeState() noexcept
{
- if (lockState == LockState::InputInvalidRetryRequired) {
+ if (lockState == LockState::InputInvalid) {
lockState = LockState::InputRequired;
}
else if (lockState == LockState::NewInputInvalid) {
lockState = LockState::NewInputRequired;
}
+ else if (lockState == LockState::NewInputConfirmRequired) {
+ lockState = LockState::NewInputRequired;
+ }
}
void Lock::putNextChar(unsigned int c)
@@ 47,4 50,4 @@ namespace locks
onActivatedCallback(lockType, inputValue);
clearAttempt();
}
-} // namespace lock
+} // namespace locks
M module-apps/locks/widgets/Lock.hpp => module-apps/locks/widgets/Lock.hpp +2 -5
@@ 12,7 12,6 @@
namespace gui
{
class PinLockHandler;
- class ChangePasscodeLockHandler;
} // namespace gui
namespace locks
@@ 33,10 32,9 @@ namespace locks
{
Unlocked,
InputRequired,
- InputInvalidRetryRequired,
+ InputInvalid,
Blocked,
NewInputRequired,
- NewInputInvalidRetryRequired,
NewInputConfirmRequired,
NewInputInvalid,
ErrorOccurred
@@ 101,7 99,7 @@ namespace locks
void popChar();
/// clear all characters passed to the Lock
void clearAttempt() noexcept;
- /// consumes LockState::PasscodeInvalidRetryRequired state and LockState::NewPasscodeInvalid)
+ /// consumes LockState::InputInvalid state and LockState::NewInputInvalid
void consumeState() noexcept;
/// calls
void activate();
@@ 143,7 141,6 @@ namespace locks
friend class PhoneLockHandler;
friend class gui::PinLockHandler;
- friend class gui::ChangePasscodeLockHandler;
};
} // namespace lock
M module-apps/locks/widgets/PhoneLockBox.cpp => module-apps/locks/widgets/PhoneLockBox.cpp +81 -11
@@ 14,9 14,67 @@ namespace gui
PhoneLockBaseBox::buildLockBox(pinSize);
}
+ top_bar::Configuration PhoneLockBox::configureTopBarLocked()
+ {
+ top_bar::Configuration appConfiguration;
+ appConfiguration.disable(top_bar::Indicator::Time);
+ appConfiguration.enable(top_bar::Indicator::Lock);
+
+ return appConfiguration;
+ }
+
+ top_bar::Configuration PhoneLockBox::configureTopBarUnLocked()
+ {
+ top_bar::Configuration appConfiguration;
+ appConfiguration.enable(top_bar::Indicator::Time);
+ appConfiguration.disable(top_bar::Indicator::Lock);
+
+ return appConfiguration;
+ }
+
+ void PhoneLockBox::applyLockActionText(locks::PhoneLockInputTypeAction phoneLockInputTypeAction)
+ {
+ switch (phoneLockInputTypeAction) {
+ case locks::PhoneLockInputTypeAction::Unlock:
+ LockWindow->setTitleBar(false, false);
+ LockWindow->configureTopBar(configureTopBarLocked());
+ textForInputRequired = "phone_lock_unlock";
+ textForInvalidInput = "phone_lock_unlock_invalid";
+ leftBottomBarState = false;
+ break;
+ case locks::PhoneLockInputTypeAction::Enable:
+ case locks::PhoneLockInputTypeAction::Disable:
+ case locks::PhoneLockInputTypeAction::ConfirmCurrent:
+ case locks::PhoneLockInputTypeAction::Change:
+ LockWindow->setTitleBar(true, false);
+ LockWindow->setText("phone_lock_configure", LockWindow::TextType::Title);
+ LockWindow->configureTopBar(configureTopBarUnLocked());
+
+ textForInputRequired = "phone_lock_current";
+ textForInvalidInput = "phone_lock_invalid";
+ textForProvideNewInput = "phone_lock_enter_new";
+ textForConfirmNewInput = "phone_lock_confirm_new";
+ leftBottomBarState = false;
+ break;
+ case locks::PhoneLockInputTypeAction::Set:
+ LockWindow->setTitleBar(true, false);
+ LockWindow->setText("phone_lock_configure", LockWindow::TextType::Title);
+ LockWindow->configureTopBar(configureTopBarUnLocked());
+
+ textForInputRequired = "phone_lock_current";
+ textForInvalidInput = "phone_lock_invalid_retry";
+ textForProvideNewInput = "phone_lock_set";
+ textForConfirmNewInput = "phone_lock_confirm";
+ leftBottomBarState = true;
+ break;
+ default:
+ break;
+ }
+ }
+
void PhoneLockBox::setVisibleStateBlocked()
{
- LockWindow->setText("app_desktop_screen_blocked_info", LockWindow::TextType::Primary);
+ LockWindow->setText("phone_lock_blocked", LockWindow::TextType::Primary);
LockWindow->setImagesVisible(false, true);
LockWindow->setBottomBarWidgetsActive(false, true, false);
}
@@ 24,34 82,46 @@ namespace gui
void PhoneLockBox::setVisibleStateInputRequired(InputActionType type)
{
LockWindow->pinLabelsBox->setVisible(true);
- LockWindow->setText("app_desktop_screen_enter_passcode_to_unlock", LockWindow::TextType::Primary, true);
+
+ switch (type) {
+ case LockBox::InputActionType::ProvideInput: {
+ LockWindow->setText(textForInputRequired, PinLockBaseWindow::TextType::Primary);
+ break;
+ }
+ case LockBox::InputActionType::ProvideNewInput: {
+ LockWindow->setText(textForProvideNewInput, PinLockBaseWindow::TextType::Primary);
+ break;
+ }
+ case LockBox::InputActionType::ConfirmNewInput:
+ LockWindow->setText(textForConfirmNewInput, PinLockBaseWindow::TextType::Primary);
+ break;
+ }
+
LockWindow->setImagesVisible(true, false);
- LockWindow->setBottomBarWidgetsActive(false, false, true);
+ LockWindow->setBottomBarWidgetsActive(leftBottomBarState, false, true);
}
void PhoneLockBox::setVisibleStateInputInvalid(InputErrorType type, unsigned int value)
{
switch (type) {
case LockBox::InputErrorType::InvalidInput:
- LockWindow->setTitleBar(false, false);
if (value == 1) {
- LockWindow->setText(
- "app_desktop_screen_wrong_passcode_last_attempt", LockWindow::TextType::Primary, true);
- LockWindow->setText("app_desktop_screen_wrong_passcode_last_attempt_warning",
+ LockWindow->setText("phone_lock_unlock_last_attempt", LockWindow::TextType::Primary);
+ LockWindow->setText("phone_lock_unlock_last_attempt_warning",
LockWindow::TextType::Secondary,
- true,
{{LockWindow->getToken(LockWindow::Token::Mins), timeToUnlock}});
}
else {
- LockWindow->setText("app_desktop_screen_wrong_passcode",
+ LockWindow->setText(textForInvalidInput,
LockWindow::TextType::Primary,
- true,
{{LockWindow->getToken(LockWindow::Token::Attempts), static_cast<int>(value)}});
}
break;
case LockBox::InputErrorType::NewInputConfirmFailed:
- LOG_ERROR("No use case for NewPasscodeConfirmFailed");
+ LockWindow->setText(textForInvalidInput,
+ LockWindow::TextType::Primary,
+ {{LockWindow->getToken(LockWindow::Token::Attempts), static_cast<int>(value)}});
break;
case LockBox::InputErrorType::UnhandledError:
LOG_ERROR("No use case for UnhandledError");
M module-apps/locks/widgets/PhoneLockBox.hpp => module-apps/locks/widgets/PhoneLockBox.hpp +16 -2
@@ 3,6 3,7 @@
#pragma once
+#include "locks/data/LockData.hpp"
#include "locks/windows/PinLockBaseWindow.hpp"
#include "PhoneLockBaseBox.hpp"
@@ 11,16 12,29 @@ namespace gui
class PhoneLockBox : public PhoneLockBaseBox
{
public:
- explicit PhoneLockBox(PinLockBaseWindow *LockBaseWindow)
+ explicit PhoneLockBox(
+ PinLockBaseWindow *LockBaseWindow,
+ locks::PhoneLockInputTypeAction phoneLockInputTypeAction = locks::PhoneLockInputTypeAction::Unlock)
: PhoneLockBaseBox(LockBaseWindow), LockWindow(LockBaseWindow)
- {}
+ {
+ applyLockActionText(phoneLockInputTypeAction);
+ }
private:
void buildLockBox(unsigned int pinSize) final;
void setVisibleStateBlocked() final;
void setVisibleStateInputRequired(InputActionType type) final;
void setVisibleStateInputInvalid(InputErrorType type, unsigned int value) final;
+ void applyLockActionText(locks::PhoneLockInputTypeAction phoneLockInputTypeAction);
+
+ [[nodiscard]] top_bar::Configuration configureTopBarLocked();
+ [[nodiscard]] top_bar::Configuration configureTopBarUnLocked();
PinLockBaseWindow *LockWindow;
+ std::string textForInputRequired;
+ std::string textForInvalidInput;
+ std::string textForProvideNewInput;
+ std::string textForConfirmNewInput;
+ bool leftBottomBarState = false;
};
} // namespace gui
M module-apps/locks/widgets/PukLockBox.cpp => module-apps/locks/widgets/PukLockBox.cpp +5 -7
@@ 48,7 48,7 @@ namespace gui
LockWindow->pinLabelsBox->setVisible(true);
switch (type) {
case LockBox::InputActionType::ProvideInput: {
- LockWindow->setText("app_desktop_sim_setup_enter_puk", PinLockBaseWindow::TextType::Primary, true);
+ LockWindow->setText("app_desktop_sim_setup_enter_puk", PinLockBaseWindow::TextType::Primary);
break;
}
case LockBox::InputActionType::ProvideNewInput: {
@@ 71,15 71,13 @@ namespace gui
LockWindow->setText(
"app_desktop_sim_setup_wrong_puk",
PinLockBaseWindow::TextType::Primary,
- true,
{{LockWindow->getToken(PinLockBaseWindow::Token::Attempts), static_cast<int>(value)}});
}
else {
- LockWindow->setText(
- "app_desktop_sim_setup_wrong_puk_last_attempt", PinLockBaseWindow::TextType::Primary, true);
+ LockWindow->setText("app_desktop_sim_setup_wrong_puk_last_attempt",
+ PinLockBaseWindow::TextType::Primary);
LockWindow->setText("app_desktop_sim_setup_wrong_puk_last_attempt_warning",
- PinLockBaseWindow::TextType::Secondary,
- true);
+ PinLockBaseWindow::TextType::Secondary);
}
break;
case LockBox::InputErrorType::NewInputConfirmFailed: {
@@ 95,7 93,7 @@ namespace gui
}
void PukLockBox::setVisibleStateBlocked()
{
- LockWindow->setText("app_desktop_sim_puk_blocked", PinLockBaseWindow::TextType::Primary, true);
+ LockWindow->setText("app_desktop_sim_puk_blocked", PinLockBaseWindow::TextType::Primary);
LockWindow->setImagesVisible(false, true);
LockWindow->setBottomBarWidgetsActive(true, false, false);
}
M module-apps/locks/widgets/SimLockBox.cpp => module-apps/locks/widgets/SimLockBox.cpp +2 -5
@@ 53,7 53,6 @@ namespace gui
LockWindow->setText(
"app_desktop_sim_enter_pin_unlock",
PinLockBaseWindow::TextType::Primary,
- true,
{{LockWindow->getToken(PinLockBaseWindow::Token::PinType), LockWindow->lock->getLockName()}});
break;
}
@@ 73,14 72,13 @@ namespace gui
switch (type) {
case LockBox::InputErrorType::InvalidInput:
if (value == 1) {
- LockWindow->setText(
- "app_desktop_sim_setup_wrong_pin_last_attempt", PinLockBaseWindow::TextType::Primary, true);
+ LockWindow->setText("app_desktop_sim_setup_wrong_pin_last_attempt",
+ PinLockBaseWindow::TextType::Primary);
}
else {
LockWindow->setText(
"app_desktop_sim_setup_wrong_pin",
PinLockBaseWindow::TextType::Primary,
- true,
{{LockWindow->getToken(PinLockBaseWindow::Token::Attempts), static_cast<int>(value)}});
}
break;
@@ 90,7 88,6 @@ namespace gui
case LockBox::InputErrorType::UnhandledError: {
LockWindow->setText("app_desktop_sim_cme_error",
PinLockBaseWindow::TextType::Primary,
- true,
{{LockWindow->getToken(PinLockBaseWindow::Token::CmeCode), static_cast<int>(value)}});
break;
}
M module-apps/locks/windows/LockWindow.cpp => module-apps/locks/windows/LockWindow.cpp +23 -31
@@ 31,7 31,7 @@ namespace gui
secondaryText->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Top));
}
- void LockWindow::buildPinLabels(std::function<Rect *()> itemBuilder,
+ void LockWindow::buildPinLabels(const std::function<Rect *()> &itemBuilder,
unsigned int pinSize,
unsigned int offsetX,
unsigned int offsetY,
@@ 70,50 70,42 @@ namespace gui
bottomBar->setActive(BottomBar::Side::RIGHT, right);
}
- void LockWindow::setText(const std::string &value,
- TextType type,
- bool isReach,
- text::RichTextParser::TokenMap tokens)
+ void LockWindow::setText(const std::string &value, TextType type, text::RichTextParser::TokenMap tokens)
{
- auto text = getText(type);
- text->setVisible(true);
- if (isReach) {
- TextFormat format(FontManager::getInstance().getFont(style::window::font::medium));
- text::RichTextParser rtParser;
- auto parsedText = rtParser.parse(utils::translate(value), &format, std::move(tokens));
- text->setText(std::move(parsedText));
+ switch (type) {
+ case TextType::Title: {
+ title->setVisible(true);
+ if (!tokens.empty()) {
+ TextFormat format(FontManager::getInstance().getFont(style::window::font::medium));
+ title->setText(
+ text::RichTextParser().parse(utils::translate(value), &format, std::move(tokens))->getText());
+ }
+ else {
+ title->setText(utils::translate(value));
+ }
+ break;
}
- else {
- text->setText(utils::translate(value));
+ case TextType::Primary:
+ primaryText->setVisible(true);
+ primaryText->setRichText(utils::translate(value), std::move(tokens));
+ break;
+ case TextType::Secondary:
+ secondaryText->setVisible(true);
+ secondaryText->setRichText(utils::translate(value), std::move(tokens));
+ break;
}
}
void LockWindow::setTitleBar(bool isVisible)
{
title->setVisible(isVisible);
- if (isVisible) {
- title->setEdges(RectangleEdge::Bottom);
- }
- else {
- title->clear();
- title->setEdges(RectangleEdge::None);
- }
}
void LockWindow::buildBottomBar()
{
+ bottomBar->setText(BottomBar::Side::LEFT, utils::translate(style::strings::common::skip));
bottomBar->setText(BottomBar::Side::CENTER, utils::translate(style::strings::common::confirm));
bottomBar->setText(BottomBar::Side::RIGHT, utils::translate(style::strings::common::back));
}
- auto LockWindow::getText(TextType type) noexcept -> gui::Text *
- {
- if (type == TextType::Title) {
- return title;
- }
- else if (type == TextType::Primary) {
- return primaryText;
- }
- return secondaryText;
- }
} // namespace gui
M module-apps/locks/windows/LockWindow.hpp => module-apps/locks/windows/LockWindow.hpp +1 -6
@@ 37,7 37,7 @@ namespace gui
{}
void build();
void buildInfoTexts();
- void buildPinLabels(std::function<Rect *()> itemBuilder,
+ void buildPinLabels(const std::function<Rect *()> &itemBuilder,
unsigned int pinSize,
unsigned int offsetX,
unsigned int offsetY,
@@ 46,7 46,6 @@ namespace gui
void setBottomBarWidgetsActive(bool left, bool center, bool right);
void setText(const std::string &value,
TextType type,
- bool isReach = false,
text::RichTextParser::TokenMap tokens = text::RichTextParser::TokenMap{});
void setTitleBar(bool isVisible);
@@ 54,13 53,9 @@ namespace gui
gui::HBox *pinLabelsBox = nullptr;
gui::Text *primaryText = nullptr;
gui::Text *secondaryText = nullptr;
- gui::Text *title = nullptr;
protected:
virtual void buildBottomBar();
virtual void buildTitleBar() = 0;
-
- private:
- [[nodiscard]] auto getText(TextType type) noexcept -> gui::Text *;
};
} // namespace gui
M module-apps/locks/windows/PinLockBaseWindow.cpp => module-apps/locks/windows/PinLockBaseWindow.cpp +7 -10
@@ 36,12 36,17 @@ namespace gui
}
return std::string{};
}
+
top_bar::Configuration PinLockBaseWindow::configureTopBar(top_bar::Configuration appConfiguration)
{
- appConfiguration.enable(top_bar::Indicator::Lock);
- appConfiguration.disable(top_bar::Indicator::Time);
+ appConfiguration.disable(top_bar::Indicator::NetworkAccessTechnology);
+ appConfiguration.enable(top_bar::Indicator::PhoneMode);
+ appConfiguration.enable(top_bar::Indicator::Battery);
+ appConfiguration.enable(top_bar::Indicator::Signal);
+ appConfiguration.enable(top_bar::Indicator::SimCard);
return appConfiguration;
}
+
void PinLockBaseWindow::restore() noexcept
{
LockWindow::restore();
@@ 88,14 93,6 @@ namespace gui
iceText->setFont(style::window::font::verysmall);
iceText->setText(utils::translate("app_desktop_emergency"));
iceBox->addWidget(iceText);
-
- title = new gui::Text(this, title::x, title::y, title::w, title::h);
- title->setFilled(false);
- title->setBorderColor(gui::ColorFullBlack);
- title->setFont(style::header::font::title);
- title->setAlignment(gui::Alignment(gui::Alignment::Horizontal::Center, gui::Alignment::Vertical::Center));
- title->setVisible(false);
- title->setPenWidth(2);
}
} // namespace gui
M module-apps/locks/windows/PinLockWindow.cpp => module-apps/locks/windows/PinLockWindow.cpp +2 -4
@@ 50,7 50,7 @@ namespace gui
if (lock->isState(Lock::LockState::InputRequired)) {
lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideInput);
}
- else if (lock->isState(Lock::LockState::InputInvalidRetryRequired)) {
+ else if (lock->isState(Lock::LockState::InputInvalid)) {
lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::InvalidInput, lock->getAttemptsLeft());
}
else if (lock->isState(Lock::LockState::Blocked)) {
@@ 105,7 105,7 @@ namespace gui
if (usesNumericKeys()) {
lock->clearAttempt();
}
- else if (lock->isState(Lock::LockState::InputInvalidRetryRequired)) {
+ else if (lock->isState(Lock::LockState::InputInvalid)) {
lock->consumeState();
}
application->returnToPreviousWindow();
@@ 147,7 147,6 @@ namespace gui
setTitleBar(true, true);
setText("app_desktop_header_sim_setup",
TextType::Title,
- true,
{{getToken(Token::Sim), utils::enumToString(lock->getSim())}});
}
else if (lockType == Lock::LockType::SimPin) {
@@ 155,7 154,6 @@ namespace gui
setTitleBar(true, false);
setText("app_desktop_header_sim_setup",
TextType::Title,
- true,
{{getToken(Token::Sim), utils::enumToString(lock->getSim())}});
}
assert(lockBox != nullptr);
M => +4 -2
@@ 25,7 25,8 @@ target_sources( ${PROJECT_NAME}
"${CMAKE_CURRENT_LIST_DIR}/presenter/PowerOffPresenter.cpp"
"${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockedInfoWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockedWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneUnLockWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockInputWindow.cpp"
"${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockChangeInfoWindow.cpp"
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/Popups.hpp"
@@ 40,5 41,6 @@ target_sources( ${PROJECT_NAME}
"${CMAKE_CURRENT_LIST_DIR}/data/PopupData.hpp"
"${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockedInfoWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockedWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneUnLockWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockInputWindow.hpp"
"${CMAKE_CURRENT_LIST_DIR}/lock-popups/PhoneLockChangeInfoWindow.hpp"
)
M => +4 -2
@@ 20,8 20,10 @@ namespace gui::popup
return gui::popup::window::tethering_phonemode_change_window;
case ID::PhoneLock:
return gui::popup::window::phone_lock_window;
case ID::InputLock:
return gui::popup::window::input_lock_window;
case ID::PhoneLockInput:
return gui::popup::window::phone_lock_input_window;
case ID::PhoneLockChangeInfo:
return gui::popup::window::phone_lock_change_info_window;
}
return {};
}
M => +4 -2
@@ 17,7 17,8 @@ namespace gui
Tethering,
TetheringPhoneModeChangeProhibited,
PhoneLock,
InputLock
PhoneLockInput,
PhoneLockChangeInfo,
};
namespace window
@@ 29,7 30,8 @@ namespace gui
inline constexpr auto tethering_phonemode_change_window = "TetheringPhoneModeChangeProhibitedPopup";
inline constexpr auto phone_lock_window = "PhoneLockPopup";
inline constexpr auto phone_lock_info_window = "PhoneLockInfoPopup";
inline constexpr auto input_lock_window = "InputLockPopup";
inline constexpr auto phone_lock_input_window = "PhoneLockInputPopup";
inline constexpr auto phone_lock_change_info_window = "PhoneLockChangeInfoPopup";
inline constexpr auto power_off_window = "PowerOffPopup";
} // namespace window
M => +11 -2
@@ 9,6 9,7 @@
#include <module-sys/PhoneModes/Common.hpp>
#include <module-audio/Audio/AudioCommon.hpp>
#include <locks/widgets/Lock.hpp>
#include <locks/data/LockData.hpp>
namespace gui
{
@@ 31,8 32,10 @@ namespace gui
class PhoneUnlockInputRequestParams : public PopupRequestParams
{
public:
PhoneUnlockInputRequestParams(gui::popup::ID popupId, locks::Lock lock)
: PopupRequestParams{popupId}, lock{std::move(lock)}
PhoneUnlockInputRequestParams(gui::popup::ID popupId,
locks::Lock lock,
locks::PhoneLockInputTypeAction phoneLockInputTypeAction)
: PopupRequestParams{popupId}, lock{std::move(lock)}, phoneLockInputTypeAction(phoneLockInputTypeAction)
{}
[[nodiscard]] auto getLock() const noexcept
@@ 40,8 43,14 @@ namespace gui
return lock;
}
[[nodiscard]] auto getPhoneLockInputTypeAction() const noexcept
{
return phoneLockInputTypeAction;
}
private:
locks::Lock lock;
locks::PhoneLockInputTypeAction phoneLockInputTypeAction;
};
class PhoneModePopupRequestParams : public PopupRequestParams
A => +63 -0
@@ 0,0 1,63 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "PhoneLockChangeInfoWindow.hpp"
#include <locks/data/LockStyle.hpp>
#include <locks/data/LockData.hpp>
#include <i18n/i18n.hpp>
using namespace gui;
PhoneLockChangeInfoWindow::PhoneLockChangeInfoWindow(app::Application *app, const std::string &name)
: WindowWithTimer(app, name)
{
buildInterface();
}
top_bar::Configuration PhoneLockChangeInfoWindow::configureTopBar(top_bar::Configuration appConfiguration)
{
appConfiguration.enable(top_bar::Indicator::NetworkAccessTechnology);
appConfiguration.enable(top_bar::Indicator::Time);
appConfiguration.enable(top_bar::Indicator::PhoneMode);
appConfiguration.enable(top_bar::Indicator::Battery);
appConfiguration.enable(top_bar::Indicator::Signal);
appConfiguration.enable(top_bar::Indicator::SimCard);
return appConfiguration;
}
void PhoneLockChangeInfoWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
WindowWithTimer::onBeforeShow(mode, data);
if (auto infoData = dynamic_cast<locks::LockData *>(data)) {
switch (infoData->getPhoneLockInputTypeAction()) {
case locks::PhoneLockInputTypeAction::Disable:
infoText->setRichText(utils::translate("phone_lock_disabled"));
break;
case locks::PhoneLockInputTypeAction::Enable:
case locks::PhoneLockInputTypeAction::Change:
infoText->setRichText(utils::translate("phone_lock_changed_successfully"));
break;
default:
break;
}
}
}
void PhoneLockChangeInfoWindow::buildInterface()
{
namespace lock_style = style::window::pin_lock;
AppWindow::buildInterface();
setTitle(utils::translate("phone_lock_configure"));
infoImage = new gui::Image(this, lock_style::image::x, lock_style::image::y, 0, 0, "success_icon_W_G");
infoText = new Text(this,
lock_style::primary_text::x,
lock_style::primary_text::y,
lock_style::primary_text::w,
lock_style::primary_text::h);
infoText->setAlignment(Alignment::Horizontal::Center);
}
A => +24 -0
@@ 0,0 1,24 @@
// 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 <popups/WindowWithTimer.hpp>
#include <Text.hpp>
#include <gui/widgets/Image.hpp>
namespace gui
{
class PhoneLockChangeInfoWindow : public WindowWithTimer
{
gui::Image *infoImage = nullptr;
gui::Text *infoText = nullptr;
public:
PhoneLockChangeInfoWindow(app::Application *app, const std::string &name);
void buildInterface() override;
void onBeforeShow(ShowMode mode, SwitchData *data) override;
top_bar::Configuration configureTopBar(top_bar::Configuration appConfiguration) override;
};
} /* namespace gui */
R => +45 -35
@@ 1,7 1,7 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "PhoneUnLockWindow.hpp"
#include "PhoneLockInputWindow.hpp"
#include <service-appmgr/Controller.hpp>
#include <locks/data/LockData.hpp>
@@ 10,87 10,86 @@
namespace gui
{
PhoneUnlockWindow::PhoneUnlockWindow(app::Application *app, const std::string &window_name)
PhoneLockInputWindow::PhoneLockInputWindow(app::Application *app, const std::string &window_name)
: PinLockBaseWindow(app, window_name)
{
buildInterface();
}
void PhoneUnlockWindow::rebuild()
void PhoneLockInputWindow::rebuild()
{
destroyInterface();
buildInterface();
}
void PhoneUnlockWindow::buildInterface()
void PhoneLockInputWindow::buildInterface()
{
AppWindow::buildInterface();
LockWindow::build();
}
void PhoneUnlockWindow::destroyInterface()
void PhoneLockInputWindow::destroyInterface()
{
erase();
}
void PhoneUnlockWindow::setVisibleState()
void PhoneLockInputWindow::setVisibleState()
{
restore();
if (lock->isState(locks::Lock::LockState::InputRequired)) {
lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideInput);
}
else if (lock->isState(locks::Lock::LockState::InputInvalidRetryRequired)) {
else if (lock->isState(locks::Lock::LockState::InputInvalid)) {
lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::InvalidInput, lock->getAttemptsLeft());
}
else if (lock->isState(locks::Lock::LockState::Blocked)) {
lockBox->setVisibleStateBlocked();
}
else if (lock->isState(locks::Lock::LockState::NewInputRequired)) {
lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ProvideNewInput);
}
else if (lock->isState(locks::Lock::LockState::NewInputConfirmRequired)) {
lockBox->setVisibleStateInputRequired(LockBox::InputActionType::ConfirmNewInput);
}
else if (lock->isState(locks::Lock::LockState::NewInputInvalid)) {
lockBox->setVisibleStateInputInvalid(LockBox::InputErrorType::NewInputConfirmFailed,
lock->getAttemptsLeft());
}
}
top_bar::Configuration PhoneUnlockWindow::configureTopBar(top_bar::Configuration appConfiguration)
{
appConfiguration.disable(top_bar::Indicator::NetworkAccessTechnology);
appConfiguration.disable(top_bar::Indicator::Time);
appConfiguration.enable(top_bar::Indicator::PhoneMode);
appConfiguration.enable(top_bar::Indicator::Lock);
appConfiguration.enable(top_bar::Indicator::Battery);
appConfiguration.enable(top_bar::Indicator::Signal);
appConfiguration.enable(top_bar::Indicator::SimCard);
return appConfiguration;
}
void PhoneUnlockWindow::onBeforeShow(ShowMode mode, SwitchData *data)
void PhoneLockInputWindow::onBeforeShow(ShowMode mode, SwitchData *data)
{
if (auto lockData = dynamic_cast<locks::LockData *>(data)) {
rebuild();
lock = std::make_unique<locks::Lock>(lockData->getLock());
lockBox = std::make_unique<PhoneLockBox>(this);
lockBox->buildLockBox(lock->getMaxInputSize());
setVisibleState();
lock = std::make_unique<locks::Lock>(lockData->getLock());
phoneLockInputTypeAction = lockData->getPhoneLockInputTypeAction();
}
// Lock need to exist in that window flow
assert(lock);
rebuild();
lockBox = std::make_unique<PhoneLockBox>(this, phoneLockInputTypeAction);
lockBox->buildLockBox(lock->getMaxInputSize());
setVisibleState();
}
bool PhoneUnlockWindow::onInput(const InputEvent &inputEvent)
bool PhoneLockInputWindow::onInput(const InputEvent &inputEvent)
{
if (!inputEvent.isShortRelease()) {
return AppWindow::onInput(inputEvent);
}
else if (inputEvent.is(KeyCode::KEY_RF) && bottomBar->isActive(BottomBar::Side::RIGHT)) {
if (usesNumericKeys()) {
if (isInInputState()) {
lock->clearAttempt();
}
else if (lock->isState(locks::Lock::LockState::InputInvalidRetryRequired)) {
else if (lock->isState(locks::Lock::LockState::InputInvalid)) {
lock->consumeState();
}
application->returnToPreviousWindow();
return true;
}
else if (inputEvent.is(KeyCode::KEY_PND)) {
if (usesNumericKeys()) {
if (isInInputState()) {
lock->popChar();
lockBox->popChar(lock->getCharCount());
bottomBar->setActive(BottomBar::Side::CENTER, lock->canVerify());
@@ 99,13 98,15 @@ namespace gui
}
else if (inputEvent.isDigit()) {
if (usesNumericKeys() && lock->canPut()) {
if (isInInputState() && lock->canPut()) {
lockBox->putChar(lock->getCharCount());
lock->putNextChar(inputEvent.numericValue());
if (lock->canVerify()) {
application->verifyPhoneLockInput(lock->getInput());
application->getPhoneLockSubject().verifyInput(lock->getInput());
lock->consumeState();
lock->clearAttempt();
}
return true;
@@ 123,13 124,22 @@ namespace gui
}
return true;
}
else if (inputEvent.is(KeyCode::KEY_LF) && bottomBar->isActive(BottomBar::Side::LEFT)) {
application->getPhoneLockSubject().skipSetPhoneLock();
lock->consumeState();
lock->clearAttempt();
return true;
}
// check if any of the lower inheritance onInput methods catch the event
return AppWindow::onInput(inputEvent);
}
auto PhoneUnlockWindow::usesNumericKeys() const noexcept -> bool
auto PhoneLockInputWindow::isInInputState() const noexcept -> bool
{
return lock && (lock->isState(locks::Lock::LockState::InputRequired));
return lock && (lock->isState(locks::Lock::LockState::InputRequired) ||
lock->isState(locks::Lock::LockState::NewInputRequired) ||
lock->isState(locks::Lock::LockState::NewInputConfirmRequired));
}
} /* namespace gui */
R => +6 -5
@@ 3,28 3,29 @@
#pragma once
#include <locks/data/LockData.hpp>
#include <locks/widgets/Lock.hpp>
#include <locks/widgets/LockBox.hpp>
#include <locks/windows/PinLockBaseWindow.hpp>
namespace gui
{
class PhoneUnlockWindow : public PinLockBaseWindow
class PhoneLockInputWindow : public PinLockBaseWindow
{
std::unique_ptr<LockBox> lockBox = nullptr;
std::unique_ptr<LockBox> lockBox = nullptr;
locks::PhoneLockInputTypeAction phoneLockInputTypeAction = locks::PhoneLockInputTypeAction::Unlock;
void setVisibleState();
[[nodiscard]] auto usesNumericKeys() const noexcept -> bool;
[[nodiscard]] auto isInInputState() const noexcept -> bool;
public:
PhoneUnlockWindow(app::Application *app, const std::string &window_name);
PhoneLockInputWindow(app::Application *app, const std::string &window_name);
void onBeforeShow(ShowMode mode, SwitchData *data) override;
bool onInput(const InputEvent &inputEvent) override;
void rebuild() override;
void buildInterface() override;
void destroyInterface() override;
top_bar::Configuration configureTopBar(top_bar::Configuration appConfiguration) override;
};
} /* namespace gui */
M => +1 -1
@@ 111,7 111,7 @@ namespace gui
// if interval between enter and pnd keys is less than time defined for unlocking
// display pin lock screen or simply refresh current window to update labels
application->handlePhoneUnLock();
application->getPhoneLockSubject().unlock();
return true;
}
else if (lockingTimer.storeEnter(inputEvent)) {
M module-apps/windows/AppWindow.cpp => module-apps/windows/AppWindow.cpp +1 -1
@@ 160,7 160,7 @@ namespace gui
if (inputEvent.isLongRelease(gui::KeyCode::KEY_PND)) {
LOG_INFO("Locking phone");
- application->handlePhoneLock();
+ application->getPhoneLockSubject().lock();
}
if ((inputEvent.isShortRelease())) {
M module-gui/gui/widgets/Text.cpp => module-gui/gui/widgets/Text.cpp +4 -4
@@ 155,15 155,15 @@ namespace gui
drawLines();
}
- void Text::setRichText(const UTF8 &text)
+ void Text::setRichText(const UTF8 &text, text::RichTextParser::TokenMap &&tokenMap)
{
setText("");
- addRichText(text);
+ addRichText(text, std::move(tokenMap));
}
- void Text::addRichText(const UTF8 &text)
+ void Text::addRichText(const UTF8 &text, text::RichTextParser::TokenMap &&tokenMap)
{
- auto tmp_document = text::RichTextParser().parse(text, &format);
+ auto tmp_document = text::RichTextParser().parse(text, &format, std::move(tokenMap));
if (!tmp_document || tmp_document->isEmpty()) {
M module-gui/gui/widgets/Text.hpp => module-gui/gui/widgets/Text.hpp +3 -2
@@ 22,6 22,7 @@
#include "TextLine.hpp"
#include "Translator.hpp"
#include "TextLineCursor.hpp"
+#include "RichTextParser.hpp"
namespace gui
{
@@ 146,9 147,9 @@ namespace gui
/// @defgroup richtext can be virtualized by parametrized RichTextParser virtual api ( as second param )
/// @{
/// set rich text with default RichTextParser - please see RichTextParser documentation on how to use format
- void setRichText(const UTF8 &text);
+ void setRichText(const UTF8 &text, text::RichTextParser::TokenMap &&tokens = text::RichTextParser::TokenMap{});
/// add rich text with default RichTextParser - please see RichTextParser documentation on how to use format
- void addRichText(const UTF8 &text);
+ void addRichText(const UTF8 &text, text::RichTextParser::TokenMap &&tokens = text::RichTextParser::TokenMap{});
/// @}
virtual void clear();
bool isEmpty();
M module-services/service-appmgr/model/ApplicationManager.cpp => module-services/service-appmgr/model/ApplicationManager.cpp +34 -4
@@ 25,6 25,7 @@
#include <service-gui/ServiceGUI.hpp>
#include <service-eink/ServiceEink.hpp>
#include <service-desktop/DesktopMessages.hpp>
+#include <service-desktop/Constants.hpp>
#include <service-appmgr/StartupType.hpp>
#include <module-services/service-audio/service-audio/AudioMessage.hpp>
@@ 134,9 135,9 @@ namespace app::manager
: Service{serviceName, {}, ApplicationManagerStackDepth},
ApplicationManagerBase(std::move(launchers)), rootApplicationName{_rootApplicationName},
actionsRegistry{[this](ActionEntry &action) { return handleAction(action); }}, notificationProvider(this),
- autoLockEnabled(false), settings(std::make_unique<settings::Settings>(this)),
+ autoLockEnabled(false), settings(std::make_shared<settings::Settings>(this)),
phoneModeObserver(std::make_unique<sys::phone_modes::Observer>()),
- phoneLockHandler(locks::PhoneLockHandler(this))
+ phoneLockHandler(locks::PhoneLockHandler(this, settings))
{
autoLockTimer = sys::TimerFactory::createSingleShotTimer(
this, timerBlock, sys::timer::InfiniteTimeout, [this](sys::Timer &) { onPhoneLocked(); });
@@ 420,6 421,7 @@ namespace app::manager
handleDBResponse(response);
return sys::msgHandled();
});
+
connect(typeid(locks::LockPhone),
[&](sys::Message *request) -> sys::MessagePointer { return phoneLockHandler.handleLockRequest(); });
connect(typeid(locks::UnlockPhone),
@@ 428,10 430,25 @@ namespace app::manager
return phoneLockHandler.handleUnlockCancelRequest();
});
connect(typeid(locks::UnLockPhoneInput), [&](sys::Message *request) -> sys::MessagePointer {
- auto msg = static_cast<locks::UnLockPhoneInput *>(request);
- return phoneLockHandler.verifyPhoneLockInput(msg->getInputData());
+ auto data = dynamic_cast<locks::UnLockPhoneInput *>(request);
+ return phoneLockHandler.verifyPhoneLockInput(data->getInputData());
+ });
+ connect(typeid(locks::EnablePhoneLock),
+ [&](sys::Message *request) -> sys::MessagePointer { return phoneLockHandler.handleEnablePhoneLock(); });
+ connect(typeid(locks::DisablePhoneLock), [&](sys::Message *request) -> sys::MessagePointer {
+ return phoneLockHandler.handleDisablePhoneLock();
+ });
+ connect(typeid(locks::ChangePhoneLock),
+ [&](sys::Message *request) -> sys::MessagePointer { return phoneLockHandler.handleChangePhoneLock(); });
+ connect(typeid(locks::SetPhoneLock),
+ [&](sys::Message *request) -> sys::MessagePointer { return phoneLockHandler.handleSetPhoneLock(); });
+ connect(typeid(locks::SkipSetPhoneLock), [&](sys::Message *request) -> sys::MessagePointer {
+ return phoneLockHandler.handleSkipSetPhoneLock();
});
+ connect(typeid(sdesktop::developerMode::DeveloperModeRequest),
+ [&](sys::Message *request) -> sys::MessagePointer { return handleDeveloperModeRequest(request); });
+
connect(typeid(app::manager::DOMRequest), [&](sys::Message *request) { return handleDOMRequest(request); });
auto convertibleToActionHandler = [this](sys::Message *request) { return handleMessageAsAction(request); };
@@ 1099,6 1116,19 @@ namespace app::manager
return std::make_shared<sys::ResponseMessage>(sys::ReturnCodes::Unresolved);
}
+ auto ApplicationManager::handleDeveloperModeRequest(sys::Message *request) -> sys::MessagePointer
+ {
+ if (auto msg = dynamic_cast<sdesktop::developerMode::DeveloperModeRequest *>(request)) {
+ if (dynamic_cast<sdesktop::developerMode::ScreenlockCheckEvent *>(msg->event.get())) {
+ auto response = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(
+ std::make_unique<sdesktop::developerMode::ScreenlockCheckEvent>(phoneLockHandler.isPhoneLocked()));
+ bus.sendUnicast(std::move(response), service::name::service_desktop);
+ return sys::msgHandled();
+ }
+ }
+ return sys::msgNotHandled();
+ }
+
void ApplicationManager::processKeypadBacklightState(bsp::keypad_backlight::State keypadLightState)
{
auto action = bsp::keypad_backlight::Action::turnOff;
M module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp => module-services/service-appmgr/service-appmgr/model/ApplicationManager.hpp +2 -1
@@ 148,6 148,7 @@ namespace app::manager
auto handleDBResponse(db::QueryResponse *msg) -> bool;
auto handlePowerSavingModeInit() -> bool;
auto handleMessageAsAction(sys::Message *request) -> std::shared_ptr<sys::ResponseMessage>;
+ auto handleDeveloperModeRequest(sys::Message *request) -> sys::MessagePointer;
/// handles dom request by passing this request to application which should provide the dom
auto handleDOMRequest(sys::Message *request) -> std::shared_ptr<sys::ResponseMessage>;
void handleStart(StartAllowedMessage *msg);
@@ 180,7 181,7 @@ namespace app::manager
// If it reaches time defined in settings database application
// manager is sending signal to Application Desktop in order to
// lock screen.
- std::unique_ptr<settings::Settings> settings;
+ std::shared_ptr<settings::Settings> settings;
std::unique_ptr<sys::phone_modes::Observer> phoneModeObserver;
locks::PhoneLockHandler phoneLockHandler;
M module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp => module-services/service-desktop/endpoints/developerMode/DeveloperModeHelper.cpp +1 -1
@@ 71,7 71,7 @@ auto DeveloperModeHelper::processPut(Context &context) -> ProcessResult
else if (body[json::developerMode::isLocked].bool_value()) {
auto event = std::make_unique<sdesktop::developerMode::ScreenlockCheckEvent>();
auto msg = std::make_shared<sdesktop::developerMode::DeveloperModeRequest>(std::move(event));
- code = toCode(owner->bus.sendUnicast(std::move(msg), "ApplicationDesktop"));
+ code = toCode(owner->bus.sendUnicast(std::move(msg), "ApplicationManager"));
return {sent::delayed, std::nullopt};
}
else if (body[json::developerMode::changeAutoLockTimeout].is_string()) {
M module-utils/i18n/i18n.cpp => module-utils/i18n/i18n.cpp +4 -6
@@ 124,6 124,10 @@ namespace utils
bool i18n::setDisplayLanguage(const Language &lang)
{
+ if (fallbackLanguage == json11::Json()) {
+ loadFallbackLanguage();
+ }
+
if ((lang.empty() || lang == currentDisplayLanguage) && !currentDisplayLanguage.empty()) {
return false;
@@ 135,12 139,6 @@ namespace utils
return true;
}
- else if (fallbackLanguage == json11::Json()) {
-
- loadFallbackLanguage();
- return true;
- }
-
return false;
}