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 "hril_manager.h"
17
18 #include "hril_base.h"
19 #include "hril_notification.h"
20 #include "hril_request.h"
21 #include "parameter.h"
22
23 namespace OHOS {
24 namespace Telephony {
25 constexpr const char *MODULE_HRIL_CALL = "hrilCall";
26 constexpr const char *MODULE_HRIL_DATA = "hrilData";
27 constexpr const char *MODULE_HRIL_MODEM = "hrilModem";
28 constexpr const char *MODULE_HRIL_SIM = "hrilSim";
29 constexpr const char *MODULE_HRIL_NETWORK = "hrilNetwork";
30 constexpr const char *MODULE_HRIL_SMS = "hrilSms";
31 static bool g_isHrilManagerDestory = false;
32 static std::shared_ptr<HRilManager> g_manager = std::make_shared<HRilManager>();
33 static pthread_mutex_t dispatchMutex = PTHREAD_MUTEX_INITIALIZER;
34 std::shared_ptr<HRilManager> HRilManager::manager_ = g_manager;
35 std::unordered_map<int32_t, int32_t> HRilManager::notificationMap_ = {
36 #include "hril_notification_map.h"
37 };
38
39 using namespace OHOS::HDI::Power::V1_0;
40
IsHrilManagerValid()41 static bool IsHrilManagerValid()
42 {
43 if (g_isHrilManagerDestory || g_manager == nullptr) {
44 return false;
45 }
46 return true;
47 }
48
GetMaxSimSlotCount()49 int32_t HRilManager::GetMaxSimSlotCount()
50 {
51 return hrilSimSlotCount_;
52 }
53
CreateHRilRequest(int32_t serial,int32_t slotId,int32_t request)54 ReqDataInfo *HRilManager::CreateHRilRequest(int32_t serial, int32_t slotId, int32_t request)
55 {
56 ReqDataInfo *requestInfo = nullptr;
57 HRilSimSlotId simSlotId = (HRilSimSlotId)slotId;
58 requestInfo = (ReqDataInfo *)malloc(sizeof(ReqDataInfo));
59 if (requestInfo == nullptr) {
60 return nullptr;
61 }
62 requestInfo->slotId = simSlotId;
63 requestInfo->request = request;
64 requestInfo->serial = serial;
65 std::lock_guard<std::mutex> lockRequest(requestListLock_);
66 auto iter = requestList_.find(request);
67 if (iter != requestList_.end()) {
68 std::list<ReqDataInfo *> &reqDataSet = iter->second;
69 reqDataSet.push_back(requestInfo);
70 TELEPHONY_LOGD("CreateHRilRequest requestId=%{public}d, list size: %{public}zu", request, reqDataSet.size());
71 } else {
72 TELEPHONY_LOGD("CreateHRilRequest create requestList, requestId=%{public}d", request);
73 std::list<ReqDataInfo *> reqDataSet;
74 reqDataSet.push_back(requestInfo);
75 requestList_.emplace(request, reqDataSet);
76 }
77 return requestInfo;
78 }
79
ReleaseHRilRequest(int32_t request,ReqDataInfo * requestInfo)80 void HRilManager::ReleaseHRilRequest(int32_t request, ReqDataInfo *requestInfo)
81 {
82 std::lock_guard<std::mutex> lockRequest(requestListLock_);
83 auto iter = requestList_.find(request);
84 if (iter != requestList_.end()) {
85 std::list<ReqDataInfo *> &reqDataSet = iter->second;
86 auto it = find(reqDataSet.begin(), reqDataSet.end(), requestInfo);
87 if (it != reqDataSet.end()) {
88 if (*it != nullptr) {
89 free(*it);
90 }
91 reqDataSet.erase(it);
92 }
93 }
94 }
95
96 template<typename ClassTypePtr, typename FuncType, typename... ParamTypes>
TaskSchedule(const std::string module,ClassTypePtr & _obj,FuncType && _func,ParamTypes &&..._args)97 inline int32_t HRilManager::TaskSchedule(
98 const std::string module, ClassTypePtr &_obj, FuncType &&_func, ParamTypes &&... _args)
99 {
100 TELEPHONY_LOGD("%{public}s enter", module.c_str());
101 if (_func == nullptr || _obj == nullptr) {
102 TELEPHONY_LOGE("%{public}s func or obj is null pointer", module.c_str());
103 return HDF_FAILURE;
104 }
105 pthread_mutex_lock(&dispatchMutex);
106 int32_t ret = (_obj.get()->*(_func))(std::forward<ParamTypes>(_args)...);
107 pthread_mutex_unlock(&dispatchMutex);
108 return ret;
109 }
110
RegisterCallFuncs(int32_t slotId,const HRilCallReq * callFuncs)111 void HRilManager::RegisterCallFuncs(int32_t slotId, const HRilCallReq *callFuncs)
112 {
113 if (hrilCall_[slotId] != nullptr) {
114 hrilCall_[slotId]->RegisterCallFuncs(callFuncs);
115 }
116 }
117
RegisterDataFuncs(int32_t slotId,const HRilDataReq * dataFuncs)118 void HRilManager::RegisterDataFuncs(int32_t slotId, const HRilDataReq *dataFuncs)
119 {
120 if (hrilData_[slotId] != nullptr) {
121 hrilData_[slotId]->RegisterDataFuncs(dataFuncs);
122 }
123 }
124
RegisterModemFuncs(int32_t slotId,const HRilModemReq * modemFuncs)125 void HRilManager::RegisterModemFuncs(int32_t slotId, const HRilModemReq *modemFuncs)
126 {
127 if (hrilModem_[slotId] != nullptr) {
128 hrilModem_[slotId]->RegisterModemFuncs(modemFuncs);
129 }
130 }
131
RegisterNetworkFuncs(int32_t slotId,const HRilNetworkReq * networkFuncs)132 void HRilManager::RegisterNetworkFuncs(int32_t slotId, const HRilNetworkReq *networkFuncs)
133 {
134 if (hrilNetwork_[slotId] != nullptr) {
135 hrilNetwork_[slotId]->RegisterNetworkFuncs(networkFuncs);
136 }
137 }
138
RegisterSimFuncs(int32_t slotId,const HRilSimReq * simFuncs)139 void HRilManager::RegisterSimFuncs(int32_t slotId, const HRilSimReq *simFuncs)
140 {
141 if (hrilSim_[slotId] != nullptr) {
142 hrilSim_[slotId]->RegisterSimFuncs(simFuncs);
143 }
144 }
145
RegisterSmsFuncs(int32_t slotId,const HRilSmsReq * smsFuncs)146 void HRilManager::RegisterSmsFuncs(int32_t slotId, const HRilSmsReq *smsFuncs)
147 {
148 if (hrilSms_[slotId] != nullptr) {
149 hrilSms_[slotId]->RegisterSmsFuncs(smsFuncs);
150 }
151 }
152
RunningLockCallback(uint8_t * param)153 static void RunningLockCallback(uint8_t *param)
154 {
155 if (!IsHrilManagerValid() || param == nullptr) {
156 TELEPHONY_LOGE("check nullptr fail.");
157 return;
158 }
159 int serialNum = *reinterpret_cast<int *>(param);
160 delete param;
161 param = nullptr;
162 std::lock_guard<std::mutex> lockRequest(g_manager->mutexRunningLock_);
163 TELEPHONY_LOGD("RunningLockCallback, serialNum:%{public}d, runningSerialNum_:%{public}d", serialNum,
164 static_cast<int>(g_manager->runningSerialNum_));
165 if (g_manager->powerInterface_ == nullptr || serialNum != static_cast<int>(g_manager->runningSerialNum_)) {
166 return;
167 }
168 g_manager->runningLockCount_ = 0;
169 g_manager->powerInterface_->SuspendUnblock("HRilRunningLock");
170 TELEPHONY_LOGD("RunningLockCallback, UnLock");
171 }
172
ApplyRunningLock(void)173 void HRilManager::ApplyRunningLock(void)
174 {
175 if (!IsHrilManagerValid() || timerCallback_ == nullptr) {
176 TELEPHONY_LOGE("check nullptr fail.");
177 return;
178 }
179
180 std::lock_guard<std::mutex> lockRequest(mutexRunningLock_);
181 if (powerInterface_ != nullptr) {
182 powerInterface_->SuspendBlock("HRilRunningLock");
183 struct timeval tv = { 0, RUNNING_LOCK_DEFAULT_TIMEOUT_US };
184 runningLockCount_++;
185 runningSerialNum_++;
186 uint8_t *serialNum = reinterpret_cast<uint8_t *>(new int(runningSerialNum_));
187 timerCallback_->HRilSetTimerCallbackInfo(RunningLockCallback, serialNum, &tv);
188 TELEPHONY_LOGD("ApplyRunningLock, runningLockCount_:%{public}d, runningSerialNum_:%{public}d",
189 static_cast<int>(runningLockCount_), static_cast<int>(runningSerialNum_));
190 } else {
191 /* Since the power management subsystem starts slower than the RilAdapter,
192 * the wakelock needs to be recreated.
193 */
194 TELEPHONY_LOGW("The powerInterface_ is nullptr, needs to be recreated.");
195 powerInterface_ = IPowerInterface::Get();
196 if (powerInterface_ == nullptr) {
197 TELEPHONY_LOGE("failed to get power hdi interface");
198 }
199 }
200 }
201
ReleaseRunningLock(void)202 void HRilManager::ReleaseRunningLock(void)
203 {
204 std::lock_guard<std::mutex> lockRequest(mutexRunningLock_);
205 TELEPHONY_LOGD("ReleaseRunningLock, runningLockCount_:%{public}d", static_cast<int>(runningLockCount_));
206 if (powerInterface_ == nullptr) {
207 TELEPHONY_LOGE("powerInterface_ is nullptr");
208 return;
209 }
210 if (runningLockCount_ > 1) {
211 runningLockCount_--;
212 } else {
213 runningLockCount_ = 0;
214 powerInterface_->SuspendUnblock("HRilRunningLock");
215 TELEPHONY_LOGD("ReleaseRunningLock UnLock");
216 }
217 }
218
219 template<typename T>
OnReport(std::vector<std::unique_ptr<T>> & subModules,int32_t slotId,const ReportInfo * reportInfo,const uint8_t * response,size_t responseLen)220 void HRilManager::OnReport(std::vector<std::unique_ptr<T>> &subModules, int32_t slotId, const ReportInfo *reportInfo,
221 const uint8_t *response, size_t responseLen)
222 {
223 if (reportInfo == nullptr) {
224 TELEPHONY_LOGE("OnReport reportInfo is null!!!");
225 return;
226 }
227 if (slotId < 0 || static_cast<uint32_t>(slotId) >= subModules.size()) {
228 TELEPHONY_LOGE("OnReport subModules out of bounds!!!");
229 return;
230 }
231 TELEPHONY_LOGI("OnReport notifyId:%{public}d", reportInfo->notifyId);
232 switch (reportInfo->type) {
233 case static_cast<int32_t>(ReportType::HRIL_RESPONSE): {
234 ReqDataInfo *reqInfo = (ReqDataInfo *)reportInfo->requestInfo;
235 if (reqInfo == nullptr) {
236 TELEPHONY_LOGE("OnReport reqInfo is null!!!");
237 return;
238 }
239 TELEPHONY_LOGI("OnReport requestId:%{public}d", reqInfo->request);
240 HRilRadioResponseInfo responseInfo = {};
241 responseInfo.serial = reqInfo->serial;
242 responseInfo.error = (HRilErrType)reportInfo->error;
243 responseInfo.type = HRIL_RESPONSE_REQUEST;
244 if (HRIL_NEED_ACK == reportInfo->ack) {
245 ApplyRunningLock();
246 responseInfo.type = HRIL_RESPONSE_REQUEST_MUST_ACK;
247 }
248 int32_t requestId = reqInfo->request;
249 ReleaseHRilRequest(requestId, reqInfo);
250 subModules[slotId]->template ProcessResponse<T>(requestId, responseInfo, response, responseLen);
251 break;
252 }
253 case static_cast<int32_t>(ReportType::HRIL_NOTIFICATION): {
254 int32_t notifyType = HRIL_RESPONSE_NOTICE;
255 auto iter = notificationMap_.find(reportInfo->notifyId);
256 if (iter != notificationMap_.end()) {
257 TELEPHONY_LOGI("OnReport notifyId:%{public}d, value:%{public}d", reportInfo->notifyId, iter->second);
258 if (NEED_LOCK == iter->second) {
259 ApplyRunningLock();
260 notifyType = HRIL_RESPONSE_NOTICE_MUST_ACK;
261 }
262 }
263 subModules[slotId]->template ProcessNotify<T>(notifyType, reportInfo, response, responseLen);
264 break;
265 }
266 default:
267 break;
268 }
269 }
270
OnCallReport(int32_t slotId,const ReportInfo * reportInfo,const uint8_t * response,size_t responseLen)271 void HRilManager::OnCallReport(
272 int32_t slotId, const ReportInfo *reportInfo, const uint8_t *response, size_t responseLen)
273 {
274 OnReport(hrilCall_, slotId, reportInfo, response, responseLen);
275 }
276
OnDataReport(int32_t slotId,const ReportInfo * reportInfo,const uint8_t * response,size_t responseLen)277 void HRilManager::OnDataReport(
278 int32_t slotId, const ReportInfo *reportInfo, const uint8_t *response, size_t responseLen)
279 {
280 OnReport(hrilData_, slotId, reportInfo, response, responseLen);
281 }
282
OnModemReport(int32_t slotId,const ReportInfo * reportInfo,const uint8_t * response,size_t responseLen)283 void HRilManager::OnModemReport(
284 int32_t slotId, const ReportInfo *reportInfo, const uint8_t *response, size_t responseLen)
285 {
286 OnReport(hrilModem_, slotId, reportInfo, response, responseLen);
287 }
288
OnNetworkReport(int32_t slotId,const ReportInfo * reportInfo,const uint8_t * response,size_t responseLen)289 void HRilManager::OnNetworkReport(
290 int32_t slotId, const ReportInfo *reportInfo, const uint8_t *response, size_t responseLen)
291 {
292 OnReport(hrilNetwork_, slotId, reportInfo, response, responseLen);
293 }
294
OnSimReport(int32_t slotId,const ReportInfo * reportInfo,const uint8_t * response,size_t responseLen)295 void HRilManager::OnSimReport(int32_t slotId, const ReportInfo *reportInfo, const uint8_t *response, size_t responseLen)
296 {
297 OnReport(hrilSim_, slotId, reportInfo, response, responseLen);
298 }
299
OnSmsReport(int32_t slotId,const ReportInfo * reportInfo,const uint8_t * response,size_t responseLen)300 void HRilManager::OnSmsReport(int32_t slotId, const ReportInfo *reportInfo, const uint8_t *response, size_t responseLen)
301 {
302 OnReport(hrilSms_, slotId, reportInfo, response, responseLen);
303 }
304
HRilManager()305 HRilManager::HRilManager() : hrilSimSlotCount_(GetSimSlotCount())
306 {
307 for (int32_t slotId = HRIL_SIM_SLOT_0; slotId < hrilSimSlotCount_; slotId++) {
308 hrilCall_.push_back(std::make_unique<HRilCall>(slotId, *this));
309 hrilModem_.push_back(std::make_unique<HRilModem>(slotId, *this));
310 hrilNetwork_.push_back(std::make_unique<HRilNetwork>(slotId, *this));
311 hrilSim_.push_back(std::make_unique<HRilSim>(slotId, *this));
312 hrilSms_.push_back(std::make_unique<HRilSms>(slotId, *this));
313 hrilData_.push_back(std::make_unique<HRilData>(slotId, *this));
314 }
315 timerCallback_ = std::make_unique<HRilTimerCallback>();
316 }
317
SetRilCallback(sptr<OHOS::HDI::Ril::V1_0::IRilCallback> callback)318 void HRilManager::SetRilCallback(sptr<OHOS::HDI::Ril::V1_0::IRilCallback> callback)
319 {
320 TELEPHONY_LOGD("SetRilCallback");
321 for (int32_t slotId = HRIL_SIM_SLOT_0; slotId < hrilSimSlotCount_; slotId++) {
322 hrilCall_[slotId]->SetRilCallback(callback);
323 hrilModem_[slotId]->SetRilCallback(callback);
324 hrilNetwork_[slotId]->SetRilCallback(callback);
325 hrilSim_[slotId]->SetRilCallback(callback);
326 hrilSms_[slotId]->SetRilCallback(callback);
327 hrilData_[slotId]->SetRilCallback(callback);
328 }
329 }
330
331 // Call
SetEmergencyCallList(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::EmergencyInfoList & emergencyInfoList)332 int32_t HRilManager::SetEmergencyCallList(
333 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::EmergencyInfoList &emergencyInfoList)
334 {
335 return TaskSchedule(
336 MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SetEmergencyCallList, serialId, emergencyInfoList);
337 }
338
GetEmergencyCallList(int32_t slotId,int32_t serialId)339 int32_t HRilManager::GetEmergencyCallList(int32_t slotId, int32_t serialId)
340 {
341 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetEmergencyCallList, serialId);
342 }
343
GetCallList(int32_t slotId,int32_t serialId)344 int32_t HRilManager::GetCallList(int32_t slotId, int32_t serialId)
345 {
346 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetCallList, serialId);
347 }
348
Dial(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::DialInfo & dialInfo)349 int32_t HRilManager::Dial(int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::DialInfo &dialInfo)
350 {
351 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::Dial, serialId, dialInfo);
352 }
353
Reject(int32_t slotId,int32_t serialId)354 int32_t HRilManager::Reject(int32_t slotId, int32_t serialId)
355 {
356 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::Reject, serialId);
357 }
358
Hangup(int32_t slotId,int32_t serialId,int32_t gsmIndex)359 int32_t HRilManager::Hangup(int32_t slotId, int32_t serialId, int32_t gsmIndex)
360 {
361 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::Hangup, serialId, gsmIndex);
362 }
363
Answer(int32_t slotId,int32_t serialId)364 int32_t HRilManager::Answer(int32_t slotId, int32_t serialId)
365 {
366 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::Answer, serialId);
367 }
368
HoldCall(int32_t slotId,int32_t serialId)369 int32_t HRilManager::HoldCall(int32_t slotId, int32_t serialId)
370 {
371 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::HoldCall, serialId);
372 }
373
UnHoldCall(int32_t slotId,int32_t serialId)374 int32_t HRilManager::UnHoldCall(int32_t slotId, int32_t serialId)
375 {
376 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::UnHoldCall, serialId);
377 }
378
SwitchCall(int32_t slotId,int32_t serialId)379 int32_t HRilManager::SwitchCall(int32_t slotId, int32_t serialId)
380 {
381 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SwitchCall, serialId);
382 }
383
CombineConference(int32_t slotId,int32_t serialId,int32_t callType)384 int32_t HRilManager::CombineConference(int32_t slotId, int32_t serialId, int32_t callType)
385 {
386 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::CombineConference, serialId, callType);
387 }
388
SeparateConference(int32_t slotId,int32_t serialId,int32_t callIndex,int32_t callType)389 int32_t HRilManager::SeparateConference(int32_t slotId, int32_t serialId, int32_t callIndex, int32_t callType)
390 {
391 return TaskSchedule(
392 MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SeparateConference, serialId, callIndex, callType);
393 }
394
GetCallWaiting(int32_t slotId,int32_t serialId)395 int32_t HRilManager::GetCallWaiting(int32_t slotId, int32_t serialId)
396 {
397 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetCallWaiting, serialId);
398 }
399
SetCallWaiting(int32_t slotId,int32_t serialId,int32_t activate)400 int32_t HRilManager::SetCallWaiting(int32_t slotId, int32_t serialId, int32_t activate)
401 {
402 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SetCallWaiting, serialId, activate);
403 }
404
GetCallTransferInfo(int32_t slotId,int32_t serialId,int32_t reason)405 int32_t HRilManager::GetCallTransferInfo(int32_t slotId, int32_t serialId, int32_t reason)
406 {
407 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetCallTransferInfo, serialId, reason);
408 }
409
SetCallTransferInfo(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::CallForwardSetInfo & callForwardSetInfo)410 int32_t HRilManager::SetCallTransferInfo(
411 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::CallForwardSetInfo &callForwardSetInfo)
412 {
413 return TaskSchedule(
414 MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SetCallTransferInfo, serialId, callForwardSetInfo);
415 }
416
GetCallRestriction(int32_t slotId,int32_t serialId,const std::string & fac)417 int32_t HRilManager::GetCallRestriction(int32_t slotId, int32_t serialId, const std::string &fac)
418 {
419 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetCallRestriction, serialId, fac);
420 }
421
SetCallRestriction(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::CallRestrictionInfo & callRestrictionInfo)422 int32_t HRilManager::SetCallRestriction(
423 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::CallRestrictionInfo &callRestrictionInfo)
424 {
425 return TaskSchedule(
426 MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SetCallRestriction, serialId, callRestrictionInfo);
427 }
428
GetClip(int32_t slotId,int32_t serialId)429 int32_t HRilManager::GetClip(int32_t slotId, int32_t serialId)
430 {
431 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetClip, serialId);
432 }
433
SetClip(int32_t slotId,int32_t serialId,int32_t action)434 int32_t HRilManager::SetClip(int32_t slotId, int32_t serialId, int32_t action)
435 {
436 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SetClip, serialId, action);
437 }
438
GetClir(int32_t slotId,int32_t serialId)439 int32_t HRilManager::GetClir(int32_t slotId, int32_t serialId)
440 {
441 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetClir, serialId);
442 }
443
SetClir(int32_t slotId,int32_t serialId,int32_t action)444 int32_t HRilManager::SetClir(int32_t slotId, int32_t serialId, int32_t action)
445 {
446 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SetClir, serialId, action);
447 }
448
SetCallPreferenceMode(int32_t slotId,int32_t serialId,int32_t mode)449 int32_t HRilManager::SetCallPreferenceMode(int32_t slotId, int32_t serialId, int32_t mode)
450 {
451 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SetCallPreferenceMode, serialId, mode);
452 }
453
GetCallPreferenceMode(int32_t slotId,int32_t serialId)454 int32_t HRilManager::GetCallPreferenceMode(int32_t slotId, int32_t serialId)
455 {
456 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetCallPreferenceMode, serialId);
457 }
458
SetUssd(int32_t slotId,int32_t serialId,const std::string & str)459 int32_t HRilManager::SetUssd(int32_t slotId, int32_t serialId, const std::string &str)
460 {
461 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SetUssd, serialId, str);
462 }
463
GetUssd(int32_t slotId,int32_t serialId)464 int32_t HRilManager::GetUssd(int32_t slotId, int32_t serialId)
465 {
466 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetUssd, serialId);
467 }
468
SetMute(int32_t slotId,int32_t serialId,int32_t mute)469 int32_t HRilManager::SetMute(int32_t slotId, int32_t serialId, int32_t mute)
470 {
471 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SetMute, serialId, mute);
472 }
473
GetMute(int32_t slotId,int32_t serialId)474 int32_t HRilManager::GetMute(int32_t slotId, int32_t serialId)
475 {
476 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetMute, serialId);
477 }
478
GetCallFailReason(int32_t slotId,int32_t serialId)479 int32_t HRilManager::GetCallFailReason(int32_t slotId, int32_t serialId)
480 {
481 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::GetCallFailReason, serialId);
482 }
483
CallSupplement(int32_t slotId,int32_t serialId,int32_t type)484 int32_t HRilManager::CallSupplement(int32_t slotId, int32_t serialId, int32_t type)
485 {
486 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::CallSupplement, serialId, type);
487 }
488
SendDtmf(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::DtmfInfo & dtmfInfo)489 int32_t HRilManager::SendDtmf(int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::DtmfInfo &dtmfInfo)
490 {
491 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SendDtmf, serialId, dtmfInfo);
492 }
493
StartDtmf(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::DtmfInfo & dtmfInfo)494 int32_t HRilManager::StartDtmf(int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::DtmfInfo &dtmfInfo)
495 {
496 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::StartDtmf, serialId, dtmfInfo);
497 }
498
StopDtmf(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::DtmfInfo & dtmfInfo)499 int32_t HRilManager::StopDtmf(int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::DtmfInfo &dtmfInfo)
500 {
501 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::StopDtmf, serialId, dtmfInfo);
502 }
503
SetBarringPassword(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SetBarringInfo & setBarringInfo)504 int32_t HRilManager::SetBarringPassword(
505 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SetBarringInfo &setBarringInfo)
506 {
507 return TaskSchedule(MODULE_HRIL_CALL, hrilCall_[slotId], &HRilCall::SetBarringPassword, serialId, setBarringInfo);
508 }
509
510 // Data
ActivatePdpContext(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::DataCallInfo & dataCallInfo)511 int32_t HRilManager::ActivatePdpContext(
512 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::DataCallInfo &dataCallInfo)
513 {
514 return TaskSchedule(MODULE_HRIL_DATA, hrilData_[slotId], &HRilData::ActivatePdpContext, serialId, dataCallInfo);
515 }
516
DeactivatePdpContext(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::UniInfo & uniInfo)517 int32_t HRilManager::DeactivatePdpContext(
518 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::UniInfo &uniInfo)
519 {
520 return TaskSchedule(MODULE_HRIL_DATA, hrilData_[slotId], &HRilData::DeactivatePdpContext, serialId, uniInfo);
521 }
522
GetPdpContextList(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::UniInfo & uniInfo)523 int32_t HRilManager::GetPdpContextList(int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::UniInfo &uniInfo)
524 {
525 return TaskSchedule(MODULE_HRIL_DATA, hrilData_[slotId], &HRilData::GetPdpContextList, serialId, uniInfo);
526 }
527
SetInitApnInfo(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::DataProfileDataInfo & dataProfileDataInfo)528 int32_t HRilManager::SetInitApnInfo(
529 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::DataProfileDataInfo &dataProfileDataInfo)
530 {
531 return TaskSchedule(MODULE_HRIL_DATA, hrilData_[slotId], &HRilData::SetInitApnInfo, serialId, dataProfileDataInfo);
532 }
533
GetLinkBandwidthInfo(int32_t slotId,int32_t serialId,int32_t cid)534 int32_t HRilManager::GetLinkBandwidthInfo(int32_t slotId, int32_t serialId, int32_t cid)
535 {
536 return TaskSchedule(MODULE_HRIL_DATA, hrilData_[slotId], &HRilData::GetLinkBandwidthInfo, serialId, cid);
537 }
538
SetLinkBandwidthReportingRule(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::DataLinkBandwidthReportingRule & dataLinkBandwidthReportingRule)539 int32_t HRilManager::SetLinkBandwidthReportingRule(int32_t slotId, int32_t serialId,
540 const OHOS::HDI::Ril::V1_0::DataLinkBandwidthReportingRule &dataLinkBandwidthReportingRule)
541 {
542 return TaskSchedule(MODULE_HRIL_DATA, hrilData_[slotId], &HRilData::SetLinkBandwidthReportingRule, serialId,
543 dataLinkBandwidthReportingRule);
544 }
545
SetDataPermitted(int32_t slotId,int32_t serialId,int32_t dataPermitted)546 int32_t HRilManager::SetDataPermitted(int32_t slotId, int32_t serialId, int32_t dataPermitted)
547 {
548 return TaskSchedule(MODULE_HRIL_DATA, hrilData_[slotId], &HRilData::SetDataPermitted, serialId, dataPermitted);
549 }
550
SetDataProfileInfo(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::DataProfilesInfo & dataProfilesInfo)551 int32_t HRilManager::SetDataProfileInfo(
552 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::DataProfilesInfo &dataProfilesInfo)
553 {
554 return TaskSchedule(MODULE_HRIL_DATA, hrilData_[slotId], &HRilData::SetDataProfileInfo, serialId, dataProfilesInfo);
555 }
556
SendDataPerformanceMode(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::DataPerformanceInfo & dataPerformanceInfo)557 int32_t HRilManager::SendDataPerformanceMode(
558 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::DataPerformanceInfo &dataPerformanceInfo)
559 {
560 return TaskSchedule(
561 MODULE_HRIL_DATA, hrilData_[slotId], &HRilData::SendDataPerformanceMode, serialId, dataPerformanceInfo);
562 }
563
SendDataSleepMode(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::DataSleepInfo & dataSleepInfo)564 int32_t HRilManager::SendDataSleepMode(
565 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::DataSleepInfo &dataSleepInfo)
566 {
567 return TaskSchedule(MODULE_HRIL_DATA, hrilData_[slotId], &HRilData::SendDataSleepMode, serialId, dataSleepInfo);
568 }
569
570 // Modem
SetRadioState(int32_t slotId,int32_t serialId,int32_t fun,int32_t rst)571 int32_t HRilManager::SetRadioState(int32_t slotId, int32_t serialId, int32_t fun, int32_t rst)
572 {
573 return TaskSchedule(MODULE_HRIL_MODEM, hrilModem_[slotId], &HRilModem::SetRadioState, serialId, fun, rst);
574 }
575
GetRadioState(int32_t slotId,int32_t serialId)576 int32_t HRilManager::GetRadioState(int32_t slotId, int32_t serialId)
577 {
578 return TaskSchedule(MODULE_HRIL_MODEM, hrilModem_[slotId], &HRilModem::GetRadioState, serialId);
579 }
580
GetImei(int32_t slotId,int32_t serialId)581 int32_t HRilManager::GetImei(int32_t slotId, int32_t serialId)
582 {
583 return TaskSchedule(MODULE_HRIL_MODEM, hrilModem_[slotId], &HRilModem::GetImei, serialId);
584 }
585
GetMeid(int32_t slotId,int32_t serialId)586 int32_t HRilManager::GetMeid(int32_t slotId, int32_t serialId)
587 {
588 return TaskSchedule(MODULE_HRIL_MODEM, hrilModem_[slotId], &HRilModem::GetMeid, serialId);
589 }
590
GetVoiceRadioTechnology(int32_t slotId,int32_t serialId)591 int32_t HRilManager::GetVoiceRadioTechnology(int32_t slotId, int32_t serialId)
592 {
593 return TaskSchedule(MODULE_HRIL_MODEM, hrilModem_[slotId], &HRilModem::GetVoiceRadioTechnology, serialId);
594 }
595
GetBasebandVersion(int32_t slotId,int32_t serialId)596 int32_t HRilManager::GetBasebandVersion(int32_t slotId, int32_t serialId)
597 {
598 return TaskSchedule(MODULE_HRIL_MODEM, hrilModem_[slotId], &HRilModem::GetBasebandVersion, serialId);
599 }
600
ShutDown(int32_t slotId,int32_t serialId)601 int32_t HRilManager::ShutDown(int32_t slotId, int32_t serialId)
602 {
603 return TaskSchedule(MODULE_HRIL_MODEM, hrilModem_[slotId], &HRilModem::ShutDown, serialId);
604 }
605
GetSimIO(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SimIoRequestInfo & simIO)606 int32_t HRilManager::GetSimIO(int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SimIoRequestInfo &simIO)
607 {
608 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::GetSimIO, serialId, simIO);
609 }
610
GetSimStatus(int32_t slotId,int32_t serialId)611 int32_t HRilManager::GetSimStatus(int32_t slotId, int32_t serialId)
612 {
613 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::GetSimStatus, serialId);
614 }
615
GetImsi(int32_t slotId,int32_t serialId)616 int32_t HRilManager::GetImsi(int32_t slotId, int32_t serialId)
617 {
618 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::GetImsi, serialId);
619 }
620
GetSimLockStatus(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SimLockInfo & simLockInfo)621 int32_t HRilManager::GetSimLockStatus(
622 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SimLockInfo &simLockInfo)
623 {
624 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::GetSimLockStatus, serialId, simLockInfo);
625 }
626
SetSimLock(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SimLockInfo & simLockInfo)627 int32_t HRilManager::SetSimLock(int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SimLockInfo &simLockInfo)
628 {
629 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SetSimLock, serialId, simLockInfo);
630 }
631
ChangeSimPassword(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SimPasswordInfo & simPassword)632 int32_t HRilManager::ChangeSimPassword(
633 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SimPasswordInfo &simPassword)
634 {
635 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::ChangeSimPassword, serialId, simPassword);
636 }
637
UnlockPin(int32_t slotId,int32_t serialId,const std::string & pin)638 int32_t HRilManager::UnlockPin(int32_t slotId, int32_t serialId, const std::string &pin)
639 {
640 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::UnlockPin, serialId, pin);
641 }
642
UnlockPuk(int32_t slotId,int32_t serialId,const std::string & puk,const std::string & pin)643 int32_t HRilManager::UnlockPuk(int32_t slotId, int32_t serialId, const std::string &puk, const std::string &pin)
644 {
645 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::UnlockPuk, serialId, puk, pin);
646 }
647
UnlockPin2(int32_t slotId,int32_t serialId,const std::string & pin2)648 int32_t HRilManager::UnlockPin2(int32_t slotId, int32_t serialId, const std::string &pin2)
649 {
650 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::UnlockPin2, serialId, pin2);
651 }
652
UnlockPuk2(int32_t slotId,int32_t serialId,const std::string & puk2,const std::string & pin2)653 int32_t HRilManager::UnlockPuk2(int32_t slotId, int32_t serialId, const std::string &puk2, const std::string &pin2)
654 {
655 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::UnlockPuk2, serialId, puk2, pin2);
656 }
657
SetActiveSim(int32_t slotId,int32_t serialId,int32_t index,int32_t enable)658 int32_t HRilManager::SetActiveSim(int32_t slotId, int32_t serialId, int32_t index, int32_t enable)
659 {
660 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SetActiveSim, serialId, index, enable);
661 }
662
SimStkSendTerminalResponse(int32_t slotId,int32_t serialId,const std::string & strCmd)663 int32_t HRilManager::SimStkSendTerminalResponse(int32_t slotId, int32_t serialId, const std::string &strCmd)
664 {
665 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SimStkSendTerminalResponse, serialId, strCmd);
666 }
667
SimStkSendEnvelope(int32_t slotId,int32_t serialId,const std::string & strCmd)668 int32_t HRilManager::SimStkSendEnvelope(int32_t slotId, int32_t serialId, const std::string &strCmd)
669 {
670 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SimStkSendEnvelope, serialId, strCmd);
671 }
672
SimStkSendCallSetupRequestResult(int32_t slotId,int32_t serialId,int32_t accept)673 int32_t HRilManager::SimStkSendCallSetupRequestResult(int32_t slotId, int32_t serialId, int32_t accept)
674 {
675 return TaskSchedule(
676 MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SimStkSendCallSetupRequestResult, serialId, accept);
677 }
678
SimStkIsReady(int32_t slotId,int32_t serialId)679 int32_t HRilManager::SimStkIsReady(int32_t slotId, int32_t serialId)
680 {
681 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SimStkIsReady, serialId);
682 }
683
GetRadioProtocol(int32_t slotId,int32_t serialId)684 int32_t HRilManager::GetRadioProtocol(int32_t slotId, int32_t serialId)
685 {
686 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::GetRadioProtocol, serialId);
687 }
688
SetRadioProtocol(int32_t slotId,int32_t serialId,const HDI::Ril::V1_0::RadioProtocol & radioProtocol)689 int32_t HRilManager::SetRadioProtocol(
690 int32_t slotId, int32_t serialId, const HDI::Ril::V1_0::RadioProtocol &radioProtocol)
691 {
692 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SetRadioProtocol, serialId, radioProtocol);
693 }
694
SimOpenLogicalChannel(int32_t slotId,int32_t serialId,const std::string & appID,int32_t p2)695 int32_t HRilManager::SimOpenLogicalChannel(int32_t slotId, int32_t serialId, const std::string &appID, int32_t p2)
696 {
697 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SimOpenLogicalChannel, serialId, appID, p2);
698 }
699
SimCloseLogicalChannel(int32_t slotId,int32_t serialId,int32_t channelId)700 int32_t HRilManager::SimCloseLogicalChannel(int32_t slotId, int32_t serialId, int32_t channelId)
701 {
702 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SimCloseLogicalChannel, serialId, channelId);
703 }
704
SimTransmitApduLogicalChannel(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::ApduSimIORequestInfo & apduSimIO)705 int32_t HRilManager::SimTransmitApduLogicalChannel(
706 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::ApduSimIORequestInfo &apduSimIO)
707 {
708 return TaskSchedule(
709 MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SimTransmitApduLogicalChannel, serialId, apduSimIO);
710 }
711
SimTransmitApduBasicChannel(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::ApduSimIORequestInfo & apduSimIO)712 int32_t HRilManager::SimTransmitApduBasicChannel(
713 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::ApduSimIORequestInfo &apduSimIO)
714 {
715 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SimTransmitApduBasicChannel, serialId, apduSimIO);
716 }
717
SimAuthentication(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SimAuthenticationRequestInfo & simAuthInfo)718 int32_t HRilManager::SimAuthentication(
719 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SimAuthenticationRequestInfo &simAuthInfo)
720 {
721 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::SimAuthentication, serialId, simAuthInfo);
722 }
723
UnlockSimLock(int32_t slotId,int32_t serialId,int32_t lockType,const std::string & key)724 int32_t HRilManager::UnlockSimLock(int32_t slotId, int32_t serialId, int32_t lockType, const std::string &key)
725 {
726 return TaskSchedule(MODULE_HRIL_SIM, hrilSim_[slotId], &HRilSim::UnlockSimLock, serialId, lockType, key);
727 }
728
729 // Network
GetSignalStrength(int32_t slotId,int32_t serialId)730 int32_t HRilManager::GetSignalStrength(int32_t slotId, int32_t serialId)
731 {
732 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::GetSignalStrength, serialId);
733 }
734
GetCsRegStatus(int32_t slotId,int32_t serialId)735 int32_t HRilManager::GetCsRegStatus(int32_t slotId, int32_t serialId)
736 {
737 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::GetCsRegStatus, serialId);
738 }
739
GetPsRegStatus(int32_t slotId,int32_t serialId)740 int32_t HRilManager::GetPsRegStatus(int32_t slotId, int32_t serialId)
741 {
742 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::GetPsRegStatus, serialId);
743 }
744
GetOperatorInfo(int32_t slotId,int32_t serialId)745 int32_t HRilManager::GetOperatorInfo(int32_t slotId, int32_t serialId)
746 {
747 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::GetOperatorInfo, serialId);
748 }
749
GetNetworkSearchInformation(int32_t slotId,int32_t serialId)750 int32_t HRilManager::GetNetworkSearchInformation(int32_t slotId, int32_t serialId)
751 {
752 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::GetNetworkSearchInformation, serialId);
753 }
754
GetNetworkSelectionMode(int32_t slotId,int32_t serialId)755 int32_t HRilManager::GetNetworkSelectionMode(int32_t slotId, int32_t serialId)
756 {
757 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::GetNetworkSelectionMode, serialId);
758 }
759
SetNetworkSelectionMode(int32_t slotId,int32_t serialId,const HDI::Ril::V1_0::SetNetworkModeInfo & networkModeInfo)760 int32_t HRilManager::SetNetworkSelectionMode(
761 int32_t slotId, int32_t serialId, const HDI::Ril::V1_0::SetNetworkModeInfo &networkModeInfo)
762 {
763 return TaskSchedule(
764 MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::SetNetworkSelectionMode, serialId, networkModeInfo);
765 }
766
GetNeighboringCellInfoList(int32_t slotId,int32_t serialId)767 int32_t HRilManager::GetNeighboringCellInfoList(int32_t slotId, int32_t serialId)
768 {
769 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::GetNeighboringCellInfoList, serialId);
770 }
771
GetCurrentCellInfo(int32_t slotId,int32_t serialId)772 int32_t HRilManager::GetCurrentCellInfo(int32_t slotId, int32_t serialId)
773 {
774 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::GetCurrentCellInfo, serialId);
775 }
776
SetPreferredNetwork(int32_t slotId,int32_t serialId,int32_t preferredNetworkType)777 int32_t HRilManager::SetPreferredNetwork(int32_t slotId, int32_t serialId, int32_t preferredNetworkType)
778 {
779 return TaskSchedule(
780 MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::SetPreferredNetwork, serialId, preferredNetworkType);
781 }
782
GetPreferredNetwork(int32_t slotId,int32_t serialId)783 int32_t HRilManager::GetPreferredNetwork(int32_t slotId, int32_t serialId)
784 {
785 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::GetPreferredNetwork, serialId);
786 }
787
GetPhysicalChannelConfig(int32_t slotId,int32_t serialId)788 int32_t HRilManager::GetPhysicalChannelConfig(int32_t slotId, int32_t serialId)
789 {
790 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::GetPhysicalChannelConfig, serialId);
791 }
792
SetLocateUpdates(int32_t slotId,int32_t serialId,const HDI::Ril::V1_0::RilRegNotifyMode mode)793 int32_t HRilManager::SetLocateUpdates(int32_t slotId, int32_t serialId, const HDI::Ril::V1_0::RilRegNotifyMode mode)
794 {
795 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::SetLocateUpdates, serialId, mode);
796 }
797
SetNotificationFilter(int32_t slotId,int32_t serialId,int32_t newFilter)798 int32_t HRilManager::SetNotificationFilter(int32_t slotId, int32_t serialId, int32_t newFilter)
799 {
800 return TaskSchedule(
801 MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::SetNotificationFilter, serialId, newFilter);
802 }
803
SetDeviceState(int32_t slotId,int32_t serialId,int32_t deviceStateType,int32_t deviceStateOn)804 int32_t HRilManager::SetDeviceState(int32_t slotId, int32_t serialId, int32_t deviceStateType, int32_t deviceStateOn)
805 {
806 return TaskSchedule(MODULE_HRIL_NETWORK, hrilNetwork_[slotId], &HRilNetwork::SetDeviceState, serialId,
807 deviceStateType, deviceStateOn);
808 }
809
810 // Sms
SendGsmSms(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::GsmSmsMessageInfo & gsmSmsMessageInfo)811 int32_t HRilManager::SendGsmSms(
812 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::GsmSmsMessageInfo &gsmSmsMessageInfo)
813 {
814 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::SendGsmSms, serialId, gsmSmsMessageInfo);
815 }
816
SendCdmaSms(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SendCdmaSmsMessageInfo & cdmaSmsMessageInfo)817 int32_t HRilManager::SendCdmaSms(
818 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SendCdmaSmsMessageInfo &cdmaSmsMessageInfo)
819 {
820 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::SendCdmaSms, serialId, cdmaSmsMessageInfo);
821 }
822
AddSimMessage(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SmsMessageIOInfo & smsMessageIOInfo)823 int32_t HRilManager::AddSimMessage(
824 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SmsMessageIOInfo &smsMessageIOInfo)
825 {
826 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::AddSimMessage, serialId, smsMessageIOInfo);
827 }
828
DelSimMessage(int32_t slotId,int32_t serialId,int32_t index)829 int32_t HRilManager::DelSimMessage(int32_t slotId, int32_t serialId, int32_t index)
830 {
831 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::DelSimMessage, serialId, index);
832 }
833
UpdateSimMessage(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SmsMessageIOInfo & smsMessageIOInfo)834 int32_t HRilManager::UpdateSimMessage(
835 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SmsMessageIOInfo &smsMessageIOInfo)
836 {
837 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::UpdateSimMessage, serialId, smsMessageIOInfo);
838 }
839
AddCdmaSimMessage(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SmsMessageIOInfo & smsMessageIOInfo)840 int32_t HRilManager::AddCdmaSimMessage(
841 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SmsMessageIOInfo &smsMessageIOInfo)
842 {
843 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::AddCdmaSimMessage, serialId, smsMessageIOInfo);
844 }
845
DelCdmaSimMessage(int32_t slotId,int32_t serialId,int32_t index)846 int32_t HRilManager::DelCdmaSimMessage(int32_t slotId, int32_t serialId, int32_t index)
847 {
848 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::DelCdmaSimMessage, serialId, index);
849 }
850
UpdateCdmaSimMessage(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::SmsMessageIOInfo & smsMessageIOInfo)851 int32_t HRilManager::UpdateCdmaSimMessage(
852 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::SmsMessageIOInfo &smsMessageIOInfo)
853 {
854 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::UpdateCdmaSimMessage, serialId, smsMessageIOInfo);
855 }
856
SetSmscAddr(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::ServiceCenterAddress & serviceCenterAddress)857 int32_t HRilManager::SetSmscAddr(
858 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::ServiceCenterAddress &serviceCenterAddress)
859 {
860 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::SetSmscAddr, serialId, serviceCenterAddress);
861 }
862
GetSmscAddr(int32_t slotId,int32_t serialId)863 int32_t HRilManager::GetSmscAddr(int32_t slotId, int32_t serialId)
864 {
865 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::GetSmscAddr, serialId);
866 }
867
SetCBConfig(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::CBConfigInfo & cellBroadcastInfo)868 int32_t HRilManager::SetCBConfig(
869 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::CBConfigInfo &cellBroadcastInfo)
870 {
871 return HRilManager::TaskSchedule(
872 MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::SetCBConfig, serialId, cellBroadcastInfo);
873 }
874
GetCBConfig(int32_t slotId,int32_t serialId)875 int32_t HRilManager::GetCBConfig(int32_t slotId, int32_t serialId)
876 {
877 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::GetCBConfig, serialId);
878 }
879
SetCdmaCBConfig(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::CdmaCBConfigInfoList & cdmaCBConfigInfoList)880 int32_t HRilManager::SetCdmaCBConfig(
881 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::CdmaCBConfigInfoList &cdmaCBConfigInfoList)
882 {
883 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::SetCdmaCBConfig, serialId, cdmaCBConfigInfoList);
884 }
885
GetCdmaCBConfig(int32_t slotId,int32_t serialId)886 int32_t HRilManager::GetCdmaCBConfig(int32_t slotId, int32_t serialId)
887 {
888 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::GetCdmaCBConfig, serialId);
889 }
890
SendSmsMoreMode(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::GsmSmsMessageInfo & gsmSmsMessageInfo)891 int32_t HRilManager::SendSmsMoreMode(
892 int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::GsmSmsMessageInfo &gsmSmsMessageInfo)
893 {
894 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::SendSmsMoreMode, serialId, gsmSmsMessageInfo);
895 }
896
SendSmsAck(int32_t slotId,int32_t serialId,const OHOS::HDI::Ril::V1_0::ModeData & modeData)897 int32_t HRilManager::SendSmsAck(int32_t slotId, int32_t serialId, const OHOS::HDI::Ril::V1_0::ModeData &modeData)
898 {
899 return TaskSchedule(MODULE_HRIL_SMS, hrilSms_[slotId], &HRilSms::SendSmsAck, serialId, modeData);
900 }
901
SendRilAck()902 int32_t HRilManager::SendRilAck()
903 {
904 ReleaseRunningLock();
905 return HRIL_ERR_SUCCESS;
906 }
907
~HRilManager()908 HRilManager::~HRilManager()
909 {
910 g_isHrilManagerDestory = true;
911 if (timerCallback_ == nullptr || timerCallback_->event_ == nullptr ||
912 timerCallback_->event_->IsNormalDestory()) {
913 return;
914 }
915 timerCallback_->event_->SetNormalDestory(true);
916 timerCallback_->OnTriggerEvent();
917 if (eventLoop_ == nullptr || !eventLoop_->joinable()) {
918 return;
919 }
920 eventLoop_->join();
921 TELEPHONY_LOGI("~HRilManager end");
922 }
923
924 #ifdef __cplusplus
925 extern "C" {
926 #endif
927
GetSimSlotCount()928 int32_t GetSimSlotCount()
929 {
930 char simSlotCount[HRIL_SYSPARA_SIZE] = { 0 };
931 GetParameter(HRIL_TEL_SIM_SLOT_COUNT, HRIL_DEFAULT_SLOT_COUNT, simSlotCount, HRIL_SYSPARA_SIZE);
932 return std::atoi(simSlotCount);
933 }
934
HRilBootUpEventLoop()935 static void HRilBootUpEventLoop()
936 {
937 if (!IsHrilManagerValid() || g_manager->timerCallback_ == nullptr) {
938 return;
939 }
940 g_manager->timerCallback_->EventLoop();
941 }
942
HRilInit(void)943 void HRilInit(void)
944 {
945 if (!IsHrilManagerValid()) {
946 TELEPHONY_LOGE("HRilInit: g_manager is nullptr");
947 return;
948 }
949 if (g_manager->powerInterface_ == nullptr) {
950 g_manager->powerInterface_ = IPowerInterface::Get();
951 if (g_manager->powerInterface_ == nullptr) {
952 TELEPHONY_LOGE("failed to get power hdi interface");
953 }
954 }
955 if (g_manager->eventLoop_ != nullptr) {
956 TELEPHONY_LOGD("eventLoop_ has exit");
957 return;
958 }
959 g_manager->eventLoop_ = std::make_unique<std::thread>(HRilBootUpEventLoop);
960 }
961
HRilRegOps(const HRilOps * hrilOps)962 void HRilRegOps(const HRilOps *hrilOps)
963 {
964 static HRilOps callBacks = { 0 };
965 static RegisterState rilRegisterStatus = RIL_REGISTER_IS_NONE;
966
967 if (hrilOps == nullptr || !IsHrilManagerValid()) {
968 TELEPHONY_LOGE("HRilRegOps: param is nullptr");
969 return;
970 }
971 if (rilRegisterStatus > RIL_REGISTER_IS_NONE) {
972 TELEPHONY_LOGE("HRilRegOps is running!!!!");
973 return;
974 }
975 rilRegisterStatus = RIL_REGISTER_IS_RUNNING;
976 (void)memcpy_s(&callBacks, sizeof(HRilOps), hrilOps, sizeof(HRilOps));
977 for (int32_t slotId = HRIL_SIM_SLOT_0; slotId < g_manager->GetMaxSimSlotCount(); slotId++) {
978 if (callBacks.smsOps != nullptr) {
979 g_manager->RegisterSmsFuncs(slotId, callBacks.smsOps);
980 }
981 if (callBacks.callOps != nullptr) {
982 g_manager->RegisterCallFuncs(slotId, callBacks.callOps);
983 }
984 if (callBacks.dataOps != nullptr) {
985 g_manager->RegisterDataFuncs(slotId, callBacks.dataOps);
986 }
987 if (callBacks.modemOps != nullptr) {
988 g_manager->RegisterModemFuncs(slotId, callBacks.modemOps);
989 }
990 if (callBacks.networkOps != nullptr) {
991 g_manager->RegisterNetworkFuncs(slotId, callBacks.networkOps);
992 }
993 if (callBacks.simOps != nullptr) {
994 g_manager->RegisterSimFuncs(slotId, callBacks.simOps);
995 }
996 }
997 }
998
OnCallReport(int32_t slotId,struct ReportInfo reportInfo,const uint8_t * response,size_t responseLen)999 void OnCallReport(int32_t slotId, struct ReportInfo reportInfo, const uint8_t *response, size_t responseLen)
1000 {
1001 if (!IsHrilManagerValid()) {
1002 TELEPHONY_LOGE("HrilManager is nullptr, id:%{public}d", slotId);
1003 return;
1004 }
1005 g_manager->OnCallReport(slotId, &reportInfo, response, responseLen);
1006 }
1007
OnDataReport(int32_t slotId,struct ReportInfo reportInfo,const uint8_t * response,size_t responseLen)1008 void OnDataReport(int32_t slotId, struct ReportInfo reportInfo, const uint8_t *response, size_t responseLen)
1009 {
1010 if (!IsHrilManagerValid()) {
1011 TELEPHONY_LOGE("HrilManager is nullptr, id:%{public}d", slotId);
1012 return;
1013 }
1014 g_manager->OnDataReport(slotId, &reportInfo, response, responseLen);
1015 }
1016
OnModemReport(int32_t slotId,struct ReportInfo reportInfo,const uint8_t * response,size_t responseLen)1017 void OnModemReport(int32_t slotId, struct ReportInfo reportInfo, const uint8_t *response, size_t responseLen)
1018 {
1019 if (!IsHrilManagerValid()) {
1020 TELEPHONY_LOGE("HrilManager is nullptr, id:%{public}d", slotId);
1021 return;
1022 }
1023 g_manager->OnModemReport(slotId, &reportInfo, response, responseLen);
1024 }
1025
OnNetworkReport(int32_t slotId,struct ReportInfo reportInfo,const uint8_t * response,size_t responseLen)1026 void OnNetworkReport(int32_t slotId, struct ReportInfo reportInfo, const uint8_t *response, size_t responseLen)
1027 {
1028 if (!IsHrilManagerValid()) {
1029 TELEPHONY_LOGE("HrilManager is nullptr, id:%{public}d", slotId);
1030 return;
1031 }
1032 g_manager->OnNetworkReport(slotId, &reportInfo, response, responseLen);
1033 }
1034
OnSimReport(int32_t slotId,struct ReportInfo reportInfo,const uint8_t * response,size_t responseLen)1035 void OnSimReport(int32_t slotId, struct ReportInfo reportInfo, const uint8_t *response, size_t responseLen)
1036 {
1037 if (!IsHrilManagerValid()) {
1038 TELEPHONY_LOGE("HrilManager is nullptr, id:%{public}d", slotId);
1039 return;
1040 }
1041 g_manager->OnSimReport(slotId, &reportInfo, response, responseLen);
1042 }
1043
OnSmsReport(int32_t slotId,struct ReportInfo reportInfo,const uint8_t * response,size_t responseLen)1044 void OnSmsReport(int32_t slotId, struct ReportInfo reportInfo, const uint8_t *response, size_t responseLen)
1045 {
1046 if (!IsHrilManagerValid()) {
1047 TELEPHONY_LOGE("HrilManager is nullptr, id:%{public}d", slotId);
1048 return;
1049 }
1050 g_manager->OnSmsReport(slotId, &reportInfo, response, responseLen);
1051 }
1052
OnTimerCallback(HRilCallbackFun func,uint8_t * param,const struct timeval * tv)1053 void OnTimerCallback(HRilCallbackFun func, uint8_t *param, const struct timeval *tv)
1054 {
1055 if (!IsHrilManagerValid() || g_manager->timerCallback_ == nullptr) {
1056 TELEPHONY_LOGE("HrilManager or timerCallback is nullptr");
1057 return;
1058 }
1059 g_manager->timerCallback_->HRilSetTimerCallbackInfo(func, param, tv);
1060 }
1061
1062 #ifdef __cplusplus
1063 }
1064 #endif
1065 } // namespace Telephony
1066 } // namespace OHOS
1067