• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "ril_impl.h"
17 
18 #include <hdf_base.h>
19 #include <hdf_log.h>
20 
21 namespace OHOS {
22 namespace HDI {
23 namespace Ril {
24 namespace V1_1 {
25 static std::mutex mutex_;
26 static sptr<IRilCallback> callback_;
27 namespace {
28 sptr<RilImpl::RilDeathRecipient> g_deathRecipient = nullptr;
29 }
RilImplGetInstance(void)30 extern "C" IRil *RilImplGetInstance(void)
31 {
32     using OHOS::HDI::Ril::V1_1::RilImpl;
33     RilImpl *service = new (std::nothrow) RilImpl();
34     if (service == nullptr) {
35         return nullptr;
36     }
37     if (service->Init() != HDF_SUCCESS) {
38         delete service;
39         service = nullptr;
40         return nullptr;
41     }
42     return service;
43 }
44 
45 // Call
SetEmergencyCallList(int32_t slotId,int32_t serialId,const EmergencyInfoList & emergencyInfoList)46 int32_t RilImpl::SetEmergencyCallList(
47     int32_t slotId, int32_t serialId, const EmergencyInfoList &emergencyInfoList)
48 {
49     return TaskSchedule(&Telephony::HRilManager::SetEmergencyCallList, slotId, serialId, emergencyInfoList);
50 }
51 
GetEmergencyCallList(int32_t slotId,int32_t serialId)52 int32_t RilImpl::GetEmergencyCallList(int32_t slotId, int32_t serialId)
53 {
54     return TaskSchedule(&Telephony::HRilManager::GetEmergencyCallList, slotId, serialId);
55 }
56 
GetCallList(int32_t slotId,int32_t serialId)57 int32_t RilImpl::GetCallList(int32_t slotId, int32_t serialId)
58 {
59     return TaskSchedule(&Telephony::HRilManager::GetCallList, slotId, serialId);
60 }
61 
Dial(int32_t slotId,int32_t serialId,const DialInfo & dialInfo)62 int32_t RilImpl::Dial(int32_t slotId, int32_t serialId, const DialInfo &dialInfo)
63 {
64     return TaskSchedule(&Telephony::HRilManager::Dial, slotId, serialId, dialInfo);
65 }
66 
Reject(int32_t slotId,int32_t serialId)67 int32_t RilImpl::Reject(int32_t slotId, int32_t serialId)
68 {
69     return TaskSchedule(&Telephony::HRilManager::Reject, slotId, serialId);
70 }
71 
Hangup(int32_t slotId,int32_t serialId,int32_t gsmIndex)72 int32_t RilImpl::Hangup(int32_t slotId, int32_t serialId, int32_t gsmIndex)
73 {
74     return TaskSchedule(&Telephony::HRilManager::Hangup, slotId, serialId, gsmIndex);
75 }
76 
Answer(int32_t slotId,int32_t serialId)77 int32_t RilImpl::Answer(int32_t slotId, int32_t serialId)
78 {
79     return TaskSchedule(&Telephony::HRilManager::Answer, slotId, serialId);
80 }
81 
HoldCall(int32_t slotId,int32_t serialId)82 int32_t RilImpl::HoldCall(int32_t slotId, int32_t serialId)
83 {
84     return TaskSchedule(&Telephony::HRilManager::HoldCall, slotId, serialId);
85 }
86 
UnHoldCall(int32_t slotId,int32_t serialId)87 int32_t RilImpl::UnHoldCall(int32_t slotId, int32_t serialId)
88 {
89     return TaskSchedule(&Telephony::HRilManager::UnHoldCall, slotId, serialId);
90 }
91 
SwitchCall(int32_t slotId,int32_t serialId)92 int32_t RilImpl::SwitchCall(int32_t slotId, int32_t serialId)
93 {
94     return TaskSchedule(&Telephony::HRilManager::SwitchCall, slotId, serialId);
95 }
96 
CombineConference(int32_t slotId,int32_t serialId,int32_t callType)97 int32_t RilImpl::CombineConference(int32_t slotId, int32_t serialId, int32_t callType)
98 {
99     return TaskSchedule(&Telephony::HRilManager::CombineConference, slotId, serialId, callType);
100 }
101 
SeparateConference(int32_t slotId,int32_t serialId,int32_t callIndex,int32_t callType)102 int32_t RilImpl::SeparateConference(
103     int32_t slotId, int32_t serialId, int32_t callIndex, int32_t callType)
104 {
105     return TaskSchedule(&Telephony::HRilManager::SeparateConference, slotId, serialId, callIndex, callType);
106 }
107 
GetCallWaiting(int32_t slotId,int32_t serialId)108 int32_t RilImpl::GetCallWaiting(int32_t slotId, int32_t serialId)
109 {
110     return TaskSchedule(&Telephony::HRilManager::GetCallWaiting, slotId, serialId);
111 }
112 
SetCallWaiting(int32_t slotId,int32_t serialId,int32_t activate)113 int32_t RilImpl::SetCallWaiting(int32_t slotId, int32_t serialId, int32_t activate)
114 {
115     return TaskSchedule(&Telephony::HRilManager::SetCallWaiting, slotId, serialId, activate);
116 }
117 
GetCallTransferInfo(int32_t slotId,int32_t serialId,int32_t reason)118 int32_t RilImpl::GetCallTransferInfo(int32_t slotId, int32_t serialId, int32_t reason)
119 {
120     return TaskSchedule(&Telephony::HRilManager::GetCallTransferInfo, slotId, serialId, reason);
121 }
122 
SetCallTransferInfo(int32_t slotId,int32_t serialId,const CallForwardSetInfo & callForwardSetInfo)123 int32_t RilImpl::SetCallTransferInfo(
124     int32_t slotId, int32_t serialId, const CallForwardSetInfo &callForwardSetInfo)
125 {
126     return TaskSchedule(&Telephony::HRilManager::SetCallTransferInfo, slotId, serialId, callForwardSetInfo);
127 }
128 
GetCallRestriction(int32_t slotId,int32_t serialId,const std::string & fac)129 int32_t RilImpl::GetCallRestriction(int32_t slotId, int32_t serialId, const std::string &fac)
130 {
131     return TaskSchedule(&Telephony::HRilManager::GetCallRestriction, slotId, serialId, fac);
132 }
133 
SetCallRestriction(int32_t slotId,int32_t serialId,const CallRestrictionInfo & callRestrictionInfo)134 int32_t RilImpl::SetCallRestriction(
135     int32_t slotId, int32_t serialId, const CallRestrictionInfo &callRestrictionInfo)
136 {
137     return TaskSchedule(&Telephony::HRilManager::SetCallRestriction, slotId, serialId, callRestrictionInfo);
138 }
139 
GetClip(int32_t slotId,int32_t serialId)140 int32_t RilImpl::GetClip(int32_t slotId, int32_t serialId)
141 {
142     return TaskSchedule(&Telephony::HRilManager::GetClip, slotId, serialId);
143 }
144 
SetClip(int32_t slotId,int32_t serialId,int32_t action)145 int32_t RilImpl::SetClip(int32_t slotId, int32_t serialId, int32_t action)
146 {
147     return TaskSchedule(&Telephony::HRilManager::SetClip, slotId, serialId, action);
148 }
149 
GetClir(int32_t slotId,int32_t serialId)150 int32_t RilImpl::GetClir(int32_t slotId, int32_t serialId)
151 {
152     return TaskSchedule(&Telephony::HRilManager::GetClir, slotId, serialId);
153 }
154 
SetClir(int32_t slotId,int32_t serialId,int32_t action)155 int32_t RilImpl::SetClir(int32_t slotId, int32_t serialId, int32_t action)
156 {
157     return TaskSchedule(&Telephony::HRilManager::SetClir, slotId, serialId, action);
158 }
159 
SetCallPreferenceMode(int32_t slotId,int32_t serialId,int32_t mode)160 int32_t RilImpl::SetCallPreferenceMode(int32_t slotId, int32_t serialId, int32_t mode)
161 {
162     return TaskSchedule(&Telephony::HRilManager::SetCallPreferenceMode, slotId, serialId, mode);
163 }
164 
GetCallPreferenceMode(int32_t slotId,int32_t serialId)165 int32_t RilImpl::GetCallPreferenceMode(int32_t slotId, int32_t serialId)
166 {
167     return TaskSchedule(&Telephony::HRilManager::GetCallPreferenceMode, slotId, serialId);
168 }
169 
SetUssd(int32_t slotId,int32_t serialId,const std::string & str)170 int32_t RilImpl::SetUssd(int32_t slotId, int32_t serialId, const std::string &str)
171 {
172     return TaskSchedule(&Telephony::HRilManager::SetUssd, slotId, serialId, str);
173 }
174 
CloseUnFinishedUssd(int32_t slotId,int32_t serialId)175 int32_t RilImpl::CloseUnFinishedUssd(int32_t slotId, int32_t serialId)
176 {
177     return TaskSchedule(&Telephony::HRilManager::CloseUnFinishedUssd, slotId, serialId);
178 }
179 
GetUssd(int32_t slotId,int32_t serialId)180 int32_t RilImpl::GetUssd(int32_t slotId, int32_t serialId)
181 {
182     return TaskSchedule(&Telephony::HRilManager::GetUssd, slotId, serialId);
183 }
184 
SetMute(int32_t slotId,int32_t serialId,int32_t mute)185 int32_t RilImpl::SetMute(int32_t slotId, int32_t serialId, int32_t mute)
186 {
187     return TaskSchedule(&Telephony::HRilManager::SetMute, slotId, serialId, mute);
188 }
189 
GetMute(int32_t slotId,int32_t serialId)190 int32_t RilImpl::GetMute(int32_t slotId, int32_t serialId)
191 {
192     return TaskSchedule(&Telephony::HRilManager::GetMute, slotId, serialId);
193 }
194 
GetCallFailReason(int32_t slotId,int32_t serialId)195 int32_t RilImpl::GetCallFailReason(int32_t slotId, int32_t serialId)
196 {
197     return TaskSchedule(&Telephony::HRilManager::GetCallFailReason, slotId, serialId);
198 }
199 
CallSupplement(int32_t slotId,int32_t serialId,int32_t type)200 int32_t RilImpl::CallSupplement(int32_t slotId, int32_t serialId, int32_t type)
201 {
202     return TaskSchedule(&Telephony::HRilManager::CallSupplement, slotId, serialId, type);
203 }
204 
SendDtmf(int32_t slotId,int32_t serialId,const DtmfInfo & dtmfInfo)205 int32_t RilImpl::SendDtmf(int32_t slotId, int32_t serialId, const DtmfInfo &dtmfInfo)
206 {
207     return TaskSchedule(&Telephony::HRilManager::SendDtmf, slotId, serialId, dtmfInfo);
208 }
209 
StartDtmf(int32_t slotId,int32_t serialId,const DtmfInfo & dtmfInfo)210 int32_t RilImpl::StartDtmf(int32_t slotId, int32_t serialId, const DtmfInfo &dtmfInfo)
211 {
212     return TaskSchedule(&Telephony::HRilManager::StartDtmf, slotId, serialId, dtmfInfo);
213 }
214 
StopDtmf(int32_t slotId,int32_t serialId,const DtmfInfo & dtmfInfo)215 int32_t RilImpl::StopDtmf(int32_t slotId, int32_t serialId, const DtmfInfo &dtmfInfo)
216 {
217     return TaskSchedule(&Telephony::HRilManager::StopDtmf, slotId, serialId, dtmfInfo);
218 }
219 
SetBarringPassword(int32_t slotId,int32_t serialId,const SetBarringInfo & setBarringInfo)220 int32_t RilImpl::SetBarringPassword(
221     int32_t slotId, int32_t serialId, const SetBarringInfo &setBarringInfo)
222 {
223     return TaskSchedule(&Telephony::HRilManager::SetBarringPassword, slotId, serialId, setBarringInfo);
224 }
225 
SetVonrSwitch(int32_t slotId,int32_t serialId,int32_t status)226 int32_t RilImpl::SetVonrSwitch(int32_t slotId, int32_t serialId, int32_t status)
227 {
228     return TaskSchedule(&Telephony::HRilManager::SetVonrSwitch, slotId, serialId, status);
229 }
230 
231 // Data
ActivatePdpContext(int32_t slotId,int32_t serialId,const DataCallInfo & dataCallInfo)232 int32_t RilImpl::ActivatePdpContext(int32_t slotId, int32_t serialId, const DataCallInfo &dataCallInfo)
233 {
234     return TaskSchedule(&Telephony::HRilManager::ActivatePdpContext, slotId, serialId, dataCallInfo);
235 }
236 
DeactivatePdpContext(int32_t slotId,int32_t serialId,const UniInfo & uniInfo)237 int32_t RilImpl::DeactivatePdpContext(int32_t slotId, int32_t serialId, const UniInfo &uniInfo)
238 {
239     return TaskSchedule(&Telephony::HRilManager::DeactivatePdpContext, slotId, serialId, uniInfo);
240 }
241 
GetPdpContextList(int32_t slotId,int32_t serialId,const UniInfo & uniInfo)242 int32_t RilImpl::GetPdpContextList(int32_t slotId, int32_t serialId, const UniInfo &uniInfo)
243 {
244     return TaskSchedule(&Telephony::HRilManager::GetPdpContextList, slotId, serialId, uniInfo);
245 }
246 
SetInitApnInfo(int32_t slotId,int32_t serialId,const DataProfileDataInfo & dataProfileDataInfo)247 int32_t RilImpl::SetInitApnInfo(
248     int32_t slotId, int32_t serialId, const DataProfileDataInfo &dataProfileDataInfo)
249 {
250     return TaskSchedule(&Telephony::HRilManager::SetInitApnInfo, slotId, serialId, dataProfileDataInfo);
251 }
252 
GetLinkBandwidthInfo(int32_t slotId,int32_t serialId,int32_t cid)253 int32_t RilImpl::GetLinkBandwidthInfo(int32_t slotId, int32_t serialId, int32_t cid)
254 {
255     return TaskSchedule(&Telephony::HRilManager::GetLinkBandwidthInfo, slotId, serialId, cid);
256 }
257 
GetLinkCapability(int32_t slotId,int32_t serialId)258 int32_t RilImpl::GetLinkCapability(int32_t slotId, int32_t serialId)
259 {
260     return TaskSchedule(&Telephony::HRilManager::GetLinkCapability, slotId, serialId);
261 }
262 
SetLinkBandwidthReportingRule(int32_t slotId,int32_t serialId,const DataLinkBandwidthReportingRule & dataLinkBandwidthReportingRule)263 int32_t RilImpl::SetLinkBandwidthReportingRule(
264     int32_t slotId, int32_t serialId, const DataLinkBandwidthReportingRule &dataLinkBandwidthReportingRule)
265 {
266     return TaskSchedule(
267         &Telephony::HRilManager::SetLinkBandwidthReportingRule, slotId, serialId, dataLinkBandwidthReportingRule);
268 }
269 
SetDataPermitted(int32_t slotId,int32_t serialId,int32_t dataPermitted)270 int32_t RilImpl::SetDataPermitted(int32_t slotId, int32_t serialId, int32_t dataPermitted)
271 {
272     return TaskSchedule(&Telephony::HRilManager::SetDataPermitted, slotId, serialId, dataPermitted);
273 }
274 
SetDataProfileInfo(int32_t slotId,int32_t serialId,const DataProfilesInfo & dataProfilesInfo)275 int32_t RilImpl::SetDataProfileInfo(
276     int32_t slotId, int32_t serialId, const DataProfilesInfo &dataProfilesInfo)
277 {
278     return TaskSchedule(&Telephony::HRilManager::SetDataProfileInfo, slotId, serialId, dataProfilesInfo);
279 }
280 
SendDataPerformanceMode(int32_t slotId,int32_t serialId,const DataPerformanceInfo & dataPerformanceInfo)281 int32_t RilImpl::SendDataPerformanceMode(
282     int32_t slotId, int32_t serialId, const DataPerformanceInfo &dataPerformanceInfo)
283 {
284     return TaskSchedule(&Telephony::HRilManager::SendDataPerformanceMode, slotId, serialId, dataPerformanceInfo);
285 }
286 
SendDataSleepMode(int32_t slotId,int32_t serialId,const DataSleepInfo & dataSleepInfo)287 int32_t RilImpl::SendDataSleepMode(
288     int32_t slotId, int32_t serialId, const DataSleepInfo &dataSleepInfo)
289 {
290     return TaskSchedule(&Telephony::HRilManager::SendDataSleepMode, slotId, serialId, dataSleepInfo);
291 }
292 
293 // Modem
SetRadioState(int32_t slotId,int32_t serialId,int32_t fun,int32_t rst)294 int32_t RilImpl::SetRadioState(int32_t slotId, int32_t serialId, int32_t fun, int32_t rst)
295 {
296     return TaskSchedule(&Telephony::HRilManager::SetRadioState, slotId, serialId, fun, rst);
297 }
298 
GetRadioState(int32_t slotId,int32_t serialId)299 int32_t RilImpl::GetRadioState(int32_t slotId, int32_t serialId)
300 {
301     return TaskSchedule(&Telephony::HRilManager::GetRadioState, slotId, serialId);
302 }
303 
GetImei(int32_t slotId,int32_t serialId)304 int32_t RilImpl::GetImei(int32_t slotId, int32_t serialId)
305 {
306     return TaskSchedule(&Telephony::HRilManager::GetImei, slotId, serialId);
307 }
308 
GetMeid(int32_t slotId,int32_t serialId)309 int32_t RilImpl::GetMeid(int32_t slotId, int32_t serialId)
310 {
311     return TaskSchedule(&Telephony::HRilManager::GetMeid, slotId, serialId);
312 }
313 
GetVoiceRadioTechnology(int32_t slotId,int32_t serialId)314 int32_t RilImpl::GetVoiceRadioTechnology(int32_t slotId, int32_t serialId)
315 {
316     return TaskSchedule(&Telephony::HRilManager::GetVoiceRadioTechnology, slotId, serialId);
317 }
318 
GetBasebandVersion(int32_t slotId,int32_t serialId)319 int32_t RilImpl::GetBasebandVersion(int32_t slotId, int32_t serialId)
320 {
321     return TaskSchedule(&Telephony::HRilManager::GetBasebandVersion, slotId, serialId);
322 }
323 
ShutDown(int32_t slotId,int32_t serialId)324 int32_t RilImpl::ShutDown(int32_t slotId, int32_t serialId)
325 {
326     return TaskSchedule(&Telephony::HRilManager::ShutDown, slotId, serialId);
327 }
328 
329 // Network
GetSignalStrength(int32_t slotId,int32_t serialId)330 int32_t RilImpl::GetSignalStrength(int32_t slotId, int32_t serialId)
331 {
332     return TaskSchedule(&Telephony::HRilManager::GetSignalStrength, slotId, serialId);
333 }
334 
GetCsRegStatus(int32_t slotId,int32_t serialId)335 int32_t RilImpl::GetCsRegStatus(int32_t slotId, int32_t serialId)
336 {
337     return TaskSchedule(&Telephony::HRilManager::GetCsRegStatus, slotId, serialId);
338 }
339 
GetPsRegStatus(int32_t slotId,int32_t serialId)340 int32_t RilImpl::GetPsRegStatus(int32_t slotId, int32_t serialId)
341 {
342     return TaskSchedule(&Telephony::HRilManager::GetPsRegStatus, slotId, serialId);
343 }
344 
GetOperatorInfo(int32_t slotId,int32_t serialId)345 int32_t RilImpl::GetOperatorInfo(int32_t slotId, int32_t serialId)
346 {
347     return TaskSchedule(&Telephony::HRilManager::GetOperatorInfo, slotId, serialId);
348 }
349 
GetNetworkSearchInformation(int32_t slotId,int32_t serialId)350 int32_t RilImpl::GetNetworkSearchInformation(int32_t slotId, int32_t serialId)
351 {
352     return TaskSchedule(&Telephony::HRilManager::GetNetworkSearchInformation, slotId, serialId);
353 }
354 
GetNetworkSelectionMode(int32_t slotId,int32_t serialId)355 int32_t RilImpl::GetNetworkSelectionMode(int32_t slotId, int32_t serialId)
356 {
357     return TaskSchedule(&Telephony::HRilManager::GetNetworkSelectionMode, slotId, serialId);
358 }
359 
SetNetworkSelectionMode(int32_t slotId,int32_t serialId,const SetNetworkModeInfo & networkModeInfo)360 int32_t RilImpl::SetNetworkSelectionMode(
361     int32_t slotId, int32_t serialId, const SetNetworkModeInfo &networkModeInfo)
362 {
363     return TaskSchedule(&Telephony::HRilManager::SetNetworkSelectionMode, slotId, serialId, networkModeInfo);
364 }
365 
GetNeighboringCellInfoList(int32_t slotId,int32_t serialId)366 int32_t RilImpl::GetNeighboringCellInfoList(int32_t slotId, int32_t serialId)
367 {
368     return TaskSchedule(&Telephony::HRilManager::GetNeighboringCellInfoList, slotId, serialId);
369 }
370 
GetCurrentCellInfo(int32_t slotId,int32_t serialId)371 int32_t RilImpl::GetCurrentCellInfo(int32_t slotId, int32_t serialId)
372 {
373     return TaskSchedule(&Telephony::HRilManager::GetCurrentCellInfo, slotId, serialId);
374 }
375 
SetPreferredNetwork(int32_t slotId,int32_t serialId,int32_t preferredNetworkType)376 int32_t RilImpl::SetPreferredNetwork(int32_t slotId, int32_t serialId, int32_t preferredNetworkType)
377 {
378     return TaskSchedule(&Telephony::HRilManager::SetPreferredNetwork, slotId, serialId, preferredNetworkType);
379 }
380 
GetPreferredNetwork(int32_t slotId,int32_t serialId)381 int32_t RilImpl::GetPreferredNetwork(int32_t slotId, int32_t serialId)
382 {
383     return TaskSchedule(&Telephony::HRilManager::GetPreferredNetwork, slotId, serialId);
384 }
385 
GetPhysicalChannelConfig(int32_t slotId,int32_t serialId)386 int32_t RilImpl::GetPhysicalChannelConfig(int32_t slotId, int32_t serialId)
387 {
388     return TaskSchedule(&Telephony::HRilManager::GetPhysicalChannelConfig, slotId, serialId);
389 }
390 
SetLocateUpdates(int32_t slotId,int32_t serialId,const RilRegNotifyMode mode)391 int32_t RilImpl::SetLocateUpdates(int32_t slotId, int32_t serialId, const RilRegNotifyMode mode)
392 {
393     return TaskSchedule(&Telephony::HRilManager::SetLocateUpdates, slotId, serialId, mode);
394 }
395 
SetNotificationFilter(int32_t slotId,int32_t serialId,int32_t newFilter)396 int32_t RilImpl::SetNotificationFilter(int32_t slotId, int32_t serialId, int32_t newFilter)
397 {
398     return TaskSchedule(&Telephony::HRilManager::SetNotificationFilter, slotId, serialId, newFilter);
399 }
400 
SetDeviceState(int32_t slotId,int32_t serialId,int32_t deviceStateType,int32_t deviceStateOn)401 int32_t RilImpl::SetDeviceState(
402     int32_t slotId, int32_t serialId, int32_t deviceStateType, int32_t deviceStateOn)
403 {
404     return TaskSchedule(
405         &Telephony::HRilManager::SetDeviceState, slotId, serialId, deviceStateType, deviceStateOn);
406 }
407 
SetNrOptionMode(int32_t slotId,int32_t serialId,int32_t mode)408 int32_t RilImpl::SetNrOptionMode(int32_t slotId, int32_t serialId, int32_t mode)
409 {
410     return TaskSchedule(&Telephony::HRilManager::SetNrOptionMode, slotId, serialId, mode);
411 }
412 
GetNrOptionMode(int32_t slotId,int32_t serialId)413 int32_t RilImpl::GetNrOptionMode(int32_t slotId, int32_t serialId)
414 {
415     return TaskSchedule(&Telephony::HRilManager::GetNrOptionMode, slotId, serialId);
416 }
417 
GetRrcConnectionState(int32_t slotId,int32_t serialId)418 int32_t RilImpl::GetRrcConnectionState(int32_t slotId, int32_t serialId)
419 {
420     return TaskSchedule(&Telephony::HRilManager::GetRrcConnectionState, slotId, serialId);
421 }
422 
SetCallback(const sptr<IRilCallback> & rilCallback)423 int32_t RilImpl::SetCallback(const sptr<IRilCallback> &rilCallback)
424 {
425     std::lock_guard<std::mutex> lock(mutex_);
426     callback_ = rilCallback;
427     if (callback_ == nullptr) {
428         UnRegister();
429         return HDF_SUCCESS;
430     }
431     g_deathRecipient = new RilDeathRecipient(this);
432     if (g_deathRecipient == nullptr) {
433         HDF_LOGE("SetCallback fail g_deathRecipient is null");
434         return HDF_FAILURE;
435     }
436     AddRilDeathRecipient(callback_);
437     if (Telephony::HRilManager::manager_ == nullptr) {
438         HDF_LOGE("SetCallback fail manager_ is null");
439         return HDF_FAILURE;
440     }
441     Telephony::HRilManager::manager_->SetRilCallback(callback_);
442     return HDF_SUCCESS;
443 }
444 
GetSimIO(int32_t slotId,int32_t serialId,const SimIoRequestInfo & simIO)445 int32_t RilImpl::GetSimIO(int32_t slotId, int32_t serialId, const SimIoRequestInfo &simIO)
446 {
447     return TaskSchedule(&Telephony::HRilManager::GetSimIO, slotId, serialId, simIO);
448 }
449 
GetSimStatus(int32_t slotId,int32_t serialId)450 int32_t RilImpl::GetSimStatus(int32_t slotId, int32_t serialId)
451 {
452     return TaskSchedule(&Telephony::HRilManager::GetSimStatus, slotId, serialId);
453 }
454 
GetImsi(int32_t slotId,int32_t serialId)455 int32_t RilImpl::GetImsi(int32_t slotId, int32_t serialId)
456 {
457     return TaskSchedule(&Telephony::HRilManager::GetImsi, slotId, serialId);
458 }
459 
GetSimLockStatus(int32_t slotId,int32_t serialId,const SimLockInfo & simLockInfo)460 int32_t RilImpl::GetSimLockStatus(int32_t slotId, int32_t serialId, const SimLockInfo &simLockInfo)
461 {
462     return TaskSchedule(&Telephony::HRilManager::GetSimLockStatus, slotId, serialId, simLockInfo);
463 }
464 
SetSimLock(int32_t slotId,int32_t serialId,const SimLockInfo & simLockInfo)465 int32_t RilImpl::SetSimLock(int32_t slotId, int32_t serialId, const SimLockInfo &simLockInfo)
466 {
467     return TaskSchedule(&Telephony::HRilManager::SetSimLock, slotId, serialId, simLockInfo);
468 }
469 
ChangeSimPassword(int32_t slotId,int32_t serialId,const SimPasswordInfo & simPassword)470 int32_t RilImpl::ChangeSimPassword(int32_t slotId, int32_t serialId, const SimPasswordInfo &simPassword)
471 {
472     return TaskSchedule(&Telephony::HRilManager::ChangeSimPassword, slotId, serialId, simPassword);
473 }
474 
UnlockPin(int32_t slotId,int32_t serialId,const std::string & pin)475 int32_t RilImpl::UnlockPin(int32_t slotId, int32_t serialId, const std::string &pin)
476 {
477     return TaskSchedule(&Telephony::HRilManager::UnlockPin, slotId, serialId, pin);
478 }
479 
UnlockPuk(int32_t slotId,int32_t serialId,const std::string & puk,const std::string & pin)480 int32_t RilImpl::UnlockPuk(int32_t slotId, int32_t serialId, const std::string &puk, const std::string &pin)
481 {
482     return TaskSchedule(&Telephony::HRilManager::UnlockPuk, slotId, serialId, puk, pin);
483 }
484 
UnlockPin2(int32_t slotId,int32_t serialId,const std::string & pin2)485 int32_t RilImpl::UnlockPin2(int32_t slotId, int32_t serialId, const std::string &pin2)
486 {
487     return TaskSchedule(&Telephony::HRilManager::UnlockPin2, slotId, serialId, pin2);
488 }
489 
UnlockPuk2(int32_t slotId,int32_t serialId,const std::string & puk2,const std::string & pin2)490 int32_t RilImpl::UnlockPuk2(int32_t slotId, int32_t serialId, const std::string &puk2, const std::string &pin2)
491 {
492     return TaskSchedule(&Telephony::HRilManager::UnlockPuk2, slotId, serialId, puk2, pin2);
493 }
494 
SetActiveSim(int32_t slotId,int32_t serialId,int32_t index,int32_t enable)495 int32_t RilImpl::SetActiveSim(int32_t slotId, int32_t serialId, int32_t index, int32_t enable)
496 {
497     return TaskSchedule(&Telephony::HRilManager::SetActiveSim, slotId, serialId, index, enable);
498 }
499 
SimStkSendTerminalResponse(int32_t slotId,int32_t serialId,const std::string & strCmd)500 int32_t RilImpl::SimStkSendTerminalResponse(int32_t slotId, int32_t serialId, const std::string &strCmd)
501 {
502     return TaskSchedule(&Telephony::HRilManager::SimStkSendTerminalResponse, slotId, serialId, strCmd);
503 }
504 
SimStkSendEnvelope(int32_t slotId,int32_t serialId,const std::string & strCmd)505 int32_t RilImpl::SimStkSendEnvelope(int32_t slotId, int32_t serialId, const std::string &strCmd)
506 {
507     return TaskSchedule(&Telephony::HRilManager::SimStkSendEnvelope, slotId, serialId, strCmd);
508 }
509 
SimStkSendCallSetupRequestResult(int32_t slotId,int32_t serialId,int32_t accept)510 int32_t RilImpl::SimStkSendCallSetupRequestResult(int32_t slotId, int32_t serialId, int32_t accept)
511 {
512     return TaskSchedule(&Telephony::HRilManager::SimStkSendCallSetupRequestResult, slotId, serialId, accept);
513 }
514 
SimStkIsReady(int32_t slotId,int32_t serialId)515 int32_t RilImpl::SimStkIsReady(int32_t slotId, int32_t serialId)
516 {
517     return TaskSchedule(&Telephony::HRilManager::SimStkIsReady, slotId, serialId);
518 }
519 
GetRadioProtocol(int32_t slotId,int32_t serialId)520 int32_t RilImpl::GetRadioProtocol(int32_t slotId, int32_t serialId)
521 {
522     return TaskSchedule(&Telephony::HRilManager::GetRadioProtocol, slotId, serialId);
523 }
524 
SetRadioProtocol(int32_t slotId,int32_t serialId,const RadioProtocol & radioProtocol)525 int32_t RilImpl::SetRadioProtocol(int32_t slotId, int32_t serialId, const RadioProtocol &radioProtocol)
526 {
527     return TaskSchedule(&Telephony::HRilManager::SetRadioProtocol, slotId, serialId, radioProtocol);
528 }
529 
SimOpenLogicalChannel(int32_t slotId,int32_t serialId,const std::string & appID,int32_t p2)530 int32_t RilImpl::SimOpenLogicalChannel(int32_t slotId, int32_t serialId, const std::string &appID, int32_t p2)
531 {
532     return TaskSchedule(&Telephony::HRilManager::SimOpenLogicalChannel, slotId, serialId, appID, p2);
533 }
534 
SimCloseLogicalChannel(int32_t slotId,int32_t serialId,int32_t channelId)535 int32_t RilImpl::SimCloseLogicalChannel(int32_t slotId, int32_t serialId, int32_t channelId)
536 {
537     return TaskSchedule(&Telephony::HRilManager::SimCloseLogicalChannel, slotId, serialId, channelId);
538 }
539 
SimTransmitApduLogicalChannel(int32_t slotId,int32_t serialId,const ApduSimIORequestInfo & apduSimIO)540 int32_t RilImpl::SimTransmitApduLogicalChannel(int32_t slotId, int32_t serialId, const ApduSimIORequestInfo &apduSimIO)
541 {
542     return TaskSchedule(&Telephony::HRilManager::SimTransmitApduLogicalChannel, slotId, serialId, apduSimIO);
543 }
544 
SimTransmitApduBasicChannel(int32_t slotId,int32_t serialId,const ApduSimIORequestInfo & apduSimIO)545 int32_t RilImpl::SimTransmitApduBasicChannel(int32_t slotId, int32_t serialId, const ApduSimIORequestInfo &apduSimIO)
546 {
547     return TaskSchedule(&Telephony::HRilManager::SimTransmitApduBasicChannel, slotId, serialId, apduSimIO);
548 }
549 
SimAuthentication(int32_t slotId,int32_t serialId,const SimAuthenticationRequestInfo & simAuthInfo)550 int32_t RilImpl::SimAuthentication(int32_t slotId, int32_t serialId, const SimAuthenticationRequestInfo &simAuthInfo)
551 {
552     return TaskSchedule(&Telephony::HRilManager::SimAuthentication, slotId, serialId, simAuthInfo);
553 }
554 
UnlockSimLock(int32_t slotId,int32_t serialId,int32_t lockType,const std::string & key)555 int32_t RilImpl::UnlockSimLock(int32_t slotId, int32_t serialId, int32_t lockType, const std::string &key)
556 {
557     return TaskSchedule(&Telephony::HRilManager::UnlockSimLock, slotId, serialId, lockType, key);
558 }
559 
560 // Sms
SendGsmSms(int32_t slotId,int32_t serialId,const GsmSmsMessageInfo & gsmSmsMessageInfo)561 int32_t RilImpl::SendGsmSms(int32_t slotId, int32_t serialId, const GsmSmsMessageInfo &gsmSmsMessageInfo)
562 {
563     return TaskSchedule(&Telephony::HRilManager::SendGsmSms, slotId, serialId, gsmSmsMessageInfo);
564 }
565 
SendCdmaSms(int32_t slotId,int32_t serialId,const SendCdmaSmsMessageInfo & cdmaSmsMessageInfo)566 int32_t RilImpl::SendCdmaSms(int32_t slotId, int32_t serialId, const SendCdmaSmsMessageInfo &cdmaSmsMessageInfo)
567 {
568     return TaskSchedule(&Telephony::HRilManager::SendCdmaSms, slotId, serialId, cdmaSmsMessageInfo);
569 }
570 
AddSimMessage(int32_t slotId,int32_t serialId,const SmsMessageIOInfo & smsMessageIOInfo)571 int32_t RilImpl::AddSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo)
572 {
573     return TaskSchedule(&Telephony::HRilManager::AddSimMessage, slotId, serialId, smsMessageIOInfo);
574 }
575 
DelSimMessage(int32_t slotId,int32_t serialId,int32_t index)576 int32_t RilImpl::DelSimMessage(int32_t slotId, int32_t serialId, int32_t index)
577 {
578     return TaskSchedule(&Telephony::HRilManager::DelSimMessage, slotId, serialId, index);
579 }
580 
UpdateSimMessage(int32_t slotId,int32_t serialId,const SmsMessageIOInfo & smsMessageIOInfo)581 int32_t RilImpl::UpdateSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo)
582 {
583     return TaskSchedule(&Telephony::HRilManager::UpdateSimMessage, slotId, serialId, smsMessageIOInfo);
584 }
585 
AddCdmaSimMessage(int32_t slotId,int32_t serialId,const SmsMessageIOInfo & smsMessageIOInfo)586 int32_t RilImpl::AddCdmaSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo)
587 {
588     return TaskSchedule(&Telephony::HRilManager::AddCdmaSimMessage, slotId, serialId, smsMessageIOInfo);
589 }
590 
DelCdmaSimMessage(int32_t slotId,int32_t serialId,int32_t index)591 int32_t RilImpl::DelCdmaSimMessage(int32_t slotId, int32_t serialId, int32_t index)
592 {
593     return TaskSchedule(&Telephony::HRilManager::DelCdmaSimMessage, slotId, serialId, index);
594 }
595 
UpdateCdmaSimMessage(int32_t slotId,int32_t serialId,const SmsMessageIOInfo & smsMessageIOInfo)596 int32_t RilImpl::UpdateCdmaSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo)
597 {
598     return TaskSchedule(&Telephony::HRilManager::UpdateCdmaSimMessage, slotId, serialId, smsMessageIOInfo);
599 }
600 
SetSmscAddr(int32_t slotId,int32_t serialId,const ServiceCenterAddress & serviceCenterAddress)601 int32_t RilImpl::SetSmscAddr(int32_t slotId, int32_t serialId, const ServiceCenterAddress &serviceCenterAddress)
602 {
603     return TaskSchedule(&Telephony::HRilManager::SetSmscAddr, slotId, serialId, serviceCenterAddress);
604 }
605 
GetSmscAddr(int32_t slotId,int32_t serialId)606 int32_t RilImpl::GetSmscAddr(int32_t slotId, int32_t serialId)
607 {
608     return TaskSchedule(&Telephony::HRilManager::GetSmscAddr, slotId, serialId);
609 }
610 
SetCBConfig(int32_t slotId,int32_t serialId,const CBConfigInfo & cellBroadcastInfo)611 int32_t RilImpl::SetCBConfig(int32_t slotId, int32_t serialId, const CBConfigInfo &cellBroadcastInfo)
612 {
613     return TaskSchedule(&Telephony::HRilManager::SetCBConfig, slotId, serialId, cellBroadcastInfo);
614 }
615 
GetCBConfig(int32_t slotId,int32_t serialId)616 int32_t RilImpl::GetCBConfig(int32_t slotId, int32_t serialId)
617 {
618     return TaskSchedule(&Telephony::HRilManager::GetCBConfig, slotId, serialId);
619 }
620 
SetCdmaCBConfig(int32_t slotId,int32_t serialId,const CdmaCBConfigInfoList & cdmaCBConfigInfoList)621 int32_t RilImpl::SetCdmaCBConfig(int32_t slotId, int32_t serialId, const CdmaCBConfigInfoList &cdmaCBConfigInfoList)
622 {
623     return TaskSchedule(&Telephony::HRilManager::SetCdmaCBConfig, slotId, serialId, cdmaCBConfigInfoList);
624 }
625 
GetCdmaCBConfig(int32_t slotId,int32_t serialId)626 int32_t RilImpl::GetCdmaCBConfig(int32_t slotId, int32_t serialId)
627 {
628     return TaskSchedule(&Telephony::HRilManager::GetCdmaCBConfig, slotId, serialId);
629 }
630 
SendSmsMoreMode(int32_t slotId,int32_t serialId,const GsmSmsMessageInfo & gsmSmsMessageInfo)631 int32_t RilImpl::SendSmsMoreMode(int32_t slotId, int32_t serialId, const GsmSmsMessageInfo &gsmSmsMessageInfo)
632 {
633     return TaskSchedule(&Telephony::HRilManager::SendSmsMoreMode, slotId, serialId, gsmSmsMessageInfo);
634 }
635 
SendSmsAck(int32_t slotId,int32_t serialId,const ModeData & modeData)636 int32_t RilImpl::SendSmsAck(int32_t slotId, int32_t serialId, const ModeData &modeData)
637 {
638     return TaskSchedule(&Telephony::HRilManager::SendSmsAck, slotId, serialId, modeData);
639 }
640 
SendRilAck()641 int32_t RilImpl::SendRilAck()
642 {
643     if (Telephony::HRilManager::manager_ == nullptr) {
644         HDF_LOGE("manager or func is null pointer");
645         return RIL_ERR_NULL_POINT;
646     }
647     return Telephony::HRilManager::manager_->SendRilAck();
648 }
649 
AddRilDeathRecipient(const sptr<IRilCallback> & callback)650 int32_t RilImpl::AddRilDeathRecipient(const sptr<IRilCallback> &callback)
651 {
652     const sptr<IRemoteObject> &remote = OHOS::HDI::hdi_objcast<IRilCallback>(callback);
653     if (!remote->AddDeathRecipient(g_deathRecipient)) {
654         HDF_LOGE("AddRilDeathRecipient fail");
655         return HDF_FAILURE;
656     }
657     return HDF_SUCCESS;
658 }
659 
RemoveRilDeathRecipient(const sptr<IRilCallback> & callback)660 int32_t RilImpl::RemoveRilDeathRecipient(const sptr<IRilCallback> &callback)
661 {
662     const sptr<IRemoteObject> &remote = OHOS::HDI::hdi_objcast<IRilCallback>(callback);
663     if (!remote->RemoveDeathRecipient(g_deathRecipient)) {
664         HDF_LOGI("RemoveRilDeathRecipient fail");
665         return HDF_FAILURE;
666     }
667     return HDF_SUCCESS;
668 }
669 
OnRemoteDied(const wptr<IRemoteObject> & object)670 void RilImpl::RilDeathRecipient::OnRemoteDied(const wptr<IRemoteObject> &object)
671 {
672     if (rilInterfaceImpl_ == nullptr) {
673         HDF_LOGE("RilImpl::RilDeathRecipient::OnRemoteDied fail rilInterfaceImpl_ is null");
674         return;
675     }
676     rilInterfaceImpl_->UnRegister();
677 }
678 
UnRegister()679 int32_t RilImpl::UnRegister()
680 {
681     HDF_LOGI("UnRegister");
682     RemoveRilDeathRecipient(callback_);
683     callback_ = nullptr;
684     if (Telephony::HRilManager::manager_ == nullptr) {
685         HDF_LOGE("RilImpl::UnRegister fail manager_ is null");
686         return HDF_FAILURE;
687     }
688     Telephony::HRilManager::manager_->SetRilCallback(nullptr);
689     return HDF_SUCCESS;
690 }
691 
Init()692 int32_t RilImpl::Init()
693 {
694     if (Telephony::HRilManager::manager_ == nullptr) {
695         HDF_LOGE("RilImpl::Init is manager_ is null");
696         return HDF_FAILURE;
697     }
698     return HDF_SUCCESS;
699 }
700 } // namespace V1_1
701 } // namespace Ril
702 } // namespace HDI
703 } // namespace OHOS
704