• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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 NETWORK_SEARCH_INCLUDE_NETWORK_SEARCH_STATE_H
17 #define NETWORK_SEARCH_INCLUDE_NETWORK_SEARCH_STATE_H
18 
19 #include <memory>
20 #include <mutex>
21 #include "network_state.h"
22 #include "network_type.h"
23 #include "ims_core_service_types.h"
24 #include "ims_reg_types.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 class NetworkSearchManager;
29 class NetworkSearchState {
30 public:
31     NetworkSearchState(const std::weak_ptr<NetworkSearchManager> &networkSearchManager, int32_t slotId);
32     virtual ~NetworkSearchState() = default;
33     bool Init();
34     void SetOperatorInfo(const std::string &longName, const std::string &shortName, const std::string &numeric,
35         DomainType domainType);
36     void SetEmergency(bool isEmergency);
37     bool IsEmergency();
38     void SetNetworkType(RadioTech tech, DomainType domainType);
39     void SetNetworkState(RegServiceState state, DomainType domainType);
40     void SetNetworkStateToRoaming(RoamingType roamingType, DomainType domainType);
41     void SetInitial();
42     int32_t GetLastCfgTech(RadioTech &tech);
43     int32_t GetLastPsRadioTech(RadioTech &tech);
44     void SetNrState(NrState state);
45     void SetCfgTech(RadioTech tech);
46     std::unique_ptr<NetworkState> GetNetworkStatus();
47     int32_t GetImsStatus(ImsServiceType imsSrvType, ImsRegInfo &info);
48     void SetImsStatus(bool imsRegStatus);
49     void SetImsServiceStatus(const ImsServiceStatus &imsServiceStatus);
50     void NotifyStateChange();
51     void CsRadioTechChange();
52     void SetLongOperatorName(const std::string &longName, DomainType domainType);
53     bool IsProcessNetworkState();
54 
55 private:
56     void NotifyPsRegStatusChange();
57     void NotifyPsRoamingStatusChange();
58     void NotifyPsRadioTechChange();
59     void NotifyEmergencyChange();
60     void NotifyNrStateChange();
61     void NotifyImsStateChange(ImsServiceType imsSrvType, const ImsRegInfo &info);
62     ImsRegState GetImsRegState(const ImsServiceType type);
63 
64 private:
65     std::mutex mutex_;
66     std::weak_ptr<NetworkSearchManager> networkSearchManager_;
67     std::unique_ptr<NetworkState> networkState_ = nullptr;
68     std::unique_ptr<NetworkState> networkStateOld_ = nullptr;
69     std::mutex imsMutex_;
70     bool imsRegStatus_ = false;
71     int32_t slotId_ = 0;
72     std::unique_ptr<ImsServiceStatus> imsServiceStatus_ = nullptr;
73     bool processNetworkState_ = false;
74 };
75 } // namespace Telephony
76 } // namespace OHOS
77 #endif // NETWORK_SEARCH_INCLUDE_NETWORK_SEARCH_STATE_H
78