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