• 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 #include "network_utils.h"
17 
18 #include <cinttypes>
19 
20 #include "hril_network_parcel.h"
21 #include "network_search_manager.h"
22 
23 namespace OHOS {
24 namespace Telephony {
25 /**
26  * @brief function pointer of class ITelRilManager.
27  *
28  */
29 using RilFunc_Event = int32_t (ITelRilManager::*)(int32_t, const AppExecFwk::InnerEvent::Pointer &);
30 using RilFunc_Int_Event = int32_t (ITelRilManager::*)(int32_t, int32_t, const AppExecFwk::InnerEvent::Pointer &);
31 using RilFunc_Int_Int_Event = int32_t (ITelRilManager::*)(
32     int32_t, int32_t, int32_t, const AppExecFwk::InnerEvent::Pointer &);
33 using RilFunc_Int_String_Event = int32_t (ITelRilManager::*)(
34     int32_t, int32_t, std::string, const AppExecFwk::InnerEvent::Pointer &);
35 
36 // group
37 static const int32_t GSM = static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_GSM);
38 static const int32_t CDMA = static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_1XRTT);
39 static const int32_t EVDO = static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_EVDO) |
40                             static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_EHRPD);
41 static const int32_t WCDMA = static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_WCDMA) |
42                              static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_HSPA) |
43                              static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_HSPAP);
44 static const int32_t TDSCDMA = static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_TD_SCDMA);
45 static const int32_t LTE = static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_LTE) |
46                            static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_LTE_CA);
47 static const int32_t NR = static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_NR);
48 
49 // generation
50 static const int32_t RAF_2G = GSM | CDMA;
51 static const int32_t RAF_3G = WCDMA | EVDO | TDSCDMA;
52 static const int32_t RAF_4G = LTE;
53 static const int32_t RAF_5G = NR;
54 // auto mode , support all radio mode
55 static const int32_t RAF_AUTO = RAF_2G | RAF_3G | RAF_4G | RAF_5G;
56 
57 static const std::map<int32_t, PreferredNetworkMode> mapNetworkModeFromRaf = {
58     { RAF_AUTO, PreferredNetworkMode::CORE_NETWORK_MODE_AUTO },
59     { GSM, PreferredNetworkMode::CORE_NETWORK_MODE_GSM },
60     { WCDMA, PreferredNetworkMode::CORE_NETWORK_MODE_WCDMA },
61     { LTE, PreferredNetworkMode::CORE_NETWORK_MODE_LTE },
62     { LTE | WCDMA, PreferredNetworkMode::CORE_NETWORK_MODE_LTE_WCDMA },
63     { LTE | WCDMA | GSM, PreferredNetworkMode::CORE_NETWORK_MODE_LTE_WCDMA_GSM },
64     { CDMA, PreferredNetworkMode::CORE_NETWORK_MODE_CDMA },
65     { WCDMA | GSM, PreferredNetworkMode::CORE_NETWORK_MODE_WCDMA_GSM },
66     { EVDO, PreferredNetworkMode::CORE_NETWORK_MODE_EVDO },
67     { EVDO | CDMA, PreferredNetworkMode::CORE_NETWORK_MODE_EVDO_CDMA },
68     { WCDMA | GSM | EVDO | CDMA, PreferredNetworkMode::CORE_NETWORK_MODE_WCDMA_GSM_EVDO_CDMA },
69     { LTE | EVDO | CDMA, PreferredNetworkMode::CORE_NETWORK_MODE_LTE_EVDO_CDMA },
70     { LTE | WCDMA | GSM | EVDO | CDMA, PreferredNetworkMode::CORE_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA },
71     { TDSCDMA, PreferredNetworkMode::CORE_NETWORK_MODE_TDSCDMA },
72     { TDSCDMA | GSM, PreferredNetworkMode::CORE_NETWORK_MODE_TDSCDMA_GSM },
73     { TDSCDMA | WCDMA, PreferredNetworkMode::CORE_NETWORK_MODE_TDSCDMA_WCDMA },
74     { TDSCDMA | WCDMA | GSM, PreferredNetworkMode::CORE_NETWORK_MODE_TDSCDMA_WCDMA_GSM },
75     { LTE | TDSCDMA, PreferredNetworkMode::CORE_NETWORK_MODE_LTE_TDSCDMA },
76     { LTE | TDSCDMA | GSM, PreferredNetworkMode::CORE_NETWORK_MODE_LTE_TDSCDMA_GSM },
77     { LTE | TDSCDMA | WCDMA, PreferredNetworkMode::CORE_NETWORK_MODE_LTE_TDSCDMA_WCDMA },
78     { LTE | TDSCDMA | WCDMA | GSM, PreferredNetworkMode::CORE_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM },
79     { TDSCDMA | WCDMA | GSM | EVDO | CDMA, PreferredNetworkMode::CORE_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA },
80     { LTE | TDSCDMA | WCDMA | GSM | EVDO | CDMA,
81         PreferredNetworkMode::CORE_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA },
82     { NR, PreferredNetworkMode::CORE_NETWORK_MODE_NR },
83     { NR | LTE, PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE },
84     { NR | LTE | WCDMA, PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_WCDMA },
85     { NR | LTE | WCDMA | GSM, PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_WCDMA_GSM },
86     { NR | LTE | EVDO | CDMA, PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_EVDO_CDMA },
87     { NR | LTE | WCDMA | GSM | EVDO | CDMA, PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_WCDMA_GSM_EVDO_CDMA },
88     { NR | LTE | TDSCDMA, PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_TDSCDMA },
89     { NR | LTE | TDSCDMA | GSM, PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_TDSCDMA_GSM },
90     { NR | LTE | TDSCDMA | WCDMA, PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA },
91     { NR | LTE | TDSCDMA | WCDMA | GSM, PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM },
92     { NR | LTE | TDSCDMA | GSM | EVDO | CDMA,
93         PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA },
94 };
95 
96 static const int32_t ALL_RAF[] = { GSM, CDMA, EVDO, WCDMA, TDSCDMA, LTE, NR };
97 
GetNetworkModeFromRaf(int32_t raf)98 PreferredNetworkMode NetworkUtils::GetNetworkModeFromRaf(int32_t raf)
99 {
100     for (int32_t i = 0; i < static_cast<int32_t>(sizeof(ALL_RAF) / sizeof(ALL_RAF[0])); i++) {
101         if (static_cast<uint32_t>(ALL_RAF[i]) & static_cast<uint32_t>(raf)) {
102             raf = static_cast<int32_t>(static_cast<uint32_t>(ALL_RAF[i]) | static_cast<uint32_t>(raf));
103         }
104     }
105 
106     auto iter = mapNetworkModeFromRaf.find(raf);
107     if (iter != mapNetworkModeFromRaf.end()) {
108         return iter->second;
109     }
110     return PreferredNetworkMode::CORE_NETWORK_MODE_AUTO;
111 }
112 
113 static const std::map<PreferredNetworkMode, int32_t> mapRafFromNetworkMode = {
114     { PreferredNetworkMode::CORE_NETWORK_MODE_AUTO, RAF_AUTO },
115     { PreferredNetworkMode::CORE_NETWORK_MODE_GSM, GSM },
116     { PreferredNetworkMode::CORE_NETWORK_MODE_WCDMA, WCDMA },
117     { PreferredNetworkMode::CORE_NETWORK_MODE_LTE, LTE },
118     { PreferredNetworkMode::CORE_NETWORK_MODE_LTE_WCDMA, LTE | WCDMA },
119     { PreferredNetworkMode::CORE_NETWORK_MODE_LTE_WCDMA_GSM, LTE | WCDMA | GSM },
120     { PreferredNetworkMode::CORE_NETWORK_MODE_WCDMA_GSM, WCDMA | GSM },
121     { PreferredNetworkMode::CORE_NETWORK_MODE_CDMA, CDMA },
122     { PreferredNetworkMode::CORE_NETWORK_MODE_EVDO, EVDO },
123     { PreferredNetworkMode::CORE_NETWORK_MODE_EVDO_CDMA, EVDO | CDMA },
124     { PreferredNetworkMode::CORE_NETWORK_MODE_WCDMA_GSM_EVDO_CDMA, WCDMA | GSM | EVDO | CDMA },
125     { PreferredNetworkMode::CORE_NETWORK_MODE_LTE_EVDO_CDMA, LTE | EVDO | CDMA },
126     { PreferredNetworkMode::CORE_NETWORK_MODE_LTE_WCDMA_GSM_EVDO_CDMA, LTE | WCDMA | GSM | EVDO | CDMA },
127     { PreferredNetworkMode::CORE_NETWORK_MODE_TDSCDMA, TDSCDMA },
128     { PreferredNetworkMode::CORE_NETWORK_MODE_TDSCDMA_GSM, TDSCDMA | GSM },
129     { PreferredNetworkMode::CORE_NETWORK_MODE_TDSCDMA_WCDMA, TDSCDMA | WCDMA },
130     { PreferredNetworkMode::CORE_NETWORK_MODE_TDSCDMA_WCDMA_GSM, TDSCDMA | WCDMA | GSM },
131     { PreferredNetworkMode::CORE_NETWORK_MODE_LTE_TDSCDMA, LTE | TDSCDMA },
132     { PreferredNetworkMode::CORE_NETWORK_MODE_LTE_TDSCDMA_GSM, LTE | TDSCDMA | GSM },
133     { PreferredNetworkMode::CORE_NETWORK_MODE_LTE_TDSCDMA_WCDMA, LTE | TDSCDMA | WCDMA },
134     { PreferredNetworkMode::CORE_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM, LTE | TDSCDMA | WCDMA | GSM },
135     { PreferredNetworkMode::CORE_NETWORK_MODE_TDSCDMA_WCDMA_GSM_EVDO_CDMA, TDSCDMA | WCDMA | GSM | EVDO | CDMA },
136     { PreferredNetworkMode::CORE_NETWORK_MODE_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA,
137         LTE | TDSCDMA | WCDMA | GSM | EVDO | CDMA },
138     { PreferredNetworkMode::CORE_NETWORK_MODE_NR, NR },
139     { PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE, NR | LTE },
140     { PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_WCDMA, NR | LTE | WCDMA },
141     { PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_WCDMA_GSM, NR | LTE | WCDMA | GSM },
142     { PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_EVDO_CDMA, NR | LTE | EVDO | CDMA },
143     { PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_WCDMA_GSM_EVDO_CDMA, NR | LTE | WCDMA | GSM | EVDO | CDMA },
144     { PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_TDSCDMA, NR | LTE | TDSCDMA },
145     { PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_TDSCDMA_GSM, NR | LTE | TDSCDMA | GSM },
146     { PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA, NR | LTE | TDSCDMA | WCDMA },
147     { PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM, NR | LTE | TDSCDMA | WCDMA | GSM },
148     { PreferredNetworkMode::CORE_NETWORK_MODE_NR_LTE_TDSCDMA_WCDMA_GSM_EVDO_CDMA,
149         NR | LTE | TDSCDMA | GSM | EVDO | CDMA },
150 };
151 
152 std::unordered_map<int64_t, std::shared_ptr<NetworkSearchCallbackInfo>> NetworkUtils::networkSearchCacheMap_;
153 std::mutex NetworkUtils::callbackMapMutex_;
154 std::atomic<int64_t> NetworkUtils::callbackIndex64bit_ = MIN_INDEX;
GetRafFromNetworkMode(PreferredNetworkMode PreferredNetworkMode)155 int32_t NetworkUtils::GetRafFromNetworkMode(PreferredNetworkMode PreferredNetworkMode)
156 {
157     auto iter = mapRafFromNetworkMode.find(PreferredNetworkMode);
158     if (iter != mapRafFromNetworkMode.end()) {
159         return iter->second;
160     }
161     return static_cast<int32_t>(RadioProtocolTech::RADIO_PROTOCOL_TECH_UNKNOWN);
162 }
163 
SplitString(const std::string & inputString,const std::string & flag)164 std::vector<std::string> NetworkUtils::SplitString(const std::string &inputString, const std::string &flag)
165 {
166     std::vector<std::string> result;
167     if (inputString.empty()) {
168         TELEPHONY_LOGE("inputString is null");
169         return result;
170     }
171     std::string::size_type start = 0;
172     std::string::size_type position = 0;
173     while ((position = inputString.find(flag, start)) != std::string::npos) {
174         result.push_back(inputString.substr(start, position - start));
175         start = position + flag.size();
176     }
177     if (start != inputString.size()) {
178         result.push_back(inputString.substr(start, inputString.size() - start));
179     }
180     return result;
181 }
182 
AddNetworkSearchCallBack(int64_t index,std::shared_ptr<NetworkSearchCallbackInfo> & callback)183 bool NetworkUtils::AddNetworkSearchCallBack(int64_t index, std::shared_ptr<NetworkSearchCallbackInfo> &callback)
184 {
185     TELEPHONY_LOGI("NetworkUtils::AddNetworkSearchCallBack index=(%{public}" PRId64 ")", index);
186     if (callback != nullptr) {
187         std::lock_guard<std::mutex> guard(callbackMapMutex_);
188         auto result = networkSearchCacheMap_.emplace(index, callback);
189         return result.second;
190     }
191     TELEPHONY_LOGE("NetworkUtils::AddNetworkSearchCallBack callback is null!");
192     return false;
193 }
194 
GetCallbackIndex64bit()195 int64_t NetworkUtils::GetCallbackIndex64bit()
196 {
197     if (callbackIndex64bit_ > MAX_INDEX || callbackIndex64bit_ < MIN_INDEX) {
198         callbackIndex64bit_ = MIN_INDEX;
199     }
200     return ++callbackIndex64bit_;
201 }
202 
FindNetworkSearchCallback(int64_t index)203 std::shared_ptr<NetworkSearchCallbackInfo> NetworkUtils::FindNetworkSearchCallback(int64_t index)
204 {
205     TELEPHONY_LOGI("NetworkUtils::FindNetworkSearchCallback index=%{public}" PRId64 "", index);
206 
207     std::lock_guard<std::mutex> guard(callbackMapMutex_);
208     auto iter = networkSearchCacheMap_.find(index);
209     if (iter != networkSearchCacheMap_.end()) {
210         std::shared_ptr<NetworkSearchCallbackInfo> callback = iter->second;
211         return callback;
212     }
213     return nullptr;
214 }
215 
RemoveCallbackFromMap(int64_t index)216 bool NetworkUtils::RemoveCallbackFromMap(int64_t index)
217 {
218     TELEPHONY_LOGI("NetworkUtils::RemoveCallbackFromMap index=%{public}" PRId64 "", index);
219     std::lock_guard<std::mutex> guard(callbackMapMutex_);
220     return (networkSearchCacheMap_.erase(index));
221 }
222 
223 const std::map<RadioEvent, std::any> EventSender::mapFunctions_ = {
224     { RadioEvent::RADIO_GET_NETWORK_SELECTION_MODE, &ITelRilManager::GetNetworkSelectionMode },
225     { RadioEvent::RADIO_SET_NETWORK_SELECTION_MODE, &ITelRilManager::SetNetworkSelectionMode },
226     { RadioEvent::RADIO_GET_PREFERRED_NETWORK_MODE, &ITelRilManager::GetPreferredNetwork },
227     { RadioEvent::RADIO_SET_PREFERRED_NETWORK_MODE, &ITelRilManager::SetPreferredNetwork },
228     { RadioEvent::RADIO_SET_STATUS, &ITelRilManager::SetRadioState },
229     { RadioEvent::RADIO_GET_STATUS, &ITelRilManager::GetRadioState },
230     { RadioEvent::RADIO_GET_IMEI, &ITelRilManager::GetImei },
231     { RadioEvent::RADIO_GET_MEID, &ITelRilManager::GetMeid },
232     { RadioEvent::RADIO_NETWORK_SEARCH_RESULT, &ITelRilManager::GetNetworkSearchInformation },
233     { RadioEvent::RADIO_GET_VOICE_TECH, &ITelRilManager::GetVoiceRadioTechnology },
234     { RadioEvent::RADIO_OPERATOR, &ITelRilManager::GetOperatorInfo },
235 };
236 
GetEvent(int32_t slotId,RadioEvent radioEvent,int32_t param)237 AppExecFwk::InnerEvent::Pointer EventSender::GetEvent(int32_t slotId, RadioEvent radioEvent, int32_t param)
238 {
239     AppExecFwk::InnerEvent::Pointer event(nullptr, nullptr);
240     std::shared_ptr<NetworkSearchManager> nsm = networkSearchManager_.lock();
241     if (nsm == nullptr) {
242         TELEPHONY_LOGE("failed to get NetworkSearchManager");
243         return event;
244     }
245 
246     auto inner = nsm->FindManagerInner(slotId);
247     if (inner != nullptr) {
248         event = AppExecFwk::InnerEvent::Get(static_cast<int32_t>(radioEvent), param);
249         if (event == nullptr) {
250             return event;
251         }
252         event->SetOwner(inner->networkSearchHandler_);
253         return event;
254     }
255     return event;
256 }
257 
GetEvent(int32_t slotId,RadioEvent radioEvent)258 AppExecFwk::InnerEvent::Pointer EventSender::GetEvent(int32_t slotId, RadioEvent radioEvent)
259 {
260     AppExecFwk::InnerEvent::Pointer event(nullptr, nullptr);
261     std::shared_ptr<NetworkSearchManager> nsm = networkSearchManager_.lock();
262     if (nsm == nullptr) {
263         TELEPHONY_LOGE("failed to get NetworkSearchManager");
264         return event;
265     }
266 
267     auto inner = nsm->FindManagerInner(slotId);
268     if (inner != nullptr) {
269         event = AppExecFwk::InnerEvent::Get(static_cast<int32_t>(radioEvent));
270         if (event == nullptr) {
271             return event;
272         }
273         event->SetOwner(inner->networkSearchHandler_);
274         return event;
275     }
276     return event;
277 }
278 
GetEvent(int32_t slotId,RadioEvent radioEvent,int32_t param,const sptr<INetworkSearchCallback> & callback)279 AppExecFwk::InnerEvent::Pointer EventSender::GetEvent(
280     int32_t slotId, RadioEvent radioEvent, int32_t param, const sptr<INetworkSearchCallback> &callback)
281 {
282     AppExecFwk::InnerEvent::Pointer event(nullptr, nullptr);
283     std::shared_ptr<NetworkSearchManager> nsm = networkSearchManager_.lock();
284     if (nsm == nullptr) {
285         TELEPHONY_LOGE("failed to get NetworkSearchManager");
286         return event;
287     }
288 
289     auto inner = nsm->FindManagerInner(slotId);
290     if (inner != nullptr) {
291         int64_t index = NetworkUtils::GetCallbackIndex64bit();
292         std::shared_ptr<NetworkSearchCallbackInfo> callbackInfo =
293             std::make_shared<NetworkSearchCallbackInfo>(param, callback);
294         if (callbackInfo == nullptr) {
295             TELEPHONY_LOGE("EventSender::GetEvent callbackInfo is null!! slotId:%{public}d", slotId);
296             return event;
297         }
298         if (!NetworkUtils::AddNetworkSearchCallBack(index, callbackInfo)) {
299             TELEPHONY_LOGE("EventSender::GetEvent AddNetworkSearchCallBack Error!! slotId:%{public}d", slotId);
300             return event;
301         }
302         event = AppExecFwk::InnerEvent::Get(static_cast<int32_t>(radioEvent), index);
303         if (event == nullptr) {
304             NetworkUtils::RemoveCallbackFromMap(index);
305             return event;
306         }
307         event->SetOwner(inner->networkSearchHandler_);
308         return event;
309     }
310     return event;
311 }
312 
SendBase(int32_t slotId,RadioEvent radioEvent)313 bool EventSender::SendBase(int32_t slotId, RadioEvent radioEvent)
314 {
315     auto fun = GetFunctionOfEvent<RilFunc_Event>(radioEvent);
316     std::tuple<int32_t, RadioEvent, int32_t, const sptr<INetworkSearchCallback> *, RilFunc_Event> parameters(
317         slotId, radioEvent, 0, nullptr, fun);
318     return Send<EventGetMode::GET_EVENT_BY_HANDLERID, RilFunc_Event>(parameters);
319 }
320 
SendBase(int32_t slotId,RadioEvent radioEvent,int32_t param)321 bool EventSender::SendBase(int32_t slotId, RadioEvent radioEvent, int32_t param)
322 {
323     auto fun = GetFunctionOfEvent<RilFunc_Int_Event>(radioEvent);
324     std::tuple<int32_t, RadioEvent, int32_t, const sptr<INetworkSearchCallback> *, RilFunc_Int_Event> parameters(
325         slotId, radioEvent, param, nullptr, fun);
326     return Send<EventGetMode::GET_EVENT_BY_PARAM, RilFunc_Int_Event, int32_t>(parameters, param);
327 }
328 
SendBase(int32_t slotId,RadioEvent radioEvent,int32_t firstParam,int32_t secondParam)329 bool EventSender::SendBase(int32_t slotId, RadioEvent radioEvent, int32_t firstParam, int32_t secondParam)
330 {
331     auto fun = GetFunctionOfEvent<RilFunc_Int_Int_Event>(radioEvent);
332     std::tuple<int32_t, RadioEvent, int32_t, const sptr<INetworkSearchCallback> *, RilFunc_Int_Int_Event> parameters(
333         slotId, radioEvent, firstParam, nullptr, fun);
334     return Send<EventGetMode::GET_EVENT_BY_PARAM, RilFunc_Int_Int_Event, int32_t, int32_t>(
335         parameters, firstParam, secondParam);
336 }
337 
SendBase(int32_t slotId,RadioEvent radioEvent,int32_t firstParam,std::string secondParam)338 bool EventSender::SendBase(int32_t slotId, RadioEvent radioEvent, int32_t firstParam, std::string secondParam)
339 {
340     auto fun = GetFunctionOfEvent<RilFunc_Int_String_Event>(radioEvent);
341     std::tuple<int32_t, RadioEvent, int32_t, const sptr<INetworkSearchCallback> *, RilFunc_Int_String_Event> parameters(
342         slotId, radioEvent, firstParam, nullptr, fun);
343     return Send<EventGetMode::GET_EVENT_BY_PARAM, RilFunc_Int_String_Event, int32_t, std::string>(
344         parameters, firstParam, secondParam);
345 }
346 
SendCallback(int32_t slotId,RadioEvent radioEvent,const sptr<INetworkSearchCallback> * callback)347 bool EventSender::SendCallback(int32_t slotId, RadioEvent radioEvent, const sptr<INetworkSearchCallback> *callback)
348 {
349     auto fun = GetFunctionOfEvent<RilFunc_Event>(radioEvent);
350     std::tuple<int32_t, RadioEvent, int32_t, const sptr<INetworkSearchCallback> *, RilFunc_Event> parameters(
351         slotId, radioEvent, 0, callback, fun);
352     return Send<EventGetMode::GET_EVENT_BY_INDEX, RilFunc_Event>(parameters);
353 }
354 
SendCallback(int32_t slotId,RadioEvent radioEvent,const sptr<INetworkSearchCallback> * callback,int32_t param)355 bool EventSender::SendCallback(
356     int32_t slotId, RadioEvent radioEvent, const sptr<INetworkSearchCallback> *callback, int32_t param)
357 {
358     auto fun = GetFunctionOfEvent<RilFunc_Event>(radioEvent);
359     std::tuple<int32_t, RadioEvent, int32_t, const sptr<INetworkSearchCallback> *, RilFunc_Event> parameters(
360         slotId, radioEvent, param, callback, fun);
361     return Send<EventGetMode::GET_EVENT_BY_PARAM, RilFunc_Event>(parameters);
362 }
363 
SendCallbackEx(int32_t slotId,RadioEvent radioEvent,const sptr<INetworkSearchCallback> * callback,int32_t param)364 bool EventSender::SendCallbackEx(
365     int32_t slotId, RadioEvent radioEvent, const sptr<INetworkSearchCallback> *callback, int32_t param)
366 {
367     auto fun = GetFunctionOfEvent<RilFunc_Int_Event>(radioEvent);
368     std::tuple<int32_t, RadioEvent, int32_t, const sptr<INetworkSearchCallback> *, RilFunc_Int_Event> parameters(
369         slotId, radioEvent, param, callback, fun);
370     return Send<EventGetMode::GET_EVENT_BY_INDEX, RilFunc_Int_Event, int32_t>(parameters, param);
371 }
372 
SendCallback(int32_t slotId,RadioEvent radioEvent,const sptr<INetworkSearchCallback> * callback,int32_t firstParam,int32_t secondParam)373 bool EventSender::SendCallback(int32_t slotId, RadioEvent radioEvent, const sptr<INetworkSearchCallback> *callback,
374     int32_t firstParam, int32_t secondParam)
375 {
376     auto fun = GetFunctionOfEvent<RilFunc_Int_Int_Event>(radioEvent);
377     std::tuple<int32_t, RadioEvent, int32_t, const sptr<INetworkSearchCallback> *, RilFunc_Int_Int_Event> parameters(
378         slotId, radioEvent, firstParam, callback, fun);
379     return Send<EventGetMode::GET_EVENT_BY_INDEX, RilFunc_Int_Int_Event, int32_t, int32_t>(
380         parameters, firstParam, secondParam);
381 }
382 
SendCallback(int32_t slotId,RadioEvent radioEvent,const sptr<INetworkSearchCallback> * callback,int32_t firstParam,std::string secondParam)383 bool EventSender::SendCallback(int32_t slotId, RadioEvent radioEvent, const sptr<INetworkSearchCallback> *callback,
384     int32_t firstParam, std::string secondParam)
385 {
386     auto fun = GetFunctionOfEvent<RilFunc_Int_String_Event>(radioEvent);
387     std::tuple<int32_t, RadioEvent, int32_t, const sptr<INetworkSearchCallback> *, RilFunc_Int_String_Event> parameters(
388         slotId, radioEvent, firstParam, callback, fun);
389     return Send<EventGetMode::GET_EVENT_BY_INDEX, RilFunc_Int_String_Event, int32_t, std::string>(
390         parameters, firstParam, secondParam);
391 }
392 } // namespace Telephony
393 } // namespace OHOS
394