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