~aleteoryx/muditaos

ref: 7ffd1c15a6d9f14424c51ab18e81835319fc557a muditaos/module-services/service-desktop/include/service-desktop/USBSecurityModel.hpp -rw-r--r-- 1.4 KiB
7ffd1c15 — Lukasz Mastalerz [CP-2032] Unplugging the cable during file upload leaves partially sent file 2 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
// 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 <endpoints/Endpoint.hpp>

namespace settings
{
    class Settings;
}

namespace sys
{
    class Service;
}

namespace sdesktop
{
    using endpoints::BlockReason;
    using endpoints::EndpointSecurity;

    class USBSecurityModel
    {
      public:
        enum PhoneLockState : bool
        {
            Unlocked = false,
            Locked
        };
        typedef struct
        {
            EndpointSecurity access;
            BlockReason reason;
        } endpointSecurity_t;

        explicit USBSecurityModel(sys::Service *ownerSrv, settings::Settings *srvSettings);

        auto setPhoneLocked() -> void;
        auto setPhoneUnlocked() -> void;
        auto isSecurityEnabled() const -> bool;
        auto getEndpointSecurity() const -> endpointSecurity_t;
        auto updatePhoneLockTime(const time_t newPhoneLockTime) -> void;
        auto getPhoneLockTime() const -> time_t;

      private:
        auto isPasscodeEnabled() const -> bool;
        auto isPhoneLocked() const -> bool;
        auto isEulaAccepted() const -> bool;
        auto isBatteryLevelCritical() const -> bool;

        PhoneLockState phoneLocked;
        settings::Settings *settings;
        time_t phoneLockTime = 0;
    };
}; // namespace sdesktop