Files
MuditaOS/module-apps/apps-common/locks/data/LockData.hpp
rrandomsky c96dc7dc30 [MOS-686] Fixed MTP availability only after phone unlocked
Fixed file access via MTP even when phone is not unlocked.
Now access is granted when the phone is unlocked by the user entering
a passcode. If the phone is not passcode protected (passcode is nor set)
then access to the files is always possible via MTP.
2023-05-18 15:57:09 +02:00

83 lines
2.1 KiB
C++

// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
#include <memory>
#include "gui/SwitchData.hpp"
#include "locks/widgets/Lock.hpp"
namespace locks
{
using LockInput = const std::vector<unsigned int> &;
enum class PhoneLockInputTypeAction
{
Unlock,
Enable,
Disable,
ConfirmCurrent,
Change,
Set
};
enum class SimInputTypeAction
{
UnlockWithPin,
UnlockWithPuk,
ChangePin,
EnablePin,
DisablePin,
Blocked,
Error,
};
// 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,
PhoneLockInputTypeAction phoneLockInputTypeAction = PhoneLockInputTypeAction::Unlock)
: SwitchData(), lock(std::move(lock)), phoneLockInputTypeAction(phoneLockInputTypeAction)
{
description = "LockPhoneData";
}
[[nodiscard]] auto getLock() const noexcept
{
return lock;
}
[[nodiscard]] auto getPhoneLockInputTypeAction() const noexcept
{
return phoneLockInputTypeAction;
}
};
class SimLockData : public LockData
{
SimInputTypeAction simInputTypeAction;
unsigned int errorCode;
public:
explicit SimLockData(Lock lock, SimInputTypeAction simInputTypeAction, unsigned int errorCode)
: LockData(std::move(lock)), simInputTypeAction(simInputTypeAction), errorCode(errorCode)
{
description = "SimLockPhoneData";
}
[[nodiscard]] auto getSimInputTypeAction() const noexcept
{
return simInputTypeAction;
}
[[nodiscard]] auto getErrorCode() const noexcept
{
return errorCode;
}
};
} // namespace locks