Files
MuditaOS/module-apps/application-desktop/widgets/PinLockHandler.hpp
Piotr Tański d5c3d41ca4 [EGD-5204] Secure USB communication
Secure all endpoints by returning 403(Forbidden) when USB is connected.
Request screen passcode to enable secured endpoints.
2021-02-24 19:49:07 +01:00

69 lines
2.9 KiB
C++

// 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 "PinLock.hpp"
#include <module-services/service-appmgr/service-appmgr/messages/ActionRequest.hpp>
#include <module-services/service-appmgr/service-appmgr/Actions.hpp>
namespace app
{
class ApplicationDesktop;
}
namespace gui
{
class PinLockHandler
{
app::ApplicationDesktop *app = nullptr;
gui::PinLock screenLock;
gui::PinLock simLock;
bool promptSimLockWindow = true;
void handleScreenPin(const std::vector<unsigned int> &pin);
void handlePasscode(PinLock::LockType type, const std::vector<unsigned int> passcode);
void handlePasscodeChange(const std::vector<unsigned int> passcode);
void handleNewPasscodeUnconfirmed(const std::vector<unsigned int> &passcode,
const std::vector<unsigned int> &pin);
void handleNewPasscodeConfirmed(PinLock::LockType type,
const std::vector<unsigned int> &passcode,
const std::vector<unsigned int> &pin);
void handleNewPasscodeInvalid(const std::vector<unsigned int> &passcode);
void handlePasscodeParams(PinLock::LockType type,
PinLock::LockState state,
app::manager::actions::ActionParamsPtr &&data);
void switchToPinLockWindow(
std::function<void(PinLock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback);
void switchToPinLockWindow(
PinLock::LockState type,
std::function<void(PinLock::LockType, const std::vector<unsigned int> &)> onLockActivatedCallback);
auto getStrongestLock() noexcept -> gui::PinLock &;
void unlock();
void setSimLockHandled() noexcept;
public:
PinLockHandler(app::ApplicationDesktop *app);
void handlePasscodeRequest(PinLock::LockType type, app::manager::actions::ActionParamsPtr &&data);
void handlePinChangeRequest(app::manager::actions::ActionParamsPtr &&data);
void handleSimBlocked(app::manager::actions::ActionParamsPtr &&data);
void handleUnlockSim(app::manager::actions::ActionParamsPtr &&data);
void handleCMEError(app::manager::actions::ActionParamsPtr &&data) const;
void handleScreenPasscodeRequest(app::manager::actions::ActionParamsPtr &&data) const;
[[nodiscard]] auto isScreenLocked() const noexcept -> bool
{
return !screenLock.isState(PinLock::LockState::Unlocked);
}
[[nodiscard]] auto isScreenBlocked() const noexcept -> bool
{
return screenLock.isState(PinLock::LockState::Blocked);
}
void lockScreen();
void unlockScreen();
};
} // namespace gui