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 std::shared_ptr<OperatorInfoResult> operatorInfoResult); 39 void NotifySpnChanged(bool isForce = false); 40 void TrySetLongOperatorNameWithTranslation(); 41 42 private: 43 void GsmOperatorInfo(const std::shared_ptr<OperatorInfoResult> operatorInfoResult); 44 void CdmaOperatorInfo(const std::shared_ptr<OperatorInfoResult> operatorInfoResult); 45 void PublishEvent(int32_t rule, RegServiceState state, bool showPlmn, const std::string &plmn, bool showSpn, 46 const std::string &spn, const std::string &domesticSpn); 47 sptr<NetworkState> GetNetworkStatus(); 48 void NotifyGsmSpnChanged(RegServiceState regStatus, sptr<NetworkState> &networkState, 49 const std::string &domesticSpn, bool isForce = false); 50 void NotifyCdmaSpnChanged(RegServiceState regStatus, sptr<NetworkState> &networkState, 51 const std::string &domesticSpn, bool isForce = false); 52 53 void UpdatePlmn(RegServiceState regStatus, sptr<NetworkState> &networkState, int32_t spnRule, std::string &plmn, 54 bool &showPlmn); 55 void UpdateSpn( 56 RegServiceState regStatus, sptr<NetworkState> &networkState, int32_t spnRule, std::string &spn, bool &showSpn); 57 int32_t GetCurrentLac(); 58 std::string GetCustomName(const std::string &numeric); 59 unsigned int GetSpnRule(sptr<NetworkState> &networkState); 60 unsigned int GetCustSpnRule(bool roaming); 61 std::string GetEons(const std::string &numeric, int32_t lac, bool longNameRequired); 62 std::string GetCustEons(const std::string &numeric, int32_t lac, bool roaming, bool longNameRequired); 63 std::string GetPlmn(const sptr<NetworkState> &networkState, bool longNameRequired); 64 void UpdatePnnCust(const std::vector<std::string> &pnnCust); 65 void UpdateOplCust(const std::vector<std::string> &oplCust); 66 void UpdateOperatorConfig(); 67 bool isDomesticRoaming(const std::string &simPlmn, const std::string &netPlmn); 68 bool IsChinaCard(); 69 bool isCMCard(const std::string &numeric); 70 bool isCUCard(const std::string &numeric); 71 bool isCTCard(const std::string &numeric); 72 bool isCBCard(const std::string &numeric); 73 bool isCMDomestic(const std::string &numeric); 74 bool isCUDomestic(const std::string &numeric); 75 bool isCTDomestic(const std::string &numeric); 76 bool isCBDomestic(const std::string &numeric); 77 void UpdateOperatorLongName(std::string &operatorLongName, const std::string &numeric); 78 void UpdateVSimSpn(std::string &spn, int32_t &rule, bool &showSpn); 79 80 private: 81 std::shared_ptr<NetworkSearchState> networkSearchState_ = nullptr; 82 std::shared_ptr<ISimManager> simManager_ = nullptr; 83 std::string curPlmn_ = ""; 84 bool curPlmnShow_ = false; 85 std::string curSpn_ = ""; 86 bool curSpnShow_ = false; 87 RegServiceState curRegState_ = RegServiceState::REG_STATE_UNKNOWN; 88 int32_t curSpnRule_ = 0; 89 sptr<NetworkState> networkState_ = nullptr; 90 std::weak_ptr<NetworkSearchManager> networkSearchManager_; 91 int32_t slotId_ = 0; 92 std::string csSpnFormat_; 93 const std::vector<std::string> cmMccMnc_ { "46000", "46002", "46004", "46007", "46008", "46013" }; 94 const std::vector<std::string> cuMccMnc_ { "46001", "46006", "46009" }; 95 const std::vector<std::string> ctMccMnc_ { "46003", "46011" }; 96 const std::vector<std::string> cbnMccMnc_ { "46015" }; 97 const std::vector<std::string> cmDomesticMccMnc_ { "46031", "46050" }; 98 const std::vector<std::string> cuDomesticMccMnc_ { "46022", "46061" }; 99 const std::vector<std::string> ctDomesticMccMnc_ { "46021", "46060" }; 100 const std::vector<std::string> cbDomesticnMccMnc_ { "46032", "46051" }; 101 bool enableCust_ = false; 102 std::string spnCust_ = ""; 103 int32_t displayConditionCust_ = SPN_INVALID; 104 std::vector<std::shared_ptr<PlmnNetworkName>> pnnCust_; 105 std::vector<std::shared_ptr<OperatorPlmnInfo>> oplCust_; 106 }; 107 } // namespace Telephony 108 } // namespace OHOS 109 #endif // NETWORK_SEARCH_INCLUDE_OPERATOR_NAME_H 110