• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 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 "tel_ril_manager.h"
17 
18 #include <iservice_registry.h>
19 #include <iservmgr_hdi.h>
20 #include <unistd.h>
21 
22 #include "radio_event.h"
23 #include "tel_ril_callback.h"
24 #include "telephony_errors.h"
25 
26 using namespace std;
27 using OHOS::IRemoteObject;
28 using OHOS::sptr;
29 namespace OHOS {
30 namespace Telephony {
31 namespace {
32 constexpr const char *RIL_INTERFACE_SERVICE_NAME = "ril_service";
33 constexpr int32_t STATUS_OK = 0;
34 } // namespace
TelRilManager()35 TelRilManager::TelRilManager() {}
36 
OnInit()37 bool TelRilManager::OnInit()
38 {
39     int32_t res = ConnectRilInterface();
40     TELEPHONY_LOGI("TelRilManager, connect ril interface result is %{public}d", res);
41     CreatTelRilHandler();
42     for (int32_t slotId = SIM_SLOT_0; slotId < SIM_SLOT_COUNT; slotId++) {
43         InitTelModule(slotId);
44     }
45     res = RegisterHdfStatusListener();
46     TELEPHONY_LOGI("TelRilManager, OnInit successfully! register hdf status is %{public}d", res);
47     return true;
48 }
49 
DeInit()50 bool TelRilManager::DeInit()
51 {
52     if (!UnRegisterHdfStatusListener()) {
53         TELEPHONY_LOGE("TelRilManager::DeInit, Unregister hdf status listener failed!");
54         return false;
55     }
56     TELEPHONY_LOGI("TelRilManager, deInit successfully!");
57     return true;
58 }
59 
ConnectRilInterface()60 bool TelRilManager::ConnectRilInterface()
61 {
62     std::lock_guard<std::mutex> lock_l(mutex_);
63     rilInterface_ = HDI::Ril::V1_2::IRil::Get();
64     if (rilInterface_ == nullptr) {
65         TELEPHONY_LOGE("TelRilManager not find RilInterfaceService");
66         return false;
67     }
68     rilInterface_->SetCallback1_2(new TelRilCallback(shared_from_this()));
69     return true;
70 }
71 
CreatTelRilHandler(void)72 void TelRilManager::CreatTelRilHandler(void)
73 {
74     handler_ = std::make_shared<TelRilHandler>();
75     handler_->OnInit();
76 }
77 
ReduceRunningLock()78 void TelRilManager::ReduceRunningLock()
79 {
80     if (handler_ == nullptr) {
81         TELEPHONY_LOGE("handler_ is null");
82         return;
83     }
84     handler_->ReduceRunningLock(TelRilHandler::NORMAL_RUNNING_LOCK);
85 }
86 
ReleaseRunningLock()87 void TelRilManager::ReleaseRunningLock()
88 {
89     if (handler_ == nullptr) {
90         TELEPHONY_LOGE("handler_ is null");
91         return;
92     }
93     handler_->ReleaseRunningLock(TelRilHandler::NORMAL_RUNNING_LOCK);
94 }
95 
SendAckAndLock(void)96 void TelRilManager::SendAckAndLock(void)
97 {
98     if (handler_ != nullptr) {
99         handler_->ApplyRunningLock(TelRilHandler::ACK_RUNNING_LOCK);
100     }
101     if (rilInterface_ == nullptr) {
102         TELEPHONY_LOGE("rilInterface_ is null");
103         return;
104     }
105     rilInterface_->SendRilAck();
106 }
107 
InitTelModule(int32_t slotId)108 void TelRilManager::InitTelModule(int32_t slotId)
109 {
110     std::shared_ptr<ObserverHandler> observerHandler = std::make_shared<ObserverHandler>();
111     observerHandler_.push_back(observerHandler);
112     telRilSms_.push_back(std::make_shared<TelRilSms>(slotId, rilInterface_, observerHandler_[slotId], handler_));
113     telRilSim_.push_back(std::make_shared<TelRilSim>(slotId, rilInterface_, observerHandler_[slotId], handler_));
114     telRilCall_.push_back(std::make_shared<TelRilCall>(slotId, rilInterface_, observerHandler_[slotId], handler_));
115     telRilData_.push_back(std::make_shared<TelRilData>(slotId, rilInterface_, observerHandler_[slotId], handler_));
116     telRilModem_.push_back(std::make_shared<TelRilModem>(slotId, rilInterface_, observerHandler_[slotId], handler_));
117     telRilNetwork_.push_back(
118         std::make_shared<TelRilNetwork>(slotId, rilInterface_, observerHandler_[slotId], handler_));
119 }
GetTelRilSms(int32_t slotId)120 std::shared_ptr<TelRilSms> TelRilManager::GetTelRilSms(int32_t slotId)
121 {
122     if (slotId < 0 || static_cast<size_t>(slotId) >= telRilSms_.size()) {
123         TELEPHONY_LOGE("telRilSms_ slotId is valid");
124         return nullptr;
125     }
126     return telRilSms_[slotId];
127 }
128 
GetTelRilSim(int32_t slotId)129 std::shared_ptr<TelRilSim> TelRilManager::GetTelRilSim(int32_t slotId)
130 {
131     if (slotId < 0 || static_cast<size_t>(slotId) >= telRilSim_.size()) {
132         TELEPHONY_LOGE("telRilSim_ slotId is valid");
133         return nullptr;
134     }
135     return telRilSim_[slotId];
136 }
137 
GetTelRilCall(int32_t slotId)138 std::shared_ptr<TelRilCall> TelRilManager::GetTelRilCall(int32_t slotId)
139 {
140     if (slotId < 0 || static_cast<size_t>(slotId) >= telRilCall_.size()) {
141         TELEPHONY_LOGE("telRilCall_ slotId is valid");
142         return nullptr;
143     }
144     return telRilCall_[slotId];
145 }
146 
GetTelRilData(int32_t slotId)147 std::shared_ptr<TelRilData> TelRilManager::GetTelRilData(int32_t slotId)
148 {
149     if (slotId < 0 || static_cast<size_t>(slotId) >= telRilData_.size()) {
150         TELEPHONY_LOGE("telRilData_ slotId is valid");
151         return nullptr;
152     }
153     return telRilData_[slotId];
154 }
155 
GetTelRilNetwork(int32_t slotId)156 std::shared_ptr<TelRilNetwork> TelRilManager::GetTelRilNetwork(int32_t slotId)
157 {
158     if (slotId < 0 || static_cast<size_t>(slotId) >= telRilNetwork_.size()) {
159         TELEPHONY_LOGE("telRilNetwork_ slotId is valid");
160         return nullptr;
161     }
162     return telRilNetwork_[slotId];
163 }
164 
GetTelRilModem(int32_t slotId)165 std::shared_ptr<TelRilModem> TelRilManager::GetTelRilModem(int32_t slotId)
166 {
167     if (slotId < 0 || static_cast<size_t>(slotId) >= telRilModem_.size()) {
168         TELEPHONY_LOGE("telRilModem_ slotId is valid");
169         return nullptr;
170     }
171     return telRilModem_[slotId];
172 }
173 
GetObserverHandler(int32_t slotId)174 std::shared_ptr<ObserverHandler> TelRilManager::GetObserverHandler(int32_t slotId)
175 {
176     return observerHandler_[slotId];
177 }
178 
ResetRilInterface(void)179 bool TelRilManager::ResetRilInterface(void)
180 {
181     int32_t size = static_cast<int32_t>(telRilCall_.size());
182     for (int32_t slotId = 0; slotId < size; slotId++) {
183         if (GetTelRilSms(slotId) != nullptr) {
184             GetTelRilSms(slotId)->ResetRilInterface(rilInterface_);
185         }
186         if (GetTelRilSim(slotId) != nullptr) {
187             GetTelRilSim(slotId)->ResetRilInterface(rilInterface_);
188         }
189         if (GetTelRilCall(slotId) != nullptr) {
190             GetTelRilCall(slotId)->ResetRilInterface(rilInterface_);
191         }
192         if (GetTelRilData(slotId) != nullptr) {
193             GetTelRilData(slotId)->ResetRilInterface(rilInterface_);
194         }
195         if (GetTelRilModem(slotId) != nullptr) {
196             GetTelRilModem(slotId)->ResetRilInterface(rilInterface_);
197         }
198         if (GetTelRilNetwork(slotId) != nullptr) {
199             GetTelRilNetwork(slotId)->ResetRilInterface(rilInterface_);
200         }
201     }
202     return true;
203 }
204 
RegisterCoreNotify(int32_t slotId,const std::shared_ptr<AppExecFwk::EventHandler> & observerCallBack,int32_t what,int32_t * obj)205 int32_t TelRilManager::RegisterCoreNotify(
206     int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &observerCallBack, int32_t what, int32_t *obj)
207 {
208     std::lock_guard<std::mutex> lock_l(mutex_);
209     std::shared_ptr<ObserverHandler> observerHandler = GetObserverHandler(slotId);
210     if (observerHandler != nullptr) {
211         switch (what) {
212             case RadioEvent::RADIO_ICC_STATUS_CHANGED:
213                 observerHandler->RegObserver(what, observerCallBack);
214                 observerHandler->NotifyObserver(RadioEvent::RADIO_ICC_STATUS_CHANGED);
215                 break;
216             case RadioEvent::RADIO_OFF:
217                 observerHandler->RegObserver(what, observerCallBack);
218                 if (GetTelRilModem(slotId) == nullptr) {
219                     TELEPHONY_LOGE("telRilModem_ slotId is valid");
220                     return TELEPHONY_ERR_LOCAL_PTR_NULL;
221                 }
222                 if (GetTelRilModem(slotId)->radioState_ == CORE_SERVICE_POWER_OFF ||
223                     CORE_SERVICE_POWER_NOT_AVAILABLE == GetTelRilModem(slotId)->radioState_) {
224                     observerHandler->NotifyObserver(what);
225                 }
226                 break;
227             default:
228                 TELEPHONY_LOGD("RegisterCoreNotify default what:%{public}d, slotId:%{public}d", what, slotId);
229                 observerHandler->RegObserver(what, observerCallBack);
230                 break;
231         }
232     }
233     return TELEPHONY_ERR_SUCCESS;
234 }
235 
UnRegisterCoreNotify(int32_t slotId,const std::shared_ptr<AppExecFwk::EventHandler> & observerCallBack,int32_t what)236 int32_t TelRilManager::UnRegisterCoreNotify(
237     int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &observerCallBack, int32_t what)
238 {
239     std::lock_guard<std::mutex> lock_l(mutex_);
240     std::shared_ptr<ObserverHandler> observerHandler = GetObserverHandler(slotId);
241     if (observerHandler != nullptr) {
242         observerHandler->Remove(what, observerCallBack);
243     } else {
244         TELEPHONY_LOGE("observerHandler_ is null");
245     }
246     return TELEPHONY_ERR_SUCCESS;
247 }
248 
249 /*********************** TelRilModem start **************************/
SetRadioState(int32_t slotId,int32_t fun,int32_t rst,const AppExecFwk::InnerEvent::Pointer & response)250 int32_t TelRilManager::SetRadioState(
251     int32_t slotId, int32_t fun, int32_t rst, const AppExecFwk::InnerEvent::Pointer &response)
252 {
253     return TaskSchedule(response, "TelRilModem", GetTelRilModem(slotId), &TelRilModem::SetRadioState, fun, rst);
254 }
255 
GetRadioState(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)256 int32_t TelRilManager::GetRadioState(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
257 {
258     return TaskSchedule(response, "TelRilModem", GetTelRilModem(slotId), &TelRilModem::GetRadioState);
259 }
260 
ShutDown(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)261 int32_t TelRilManager::ShutDown(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
262 {
263     return TaskSchedule(response, "TelRilModem", GetTelRilModem(slotId), &TelRilModem::ShutDown);
264 }
265 
GetVoiceRadioTechnology(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)266 int32_t TelRilManager::GetVoiceRadioTechnology(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
267 {
268     return TaskSchedule(response, "TelRilModem", GetTelRilModem(slotId), &TelRilModem::GetVoiceRadioTechnology);
269 }
270 
GetImei(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)271 int32_t TelRilManager::GetImei(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
272 {
273     return TaskSchedule(response, "TelRilModem", GetTelRilModem(slotId), &TelRilModem::GetImei);
274 }
275 
GetMeid(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)276 int32_t TelRilManager::GetMeid(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
277 {
278     return TaskSchedule(response, "TelRilModem", GetTelRilModem(slotId), &TelRilModem::GetMeid);
279 }
280 
GetBasebandVersion(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)281 int32_t TelRilManager::GetBasebandVersion(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
282 {
283     return TaskSchedule(response, "TelRilModem", GetTelRilModem(slotId), &TelRilModem::GetBasebandVersion);
284 }
285 
286 /*********************** TelRilModem end ***************************/
287 /*********************** TelRilCall start **************************/
Dial(int32_t slotId,std::string address,int32_t clirMode,const AppExecFwk::InnerEvent::Pointer & response)288 int32_t TelRilManager::Dial(
289     int32_t slotId, std::string address, int32_t clirMode, const AppExecFwk::InnerEvent::Pointer &response)
290 {
291     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::Dial, address, clirMode);
292 }
293 
Reject(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)294 int32_t TelRilManager::Reject(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
295 {
296     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::Reject);
297 }
298 
HoldCall(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)299 int32_t TelRilManager::HoldCall(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
300 {
301     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::HoldCall);
302 }
303 
UnHoldCall(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)304 int32_t TelRilManager::UnHoldCall(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
305 {
306     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::UnHoldCall);
307 }
308 
SwitchCall(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)309 int32_t TelRilManager::SwitchCall(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
310 {
311     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SwitchCall);
312 }
313 
Hangup(int32_t slotId,int32_t gsmIndex,const AppExecFwk::InnerEvent::Pointer & response)314 int32_t TelRilManager::Hangup(int32_t slotId, int32_t gsmIndex, const AppExecFwk::InnerEvent::Pointer &response)
315 {
316     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::Hangup, gsmIndex);
317 }
318 
Answer(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)319 int32_t TelRilManager::Answer(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
320 {
321     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::Answer);
322 }
323 
CombineConference(int32_t slotId,int32_t callType,const AppExecFwk::InnerEvent::Pointer & response)324 int32_t TelRilManager::CombineConference(
325     int32_t slotId, int32_t callType, const AppExecFwk::InnerEvent::Pointer &response)
326 {
327     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::CombineConference, callType);
328 }
329 
SeparateConference(int32_t slotId,int32_t callIndex,int32_t callType,const AppExecFwk::InnerEvent::Pointer & response)330 int32_t TelRilManager::SeparateConference(
331     int32_t slotId, int32_t callIndex, int32_t callType, const AppExecFwk::InnerEvent::Pointer &response)
332 {
333     return TaskSchedule(
334         response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SeparateConference, callIndex, callType);
335 }
336 
CallSupplement(int32_t slotId,int32_t type,const AppExecFwk::InnerEvent::Pointer & response)337 int32_t TelRilManager::CallSupplement(int32_t slotId, int32_t type, const AppExecFwk::InnerEvent::Pointer &response)
338 {
339     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::CallSupplement, type);
340 }
341 
GetCallList(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)342 int32_t TelRilManager::GetCallList(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
343 {
344     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetCallList);
345 }
346 
GetCallWaiting(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)347 int32_t TelRilManager::GetCallWaiting(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
348 {
349     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetCallWaiting);
350 }
351 
SetCallWaiting(int32_t slotId,const int32_t activate,const AppExecFwk::InnerEvent::Pointer & response)352 int32_t TelRilManager::SetCallWaiting(
353     int32_t slotId, const int32_t activate, const AppExecFwk::InnerEvent::Pointer &response)
354 {
355     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetCallWaiting, activate);
356 }
357 
GetCallTransferInfo(int32_t slotId,const int32_t reason,const AppExecFwk::InnerEvent::Pointer & response)358 int32_t TelRilManager::GetCallTransferInfo(
359     int32_t slotId, const int32_t reason, const AppExecFwk::InnerEvent::Pointer &response)
360 {
361     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetCallTransferInfo, reason);
362 }
363 
SetCallTransferInfo(int32_t slotId,const CallTransferParam & callTransfer,const AppExecFwk::InnerEvent::Pointer & response)364 int32_t TelRilManager::SetCallTransferInfo(
365     int32_t slotId, const CallTransferParam &callTransfer, const AppExecFwk::InnerEvent::Pointer &response)
366 {
367     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetCallTransferInfo,
368         callTransfer.reason, callTransfer.mode, callTransfer.number, callTransfer.classx);
369 }
370 
GetClip(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)371 int32_t TelRilManager::GetClip(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
372 {
373     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetClip);
374 }
375 
SetClip(int32_t slotId,const int32_t action,const AppExecFwk::InnerEvent::Pointer & response)376 int32_t TelRilManager::SetClip(int32_t slotId, const int32_t action, const AppExecFwk::InnerEvent::Pointer &response)
377 {
378     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetClip, action);
379 }
380 
GetClir(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)381 int32_t TelRilManager::GetClir(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
382 {
383     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetClir);
384 }
385 
SetClir(int32_t slotId,const int32_t action,const AppExecFwk::InnerEvent::Pointer & response)386 int32_t TelRilManager::SetClir(int32_t slotId, const int32_t action, const AppExecFwk::InnerEvent::Pointer &response)
387 {
388     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetClir, action);
389 }
390 
GetCallRestriction(int32_t slotId,std::string fac,const AppExecFwk::InnerEvent::Pointer & response)391 int32_t TelRilManager::GetCallRestriction(
392     int32_t slotId, std::string fac, const AppExecFwk::InnerEvent::Pointer &response)
393 {
394     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetCallRestriction, fac);
395 }
396 
SetCallRestriction(int32_t slotId,const CallRestrictionParam & callRestriction,const AppExecFwk::InnerEvent::Pointer & response)397 int32_t TelRilManager::SetCallRestriction(
398     int32_t slotId, const CallRestrictionParam &callRestriction, const AppExecFwk::InnerEvent::Pointer &response)
399 {
400     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetCallRestriction,
401         callRestriction.fac, callRestriction.mode, callRestriction.password);
402 }
403 
SetBarringPassword(int32_t slotId,const char * oldPassword,const char * newPassword,const std::string & restrictionType,const AppExecFwk::InnerEvent::Pointer & response)404 int32_t TelRilManager::SetBarringPassword(int32_t slotId, const char *oldPassword,
405     const char *newPassword, const std::string &restrictionType, const AppExecFwk::InnerEvent::Pointer &response)
406 {
407     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetBarringPassword,
408         restrictionType, oldPassword, newPassword);
409 }
410 
SendDtmf(int32_t slotId,const DtmfParam & dtmfParam,const AppExecFwk::InnerEvent::Pointer & response)411 int32_t TelRilManager::SendDtmf(
412     int32_t slotId, const DtmfParam &dtmfParam, const AppExecFwk::InnerEvent::Pointer &response)
413 {
414     // Define the function pointer type here, it is necessary to deal with
415     // the function pointer difference caused by overloading
416     typedef int32_t (TelRilCall::*SendDtmfFunc)(
417         const std::string &, int32_t, int32_t, int32_t, const AppExecFwk::InnerEvent::Pointer &);
418     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), (SendDtmfFunc)&TelRilCall::SendDtmf,
419         dtmfParam.sDTMFCode, dtmfParam.index, dtmfParam.switchOn, dtmfParam.switchOff);
420 }
421 
SendDtmf(int32_t slotId,char cDTMFCode,int32_t index,const AppExecFwk::InnerEvent::Pointer & response)422 int32_t TelRilManager::SendDtmf(
423     int32_t slotId, char cDTMFCode, int32_t index, const AppExecFwk::InnerEvent::Pointer &response)
424 {
425     // Define the function pointer type here, it is necessary to deal with
426     // the function pointer difference caused by overloading
427     typedef int32_t (TelRilCall::*SendDtmfFunc)(char, int32_t, const AppExecFwk::InnerEvent::Pointer &);
428     return TaskSchedule(
429         response, "TelRilCall", GetTelRilCall(slotId), (SendDtmfFunc)&TelRilCall::SendDtmf, cDTMFCode, index);
430 }
431 
StartDtmf(int32_t slotId,char cDTMFCode,int32_t index,const AppExecFwk::InnerEvent::Pointer & response)432 int32_t TelRilManager::StartDtmf(
433     int32_t slotId, char cDTMFCode, int32_t index, const AppExecFwk::InnerEvent::Pointer &response)
434 {
435     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::StartDtmf, cDTMFCode, index);
436 }
437 
StopDtmf(int32_t slotId,int32_t index,const AppExecFwk::InnerEvent::Pointer & response)438 int32_t TelRilManager::StopDtmf(int32_t slotId, int32_t index, const AppExecFwk::InnerEvent::Pointer &response)
439 {
440     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::StopDtmf, index);
441 }
442 
SetCallPreferenceMode(int32_t slotId,const int32_t mode,const AppExecFwk::InnerEvent::Pointer & response)443 int32_t TelRilManager::SetCallPreferenceMode(
444     int32_t slotId, const int32_t mode, const AppExecFwk::InnerEvent::Pointer &response)
445 {
446     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetCallPreferenceMode, mode);
447 }
448 
GetCallPreferenceMode(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)449 int32_t TelRilManager::GetCallPreferenceMode(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
450 {
451     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetCallPreferenceMode);
452 }
453 
SetUssd(int32_t slotId,const std::string str,const AppExecFwk::InnerEvent::Pointer & response)454 int32_t TelRilManager::SetUssd(int32_t slotId, const std::string str, const AppExecFwk::InnerEvent::Pointer &response)
455 {
456     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetUssd, str);
457 }
458 
GetUssd(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)459 int32_t TelRilManager::GetUssd(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
460 {
461     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetUssd);
462 }
463 
SetMute(int32_t slotId,const int32_t mute,const AppExecFwk::InnerEvent::Pointer & response)464 int32_t TelRilManager::SetMute(int32_t slotId, const int32_t mute, const AppExecFwk::InnerEvent::Pointer &response)
465 {
466     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetMute, mute);
467 }
468 
GetMute(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)469 int32_t TelRilManager::GetMute(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
470 {
471     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetMute);
472 }
473 
GetEmergencyCallList(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)474 int32_t TelRilManager::GetEmergencyCallList(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
475 {
476     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetEmergencyCallList);
477 }
478 
SetEmergencyCallList(int32_t slotId,const std::vector<EmergencyCall> & eccVec,const AppExecFwk::InnerEvent::Pointer & response)479 int32_t TelRilManager::SetEmergencyCallList(
480     int32_t slotId, const std::vector<EmergencyCall> &eccVec, const AppExecFwk::InnerEvent::Pointer &response)
481 {
482     TELEPHONY_LOGD("SetEmergencyCallList start");
483     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetEmergencyCallList, eccVec);
484 }
485 
GetCallFailReason(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)486 int32_t TelRilManager::GetCallFailReason(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
487 {
488     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::GetCallFailReason);
489 }
490 
CloseUnFinishedUssd(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)491 int32_t TelRilManager::CloseUnFinishedUssd(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
492 {
493     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::CloseUnFinishedUssd);
494 }
495 
SetVoNRSwitch(int32_t slotId,const int32_t state,const AppExecFwk::InnerEvent::Pointer & response)496 int32_t TelRilManager::SetVoNRSwitch(
497     int32_t slotId, const int32_t state, const AppExecFwk::InnerEvent::Pointer &response)
498 {
499     return TaskSchedule(response, "TelRilCall", GetTelRilCall(slotId), &TelRilCall::SetVoNRSwitch, state);
500 }
501 
502 /*********************** TelRilCall end ****************************/
503 /*********************** TelRilData start **************************/
SetInitApnInfo(int32_t slotId,const DataProfile & dataProfile,const AppExecFwk::InnerEvent::Pointer & response)504 int32_t TelRilManager::SetInitApnInfo(
505     int32_t slotId, const DataProfile &dataProfile, const AppExecFwk::InnerEvent::Pointer &response)
506 {
507     return TaskSchedule(response, "TelRilData", GetTelRilData(slotId), &TelRilData::SetInitApnInfo, dataProfile);
508 }
509 
ActivatePdpContext(int32_t slotId,const ActivateDataParam & activateData,const AppExecFwk::InnerEvent::Pointer & response)510 int32_t TelRilManager::ActivatePdpContext(
511     int32_t slotId, const ActivateDataParam &activateData, const AppExecFwk::InnerEvent::Pointer &response)
512 {
513     return TaskSchedule(response, "TelRilData", GetTelRilData(slotId), &TelRilData::ActivatePdpContext,
514         activateData.radioTechnology, activateData.dataProfile, activateData.isRoaming, activateData.allowRoaming);
515 }
516 
DeactivatePdpContext(int32_t slotId,int32_t cid,int32_t reason,const AppExecFwk::InnerEvent::Pointer & response)517 int32_t TelRilManager::DeactivatePdpContext(
518     int32_t slotId, int32_t cid, int32_t reason, const AppExecFwk::InnerEvent::Pointer &response)
519 {
520     return TaskSchedule(response, "TelRilData", GetTelRilData(slotId), &TelRilData::DeactivatePdpContext, cid, reason);
521 }
522 
GetPdpContextList(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)523 int32_t TelRilManager::GetPdpContextList(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
524 {
525     return TaskSchedule(response, "TelRilData", GetTelRilData(slotId), &TelRilData::GetPdpContextList);
526 }
527 
SetLinkBandwidthReportingRule(int32_t slotId,LinkBandwidthRule linkBandwidth,const AppExecFwk::InnerEvent::Pointer & response)528 int32_t TelRilManager::SetLinkBandwidthReportingRule(
529     int32_t slotId, LinkBandwidthRule linkBandwidth, const AppExecFwk::InnerEvent::Pointer &response)
530 {
531     return TaskSchedule(
532         response, "TelRilData", GetTelRilData(slotId), &TelRilData::SetLinkBandwidthReportingRule, linkBandwidth);
533 }
534 
GetLinkBandwidthInfo(int32_t slotId,const int32_t cid,const AppExecFwk::InnerEvent::Pointer & response)535 int32_t TelRilManager::GetLinkBandwidthInfo(
536     int32_t slotId, const int32_t cid, const AppExecFwk::InnerEvent::Pointer &response)
537 {
538     return TaskSchedule(response, "TelRilData", GetTelRilData(slotId), &TelRilData::GetLinkBandwidthInfo, cid);
539 }
540 
SetDataPermitted(int32_t slotId,int32_t dataPermitted,const AppExecFwk::InnerEvent::Pointer & response)541 int32_t TelRilManager::SetDataPermitted(
542     int32_t slotId, int32_t dataPermitted, const AppExecFwk::InnerEvent::Pointer &response)
543 {
544     return TaskSchedule(response, "TelRilData", GetTelRilData(slotId), &TelRilData::SetDataPermitted, dataPermitted);
545 }
546 
GetLinkCapability(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)547 int32_t TelRilManager::GetLinkCapability(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
548 {
549     return TaskSchedule(response, "TelRilData", GetTelRilData(slotId), &TelRilData::GetLinkCapability);
550 }
551 
CleanAllConnections(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)552 int32_t TelRilManager::CleanAllConnections(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
553 {
554     return TaskSchedule(response, "TelRilData", GetTelRilData(slotId), &TelRilData::CleanAllConnections);
555 }
556 
557 /*********************** TelRilData end ****************************/
558 /*********************** TelRilNetwork start ***********************/
GetSignalStrength(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)559 int32_t TelRilManager::GetSignalStrength(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
560 {
561     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetSignalStrength);
562 }
563 
GetCsRegStatus(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)564 int32_t TelRilManager::GetCsRegStatus(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
565 {
566     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetCsRegStatus);
567 }
568 
GetPsRegStatus(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)569 int32_t TelRilManager::GetPsRegStatus(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
570 {
571     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetPsRegStatus);
572 }
573 
GetOperatorInfo(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)574 int32_t TelRilManager::GetOperatorInfo(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
575 {
576     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetOperatorInfo);
577 }
578 
GetNetworkSearchInformation(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)579 int32_t TelRilManager::GetNetworkSearchInformation(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
580 {
581     return TaskSchedule(
582         response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetNetworkSearchInformation);
583 }
584 
GetNetworkSelectionMode(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)585 int32_t TelRilManager::GetNetworkSelectionMode(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
586 {
587     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetNetworkSelectionMode);
588 }
589 
SetNetworkSelectionMode(int32_t slotId,int32_t automaticFlag,std::string oper,const AppExecFwk::InnerEvent::Pointer & response)590 int32_t TelRilManager::SetNetworkSelectionMode(
591     int32_t slotId, int32_t automaticFlag, std::string oper, const AppExecFwk::InnerEvent::Pointer &response)
592 {
593     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::SetNetworkSelectionMode,
594         automaticFlag, oper);
595 }
596 
GetPreferredNetwork(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)597 int32_t TelRilManager::GetPreferredNetwork(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
598 {
599     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetPreferredNetwork);
600 }
601 
SetPreferredNetwork(int32_t slotId,int32_t preferredNetworkType,const AppExecFwk::InnerEvent::Pointer & response)602 int32_t TelRilManager::SetPreferredNetwork(
603     int32_t slotId, int32_t preferredNetworkType, const AppExecFwk::InnerEvent::Pointer &response)
604 {
605     return TaskSchedule(
606         response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::SetPreferredNetwork, preferredNetworkType);
607 }
608 
GetCellInfoList(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)609 int32_t TelRilManager::GetCellInfoList(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
610 {
611     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetCellInfoList);
612 }
613 
GetCurrentCellInfo(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)614 int32_t TelRilManager::GetCurrentCellInfo(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
615 {
616     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetCurrentCellInfo);
617 }
618 
GetPhysicalChannelConfig(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)619 int32_t TelRilManager::GetPhysicalChannelConfig(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
620 {
621     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetPhysicalChannelConfig);
622 }
623 
SetLocateUpdates(int32_t slotId,HRilRegNotifyMode mode,const AppExecFwk::InnerEvent::Pointer & response)624 int32_t TelRilManager::SetLocateUpdates(
625     int32_t slotId, HRilRegNotifyMode mode, const AppExecFwk::InnerEvent::Pointer &response)
626 {
627     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::SetLocateUpdates, mode);
628 }
629 
SetNotificationFilter(int32_t slotId,int32_t newFilter,const AppExecFwk::InnerEvent::Pointer & response)630 int32_t TelRilManager::SetNotificationFilter(
631     int32_t slotId, int32_t newFilter, const AppExecFwk::InnerEvent::Pointer &response)
632 {
633     return TaskSchedule(
634         response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::SetNotificationFilter, newFilter);
635 }
636 
SetDeviceState(int32_t slotId,int32_t deviceStateType,bool deviceStateOn,const AppExecFwk::InnerEvent::Pointer & response)637 int32_t TelRilManager::SetDeviceState(
638     int32_t slotId, int32_t deviceStateType, bool deviceStateOn, const AppExecFwk::InnerEvent::Pointer &response)
639 {
640     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::SetDeviceState,
641         deviceStateType, deviceStateOn);
642 }
643 
SetNrOptionMode(int32_t slotId,int32_t mode,const AppExecFwk::InnerEvent::Pointer & response)644 int32_t TelRilManager::SetNrOptionMode(int32_t slotId, int32_t mode, const AppExecFwk::InnerEvent::Pointer &response)
645 {
646     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::SetNrOptionMode, mode);
647 }
648 
GetNrOptionMode(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)649 int32_t TelRilManager::GetNrOptionMode(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
650 {
651     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetNrOptionMode);
652 }
653 
GetRrcConnectionState(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)654 int32_t TelRilManager::GetRrcConnectionState(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
655 {
656     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetRrcConnectionState);
657 }
658 
GetNrSsbId(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)659 int32_t TelRilManager::GetNrSsbId(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
660 {
661     return TaskSchedule(response, "TelRilNetwork", GetTelRilNetwork(slotId), &TelRilNetwork::GetNrSsbId);
662 }
663 
664 /*********************** TelRilNetwork end ****************************/
665 /*********************** TelRilSms start ******************************/
SendGsmSms(int32_t slotId,std::string smscPdu,std::string pdu,const AppExecFwk::InnerEvent::Pointer & response)666 int32_t TelRilManager::SendGsmSms(
667     int32_t slotId, std::string smscPdu, std::string pdu, const AppExecFwk::InnerEvent::Pointer &response)
668 {
669     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::SendGsmSms, smscPdu, pdu);
670 }
671 
SendCdmaSms(int32_t slotId,std::string pdu,const AppExecFwk::InnerEvent::Pointer & response)672 int32_t TelRilManager::SendCdmaSms(int32_t slotId, std::string pdu, const AppExecFwk::InnerEvent::Pointer &response)
673 {
674     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::SendCdmaSms, pdu);
675 }
676 
AddSimMessage(int32_t slotId,const SimMessageParam & simMessage,const AppExecFwk::InnerEvent::Pointer & response)677 int32_t TelRilManager::AddSimMessage(
678     int32_t slotId, const SimMessageParam &simMessage, const AppExecFwk::InnerEvent::Pointer &response)
679 {
680     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::AddSimMessage, simMessage.status,
681         simMessage.smscPdu, simMessage.pdu);
682 }
683 
DelSimMessage(int32_t slotId,int32_t gsmIndex,const AppExecFwk::InnerEvent::Pointer & response)684 int32_t TelRilManager::DelSimMessage(int32_t slotId, int32_t gsmIndex, const AppExecFwk::InnerEvent::Pointer &response)
685 {
686     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::DelSimMessage, gsmIndex);
687 }
688 
UpdateSimMessage(int32_t slotId,const SimMessageParam & simMessage,const AppExecFwk::InnerEvent::Pointer & response)689 int32_t TelRilManager::UpdateSimMessage(
690     int32_t slotId, const SimMessageParam &simMessage, const AppExecFwk::InnerEvent::Pointer &response)
691 {
692     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::UpdateSimMessage, simMessage.gsmIndex,
693         simMessage.status, simMessage.smscPdu, simMessage.pdu);
694 }
695 
GetSmscAddr(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)696 int32_t TelRilManager::GetSmscAddr(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
697 {
698     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::GetSmscAddr);
699 }
700 
GetCdmaCBConfig(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)701 int32_t TelRilManager::GetCdmaCBConfig(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
702 {
703     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::GetCdmaCBConfig);
704 }
705 
SetSmscAddr(int32_t slotId,int32_t tosca,std::string address,const AppExecFwk::InnerEvent::Pointer & response)706 int32_t TelRilManager::SetSmscAddr(
707     int32_t slotId, int32_t tosca, std::string address, const AppExecFwk::InnerEvent::Pointer &response)
708 {
709     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::SetSmscAddr, tosca, address);
710 }
711 
SetCBConfig(int32_t slotId,const CBConfigParam & cbConfig,const AppExecFwk::InnerEvent::Pointer & response)712 int32_t TelRilManager::SetCBConfig(
713     int32_t slotId, const CBConfigParam &cbConfig, const AppExecFwk::InnerEvent::Pointer &response)
714 {
715     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::SetCBConfig, cbConfig.mode,
716         cbConfig.idList, cbConfig.dcsList);
717 }
718 
SetCdmaCBConfig(int32_t slotId,CdmaCBConfigInfoList & cdmaCBConfigInfoList,const AppExecFwk::InnerEvent::Pointer & response)719 int32_t TelRilManager::SetCdmaCBConfig(
720     int32_t slotId, CdmaCBConfigInfoList &cdmaCBConfigInfoList, const AppExecFwk::InnerEvent::Pointer &response)
721 {
722     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::SetCdmaCBConfig, cdmaCBConfigInfoList);
723 }
724 
GetCBConfig(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)725 int32_t TelRilManager::GetCBConfig(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
726 {
727     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::GetCBConfig);
728 }
729 
SendSmsMoreMode(int32_t slotId,std::string smscPdu,std::string pdu,const AppExecFwk::InnerEvent::Pointer & response)730 int32_t TelRilManager::SendSmsMoreMode(
731     int32_t slotId, std::string smscPdu, std::string pdu, const AppExecFwk::InnerEvent::Pointer &response)
732 {
733     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::SendSmsMoreMode, smscPdu, pdu);
734 }
735 
SendSmsAck(int32_t slotId,bool success,int32_t cause,const AppExecFwk::InnerEvent::Pointer & response)736 int32_t TelRilManager::SendSmsAck(
737     int32_t slotId, bool success, int32_t cause, const AppExecFwk::InnerEvent::Pointer &response)
738 {
739     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::SendSmsAck, success, cause);
740 }
741 
AddCdmaSimMessage(int32_t slotId,int32_t status,std::string pdu,const AppExecFwk::InnerEvent::Pointer & response)742 int32_t TelRilManager::AddCdmaSimMessage(
743     int32_t slotId, int32_t status, std::string pdu, const AppExecFwk::InnerEvent::Pointer &response)
744 {
745     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::AddCdmaSimMessage, status, pdu);
746 }
747 
DelCdmaSimMessage(int32_t slotId,int32_t cdmaIndex,const AppExecFwk::InnerEvent::Pointer & response)748 int32_t TelRilManager::DelCdmaSimMessage(
749     int32_t slotId, int32_t cdmaIndex, const AppExecFwk::InnerEvent::Pointer &response)
750 {
751     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::DelCdmaSimMessage, cdmaIndex);
752 }
753 
UpdateCdmaSimMessage(int32_t slotId,const CdmaSimMessageParam & cdmaSimMsg,const AppExecFwk::InnerEvent::Pointer & response)754 int32_t TelRilManager::UpdateCdmaSimMessage(
755     int32_t slotId, const CdmaSimMessageParam &cdmaSimMsg, const AppExecFwk::InnerEvent::Pointer &response)
756 {
757     return TaskSchedule(response, "TelRilSms", GetTelRilSms(slotId), &TelRilSms::UpdateCdmaSimMessage,
758         cdmaSimMsg.cdmaIndex, cdmaSimMsg.status, cdmaSimMsg.pdu);
759 }
760 
761 /*********************** TelRilSms end ********************************/
762 /*********************** TelRilSim start ******************************/
GetSimStatus(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)763 int32_t TelRilManager::GetSimStatus(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
764 {
765     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::GetSimStatus);
766 }
767 
GetSimIO(int32_t slotId,SimIoRequestInfo data,const AppExecFwk::InnerEvent::Pointer & response)768 int32_t TelRilManager::GetSimIO(int32_t slotId, SimIoRequestInfo data, const AppExecFwk::InnerEvent::Pointer &response)
769 {
770     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::GetSimIO, data);
771 }
772 
GetImsi(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)773 int32_t TelRilManager::GetImsi(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
774 {
775     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::GetImsi);
776 }
777 
GetSimLockStatus(int32_t slotId,std::string fac,const AppExecFwk::InnerEvent::Pointer & response)778 int32_t TelRilManager::GetSimLockStatus(
779     int32_t slotId, std::string fac, const AppExecFwk::InnerEvent::Pointer &response)
780 {
781     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::GetSimLockStatus, fac);
782 }
783 
SetSimLock(int32_t slotId,const SimLockParam & simLock,const AppExecFwk::InnerEvent::Pointer & response)784 int32_t TelRilManager::SetSimLock(
785     int32_t slotId, const SimLockParam &simLock, const AppExecFwk::InnerEvent::Pointer &response)
786 {
787     return TaskSchedule(
788         response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SetSimLock, simLock.fac, simLock.mode, simLock.passwd);
789 }
790 
ChangeSimPassword(int32_t slotId,const SimPasswordParam & simPassword,const AppExecFwk::InnerEvent::Pointer & response)791 int32_t TelRilManager::ChangeSimPassword(
792     int32_t slotId, const SimPasswordParam &simPassword, const AppExecFwk::InnerEvent::Pointer &response)
793 {
794     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::ChangeSimPassword, simPassword.fac,
795         simPassword.oldPassword, simPassword.newPassword, simPassword.passwordLength);
796 }
797 
UnlockPin(int32_t slotId,const std::string & pin,const AppExecFwk::InnerEvent::Pointer & response)798 int32_t TelRilManager::UnlockPin(
799     int32_t slotId, const std::string &pin, const AppExecFwk::InnerEvent::Pointer &response)
800 {
801     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::UnlockPin, pin);
802 }
803 
UnlockPuk(int32_t slotId,const std::string & puk,const std::string & pin,const AppExecFwk::InnerEvent::Pointer & response)804 int32_t TelRilManager::UnlockPuk(
805     int32_t slotId, const std::string &puk, const std::string &pin, const AppExecFwk::InnerEvent::Pointer &response)
806 {
807     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::UnlockPuk, puk, pin);
808 }
809 
UnlockPin2(int32_t slotId,const std::string & pin2,const AppExecFwk::InnerEvent::Pointer & response)810 int32_t TelRilManager::UnlockPin2(
811     int32_t slotId, const std::string &pin2, const AppExecFwk::InnerEvent::Pointer &response)
812 {
813     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::UnlockPin2, pin2);
814 }
815 
UnlockPuk2(int32_t slotId,const std::string & puk2,const std::string & pin2,const AppExecFwk::InnerEvent::Pointer & response)816 int32_t TelRilManager::UnlockPuk2(
817     int32_t slotId, const std::string &puk2, const std::string &pin2, const AppExecFwk::InnerEvent::Pointer &response)
818 {
819     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::UnlockPuk2, puk2, pin2);
820 }
821 
SetActiveSim(int32_t slotId,int32_t index,int32_t enable,const AppExecFwk::InnerEvent::Pointer & response)822 int32_t TelRilManager::SetActiveSim(
823     int32_t slotId, int32_t index, int32_t enable, const AppExecFwk::InnerEvent::Pointer &response)
824 {
825     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SetActiveSim, index, enable);
826 }
827 
SendTerminalResponseCmd(int32_t slotId,const std::string & strCmd,const AppExecFwk::InnerEvent::Pointer & response)828 int32_t TelRilManager::SendTerminalResponseCmd(
829     int32_t slotId, const std::string &strCmd, const AppExecFwk::InnerEvent::Pointer &response)
830 {
831     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SimStkSendTerminalResponse, strCmd);
832 }
833 
SendEnvelopeCmd(int32_t slotId,const std::string & strCmd,const AppExecFwk::InnerEvent::Pointer & response)834 int32_t TelRilManager::SendEnvelopeCmd(
835     int32_t slotId, const std::string &strCmd, const AppExecFwk::InnerEvent::Pointer &response)
836 {
837     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SimStkSendEnvelope, strCmd);
838 }
839 
SendCallSetupRequestResult(int32_t slotId,bool accept,const AppExecFwk::InnerEvent::Pointer & response)840 int32_t TelRilManager::SendCallSetupRequestResult(
841     int32_t slotId, bool accept, const AppExecFwk::InnerEvent::Pointer &response)
842 {
843     return TaskSchedule(
844         response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SimStkSendCallSetupRequestResult, accept);
845 }
846 
SimStkIsReady(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)847 int32_t TelRilManager::SimStkIsReady(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
848 {
849     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SimStkIsReady);
850 }
851 
SimOpenLogicalChannel(int32_t slotId,const std::string & appID,const int32_t p2,const AppExecFwk::InnerEvent::Pointer & response)852 int32_t TelRilManager::SimOpenLogicalChannel(
853     int32_t slotId, const std::string &appID, const int32_t p2, const AppExecFwk::InnerEvent::Pointer &response)
854 {
855     return TaskSchedule(
856         response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SimOpenLogicalChannel, appID.substr(0), p2);
857 }
858 
SimCloseLogicalChannel(int32_t slotId,const int32_t channelId,const AppExecFwk::InnerEvent::Pointer & response)859 int32_t TelRilManager::SimCloseLogicalChannel(
860     int32_t slotId, const int32_t channelId, const AppExecFwk::InnerEvent::Pointer &response)
861 {
862     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SimCloseLogicalChannel, channelId);
863 }
864 
SimTransmitApduLogicalChannel(int32_t slotId,const ApduSimIORequestInfo & reqInfo,const AppExecFwk::InnerEvent::Pointer & response)865 int32_t TelRilManager::SimTransmitApduLogicalChannel(
866     int32_t slotId, const ApduSimIORequestInfo &reqInfo, const AppExecFwk::InnerEvent::Pointer &response)
867 {
868     return TaskSchedule(
869         response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SimTransmitApduLogicalChannel, reqInfo);
870 }
871 
SimTransmitApduBasicChannel(int32_t slotId,const ApduSimIORequestInfo & reqInfo,const AppExecFwk::InnerEvent::Pointer & response)872 int32_t TelRilManager::SimTransmitApduBasicChannel(
873     int32_t slotId, const ApduSimIORequestInfo &reqInfo, const AppExecFwk::InnerEvent::Pointer &response)
874 {
875     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SimTransmitApduBasicChannel, reqInfo);
876 }
877 
SimAuthentication(int32_t slotId,const SimAuthenticationRequestInfo & reqInfo,const AppExecFwk::InnerEvent::Pointer & response)878 int32_t TelRilManager::SimAuthentication(
879     int32_t slotId, const SimAuthenticationRequestInfo &reqInfo, const AppExecFwk::InnerEvent::Pointer &response)
880 {
881     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SimAuthentication, reqInfo);
882 }
883 
UnlockSimLock(int32_t slotId,int32_t lockType,std::string password,const AppExecFwk::InnerEvent::Pointer & response)884 int32_t TelRilManager::UnlockSimLock(
885     int32_t slotId, int32_t lockType, std::string password, const AppExecFwk::InnerEvent::Pointer &response)
886 {
887     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::UnlockSimLock, lockType, password);
888 }
889 
SendSimMatchedOperatorInfo(int32_t slotId,const NcfgOperatorInfo & reqInfo,const AppExecFwk::InnerEvent::Pointer & response)890 int32_t TelRilManager::SendSimMatchedOperatorInfo(
891     int32_t slotId, const NcfgOperatorInfo &reqInfo, const AppExecFwk::InnerEvent::Pointer &response)
892 {
893     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SendSimMatchedOperatorInfo, reqInfo);
894 }
895 
GetRadioProtocol(int32_t slotId,const AppExecFwk::InnerEvent::Pointer & response)896 int32_t TelRilManager::GetRadioProtocol(int32_t slotId, const AppExecFwk::InnerEvent::Pointer &response)
897 {
898     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::GetRadioProtocol);
899 }
900 
SetRadioProtocol(int32_t slotId,RadioProtocol radioProtocol,const AppExecFwk::InnerEvent::Pointer & response)901 int32_t TelRilManager::SetRadioProtocol(
902     int32_t slotId, RadioProtocol radioProtocol, const AppExecFwk::InnerEvent::Pointer &response)
903 {
904     return TaskSchedule(response, "TelRilSim", GetTelRilSim(slotId), &TelRilSim::SetRadioProtocol, radioProtocol);
905 }
906 /*********************** TelRilSim end ********************************/
907 
HandleRilInterfaceStatusCallback(const OHOS::HDI::ServiceManager::V1_0::ServiceStatus & status)908 void TelRilManager::HandleRilInterfaceStatusCallback(const OHOS::HDI::ServiceManager::V1_0::ServiceStatus &status)
909 {
910     TELEPHONY_LOGD("TelRilManager::HandleRilInterfaceCallback, service name %{public}s %{public}d",
911         status.serviceName.c_str(), status.status);
912     if (status.serviceName != std::string(RIL_INTERFACE_SERVICE_NAME)) {
913         return;
914     }
915     if (status.deviceClass != DEVICE_CLASS_DEFAULT) {
916         TELEPHONY_LOGE("TelRilManager::HandleRilInterfaceCallback, deviceClass mismatch");
917         return;
918     }
919     if (status.status == SERVIE_STATUS_START) {
920         if (!ReConnectRilInterface()) {
921             TELEPHONY_LOGE("TelRilManager::HandleRilInterfaceCallback, ReConnectRilAdapterService fail");
922             return;
923         }
924         TELEPHONY_LOGI("TelRilManager::HandleRilInterfaceCallback, reconnect riladapter service success");
925         return;
926     }
927     if (status.status == SERVIE_STATUS_STOP) {
928         if (!DisConnectRilInterface()) {
929             TELEPHONY_LOGE("TelRilManager::HandleRilInterfaceCallback, DisConnectRilAdapterService fail");
930             return;
931         }
932         int32_t size = static_cast<int32_t>(telRilModem_.size());
933         for (int32_t slotId = SIM_SLOT_0; slotId < size; slotId++) {
934             if (GetTelRilModem(slotId) != nullptr) {
935                 GetTelRilModem(slotId)->OnRilAdapterHostDied();
936             }
937         }
938         ReleaseRunningLock();
939         TELEPHONY_LOGI("TelRilManager::HandleRilInterfaceCallback, disconnect riladapter service successfully!");
940         return;
941     }
942 }
943 
RegisterHdfStatusListener()944 bool TelRilManager::RegisterHdfStatusListener()
945 {
946     if (servMgr_ == nullptr) {
947         servMgr_ = OHOS::HDI::ServiceManager::V1_0::IServiceManager::Get();
948         if (servMgr_ == nullptr) {
949             TELEPHONY_LOGE("TelRilManager::RegisterHdfStatusListener, servMgr_ is nullptr");
950             return false;
951         }
952     }
953 
954     hdfListener_ = new HdfServiceStatusListener(
955         HdfServiceStatusListener::StatusCallback([&](const OHOS::HDI::ServiceManager::V1_0::ServiceStatus &status) {
956             HandleRilInterfaceStatusCallback(status);
957         }));
958 
959     int status = servMgr_->RegisterServiceStatusListener(hdfListener_, DEVICE_CLASS_DEFAULT);
960     if (status != STATUS_OK) {
961         TELEPHONY_LOGE("TelRilManager::RegisterHdfStatusListener, register failed!");
962         return false;
963     }
964     return true;
965 }
966 
UnRegisterHdfStatusListener()967 bool TelRilManager::UnRegisterHdfStatusListener()
968 {
969     if (servMgr_ == nullptr) {
970         servMgr_ = OHOS::HDI::ServiceManager::V1_0::IServiceManager::Get();
971         if (servMgr_ == nullptr) {
972             TELEPHONY_LOGE("TelRilManager::UnRegisterHdfStatusListener, servmgr_ is nullptr");
973             return false;
974         }
975     }
976     if (hdfListener_ == nullptr) {
977         TELEPHONY_LOGE("TelRilManager::UnRegisterHdfStatusListener, hdfListener_ is nullptr");
978         return false;
979     }
980 
981     int status = servMgr_->UnregisterServiceStatusListener(hdfListener_);
982     if (status != STATUS_OK) {
983         TELEPHONY_LOGE("TelRilManager::UnRegisterHdfStatusListener, unregister failed!");
984         return false;
985     }
986 
987     TELEPHONY_LOGD("TelRilManager::UnRegisterHdfStatusListener, unregister successfully!");
988     return true;
989 }
990 
ReConnectRilInterface()991 bool TelRilManager::ReConnectRilInterface()
992 {
993     if (rilInterface_ != nullptr) {
994         TELEPHONY_LOGI("TelRilManager::ReConnectRilInterface has been successfully connected!");
995         return true;
996     }
997 
998     if (!ConnectRilInterface()) {
999         TELEPHONY_LOGE("TelRilManager::ReConnectRilInterface, Connect riladapter service failed!");
1000         return false;
1001     }
1002 
1003     if (!ResetRilInterface()) {
1004         TELEPHONY_LOGE("TelRilManager::ReConnectRilInterface, Reset remote object failed!");
1005         return false;
1006     }
1007     TELEPHONY_LOGD("TelRilManager::ReConnectRilInterface, Connect riladapter service successfully!");
1008     return true;
1009 }
1010 
DisConnectRilInterface()1011 bool TelRilManager::DisConnectRilInterface()
1012 {
1013     std::lock_guard<std::mutex> lock_l(mutex_);
1014     if (rilInterface_ == nullptr) {
1015         TELEPHONY_LOGD("TelRilManager::DisConnectRilInterface has been successfully disconnected!");
1016         return true;
1017     }
1018     rilInterface_ = nullptr;
1019     if (!ResetRilInterface()) {
1020         TELEPHONY_LOGE("TelRilManager::DisConnectRilInterface, Reset remote object failed!");
1021         return false;
1022     }
1023     TELEPHONY_LOGD("TelRilManager::DisConnectRilInterface, disconnect riladapter service successfully");
1024     return true;
1025 }
1026 } // namespace Telephony
1027 } // namespace OHOS
1028