• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "operator_name_params.h"
29 
30 namespace OHOS {
31 namespace Telephony {
32 class OperatorName : public EventFwk::CommonEventSubscriber {
33 public:
34     OperatorName(const EventFwk::CommonEventSubscribeInfo &sp, std::shared_ptr<NetworkSearchState> networkSearchState,
35         std::shared_ptr<ISimManager> simManager, std::weak_ptr<NetworkSearchManager> networkSearchManager,
36         int32_t slotId);
37     virtual ~OperatorName() = default;
38     void OnReceiveEvent(const EventFwk::CommonEventData &data) override;
39     void HandleOperatorInfo(const std::shared_ptr<OperatorInfoResult> operatorInfoResult);
40     void NotifySpnChanged(bool isForce = false);
41     void TrySetLongOperatorNameWithTranslation();
42 
43 private:
44     void GsmOperatorInfo(const std::shared_ptr<OperatorInfoResult> operatorInfoResult);
45     void CdmaOperatorInfo(const std::shared_ptr<OperatorInfoResult> operatorInfoResult);
46     void PublishEvent(OperatorNameParams params, RegServiceState state, 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, OperatorNameParams &params);
54     void UpdateSpn(RegServiceState regStatus, sptr<NetworkState> &networkState, OperatorNameParams &params);
55     int32_t GetCurrentLac();
56     std::string GetCustomName(const std::string &numeric);
57     unsigned int GetSpnRule(sptr<NetworkState> &networkState);
58     unsigned int GetCustSpnRule(bool roaming);
59     std::string GetEons(const std::string &numeric, int32_t lac, bool longNameRequired);
60     std::string GetCustEons(const std::string &numeric, int32_t lac, bool roaming, bool longNameRequired);
61     std::string GetPlmn(const sptr<NetworkState> &networkState, bool longNameRequired);
62     void UpdatePnnCust(const std::vector<std::string> &pnnCust);
63     void UpdateOplCust(const std::vector<std::string> &oplCust);
64     void UpdateOperatorConfig();
65     bool isDomesticRoaming(const std::string &simPlmn, const std::string &netPlmn);
66     bool IsChinaCard();
67     bool isCMCard(const std::string &numeric);
68     bool isCUCard(const std::string &numeric);
69     bool isCTCard(const std::string &numeric);
70     bool isCBCard(const std::string &numeric);
71     bool isCMDomestic(const std::string &numeric);
72     bool isCUDomestic(const std::string &numeric);
73     bool isCTDomestic(const std::string &numeric);
74     bool isCBDomestic(const std::string &numeric);
75     void UpdateOperatorLongName(std::string &operatorLongName, const std::string &numeric);
76     void UpdateVSimSpn(OperatorNameParams &params);
77     void SetOperatorName(const std::string &operatorName);
78     void SetOperatorNameByParams(OperatorNameParams &params);
79 
80 private:
81     std::shared_ptr<NetworkSearchState> networkSearchState_ = nullptr;
82     std::shared_ptr<ISimManager> simManager_ = nullptr;
83     OperatorNameParams curParams_ = {false, "", false, "", 0};
84     RegServiceState curRegState_ = RegServiceState::REG_STATE_UNKNOWN;
85     std::weak_ptr<NetworkSearchManager> networkSearchManager_;
86     int32_t slotId_ = 0;
87     std::string csSpnFormat_;
88     const std::vector<std::string> cmMccMnc_ { "46000", "46002", "46004", "46007", "46008", "46013" };
89     const std::vector<std::string> cuMccMnc_ { "46001", "46006", "46009" };
90     const std::vector<std::string> ctMccMnc_ { "46003", "46011" };
91     const std::vector<std::string> cbnMccMnc_ { "46015" };
92     const std::vector<std::string> cmDomesticMccMnc_ { "46031", "46050" };
93     const std::vector<std::string> cuDomesticMccMnc_ { "46022", "46061", "46059" };
94     const std::vector<std::string> ctDomesticMccMnc_ { "46021", "46060" };
95     const std::vector<std::string> cbDomesticnMccMnc_ { "46032", "46051" };
96     bool enableCust_ = false;
97     bool netPriCust_ = false;
98     std::string spnCust_ = "";
99     int32_t displayConditionCust_ = SPN_INVALID;
100     std::vector<std::shared_ptr<PlmnNetworkName>> pnnCust_;
101     std::vector<std::shared_ptr<OperatorPlmnInfo>> oplCust_;
102     std::string longName_ = "";
103 };
104 } // namespace Telephony
105 } // namespace OHOS
106 #endif // NETWORK_SEARCH_INCLUDE_OPERATOR_NAME_H
107