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 NETWORK_SEARCH_INCLUDE_OPERATOR_NAME_H 17 #define NETWORK_SEARCH_INCLUDE_OPERATOR_NAME_H 18 19 #include <memory> 20 21 #include "common_event_subscriber.h" 22 #include "event_handler.h" 23 #include "i_sim_manager.h" 24 #include "network_search_state.h" 25 #include "sim_constant.h" 26 #include "telephony_types.h" 27 #include "want.h" 28 29 namespace OHOS { 30 namespace Telephony { 31 class OperatorName : public EventFwk::CommonEventSubscriber { 32 public: 33 OperatorName(const EventFwk::CommonEventSubscribeInfo &sp, std::shared_ptr<NetworkSearchState> networkSearchState, 34 std::shared_ptr<ISimManager> simManager, std::weak_ptr<NetworkSearchManager> networkSearchManager, 35 int32_t slotId); 36 virtual ~OperatorName() = default; 37 void OnReceiveEvent(const EventFwk::CommonEventData &data) override; 38 void HandleOperatorInfo(const AppExecFwk::InnerEvent::Pointer &event); 39 void NotifySpnChanged(); 40 41 private: 42 void GsmOperatorInfo(const AppExecFwk::InnerEvent::Pointer &event) const; 43 void CdmaOperatorInfo(const AppExecFwk::InnerEvent::Pointer &event) const; 44 void PublishEvent(int32_t rule, RegServiceState state, bool showPlmn, const std::string &plmn, bool showSpn, 45 const std::string &spn); 46 sptr<NetworkState> GetNetworkStatus(); 47 void NotifyGsmSpnChanged(RegServiceState regStatus, sptr<NetworkState> &networkState); 48 void NotifyCdmaSpnChanged(RegServiceState regStatus, sptr<NetworkState> &networkState); 49 50 void UpdatePlmn(RegServiceState regStatus, sptr<NetworkState> &networkState, int32_t spnRule, std::string &plmn, 51 bool &showPlmn); 52 void UpdateSpn( 53 RegServiceState regStatus, sptr<NetworkState> &networkState, int32_t spnRule, std::string &spn, bool &showSpn); 54 int32_t GetCurrentLac(); 55 std::string GetCustomName(const std::string &numeric); 56 unsigned int GetCustSpnRule(bool roaming); 57 std::string GetEons(const std::string &numeric, int32_t lac, bool longNameRequired); 58 std::string GetCustEons(const std::string &numeric, int32_t lac, bool roaming, bool longNameRequired); 59 std::string GetPlmn(const sptr<NetworkState> &networkState, bool longNameRequired); 60 void UpdatePnnCust(const std::vector<std::string> &pnnCust); 61 void UpdateOplCust(const std::vector<std::string> &oplCust); 62 void UpdateOperatorConfig(); 63 64 private: 65 std::shared_ptr<NetworkSearchState> networkSearchState_ = nullptr; 66 std::shared_ptr<ISimManager> simManager_ = nullptr; 67 std::string curPlmn_ = ""; 68 bool curPlmnShow_ = false; 69 std::string curSpn_ = ""; 70 bool curSpnShow_ = false; 71 RegServiceState curRegState_ = RegServiceState::REG_STATE_UNKNOWN; 72 int32_t curSpnRule_ = 0; 73 sptr<NetworkState> networkState_ = nullptr; 74 std::weak_ptr<NetworkSearchManager> networkSearchManager_; 75 int32_t slotId_ = 0; 76 std::string csSpnFormat_; 77 const std::vector<std::string> cmMccMnc_ { "46000", "46002", "46004", "46007", "46008" }; 78 const std::vector<std::string> cuMccMnc_ { "46001", "46009" }; 79 const std::vector<std::string> ctMccMnc_ { "46003", "46011" }; 80 bool enableCust_ = false; 81 std::string spnCust_ = ""; 82 int32_t displayConditionCust_ = SPN_INVALID; 83 std::vector<std::shared_ptr<PlmnNetworkName>> pnnCust_; 84 std::vector<std::shared_ptr<OperatorPlmnInfo>> oplCust_; 85 }; 86 } // namespace Telephony 87 } // namespace OHOS 88 #endif // NETWORK_SEARCH_INCLUDE_OPERATOR_NAME_H 89