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 54 private: 55 void NotifyPsRegStatusChange(); 56 void NotifyPsRoamingStatusChange(); 57 void NotifyPsRadioTechChange(); 58 void NotifyEmergencyChange(); 59 void NotifyNrStateChange(); 60 void NotifyImsStateChange(ImsServiceType imsSrvType, const ImsRegInfo &info); 61 ImsRegState GetImsRegState(const ImsServiceType type); 62 63 private: 64 std::mutex mutex_; 65 std::weak_ptr<NetworkSearchManager> networkSearchManager_; 66 std::unique_ptr<NetworkState> networkState_ = nullptr; 67 std::unique_ptr<NetworkState> networkStateOld_ = nullptr; 68 std::mutex imsMutex_; 69 bool imsRegStatus_ = false; 70 int32_t slotId_ = 0; 71 std::unique_ptr<ImsServiceStatus> imsServiceStatus_ = nullptr; 72 bool processNetworkState_ = false; 73 }; 74 } // namespace Telephony 75 } // namespace OHOS 76 #endif // NETWORK_SEARCH_INCLUDE_NETWORK_SEARCH_STATE_H 77