• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *    http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SMS_NETWORK_POLICY_MANAGER_H
17 #define SMS_NETWORK_POLICY_MANAGER_H
18 
19 #include <functional>
20 #include <map>
21 #include <optional>
22 
23 #include "event_handler.h"
24 #include "event_runner.h"
25 
26 #include "sms_common.h"
27 #include "network_state.h"
28 
29 namespace OHOS {
30 namespace Telephony {
31 class SmsNetworkPolicyManager : public AppExecFwk::EventHandler {
32 public:
33     SmsNetworkPolicyManager(const std::shared_ptr<AppExecFwk::EventRunner> &runner, int32_t slotId);
34     virtual ~SmsNetworkPolicyManager();
35     virtual void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override;
36     bool IsImsSmsSupported();
37     std::string GetImsShortMessageFormat();
38     void Init();
39     NetWorkType GetNetWorkType();
40     bool IsImsNetDomain() const;
41     int32_t GetVoiceServiceState() const;
42     std::optional<int32_t> NetworkRegister(
43         const std::function<void(bool isImsNetDomain, int32_t serviceState)> &callback);
44     std::optional<int32_t> NetworkRegister(
45         const std::function<void(bool isImsNetDomain, int32_t serviceState)> &&callback);
46     void NetworkUnregister(int32_t id);
47 
48 protected:
49     void HandlerRadioState(const AppExecFwk::InnerEvent::Pointer &event);
50     void GetRadioState();
51     void RegisterHandler();
52     void UnRegisterHandler();
53 
54 private:
55     int32_t GetId();
56 
57     int32_t slotId_;
58     enum NetWorkType netWorkType_ = NetWorkType::NET_TYPE_UNKNOWN;
59     bool isImsNetDomain_ = false;
60     int32_t voiceServiceState_ = static_cast<int32_t>(RegServiceState::REG_STATE_UNKNOWN);
61     std::map<int32_t, const std::function<void(bool isImsNetDomain, int32_t serviceState)>> callbackMap_;
62     int32_t id_ = 0;
63 };
64 } // namespace Telephony
65 } // namespace OHOS
66 #endif // SMS_NETWORK_POLICY_MANAGER_H
67