~aleteoryx/muditaos

ref: bc737e93f697de2dda221f8f97f0ce0ff05edd0b muditaos/module-apps/locks/handlers/SimLockHandler.hpp -rw-r--r-- 2.6 KiB
bc737e93 — Przemyslaw Brudny [EGD-5885] Added SimLockHandler 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// 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>
#include <locks/data/SimLockMessages.hpp>
#include <locks/data/LockData.hpp>

#include <module-sys/Service/Service.hpp>

namespace locks
{
    using StoredLockInput = std::vector<unsigned int>;

    class SimLockHandler
    {
      private:
        sys::Service *owner;
        Lock lock;

        SimInputTypeAction simInputTypeAction = SimInputTypeAction::UnlockWithPin;
        unsigned int storedErrorCode          = 0;
        bool simUnlockBlockOnLockedPhone      = false;
        StoredLockInput storedFirstInput;
        StoredLockInput storedSecondInput;

        void clearStoredInputs();
        void setSimInputTypeAction(SimInputTypeAction _simInputTypeAction);

        void simInputRequiredAction();
        void simErrorAction(unsigned int errorCode);
        void simUnlockAction();
        void simInfoAction();

        sys::MessagePointer unlockSimWithPin(LockInput pinInputData);
        sys::MessagePointer processLockWithNewInput(LockInput inputData);
        sys::MessagePointer resolveNewInputAction(LockInput firstInputData, LockInput secondInputData);
        sys::MessagePointer unlockSimWithPuk(LockInput pukInputData, LockInput newPinInputData);
        sys::MessagePointer changeSimPin(LockInput oldPinInputData, LockInput newPinInputData);
        sys::MessagePointer enableSimPin(LockInput pinInputData);
        sys::MessagePointer disableSimPin(LockInput pinInputData);

      public:
        explicit SimLockHandler(sys::Service *owner);

        void setSimUnlockBlockOnLockedPhone();
        sys::MessagePointer releaseSimUnlockBlockOnLockedPhone();

        sys::MessagePointer verifySimLockInput(LockInput inputData);

        sys::MessagePointer handleSimPinRequest(unsigned int attempts);
        sys::MessagePointer handleSimPukRequest(unsigned int attempts);
        sys::MessagePointer handleSimPinChangeRequest();
        sys::MessagePointer handleSimPinChangeFailedRequest();
        sys::MessagePointer handleSimEnableRequest();
        sys::MessagePointer handleSimDisableRequest();
        sys::MessagePointer handleSimBlockedRequest();
        sys::MessagePointer handleCMEErrorRequest(unsigned int errorCode);
        sys::MessagePointer handleSimUnlockedMessage();
        sys::MessagePointer handleSimChangedMessage();
        sys::MessagePointer handleSimAvailabilityMessage();

        void getSettingsSimSelect(const std::string &settingsSim);
        void setSim(cellular::api::SimSlot simSlot);
    };

} // namespace locks