~aleteoryx/muditaos

ref: d9a1194e6f203247ebcef4b03f8ce5ebccc7c778 muditaos/module-services/service-cellular/src/volte/VolteCapabilityHandler.cpp -rw-r--r-- 1.4 KiB
d9a1194e — Lukasz Mastalerz [BH-1688] Create a standard for logs 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
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "VolteCapabilityHandler.hpp"
#include <modem/BaseChannel.hpp>
#include <log/log.hpp>

namespace cellular::service
{
    VolteCapabilityHandler::VolteCapabilityHandler(std::unique_ptr<VolteAllowedListInterface> allowedList,
                                                   std::unique_ptr<VolteCapabilityCellularInterface> cellularInterface)
        : allowedList(std::move(allowedList)), cellularInterface(std::move(cellularInterface))
    {}

    auto VolteCapabilityHandler::isVolteAllowed(at::BaseChannel &channel) -> bool
    {
        const auto &imsi = cellularInterface->getImsi(channel);
        if (!imsi.has_value()) {
            LOG_ERROR("VoLTE not permitted - failed to read IMSI");
            return false;
        }

        return allowedList->isVolteAllowed(imsi.value());
    }

    auto VolteCapabilityHandler::getSupportStatus(at::BaseChannel &channel) -> ImsiParser::SupportStatus
    {
        const auto &imsi = cellularInterface->getImsi(channel);
        if (!imsi.has_value()) {
            LOG_ERROR("VoLTE not permitted - failed to read IMSI");
            return ImsiParser::SupportStatus::Unsupported;
        }

        return allowedList->getSupportStatus(imsi.value());
    }
} // namespace cellular::service