• 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 #include "ffrt_inner.h"
30 
31 namespace OHOS {
32 namespace Telephony {
33 class OperatorName : public EventFwk::CommonEventSubscriber {
34 public:
35     OperatorName(const EventFwk::CommonEventSubscribeInfo &sp, std::shared_ptr<NetworkSearchState> networkSearchState,
36         std::shared_ptr<ISimManager> simManager, std::weak_ptr<NetworkSearchManager> networkSearchManager,
37         int32_t slotId);
38     virtual ~OperatorName() = default;
39     void OnReceiveEvent(const EventFwk::CommonEventData &data) override;
40     void HandleOperatorInfo(const std::shared_ptr<OperatorInfoResult> operatorInfoResult);
41     void NotifySpnChanged(bool isForce = false);
42     void TrySetLongOperatorNameWithTranslation();
43 
44 private:
45     void GsmOperatorInfo(const std::shared_ptr<OperatorInfoResult> operatorInfoResult);
46     void CdmaOperatorInfo(const std::shared_ptr<OperatorInfoResult> operatorInfoResult);
47     void PublishEvent(OperatorNameParams params, RegServiceState state, const std::string &domesticSpn);
48     sptr<NetworkState> GetNetworkStatus();
49     void NotifyGsmSpnChanged(RegServiceState regStatus, sptr<NetworkState> &networkState,
50         const std::string &domesticSpn, bool isForce = false);
51     void NotifyCdmaSpnChanged(RegServiceState regStatus, sptr<NetworkState> &networkState,
52         const std::string &domesticSpn, bool isForce = false);
53 
54     void UpdatePlmn(RegServiceState regStatus, sptr<NetworkState> &networkState, OperatorNameParams &params);
55     void UpdateSpn(RegServiceState regStatus, sptr<NetworkState> &networkState, OperatorNameParams &params);
56     int32_t GetCurrentLac();
57     std::string GetCustomName(const std::string &numeric);
58     bool GetRoamStateBySimFile(const std::string &netPlmn);
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(OperatorNameParams &params);
79     void SetOperatorName(const std::string &operatorName);
80     void SetOperatorNameByParams(OperatorNameParams &params);
81     bool IsShouldNotify(const RegServiceState &regStatus, const OperatorNameParams &params, bool isForce);
82 
83 private:
84     std::shared_ptr<NetworkSearchState> networkSearchState_ = nullptr;
85     std::shared_ptr<ISimManager> simManager_ = nullptr;
86     OperatorNameParams curParams_ = {false, "", false, "", 0};
87     RegServiceState curRegState_ = RegServiceState::REG_STATE_UNKNOWN;
88     std::weak_ptr<NetworkSearchManager> networkSearchManager_;
89     int32_t slotId_ = 0;
90     std::string csSpnFormat_;
91     const std::vector<std::string> cmMccMnc_ { "46000", "46002", "46004", "46007", "46008", "46013" };
92     const std::vector<std::string> cuMccMnc_ { "46001", "46006", "46009" };
93     const std::vector<std::string> ctMccMnc_ { "46003", "46011" };
94     const std::vector<std::string> cbnMccMnc_ { "46015" };
95     const std::vector<std::string> cmDomesticMccMnc_ { "46031", "46050", "46059" };
96     const std::vector<std::string> cuDomesticMccMnc_ { "46022", "46061", "46059" };
97     const std::vector<std::string> ctDomesticMccMnc_ { "46021", "46060" };
98     const std::vector<std::string> cbDomesticnMccMnc_ { "46032", "46051" };
99     bool enableCust_ = false;
100     bool netPriCust_ = false;
101     std::string spnCust_ = "";
102     int32_t displayConditionCust_ = SPN_INVALID;
103     std::vector<std::shared_ptr<PlmnNetworkName>> pnnCust_;
104     std::vector<std::shared_ptr<OperatorPlmnInfo>> oplCust_;
105     std::string longName_ = "";
106     ffrt::shared_mutex mutex_;
107 };
108 } // namespace Telephony
109 } // namespace OHOS
110 #endif // NETWORK_SEARCH_INCLUDE_OPERATOR_NAME_H
111