~aleteoryx/muditaos

ref: 395e99e16239630263d5892e2462f1333236ae99 muditaos/module-sys/Service/Common.hpp -rw-r--r-- 3.4 KiB
395e99e1 — Marek Niepieklo [CP-583] Update failure due to version.json on the phone 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// 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 "SystemReturnCodes.hpp"

namespace sys
{

    enum class BusChannel
    {
        Unknown,
        System,
        SystemManagerRequests,
        PowerManagerRequests,
        ServiceCellularNotifications,
        Test2CustomBusChannel,
        ServiceDBNotifications,
        ServiceAudioNotifications,
        AppManagerNotifications,
        ServiceFotaNotifications,
        AntennaNotifications,
        ServiceEvtmgrNotifications,
        PhoneModeChanges,
        BluetoothModeChanges,
        PhoneLockChanges
    };

    enum class ServicePriority
    {
        Idle     = 0, ///< priority: idle (lowest)
        Low      = 1, ///< priority: low
        Normal   = 2, ///< priority: normal
        High     = 3, ///< priority: high
        Realtime = 4, ///< priority: realtime (highest)
    };

    enum class ServicePowerMode
    {
        Active,
        SuspendToRAM,
        SuspendToNVM
    };

    enum class CloseReason
    {
        RegularPowerDown,
        Reboot,
        SystemBrownout,
        LowBattery
    };

    // Updater reason code
    enum class UpdateReason
    {
        Update,
        Recovery,
        FactoryReset
    };

} // namespace sys

inline const char *c_str(sys::ReturnCodes code)
{
    switch (code) {
    case sys::ReturnCodes::Success:
        return "Success";
    case sys::ReturnCodes::Failure:
        return "Failure";
    case sys::ReturnCodes::Timeout:
        return "Timeout";
    case sys::ReturnCodes::ServiceDoesntExist:
        return "ServiceDoesntExist";
    case sys::ReturnCodes::Unresolved:
        return "Unresolved";
    }
    return "Undefined";
}

inline const char *c_str(sys::ServicePowerMode code)
{
    switch (code) {
    case sys::ServicePowerMode::Active:
        return "Active";
    case sys::ServicePowerMode::SuspendToRAM:
        return "SuspendToRAM";
    case sys::ServicePowerMode::SuspendToNVM:
        return "SuspendToNVM";
    }
    return "";
}

inline const char *c_str(sys::BusChannel channel)
{
    switch (channel) {
    case sys::BusChannel::Unknown:
        return "Unknown";
    case sys::BusChannel::System:
        return "System";
    case sys::BusChannel::SystemManagerRequests:
        return "SystemManagerRequests";
    case sys::BusChannel::PowerManagerRequests:
        return "PowerManagerRequests";
    case sys::BusChannel::ServiceCellularNotifications:
        return "ServiceCellularNotifications,";
    case sys::BusChannel::Test2CustomBusChannel:
        return "Test2CustomBusChannel,";
    case sys::BusChannel::ServiceDBNotifications:
        return "ServiceDBNotifications,";
    case sys::BusChannel::ServiceAudioNotifications:
        return "ServiceAudioNotifications";
    case sys::BusChannel::AppManagerNotifications:
        return "AppManagerNotifications,";
    case sys::BusChannel::ServiceFotaNotifications:
        return "ServiceFotaNotifications";
    case sys::BusChannel::AntennaNotifications:
        return "AntennaNotifications";
    case sys::BusChannel::ServiceEvtmgrNotifications:
        return "ServiceEvtmgrNotifications";
    case sys::BusChannel::PhoneModeChanges:
        return "PhoneModeChanges";
    case sys::BusChannel::BluetoothModeChanges:
        return "BluetoothModeChanges";
    case sys::BusChannel::PhoneLockChanges:
        return "PhoneLockChanges";
    }
    return "";
}