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