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 void SetNrState(NrState state); 43 void SetCfgTech(RadioTech tech); 44 std::unique_ptr<NetworkState> GetNetworkStatus(); 45 int32_t GetImsStatus(ImsServiceType imsSrvType, ImsRegInfo &info); 46 void SetImsStatus(bool imsRegStatus); 47 void SetImsServiceStatus(const ImsServiceStatus &imsServiceStatus); 48 void NotifyStateChange(); 49 void CsRadioTechChange(); 50 51 private: 52 void NotifyPsRegStatusChange(); 53 void NotifyPsRoamingStatusChange(); 54 void NotifyPsRadioTechChange(); 55 void NotifyEmergencyChange(); 56 void NotifyNrStateChange(); 57 void NotifyImsStateChange(ImsServiceType imsSrvType, const ImsRegInfo &info); 58 59 private: 60 std::mutex mutex_; 61 std::weak_ptr<NetworkSearchManager> networkSearchManager_; 62 std::unique_ptr<NetworkState> networkState_ = nullptr; 63 std::unique_ptr<NetworkState> networkStateOld_ = nullptr; 64 std::mutex imsMutex_; 65 bool imsRegStatus_ = false; 66 int32_t slotId_ = 0; 67 std::unique_ptr<ImsServiceStatus> imsServiceStatus_ = nullptr; 68 }; 69 } // namespace Telephony 70 } // namespace OHOS 71 #endif // NETWORK_SEARCH_INCLUDE_NETWORK_SEARCH_STATE_H 72