1 /*
2  * Copyright (C) 2021-2024 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_network.h"
17 
18 #include <securec.h>
19 
20 #include "radio_event.h"
21 
22 using namespace std;
23 using OHOS::IRemoteObject;
24 using OHOS::sptr;
25 namespace OHOS {
26 namespace Telephony {
TelRilNetwork(int32_t slotId,sptr<HDI::Ril::V1_3::IRil> rilInterface,std::shared_ptr<ObserverHandler> observerHandler,std::shared_ptr<TelRilHandler> handler)27 TelRilNetwork::TelRilNetwork(int32_t slotId, sptr<HDI::Ril::V1_3::IRil> rilInterface,
28     std::shared_ptr<ObserverHandler> observerHandler, std::shared_ptr<TelRilHandler> handler)
29     : TelRilBase(slotId, rilInterface, observerHandler, handler)
30 {}
31 
GetSignalStrength(const AppExecFwk::InnerEvent::Pointer & response)32 int32_t TelRilNetwork::GetSignalStrength(const AppExecFwk::InnerEvent::Pointer &response)
33 {
34     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetSignalStrength);
35 }
36 
GetCsRegStatus(const AppExecFwk::InnerEvent::Pointer & response)37 int32_t TelRilNetwork::GetCsRegStatus(const AppExecFwk::InnerEvent::Pointer &response)
38 {
39     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetCsRegStatus);
40 }
41 
GetPsRegStatus(const AppExecFwk::InnerEvent::Pointer & response)42 int32_t TelRilNetwork::GetPsRegStatus(const AppExecFwk::InnerEvent::Pointer &response)
43 {
44     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetPsRegStatus);
45 }
46 
GetOperatorInfo(const AppExecFwk::InnerEvent::Pointer & response)47 int32_t TelRilNetwork::GetOperatorInfo(const AppExecFwk::InnerEvent::Pointer &response)
48 {
49     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetOperatorInfo);
50 }
51 
GetNetworkSearchInformation(const AppExecFwk::InnerEvent::Pointer & response)52 int32_t TelRilNetwork::GetNetworkSearchInformation(const AppExecFwk::InnerEvent::Pointer &response)
53 {
54     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetNetworkSearchInformation);
55 }
56 
GetNetworkSelectionMode(const AppExecFwk::InnerEvent::Pointer & response)57 int32_t TelRilNetwork::GetNetworkSelectionMode(const AppExecFwk::InnerEvent::Pointer &response)
58 {
59     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetNetworkSelectionMode);
60 }
61 
SetNetworkSelectionMode(int32_t automaticFlag,std::string oper,const AppExecFwk::InnerEvent::Pointer & response)62 int32_t TelRilNetwork::SetNetworkSelectionMode(
63     int32_t automaticFlag, std::string oper, const AppExecFwk::InnerEvent::Pointer &response)
64 {
65     HDI::Ril::V1_1::SetNetworkModeInfo setNetworkModeInfo;
66     setNetworkModeInfo.selectMode = automaticFlag;
67     setNetworkModeInfo.oper = oper;
68     return Request(
69         TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::SetNetworkSelectionMode, setNetworkModeInfo);
70 }
71 
SetPreferredNetwork(int32_t preferredNetworkType,const AppExecFwk::InnerEvent::Pointer & response)72 int32_t TelRilNetwork::SetPreferredNetwork(
73     int32_t preferredNetworkType, const AppExecFwk::InnerEvent::Pointer &response)
74 {
75     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::SetPreferredNetwork, preferredNetworkType);
76 }
77 
GetPreferredNetwork(const AppExecFwk::InnerEvent::Pointer & response)78 int32_t TelRilNetwork::GetPreferredNetwork(const AppExecFwk::InnerEvent::Pointer &response)
79 {
80     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetPreferredNetwork);
81 }
82 
GetCellInfoList(const AppExecFwk::InnerEvent::Pointer & response)83 int32_t TelRilNetwork::GetCellInfoList(const AppExecFwk::InnerEvent::Pointer &response)
84 {
85     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetNeighboringCellInfoList);
86 }
87 
GetCurrentCellInfo(const AppExecFwk::InnerEvent::Pointer & response)88 int32_t TelRilNetwork::GetCurrentCellInfo(const AppExecFwk::InnerEvent::Pointer &response)
89 {
90     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetCurrentCellInfo);
91 }
92 
GetPhysicalChannelConfig(const AppExecFwk::InnerEvent::Pointer & response)93 int32_t TelRilNetwork::GetPhysicalChannelConfig(const AppExecFwk::InnerEvent::Pointer &response)
94 {
95     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetPhysicalChannelConfig);
96 }
97 
SetLocateUpdates(RegNotifyMode mode,const AppExecFwk::InnerEvent::Pointer & response)98 int32_t TelRilNetwork::SetLocateUpdates(RegNotifyMode mode, const AppExecFwk::InnerEvent::Pointer &response)
99 {
100     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::SetLocateUpdates,
101         static_cast<HDI::Ril::V1_1::RilRegNotifyMode>(mode));
102 }
103 
SetNotificationFilter(int32_t newFilter,const AppExecFwk::InnerEvent::Pointer & response)104 int32_t TelRilNetwork::SetNotificationFilter(int32_t newFilter, const AppExecFwk::InnerEvent::Pointer &response)
105 {
106     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::SetNotificationFilter, newFilter);
107 }
108 
SetDeviceState(int32_t deviceStateType,bool deviceStateOn,const AppExecFwk::InnerEvent::Pointer & response)109 int32_t TelRilNetwork::SetDeviceState(
110     int32_t deviceStateType, bool deviceStateOn, const AppExecFwk::InnerEvent::Pointer &response)
111 {
112     return Request(
113         TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::SetDeviceState, deviceStateType, deviceStateOn);
114 }
115 
SetNrOptionMode(int32_t mode,const AppExecFwk::InnerEvent::Pointer & response)116 int32_t TelRilNetwork::SetNrOptionMode(int32_t mode, const AppExecFwk::InnerEvent::Pointer &response)
117 {
118     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::SetNrOptionMode, mode);
119 }
120 
GetNrOptionMode(const AppExecFwk::InnerEvent::Pointer & response)121 int32_t TelRilNetwork::GetNrOptionMode(const AppExecFwk::InnerEvent::Pointer &response)
122 {
123     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetNrOptionMode);
124 }
125 
GetRrcConnectionState(const AppExecFwk::InnerEvent::Pointer & response)126 int32_t TelRilNetwork::GetRrcConnectionState(const AppExecFwk::InnerEvent::Pointer &response)
127 {
128     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_1::IRil::GetRrcConnectionState);
129 }
130 
GetNrSsbId(const AppExecFwk::InnerEvent::Pointer & response)131 int32_t TelRilNetwork::GetNrSsbId(const AppExecFwk::InnerEvent::Pointer &response)
132 {
133     return Request(TELEPHONY_LOG_FUNC_NAME, response, &HDI::Ril::V1_2::IRil::GetNrSsbId);
134 }
135 
SignalStrengthUpdated(const HDI::Ril::V1_1::Rssi & rssi)136 int32_t TelRilNetwork::SignalStrengthUpdated(const HDI::Ril::V1_1::Rssi &rssi)
137 {
138     std::shared_ptr<Rssi> signalStrength = std::make_shared<Rssi>();
139     BuildSignalStrength(signalStrength, rssi);
140     return Notify<Rssi>(TELEPHONY_LOG_FUNC_NAME, signalStrength, RadioEvent::RADIO_SIGNAL_STRENGTH_UPDATE);
141 }
142 
NetworkCsRegStatusUpdated(const HDI::Ril::V1_1::CsRegStatusInfo & csRegStatusInfo)143 int32_t TelRilNetwork::NetworkCsRegStatusUpdated(const HDI::Ril::V1_1::CsRegStatusInfo &csRegStatusInfo)
144 {
145     std::shared_ptr<CsRegStatusInfo> regStatusInfo = std::make_shared<CsRegStatusInfo>();
146     BuildCsRegStatusInfo(regStatusInfo, csRegStatusInfo);
147     return Notify<CsRegStatusInfo>(TELEPHONY_LOG_FUNC_NAME, regStatusInfo, RadioEvent::RADIO_NETWORK_STATE);
148 }
149 
NetworkPsRegStatusUpdated(const HDI::Ril::V1_1::PsRegStatusInfo & psRegStatusInfo)150 int32_t TelRilNetwork::NetworkPsRegStatusUpdated(const HDI::Ril::V1_1::PsRegStatusInfo &psRegStatusInfo)
151 {
152     std::shared_ptr<PsRegStatusResultInfo> regStatusInfo = std::make_shared<PsRegStatusResultInfo>();
153     BuildPsRegStatusInfo(regStatusInfo, psRegStatusInfo);
154     return Notify<PsRegStatusResultInfo>(TELEPHONY_LOG_FUNC_NAME, regStatusInfo, RadioEvent::RADIO_NETWORK_STATE);
155 }
156 
NetworkTimeZoneUpdated(const std::string & timeZoneStr)157 int32_t TelRilNetwork::NetworkTimeZoneUpdated(const std::string &timeZoneStr)
158 {
159     return Notify<std::string>(TELEPHONY_LOG_FUNC_NAME, std::make_shared<std::string>(timeZoneStr),
160         RadioEvent::RADIO_NETWORK_TIME_ZONE_UPDATE);
161 }
162 
NetworkTimeUpdated(const std::string & timeStr)163 int32_t TelRilNetwork::NetworkTimeUpdated(const std::string &timeStr)
164 {
165     return Notify<std::string>(
166         TELEPHONY_LOG_FUNC_NAME, std::make_shared<std::string>(timeStr), RadioEvent::RADIO_NETWORK_TIME_UPDATE);
167 }
168 
NetworkPhyChnlCfgUpdated(const HDI::Ril::V1_1::ChannelConfigInfoList & channelConfigInfoList)169 int32_t TelRilNetwork::NetworkPhyChnlCfgUpdated(const HDI::Ril::V1_1::ChannelConfigInfoList &channelConfigInfoList)
170 {
171     std::shared_ptr<ChannelConfigInfoList> channelConfigList = std::make_shared<ChannelConfigInfoList>();
172     BuildChannelConfigInfoList(channelConfigList, channelConfigInfoList);
173     return Notify<ChannelConfigInfoList>(
174         TELEPHONY_LOG_FUNC_NAME, channelConfigList, RadioEvent::RADIO_CHANNEL_CONFIG_UPDATE);
175 }
176 
NetworkCurrentCellUpdated(const HDI::Ril::V1_1::CellListCurrentInfo & cellListCurrentInfo)177 int32_t TelRilNetwork::NetworkCurrentCellUpdated(const HDI::Ril::V1_1::CellListCurrentInfo &cellListCurrentInfo)
178 {
179     std::shared_ptr<CellListCurrentInfo> currentCellList = std::make_shared<CellListCurrentInfo>();
180     BuildCurrentCellInfoList(currentCellList, cellListCurrentInfo);
181     return Notify<CellListCurrentInfo>(TELEPHONY_LOG_FUNC_NAME, currentCellList, RadioEvent::RADIO_CURRENT_CELL_UPDATE);
182 }
183 
GetRrcConnectionStateUpdated(int32_t state)184 int32_t TelRilNetwork::GetRrcConnectionStateUpdated(int32_t state)
185 {
186     return Notify<Int32Parcel>(TELEPHONY_LOG_FUNC_NAME, std::make_shared<Int32Parcel>(state),
187         RadioEvent::RADIO_RRC_CONNECTION_STATE_UPDATE);
188 }
189 
NetworkCurrentCellUpdated_1_1(const HDI::Ril::V1_1::CellListCurrentInfo_1_1 & cellListCurrentInformation)190 int32_t TelRilNetwork::NetworkCurrentCellUpdated_1_1(
191     const HDI::Ril::V1_1::CellListCurrentInfo_1_1 &cellListCurrentInformation)
192 {
193     std::shared_ptr<CellListCurrentInformation> currentCellList = std::make_shared<CellListCurrentInformation>();
194     BuildCurrentCellInformationList(currentCellList, cellListCurrentInformation);
195     return Notify<CellListCurrentInformation>(
196         TELEPHONY_LOG_FUNC_NAME, currentCellList, RadioEvent::RADIO_CURRENT_CELL_UPDATE);
197 }
198 
NetworkCurrentCellUpdated_1_2(const HDI::Ril::V1_2::CellListCurrentInfo_1_2 & cellListCurrentInformation)199 int32_t TelRilNetwork::NetworkCurrentCellUpdated_1_2(
200     const HDI::Ril::V1_2::CellListCurrentInfo_1_2 &cellListCurrentInformation)
201 {
202     std::shared_ptr<CellListCurrentInformation> currentCellList = std::make_shared<CellListCurrentInformation>();
203     BuildCurrentCellInformationList(currentCellList, cellListCurrentInformation);
204     return Notify<CellListCurrentInformation>(
205         TELEPHONY_LOG_FUNC_NAME, currentCellList, RadioEvent::RADIO_CURRENT_CELL_UPDATE);
206 }
207 
ResidentNetworkUpdated(const std::string & plmn)208 int32_t TelRilNetwork::ResidentNetworkUpdated(const std::string &plmn)
209 {
210     return Notify<std::string>(
211         TELEPHONY_LOG_FUNC_NAME, std::make_shared<std::string>(plmn), RadioEvent::RADIO_RESIDENT_NETWORK_CHANGE);
212 }
213 
GetSignalStrengthResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::Rssi & rssi)214 int32_t TelRilNetwork::GetSignalStrengthResponse(
215     const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::Rssi &rssi)
216 {
217     std::shared_ptr<Rssi> signalStrength = std::make_shared<Rssi>();
218     BuildSignalStrength(signalStrength, rssi);
219     return Response<Rssi>(TELEPHONY_LOG_FUNC_NAME, responseInfo, signalStrength);
220 }
221 
GetCsRegStatusResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::CsRegStatusInfo & csRegStatusInfo)222 int32_t TelRilNetwork::GetCsRegStatusResponse(
223     const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::CsRegStatusInfo &csRegStatusInfo)
224 {
225     auto getDataFunc = [&csRegStatusInfo, this](std::shared_ptr<TelRilRequest> telRilRequest) {
226         std::shared_ptr<CsRegStatusInfo> regStatusInfo = std::make_shared<CsRegStatusInfo>();
227         this->BuildCsRegStatusInfo(regStatusInfo, csRegStatusInfo);
228         regStatusInfo->flag = telRilRequest->pointer_->GetParam();
229         return regStatusInfo;
230     };
231     return Response<CsRegStatusInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, getDataFunc);
232 }
233 
GetPsRegStatusResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::PsRegStatusInfo & psRegStatusInfo)234 int32_t TelRilNetwork::GetPsRegStatusResponse(
235     const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::PsRegStatusInfo &psRegStatusInfo)
236 {
237     auto getDataFunc = [&psRegStatusInfo, this](std::shared_ptr<TelRilRequest> telRilRequest) {
238         std::shared_ptr<PsRegStatusResultInfo> regStatusInfo = std::make_shared<PsRegStatusResultInfo>();
239         this->BuildPsRegStatusInfo(regStatusInfo, psRegStatusInfo);
240         regStatusInfo->flag = telRilRequest->pointer_->GetParam();
241         return regStatusInfo;
242     };
243     return Response<PsRegStatusResultInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, getDataFunc);
244 }
245 
GetOperatorInfoResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::OperatorInfo & operatorInfo)246 int32_t TelRilNetwork::GetOperatorInfoResponse(
247     const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::OperatorInfo &operatorInfo)
248 {
249     auto getDataFunc = [&operatorInfo, this](std::shared_ptr<TelRilRequest> telRilRequest) {
250         std::shared_ptr<OperatorInfoResult> operatorResult = std::make_shared<OperatorInfoResult>();
251         this->BuildOperatorInfo(operatorResult, operatorInfo);
252         operatorResult->flag = telRilRequest->pointer_->GetParam();
253         return operatorResult;
254     };
255     return Response<OperatorInfoResult>(TELEPHONY_LOG_FUNC_NAME, responseInfo, getDataFunc);
256 }
257 
GetNetworkSearchInformationResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::AvailableNetworkList & availableNetworkList)258 int32_t TelRilNetwork::GetNetworkSearchInformationResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
259     const HDI::Ril::V1_1::AvailableNetworkList &availableNetworkList)
260 {
261     auto getDataFunc = [&availableNetworkList, this](std::shared_ptr<TelRilRequest> telRilRequest) {
262         std::shared_ptr<AvailableNetworkList> availableNetworkInfos = std::make_shared<AvailableNetworkList>();
263         this->BuildAvailableNetworkList(availableNetworkInfos, availableNetworkList);
264         availableNetworkInfos->flag = telRilRequest->pointer_->GetParam();
265         return availableNetworkInfos;
266     };
267     return Response<AvailableNetworkList>(TELEPHONY_LOG_FUNC_NAME, responseInfo, getDataFunc);
268 }
269 
GetNetworkSelectionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::SetNetworkModeInfo & setNetworkModeInfo)270 int32_t TelRilNetwork::GetNetworkSelectionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
271     const HDI::Ril::V1_1::SetNetworkModeInfo &setNetworkModeInfo)
272 {
273     auto getDataFunc = [&setNetworkModeInfo, this](std::shared_ptr<TelRilRequest> telRilRequest) {
274         std::shared_ptr<SetNetworkModeInfo> networkModeInfo = std::make_shared<SetNetworkModeInfo>();
275         this->BuildNetworkModeInfo(networkModeInfo, setNetworkModeInfo);
276         networkModeInfo->flag = telRilRequest->pointer_->GetParam();
277         return networkModeInfo;
278     };
279     return Response<SetNetworkModeInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, getDataFunc);
280 }
281 
SetNetworkSelectionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo)282 int32_t TelRilNetwork::SetNetworkSelectionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo)
283 {
284     return Response(TELEPHONY_LOG_FUNC_NAME, responseInfo);
285 }
286 
GetNeighboringCellInfoListResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::CellListNearbyInfo & cellInfoList)287 int32_t TelRilNetwork::GetNeighboringCellInfoListResponse(
288     const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::CellListNearbyInfo &cellInfoList)
289 {
290     std::shared_ptr<CellListNearbyInfo> cellListNearbyInfo = std::make_shared<CellListNearbyInfo>();
291     BuildNeighboringCellInfoList(cellListNearbyInfo, cellInfoList);
292     return Response<CellListNearbyInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, cellListNearbyInfo);
293 }
294 
GetNeighboringCellInfoListResponse_1_2(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_2::CellListNearbyInfo_1_2 & cellInfoList)295 int32_t TelRilNetwork::GetNeighboringCellInfoListResponse_1_2(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
296     const HDI::Ril::V1_2::CellListNearbyInfo_1_2 &cellInfoList)
297 {
298     std::shared_ptr<CellListNearbyInfo> cellListNearbyInfo = std::make_shared<CellListNearbyInfo>();
299     BuildNeighboringCellInfoList(cellListNearbyInfo, cellInfoList);
300     return Response<CellListNearbyInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, cellListNearbyInfo);
301 }
302 
GetCurrentCellInfoResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::CellListCurrentInfo & cellInfoList)303 int32_t TelRilNetwork::GetCurrentCellInfoResponse(
304     const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::CellListCurrentInfo &cellInfoList)
305 {
306     std::shared_ptr<CellListCurrentInfo> currentCellList = std::make_shared<CellListCurrentInfo>();
307     BuildCurrentCellInfoList(currentCellList, cellInfoList);
308     return Response<CellListCurrentInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, currentCellList);
309 }
310 
GetCurrentCellInfoResponse_1_1(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::CellListCurrentInfo_1_1 & cellListCurrentInformation)311 int32_t TelRilNetwork::GetCurrentCellInfoResponse_1_1(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
312     const HDI::Ril::V1_1::CellListCurrentInfo_1_1 &cellListCurrentInformation)
313 {
314     std::shared_ptr<CellListCurrentInformation> currentCellList = std::make_shared<CellListCurrentInformation>();
315     BuildCurrentCellInformationList(currentCellList, cellListCurrentInformation);
316     return Response<CellListCurrentInformation>(TELEPHONY_LOG_FUNC_NAME, responseInfo, currentCellList);
317 }
318 
GetCurrentCellInfoResponse_1_2(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_2::CellListCurrentInfo_1_2 & cellListCurrentInformation)319 int32_t TelRilNetwork::GetCurrentCellInfoResponse_1_2(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
320     const HDI::Ril::V1_2::CellListCurrentInfo_1_2 &cellListCurrentInformation)
321 {
322     std::shared_ptr<CellListCurrentInformation> currentCellList = std::make_shared<CellListCurrentInformation>();
323     BuildCurrentCellInformationList(currentCellList, cellListCurrentInformation);
324     return Response<CellListCurrentInformation>(TELEPHONY_LOG_FUNC_NAME, responseInfo, currentCellList);
325 }
326 
SetPreferredNetworkResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo)327 int32_t TelRilNetwork::SetPreferredNetworkResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo)
328 {
329     return Response(TELEPHONY_LOG_FUNC_NAME, responseInfo);
330 }
331 
GetPreferredNetworkResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::PreferredNetworkTypeInfo & preferredNetworkTypeInfo)332 int32_t TelRilNetwork::GetPreferredNetworkResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
333     const HDI::Ril::V1_1::PreferredNetworkTypeInfo &preferredNetworkTypeInfo)
334 {
335     auto getDataFunc = [&preferredNetworkTypeInfo](std::shared_ptr<TelRilRequest> telRilRequest) {
336         std::shared_ptr<PreferredNetworkTypeInfo> preferredTypeInfo = std::make_shared<PreferredNetworkTypeInfo>();
337         preferredTypeInfo->preferredNetworkType = preferredNetworkTypeInfo.preferredNetworkType;
338         preferredTypeInfo->flag = telRilRequest->pointer_->GetParam();
339         return preferredTypeInfo;
340     };
341     return Response<PreferredNetworkTypeInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, getDataFunc);
342 }
343 
GetPhysicalChannelConfigResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_1::ChannelConfigInfoList & channelConfigInfoList)344 int32_t TelRilNetwork::GetPhysicalChannelConfigResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
345     const HDI::Ril::V1_1::ChannelConfigInfoList &channelConfigInfoList)
346 {
347     auto getDataFunc = [&channelConfigInfoList, this](std::shared_ptr<TelRilRequest> telRilRequest) {
348         std::shared_ptr<ChannelConfigInfoList> channelConfigList = std::make_shared<ChannelConfigInfoList>();
349         this->BuildChannelConfigInfoList(channelConfigList, channelConfigInfoList);
350         channelConfigList->flag = telRilRequest->pointer_->GetParam();
351         return channelConfigList;
352     };
353     return Response<ChannelConfigInfoList>(TELEPHONY_LOG_FUNC_NAME, responseInfo, getDataFunc);
354 }
355 
SetLocateUpdatesResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo)356 int32_t TelRilNetwork::SetLocateUpdatesResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo)
357 {
358     return Response(TELEPHONY_LOG_FUNC_NAME, responseInfo);
359 }
360 
SetNotificationFilterResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo)361 int32_t TelRilNetwork::SetNotificationFilterResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo)
362 {
363     return Response(TELEPHONY_LOG_FUNC_NAME, responseInfo);
364 }
365 
SetDeviceStateResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo)366 int32_t TelRilNetwork::SetDeviceStateResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo)
367 {
368     return Response(TELEPHONY_LOG_FUNC_NAME, responseInfo);
369 }
370 
SetNrOptionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo)371 int32_t TelRilNetwork::SetNrOptionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo)
372 {
373     return Response(TELEPHONY_LOG_FUNC_NAME, responseInfo);
374 }
375 
GetNrOptionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,int32_t mode)376 int32_t TelRilNetwork::GetNrOptionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, int32_t mode)
377 {
378     auto getDataFunc = [mode](std::shared_ptr<TelRilRequest> telRilRequest) {
379         std::shared_ptr<NrModeInfo> nrModeInfo = std::make_shared<NrModeInfo>();
380         nrModeInfo->nrMode = mode;
381         nrModeInfo->flag = telRilRequest->pointer_->GetParam();
382         return nrModeInfo;
383     };
384     return Response<NrModeInfo>(TELEPHONY_LOG_FUNC_NAME, responseInfo, getDataFunc);
385 }
386 
GetRrcConnectionStateResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,int32_t rrcConnectionState)387 int32_t TelRilNetwork::GetRrcConnectionStateResponse(
388     const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, int32_t rrcConnectionState)
389 {
390     return Response<Int32Parcel>(
391         TELEPHONY_LOG_FUNC_NAME, responseInfo, std::make_shared<Int32Parcel>(rrcConnectionState));
392 }
393 
GetNrSsbIdResponse(const HDI::Ril::V1_1::RilRadioResponseInfo & responseInfo,const HDI::Ril::V1_2::NrCellSsbIds & nrCellSsbIds)394 int32_t TelRilNetwork::GetNrSsbIdResponse(
395     const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_2::NrCellSsbIds &nrCellSsbIds)
396 {
397     std::shared_ptr<NrCellSsbIds> nrCellSsbIdsInfo = std::make_shared<NrCellSsbIds>();
398     if (nrCellSsbIdsInfo == nullptr) {
399         return Response<NrCellSsbIds>(TELEPHONY_LOG_FUNC_NAME, responseInfo, nrCellSsbIdsInfo);
400     }
401     TELEPHONY_LOGI("Get ssbid response from hril");
402     nrCellSsbIdsInfo->arfcn = nrCellSsbIds.arfcn;
403     nrCellSsbIdsInfo->cid = nrCellSsbIds.cid;
404     nrCellSsbIdsInfo->pic = nrCellSsbIds.pic;
405     nrCellSsbIdsInfo->rsrp = nrCellSsbIds.rsrp;
406     nrCellSsbIdsInfo->sinr = nrCellSsbIds.sinr;
407     nrCellSsbIdsInfo->timeAdvance = nrCellSsbIds.timeAdvance;
408     nrCellSsbIdsInfo->nbCellCount = nrCellSsbIds.nbCellCount;
409     for (const auto &info : nrCellSsbIds.sCellSsbList) {
410         SsbIdInfo ssbIdInfo;
411         ssbIdInfo.ssbId = info.ssbId;
412         ssbIdInfo.rsrp = info.rsrp;
413         nrCellSsbIdsInfo->sCellSsbList.push_back(ssbIdInfo);
414     }
415     int32_t nbCellCount =
416         (nrCellSsbIdsInfo->nbCellCount > MAX_NBCELL_COUNT) ? MAX_NBCELL_COUNT : nrCellSsbIdsInfo->nbCellCount;
417     for (int32_t i = 0; i < nbCellCount; i++) {
418         NeighboringCellSsbInfo neighboringCellSsbInfo;
419         neighboringCellSsbInfo.pci = nrCellSsbIds.nbCellSsbList[i].pci;
420         neighboringCellSsbInfo.arfcn = nrCellSsbIds.nbCellSsbList[i].arfcn;
421         neighboringCellSsbInfo.rsrp = nrCellSsbIds.nbCellSsbList[i].rsrp;
422         neighboringCellSsbInfo.sinr = nrCellSsbIds.nbCellSsbList[i].sinr;
423         for (const auto &info : nrCellSsbIds.nbCellSsbList[i].ssbIdList) {
424             SsbIdInfo nbCellSsbIdInfo;
425             nbCellSsbIdInfo.ssbId = info.ssbId;
426             nbCellSsbIdInfo.rsrp = info.rsrp;
427             neighboringCellSsbInfo.ssbIdList.push_back(nbCellSsbIdInfo);
428         }
429         nrCellSsbIdsInfo->nbCellSsbList.push_back(neighboringCellSsbInfo);
430     }
431     return Response<NrCellSsbIds>(TELEPHONY_LOG_FUNC_NAME, responseInfo, nrCellSsbIdsInfo);
432 }
433 
BuildSignalStrength(std::shared_ptr<Rssi> signalStrength,const HDI::Ril::V1_1::Rssi & rssi)434 void TelRilNetwork::BuildSignalStrength(std::shared_ptr<Rssi> signalStrength, const HDI::Ril::V1_1::Rssi &rssi)
435 {
436     signalStrength->gw.rxlev = rssi.gw.rxlev;
437     signalStrength->gw.ber = rssi.gw.ber;
438     signalStrength->cdma.absoluteRssi = rssi.cdma.absoluteRssi;
439     signalStrength->cdma.ecno = rssi.cdma.ecno;
440     signalStrength->wcdma.rxlev = rssi.wcdma.rxlev;
441     signalStrength->wcdma.ber = rssi.wcdma.ber;
442     signalStrength->wcdma.ecio = rssi.wcdma.ecio;
443     signalStrength->wcdma.rscp = rssi.wcdma.rscp;
444     signalStrength->lte.rxlev = rssi.lte.rxlev;
445     signalStrength->lte.rsrp = rssi.lte.rsrp;
446     signalStrength->lte.rsrq = rssi.lte.rsrq;
447     signalStrength->lte.snr = rssi.lte.snr;
448     signalStrength->tdScdma.rscp = rssi.tdScdma.rscp;
449     signalStrength->nr.rsrp = rssi.nr.rsrp;
450     signalStrength->nr.rsrq = rssi.nr.rsrq;
451     signalStrength->nr.sinr = rssi.nr.sinr;
452 }
453 
BuildCsRegStatusInfo(std::shared_ptr<CsRegStatusInfo> regStatusInfo,const HDI::Ril::V1_1::CsRegStatusInfo & csRegStatusInfo)454 void TelRilNetwork::BuildCsRegStatusInfo(
455     std::shared_ptr<CsRegStatusInfo> regStatusInfo, const HDI::Ril::V1_1::CsRegStatusInfo &csRegStatusInfo)
456 {
457     regStatusInfo->notifyType = csRegStatusInfo.notifyType;
458     regStatusInfo->regStatus = static_cast<TelRilRegStatus>(csRegStatusInfo.regStatus);
459     regStatusInfo->lacCode = csRegStatusInfo.lacCode;
460     regStatusInfo->cellId = csRegStatusInfo.cellId;
461     regStatusInfo->radioTechnology = static_cast<TelRilRadioTech>(csRegStatusInfo.radioTechnology);
462 }
463 
BuildPsRegStatusInfo(std::shared_ptr<PsRegStatusResultInfo> regStatusInfo,const HDI::Ril::V1_1::PsRegStatusInfo & psRegStatusInfo)464 void TelRilNetwork::BuildPsRegStatusInfo(
465     std::shared_ptr<PsRegStatusResultInfo> regStatusInfo, const HDI::Ril::V1_1::PsRegStatusInfo &psRegStatusInfo)
466 {
467     regStatusInfo->notifyType = psRegStatusInfo.notifyType;
468     regStatusInfo->regStatus = static_cast<TelRilRegStatus>(psRegStatusInfo.regStatus);
469     regStatusInfo->lacCode = psRegStatusInfo.lacCode;
470     regStatusInfo->cellId = psRegStatusInfo.cellId;
471     regStatusInfo->radioTechnology = static_cast<TelRilRadioTech>(psRegStatusInfo.radioTechnology);
472     regStatusInfo->isNrAvailable = psRegStatusInfo.isNrAvailable;
473     regStatusInfo->isEnDcAvailable = psRegStatusInfo.isEnDcAvailable;
474     regStatusInfo->isDcNrRestricted = psRegStatusInfo.isDcNrRestricted;
475 }
476 
BuildOperatorInfo(std::shared_ptr<OperatorInfoResult> operatorInfoResult,const HDI::Ril::V1_1::OperatorInfo & operatorInfo)477 void TelRilNetwork::BuildOperatorInfo(
478     std::shared_ptr<OperatorInfoResult> operatorInfoResult, const HDI::Ril::V1_1::OperatorInfo &operatorInfo)
479 {
480     operatorInfoResult->longName = operatorInfo.longName;
481     operatorInfoResult->shortName = operatorInfo.shortName;
482     operatorInfoResult->numeric = operatorInfo.numeric;
483 }
484 
BuildAvailableNetworkList(std::shared_ptr<AvailableNetworkList> availableNetworkInfos,const HDI::Ril::V1_1::AvailableNetworkList & availableNetworkList)485 void TelRilNetwork::BuildAvailableNetworkList(std::shared_ptr<AvailableNetworkList> availableNetworkInfos,
486     const HDI::Ril::V1_1::AvailableNetworkList &availableNetworkList)
487 {
488     AvailableNetworkInfo operInfo = {};
489     availableNetworkInfos->itemNum = availableNetworkList.itemNum;
490     for (auto availableInfo : availableNetworkList.availableNetworkInfo) {
491         AvailableNetworkInfo info;
492         info.status = availableInfo.status;
493         info.longName = availableInfo.longName;
494         info.numeric = availableInfo.numeric;
495         info.shortName = availableInfo.shortName;
496         info.rat = availableInfo.rat;
497         availableNetworkInfos->availableNetworkInfo.push_back(info);
498     }
499 }
500 
BuildNetworkModeInfo(std::shared_ptr<SetNetworkModeInfo> networkModeInfo,const HDI::Ril::V1_1::SetNetworkModeInfo & setNetworkModeInfo)501 void TelRilNetwork::BuildNetworkModeInfo(
502     std::shared_ptr<SetNetworkModeInfo> networkModeInfo, const HDI::Ril::V1_1::SetNetworkModeInfo &setNetworkModeInfo)
503 {
504     networkModeInfo->selectMode = setNetworkModeInfo.selectMode;
505     networkModeInfo->oper = setNetworkModeInfo.oper;
506 }
507 
BuildNeighboringCellInfoList(std::shared_ptr<CellListNearbyInfo> cellListNearbyInfo,const HDI::Ril::V1_1::CellListNearbyInfo & cellInfoList)508 void TelRilNetwork::BuildNeighboringCellInfoList(
509     std::shared_ptr<CellListNearbyInfo> cellListNearbyInfo, const HDI::Ril::V1_1::CellListNearbyInfo &cellInfoList)
510 {
511     cellListNearbyInfo->itemNum = cellInfoList.itemNum;
512     for (auto info : cellInfoList.cellNearbyInfo) {
513         CellNearbyInfo cellInfo;
514         FillCellNearbyInfo(cellInfo, info);
515         cellListNearbyInfo->cellNearbyInfo.push_back(cellInfo);
516     }
517 }
518 
FillGsmCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_1::CellNearbyInfo & info)519 void TelRilNetwork::FillGsmCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info)
520 {
521     cellInfo.ServiceCellParas.gsm.band = info.serviceCells.gsm.band;
522     cellInfo.ServiceCellParas.gsm.arfcn = info.serviceCells.gsm.arfcn;
523     cellInfo.ServiceCellParas.gsm.bsic = info.serviceCells.gsm.bsic;
524     cellInfo.ServiceCellParas.gsm.cellId = info.serviceCells.gsm.cellId;
525     cellInfo.ServiceCellParas.gsm.lac = info.serviceCells.gsm.lac;
526     cellInfo.ServiceCellParas.gsm.rxlev = info.serviceCells.gsm.rxlev;
527 }
528 
FillLteCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_1::CellNearbyInfo & info)529 void TelRilNetwork::FillLteCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info)
530 {
531     cellInfo.ServiceCellParas.lte.arfcn = info.serviceCells.lte.arfcn;
532     cellInfo.ServiceCellParas.lte.pci = info.serviceCells.lte.pci;
533     cellInfo.ServiceCellParas.lte.rsrp = info.serviceCells.lte.rsrp;
534     cellInfo.ServiceCellParas.lte.rsrq = info.serviceCells.lte.rsrq;
535     cellInfo.ServiceCellParas.lte.rxlev = info.serviceCells.lte.rxlev;
536 }
537 
FillWcdmaCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_1::CellNearbyInfo & info)538 void TelRilNetwork::FillWcdmaCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info)
539 {
540     cellInfo.ServiceCellParas.wcdma.arfcn = info.serviceCells.wcdma.arfcn;
541     cellInfo.ServiceCellParas.wcdma.psc = info.serviceCells.wcdma.psc;
542     cellInfo.ServiceCellParas.wcdma.rscp = info.serviceCells.wcdma.rscp;
543     cellInfo.ServiceCellParas.wcdma.ecno = info.serviceCells.wcdma.ecno;
544 }
545 
FillCdmaCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_1::CellNearbyInfo & info)546 void TelRilNetwork::FillCdmaCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info)
547 {
548     cellInfo.ServiceCellParas.cdma.systemId = info.serviceCells.cdma.systemId;
549     cellInfo.ServiceCellParas.cdma.networkId = info.serviceCells.cdma.networkId;
550     cellInfo.ServiceCellParas.cdma.baseId = info.serviceCells.cdma.baseId;
551     cellInfo.ServiceCellParas.cdma.zoneId = info.serviceCells.cdma.zoneId;
552     cellInfo.ServiceCellParas.cdma.pilotPn = info.serviceCells.cdma.pilotPn;
553     cellInfo.ServiceCellParas.cdma.pilotStrength = info.serviceCells.cdma.pilotStrength;
554     cellInfo.ServiceCellParas.cdma.channel = info.serviceCells.cdma.channel;
555     cellInfo.ServiceCellParas.cdma.longitude = info.serviceCells.cdma.longitude;
556     cellInfo.ServiceCellParas.cdma.latitude = info.serviceCells.cdma.latitude;
557 }
558 
FillTdscdmaCellNearbyInfo(CellNearbyInfo & cellNearbyInfo,const HDI::Ril::V1_1::CellNearbyInfo & info)559 void TelRilNetwork::FillTdscdmaCellNearbyInfo(
560     CellNearbyInfo &cellNearbyInfo, const HDI::Ril::V1_1::CellNearbyInfo &info)
561 {
562     cellNearbyInfo.ServiceCellParas.tdscdma.arfcn = info.serviceCells.tdscdma.arfcn;
563     cellNearbyInfo.ServiceCellParas.tdscdma.syncId = info.serviceCells.tdscdma.syncId;
564     cellNearbyInfo.ServiceCellParas.tdscdma.sc = info.serviceCells.tdscdma.sc;
565     cellNearbyInfo.ServiceCellParas.tdscdma.cellId = info.serviceCells.tdscdma.cellId;
566     cellNearbyInfo.ServiceCellParas.tdscdma.lac = info.serviceCells.tdscdma.lac;
567     cellNearbyInfo.ServiceCellParas.tdscdma.rscp = info.serviceCells.tdscdma.rscp;
568     cellNearbyInfo.ServiceCellParas.tdscdma.drx = info.serviceCells.tdscdma.drx;
569     cellNearbyInfo.ServiceCellParas.tdscdma.rac = info.serviceCells.tdscdma.rac;
570     cellNearbyInfo.ServiceCellParas.tdscdma.cpid = info.serviceCells.tdscdma.cpid;
571 }
572 
FillNrCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_1::CellNearbyInfo & info)573 void TelRilNetwork::FillNrCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info)
574 {
575     cellInfo.ServiceCellParas.nr.nrArfcn = info.serviceCells.nr.nrArfcn;
576     cellInfo.ServiceCellParas.nr.pci = info.serviceCells.nr.pci;
577     cellInfo.ServiceCellParas.nr.tac = info.serviceCells.nr.tac;
578     cellInfo.ServiceCellParas.nr.nci = info.serviceCells.nr.nci;
579 }
580 
FillCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_1::CellNearbyInfo & info)581 void TelRilNetwork::FillCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info)
582 {
583     cellInfo.ratType = info.ratType;
584     switch (info.ratType) {
585         case NETWORK_TYPE_GSM:
586             FillGsmCellNearbyInfo(cellInfo, info);
587             break;
588         case NETWORK_TYPE_LTE:
589             FillLteCellNearbyInfo(cellInfo, info);
590             break;
591         case NETWORK_TYPE_WCDMA:
592             FillWcdmaCellNearbyInfo(cellInfo, info);
593             break;
594         case NETWORK_TYPE_CDMA:
595             FillCdmaCellNearbyInfo(cellInfo, info);
596             break;
597         case NETWORK_TYPE_TDSCDMA:
598             FillTdscdmaCellNearbyInfo(cellInfo, info);
599             break;
600         case NETWORK_TYPE_NR:
601             FillNrCellNearbyInfo(cellInfo, info);
602             break;
603         default:
604             TELEPHONY_LOGE("TelRilNetwork::FillCellNearbyInfo invalid ratType");
605             break;
606     }
607 }
608 
BuildNeighboringCellInfoList(std::shared_ptr<CellListNearbyInfo> cellListNearbyInfo,const HDI::Ril::V1_2::CellListNearbyInfo_1_2 & cellInfoList)609 void TelRilNetwork::BuildNeighboringCellInfoList(
610     std::shared_ptr<CellListNearbyInfo> cellListNearbyInfo, const HDI::Ril::V1_2::CellListNearbyInfo_1_2 &cellInfoList)
611 {
612     cellListNearbyInfo->itemNum = cellInfoList.itemNum;
613     for (auto info : cellInfoList.cellNearbyInfo) {
614         CellNearbyInfo cellInfo;
615         FillCellNearbyInfo(cellInfo, info);
616         cellListNearbyInfo->cellNearbyInfo.push_back(cellInfo);
617     }
618 }
619 
FillCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_2::CellNearbyInfo_1_2 & info)620 void TelRilNetwork::FillCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info)
621 {
622     cellInfo.ratType = info.ratType;
623     switch (info.ratType) {
624         case NETWORK_TYPE_GSM:
625             FillGsmCellNearbyInfo(cellInfo, info);
626             break;
627         case NETWORK_TYPE_LTE:
628             FillLteCellNearbyInfo(cellInfo, info);
629             break;
630         case NETWORK_TYPE_WCDMA:
631             FillWcdmaCellNearbyInfo(cellInfo, info);
632             break;
633         case NETWORK_TYPE_CDMA:
634             FillCdmaCellNearbyInfo(cellInfo, info);
635             break;
636         case NETWORK_TYPE_TDSCDMA:
637             FillTdscdmaCellNearbyInfo(cellInfo, info);
638             break;
639         case NETWORK_TYPE_NR:
640             FillNrCellNearbyInfo(cellInfo, info);
641             break;
642         default:
643             TELEPHONY_LOGE("invalid ratType");
644             break;
645     }
646 }
647 
FillGsmCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_2::CellNearbyInfo_1_2 & info)648 void TelRilNetwork::FillGsmCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info)
649 {
650     cellInfo.ServiceCellParas.gsm.band = info.serviceCells.gsm.band;
651     cellInfo.ServiceCellParas.gsm.arfcn = info.serviceCells.gsm.arfcn;
652     cellInfo.ServiceCellParas.gsm.bsic = info.serviceCells.gsm.bsic;
653     cellInfo.ServiceCellParas.gsm.cellId = info.serviceCells.gsm.cellId;
654     cellInfo.ServiceCellParas.gsm.lac = info.serviceCells.gsm.lac;
655     cellInfo.ServiceCellParas.gsm.rxlev = info.serviceCells.gsm.rxlev;
656 }
657 
FillLteCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_2::CellNearbyInfo_1_2 & info)658 void TelRilNetwork::FillLteCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info)
659 {
660     cellInfo.ServiceCellParas.lte.arfcn = info.serviceCells.lte.arfcn;
661     cellInfo.ServiceCellParas.lte.pci = info.serviceCells.lte.pci;
662     cellInfo.ServiceCellParas.lte.rsrp = info.serviceCells.lte.rsrp;
663     cellInfo.ServiceCellParas.lte.rsrq = info.serviceCells.lte.rsrq;
664     cellInfo.ServiceCellParas.lte.rxlev = info.serviceCells.lte.rxlev;
665 }
666 
FillWcdmaCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_2::CellNearbyInfo_1_2 & info)667 void TelRilNetwork::FillWcdmaCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info)
668 {
669     cellInfo.ServiceCellParas.wcdma.arfcn = info.serviceCells.wcdma.arfcn;
670     cellInfo.ServiceCellParas.wcdma.psc = info.serviceCells.wcdma.psc;
671     cellInfo.ServiceCellParas.wcdma.rscp = info.serviceCells.wcdma.rscp;
672     cellInfo.ServiceCellParas.wcdma.ecno = info.serviceCells.wcdma.ecno;
673 }
674 
FillCdmaCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_2::CellNearbyInfo_1_2 & info)675 void TelRilNetwork::FillCdmaCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info)
676 {
677     cellInfo.ServiceCellParas.cdma.systemId = info.serviceCells.cdma.systemId;
678     cellInfo.ServiceCellParas.cdma.networkId = info.serviceCells.cdma.networkId;
679     cellInfo.ServiceCellParas.cdma.baseId = info.serviceCells.cdma.baseId;
680     cellInfo.ServiceCellParas.cdma.zoneId = info.serviceCells.cdma.zoneId;
681     cellInfo.ServiceCellParas.cdma.pilotPn = info.serviceCells.cdma.pilotPn;
682     cellInfo.ServiceCellParas.cdma.pilotStrength = info.serviceCells.cdma.pilotStrength;
683     cellInfo.ServiceCellParas.cdma.channel = info.serviceCells.cdma.channel;
684     cellInfo.ServiceCellParas.cdma.longitude = info.serviceCells.cdma.longitude;
685     cellInfo.ServiceCellParas.cdma.latitude = info.serviceCells.cdma.latitude;
686 }
687 
FillTdscdmaCellNearbyInfo(CellNearbyInfo & cellNearbyInfo,const HDI::Ril::V1_2::CellNearbyInfo_1_2 & info)688 void TelRilNetwork::FillTdscdmaCellNearbyInfo(
689     CellNearbyInfo &cellNearbyInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info)
690 {
691     cellNearbyInfo.ServiceCellParas.tdscdma.arfcn = info.serviceCells.tdscdma.arfcn;
692     cellNearbyInfo.ServiceCellParas.tdscdma.syncId = info.serviceCells.tdscdma.syncId;
693     cellNearbyInfo.ServiceCellParas.tdscdma.sc = info.serviceCells.tdscdma.sc;
694     cellNearbyInfo.ServiceCellParas.tdscdma.cellId = info.serviceCells.tdscdma.cellId;
695     cellNearbyInfo.ServiceCellParas.tdscdma.lac = info.serviceCells.tdscdma.lac;
696     cellNearbyInfo.ServiceCellParas.tdscdma.rscp = info.serviceCells.tdscdma.rscp;
697     cellNearbyInfo.ServiceCellParas.tdscdma.drx = info.serviceCells.tdscdma.drx;
698     cellNearbyInfo.ServiceCellParas.tdscdma.rac = info.serviceCells.tdscdma.rac;
699     cellNearbyInfo.ServiceCellParas.tdscdma.cpid = info.serviceCells.tdscdma.cpid;
700 }
701 
FillNrCellNearbyInfo(CellNearbyInfo & cellInfo,const HDI::Ril::V1_2::CellNearbyInfo_1_2 & info)702 void TelRilNetwork::FillNrCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info)
703 {
704     cellInfo.ServiceCellParas.nr.nrArfcn = info.serviceCells.nr.nrArfcn;
705     cellInfo.ServiceCellParas.nr.pci = info.serviceCells.nr.pci;
706     cellInfo.ServiceCellParas.nr.tac = info.serviceCells.nr.tac;
707     cellInfo.ServiceCellParas.nr.nci = info.serviceCells.nr.nci;
708 }
709 
BuildCurrentCellInfoList(std::shared_ptr<CellListCurrentInfo> currentCellList,const HDI::Ril::V1_1::CellListCurrentInfo & cellInfoList)710 void TelRilNetwork::BuildCurrentCellInfoList(
711     std::shared_ptr<CellListCurrentInfo> currentCellList, const HDI::Ril::V1_1::CellListCurrentInfo &cellInfoList)
712 {
713     currentCellList->itemNum = cellInfoList.itemNum;
714     for (auto &info : cellInfoList.cellCurrentInfo) {
715         CurrentCellInfo cellInfo;
716         FillCurrentCellInfo(cellInfo, info);
717         currentCellList->cellCurrentInfo.push_back(cellInfo);
718     }
719 }
720 
FillCurrentCellInfo(CurrentCellInfo & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo & info)721 void TelRilNetwork::FillCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info)
722 {
723     cellInfo.ratType = info.ratType;
724     cellInfo.mcc = info.mcc;
725     cellInfo.mnc = info.mnc;
726     switch (info.ratType) {
727         case NETWORK_TYPE_GSM:
728             FillGsmCurrentCellInfo(cellInfo, info);
729             break;
730         case NETWORK_TYPE_LTE:
731             FillLteCurrentCellInfo(cellInfo, info);
732             break;
733         case NETWORK_TYPE_WCDMA:
734             FillWcdmaCurrentCellInfo(cellInfo, info);
735             break;
736         case NETWORK_TYPE_CDMA:
737             FillCdmaCurrentCellInfo(cellInfo, info);
738             break;
739         case NETWORK_TYPE_TDSCDMA:
740             FillTdscdmaCurrentCellInfo(cellInfo, info);
741             break;
742         case NETWORK_TYPE_NR:
743             FillNrCurrentCellInfo(cellInfo, info);
744             break;
745         default:
746             TELEPHONY_LOGE("TelRilNetwork::FillCurrentCellInfo invalid ratType");
747             break;
748     }
749 }
750 
FillGsmCurrentCellInfo(CurrentCellInfo & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo & info)751 void TelRilNetwork::FillGsmCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info)
752 {
753     cellInfo.ServiceCellParas.gsm.band = info.serviceCells.gsm.band;
754     cellInfo.ServiceCellParas.gsm.arfcn = info.serviceCells.gsm.arfcn;
755     cellInfo.ServiceCellParas.gsm.bsic = info.serviceCells.gsm.bsic;
756     cellInfo.ServiceCellParas.gsm.cellId = info.serviceCells.gsm.cellId;
757     cellInfo.ServiceCellParas.gsm.lac = info.serviceCells.gsm.lac;
758     cellInfo.ServiceCellParas.gsm.rxlev = info.serviceCells.gsm.rxlev;
759     cellInfo.ServiceCellParas.gsm.rxQuality = info.serviceCells.gsm.rxQuality;
760     cellInfo.ServiceCellParas.gsm.ta = info.serviceCells.gsm.ta;
761 }
762 
FillLteCurrentCellInfo(CurrentCellInfo & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo & info)763 void TelRilNetwork::FillLteCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info)
764 {
765     cellInfo.ServiceCellParas.lte.arfcn = info.serviceCells.lte.arfcn;
766     cellInfo.ServiceCellParas.lte.cellId = info.serviceCells.lte.cellId;
767     cellInfo.ServiceCellParas.lte.pci = info.serviceCells.lte.pci;
768     cellInfo.ServiceCellParas.lte.tac = info.serviceCells.lte.tac;
769     cellInfo.ServiceCellParas.lte.rsrp = info.serviceCells.lte.rsrp;
770     cellInfo.ServiceCellParas.lte.rsrq = info.serviceCells.lte.rsrq;
771     cellInfo.ServiceCellParas.lte.rssi = info.serviceCells.lte.rssi;
772 }
773 
FillWcdmaCurrentCellInfo(CurrentCellInfo & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo & info)774 void TelRilNetwork::FillWcdmaCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info)
775 {
776     cellInfo.ServiceCellParas.wcdma.arfcn = info.serviceCells.wcdma.arfcn;
777     cellInfo.ServiceCellParas.wcdma.cellId = info.serviceCells.wcdma.cellId;
778     cellInfo.ServiceCellParas.wcdma.psc = info.serviceCells.wcdma.psc;
779     cellInfo.ServiceCellParas.wcdma.lac = info.serviceCells.wcdma.lac;
780     cellInfo.ServiceCellParas.wcdma.rxlev = info.serviceCells.wcdma.rxlev;
781     cellInfo.ServiceCellParas.wcdma.rscp = info.serviceCells.wcdma.rscp;
782     cellInfo.ServiceCellParas.wcdma.ecno = info.serviceCells.wcdma.ecno;
783     cellInfo.ServiceCellParas.wcdma.ura = info.serviceCells.wcdma.ura;
784     cellInfo.ServiceCellParas.wcdma.drx = info.serviceCells.wcdma.drx;
785 }
786 
FillCdmaCurrentCellInfo(CurrentCellInfo & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo & info)787 void TelRilNetwork::FillCdmaCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info)
788 {
789     cellInfo.ServiceCellParas.cdma.systemId = info.serviceCells.cdma.systemId;
790     cellInfo.ServiceCellParas.cdma.networkId = info.serviceCells.cdma.networkId;
791     cellInfo.ServiceCellParas.cdma.baseId = info.serviceCells.cdma.baseId;
792     cellInfo.ServiceCellParas.cdma.zoneId = info.serviceCells.cdma.zoneId;
793     cellInfo.ServiceCellParas.cdma.pilotPn = info.serviceCells.cdma.pilotPn;
794     cellInfo.ServiceCellParas.cdma.pilotStrength = info.serviceCells.cdma.pilotStrength;
795     cellInfo.ServiceCellParas.cdma.channel = info.serviceCells.cdma.channel;
796     cellInfo.ServiceCellParas.cdma.longitude = info.serviceCells.cdma.longitude;
797     cellInfo.ServiceCellParas.cdma.latitude = info.serviceCells.cdma.latitude;
798 }
799 
FillTdscdmaCurrentCellInfo(CurrentCellInfo & currentCellInfo,const HDI::Ril::V1_1::CurrentCellInfo & info)800 void TelRilNetwork::FillTdscdmaCurrentCellInfo(
801     CurrentCellInfo &currentCellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info)
802 {
803     currentCellInfo.ServiceCellParas.tdscdma.arfcn = info.serviceCells.tdscdma.arfcn;
804     currentCellInfo.ServiceCellParas.tdscdma.syncId = info.serviceCells.tdscdma.syncId;
805     currentCellInfo.ServiceCellParas.tdscdma.sc = info.serviceCells.tdscdma.sc;
806     currentCellInfo.ServiceCellParas.tdscdma.cellId = info.serviceCells.tdscdma.cellId;
807     currentCellInfo.ServiceCellParas.tdscdma.lac = info.serviceCells.tdscdma.lac;
808     currentCellInfo.ServiceCellParas.tdscdma.rscp = info.serviceCells.tdscdma.rscp;
809     currentCellInfo.ServiceCellParas.tdscdma.drx = info.serviceCells.tdscdma.drx;
810     currentCellInfo.ServiceCellParas.tdscdma.rac = info.serviceCells.tdscdma.rac;
811     currentCellInfo.ServiceCellParas.tdscdma.cpid = info.serviceCells.tdscdma.cpid;
812 }
813 
FillNrCurrentCellInfo(CurrentCellInfo & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo & info)814 void TelRilNetwork::FillNrCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info)
815 {
816     cellInfo.ServiceCellParas.nr.nrArfcn = info.serviceCells.nr.nrArfcn;
817     cellInfo.ServiceCellParas.nr.pci = info.serviceCells.nr.pci;
818     cellInfo.ServiceCellParas.nr.tac = info.serviceCells.nr.tac;
819     cellInfo.ServiceCellParas.nr.nci = info.serviceCells.nr.nci;
820 }
821 
BuildCurrentCellInformationList(std::shared_ptr<CellListCurrentInformation> currentCellList,const HDI::Ril::V1_1::CellListCurrentInfo_1_1 & cellInfoList)822 void TelRilNetwork::BuildCurrentCellInformationList(std::shared_ptr<CellListCurrentInformation> currentCellList,
823     const HDI::Ril::V1_1::CellListCurrentInfo_1_1 &cellInfoList)
824 {
825     currentCellList->itemNum = cellInfoList.itemNum;
826     for (auto &info : cellInfoList.cellCurrentInfo) {
827         CurrentCellInformation cellInfo;
828         FillCurrentCellInformation(cellInfo, info);
829         currentCellList->cellCurrentInfo.push_back(cellInfo);
830     }
831 }
832 
FillCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo_1_1 & info)833 void TelRilNetwork::FillCurrentCellInformation(
834     CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info)
835 {
836     cellInfo.ratType = info.ratType;
837     cellInfo.mcc = info.mcc;
838     cellInfo.mnc = info.mnc;
839     switch (info.ratType) {
840         case NETWORK_TYPE_GSM:
841             FillGsmCurrentCellInformation(cellInfo, info);
842             break;
843         case NETWORK_TYPE_LTE:
844             FillLteCurrentCellInformation(cellInfo, info);
845             break;
846         case NETWORK_TYPE_WCDMA:
847             FillWcdmaCurrentCellInformation(cellInfo, info);
848             break;
849         case NETWORK_TYPE_CDMA:
850             FillCdmaCurrentCellInformation(cellInfo, info);
851             break;
852         case NETWORK_TYPE_TDSCDMA:
853             FillTdscdmaCurrentCellInformation(cellInfo, info);
854             break;
855         case NETWORK_TYPE_NR:
856             FillNrCurrentCellInformation(cellInfo, info);
857             break;
858         default:
859             TELEPHONY_LOGE("TelRilNetwork::FillCurrentCellInformation invalid ratType");
860             break;
861     }
862 }
863 
FillGsmCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo_1_1 & info)864 void TelRilNetwork::FillGsmCurrentCellInformation(
865     CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info)
866 {
867     cellInfo.ServiceCellParas.gsm.band = info.serviceCells.gsm.band;
868     cellInfo.ServiceCellParas.gsm.arfcn = info.serviceCells.gsm.arfcn;
869     cellInfo.ServiceCellParas.gsm.bsic = info.serviceCells.gsm.bsic;
870     cellInfo.ServiceCellParas.gsm.cellId = info.serviceCells.gsm.cellId;
871     cellInfo.ServiceCellParas.gsm.lac = info.serviceCells.gsm.lac;
872     cellInfo.ServiceCellParas.gsm.rxlev = info.serviceCells.gsm.rxlev;
873     cellInfo.ServiceCellParas.gsm.rxQuality = info.serviceCells.gsm.rxQuality;
874     cellInfo.ServiceCellParas.gsm.ta = info.serviceCells.gsm.ta;
875 }
876 
FillLteCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo_1_1 & info)877 void TelRilNetwork::FillLteCurrentCellInformation(
878     CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info)
879 {
880     cellInfo.ServiceCellParas.lte.arfcn = info.serviceCells.lte.arfcn;
881     cellInfo.ServiceCellParas.lte.cellId = info.serviceCells.lte.cellId;
882     cellInfo.ServiceCellParas.lte.pci = info.serviceCells.lte.pci;
883     cellInfo.ServiceCellParas.lte.tac = info.serviceCells.lte.tac;
884     cellInfo.ServiceCellParas.lte.rsrp = info.serviceCells.lte.rsrp;
885     cellInfo.ServiceCellParas.lte.rsrq = info.serviceCells.lte.rsrq;
886     cellInfo.ServiceCellParas.lte.rssi = info.serviceCells.lte.rssi;
887 }
888 
FillWcdmaCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo_1_1 & info)889 void TelRilNetwork::FillWcdmaCurrentCellInformation(
890     CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info)
891 {
892     cellInfo.ServiceCellParas.wcdma.arfcn = info.serviceCells.wcdma.arfcn;
893     cellInfo.ServiceCellParas.wcdma.cellId = info.serviceCells.wcdma.cellId;
894     cellInfo.ServiceCellParas.wcdma.psc = info.serviceCells.wcdma.psc;
895     cellInfo.ServiceCellParas.wcdma.lac = info.serviceCells.wcdma.lac;
896     cellInfo.ServiceCellParas.wcdma.rxlev = info.serviceCells.wcdma.rxlev;
897     cellInfo.ServiceCellParas.wcdma.rscp = info.serviceCells.wcdma.rscp;
898     cellInfo.ServiceCellParas.wcdma.ecno = info.serviceCells.wcdma.ecno;
899     cellInfo.ServiceCellParas.wcdma.ura = info.serviceCells.wcdma.ura;
900     cellInfo.ServiceCellParas.wcdma.drx = info.serviceCells.wcdma.drx;
901 }
902 
FillCdmaCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo_1_1 & info)903 void TelRilNetwork::FillCdmaCurrentCellInformation(
904     CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info)
905 {
906     cellInfo.ServiceCellParas.cdma.systemId = info.serviceCells.cdma.systemId;
907     cellInfo.ServiceCellParas.cdma.networkId = info.serviceCells.cdma.networkId;
908     cellInfo.ServiceCellParas.cdma.baseId = info.serviceCells.cdma.baseId;
909     cellInfo.ServiceCellParas.cdma.zoneId = info.serviceCells.cdma.zoneId;
910     cellInfo.ServiceCellParas.cdma.pilotPn = info.serviceCells.cdma.pilotPn;
911     cellInfo.ServiceCellParas.cdma.pilotStrength = info.serviceCells.cdma.pilotStrength;
912     cellInfo.ServiceCellParas.cdma.channel = info.serviceCells.cdma.channel;
913     cellInfo.ServiceCellParas.cdma.longitude = info.serviceCells.cdma.longitude;
914     cellInfo.ServiceCellParas.cdma.latitude = info.serviceCells.cdma.latitude;
915 }
916 
FillTdscdmaCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo_1_1 & info)917 void TelRilNetwork::FillTdscdmaCurrentCellInformation(
918     CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info)
919 {
920     cellInfo.ServiceCellParas.tdscdma.arfcn = info.serviceCells.tdscdma.arfcn;
921     cellInfo.ServiceCellParas.tdscdma.syncId = info.serviceCells.tdscdma.syncId;
922     cellInfo.ServiceCellParas.tdscdma.sc = info.serviceCells.tdscdma.sc;
923     cellInfo.ServiceCellParas.tdscdma.cellId = info.serviceCells.tdscdma.cellId;
924     cellInfo.ServiceCellParas.tdscdma.lac = info.serviceCells.tdscdma.lac;
925     cellInfo.ServiceCellParas.tdscdma.rscp = info.serviceCells.tdscdma.rscp;
926     cellInfo.ServiceCellParas.tdscdma.drx = info.serviceCells.tdscdma.drx;
927     cellInfo.ServiceCellParas.tdscdma.rac = info.serviceCells.tdscdma.rac;
928     cellInfo.ServiceCellParas.tdscdma.cpid = info.serviceCells.tdscdma.cpid;
929 }
930 
FillNrCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_1::CurrentCellInfo_1_1 & info)931 void TelRilNetwork::FillNrCurrentCellInformation(
932     CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info)
933 {
934     cellInfo.ServiceCellParas.nr.nrArfcn = info.serviceCells.nr.nrArfcn;
935     cellInfo.ServiceCellParas.nr.pci = info.serviceCells.nr.pci;
936     cellInfo.ServiceCellParas.nr.tac = info.serviceCells.nr.tac;
937     cellInfo.ServiceCellParas.nr.nci = info.serviceCells.nr.nci;
938     cellInfo.ServiceCellParas.nr.rsrp = info.serviceCells.nr.rsrp;
939     cellInfo.ServiceCellParas.nr.rsrq = info.serviceCells.nr.rsrq;
940 }
941 
BuildCurrentCellInformationList(std::shared_ptr<CellListCurrentInformation> currentCellList,const HDI::Ril::V1_2::CellListCurrentInfo_1_2 & cellInfoList)942 void TelRilNetwork::BuildCurrentCellInformationList(std::shared_ptr<CellListCurrentInformation> currentCellList,
943     const HDI::Ril::V1_2::CellListCurrentInfo_1_2 &cellInfoList)
944 {
945     currentCellList->itemNum = cellInfoList.itemNum;
946     for (auto &info : cellInfoList.cellCurrentInfo) {
947         CurrentCellInformation cellInfo;
948         FillCurrentCellInformation(cellInfo, info);
949         currentCellList->cellCurrentInfo.push_back(cellInfo);
950     }
951 }
952 
FillCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_2::CurrentCellInfo_1_2 & info)953 void TelRilNetwork::FillCurrentCellInformation(
954     CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info)
955 {
956     cellInfo.ratType = info.ratType;
957     cellInfo.mcc = info.mcc;
958     cellInfo.mnc = info.mnc;
959     switch (info.ratType) {
960         case NETWORK_TYPE_GSM:
961             FillGsmCurrentCellInformation(cellInfo, info);
962             break;
963         case NETWORK_TYPE_LTE:
964             FillLteCurrentCellInformation(cellInfo, info);
965             break;
966         case NETWORK_TYPE_WCDMA:
967             FillWcdmaCurrentCellInformation(cellInfo, info);
968             break;
969         case NETWORK_TYPE_CDMA:
970             FillCdmaCurrentCellInformation(cellInfo, info);
971             break;
972         case NETWORK_TYPE_TDSCDMA:
973             FillTdscdmaCurrentCellInformation(cellInfo, info);
974             break;
975         case NETWORK_TYPE_NR:
976             FillNrCurrentCellInformation(cellInfo, info);
977             break;
978         default:
979             TELEPHONY_LOGE("invalid ratType");
980             break;
981     }
982 }
983 
FillGsmCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_2::CurrentCellInfo_1_2 & info)984 void TelRilNetwork::FillGsmCurrentCellInformation(
985     CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info)
986 {
987     cellInfo.ServiceCellParas.gsm.band = info.serviceCells.gsm.band;
988     cellInfo.ServiceCellParas.gsm.arfcn = info.serviceCells.gsm.arfcn;
989     cellInfo.ServiceCellParas.gsm.bsic = info.serviceCells.gsm.bsic;
990     cellInfo.ServiceCellParas.gsm.cellId = info.serviceCells.gsm.cellId;
991     cellInfo.ServiceCellParas.gsm.lac = info.serviceCells.gsm.lac;
992     cellInfo.ServiceCellParas.gsm.rxlev = info.serviceCells.gsm.rxlev;
993     cellInfo.ServiceCellParas.gsm.rxQuality = info.serviceCells.gsm.rxQuality;
994     cellInfo.ServiceCellParas.gsm.ta = info.serviceCells.gsm.ta;
995 }
996 
FillLteCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_2::CurrentCellInfo_1_2 & info)997 void TelRilNetwork::FillLteCurrentCellInformation(
998     CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info)
999 {
1000     cellInfo.ServiceCellParas.lte.arfcn = info.serviceCells.lte.arfcn;
1001     cellInfo.ServiceCellParas.lte.cellId = info.serviceCells.lte.cellId;
1002     cellInfo.ServiceCellParas.lte.pci = info.serviceCells.lte.pci;
1003     cellInfo.ServiceCellParas.lte.tac = info.serviceCells.lte.tac;
1004     cellInfo.ServiceCellParas.lte.rsrp = info.serviceCells.lte.rsrp;
1005     cellInfo.ServiceCellParas.lte.rsrq = info.serviceCells.lte.rsrq;
1006     cellInfo.ServiceCellParas.lte.rssi = info.serviceCells.lte.rssi;
1007 }
1008 
FillWcdmaCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_2::CurrentCellInfo_1_2 & info)1009 void TelRilNetwork::FillWcdmaCurrentCellInformation(
1010     CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info)
1011 {
1012     cellInfo.ServiceCellParas.wcdma.arfcn = info.serviceCells.wcdma.arfcn;
1013     cellInfo.ServiceCellParas.wcdma.cellId = info.serviceCells.wcdma.cellId;
1014     cellInfo.ServiceCellParas.wcdma.psc = info.serviceCells.wcdma.psc;
1015     cellInfo.ServiceCellParas.wcdma.lac = info.serviceCells.wcdma.lac;
1016     cellInfo.ServiceCellParas.wcdma.rxlev = info.serviceCells.wcdma.rxlev;
1017     cellInfo.ServiceCellParas.wcdma.rscp = info.serviceCells.wcdma.rscp;
1018     cellInfo.ServiceCellParas.wcdma.ecno = info.serviceCells.wcdma.ecno;
1019     cellInfo.ServiceCellParas.wcdma.ura = info.serviceCells.wcdma.ura;
1020     cellInfo.ServiceCellParas.wcdma.drx = info.serviceCells.wcdma.drx;
1021 }
1022 
FillCdmaCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_2::CurrentCellInfo_1_2 & info)1023 void TelRilNetwork::FillCdmaCurrentCellInformation(
1024     CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info)
1025 {
1026     cellInfo.ServiceCellParas.cdma.systemId = info.serviceCells.cdma.systemId;
1027     cellInfo.ServiceCellParas.cdma.networkId = info.serviceCells.cdma.networkId;
1028     cellInfo.ServiceCellParas.cdma.baseId = info.serviceCells.cdma.baseId;
1029     cellInfo.ServiceCellParas.cdma.zoneId = info.serviceCells.cdma.zoneId;
1030     cellInfo.ServiceCellParas.cdma.pilotPn = info.serviceCells.cdma.pilotPn;
1031     cellInfo.ServiceCellParas.cdma.pilotStrength = info.serviceCells.cdma.pilotStrength;
1032     cellInfo.ServiceCellParas.cdma.channel = info.serviceCells.cdma.channel;
1033     cellInfo.ServiceCellParas.cdma.longitude = info.serviceCells.cdma.longitude;
1034     cellInfo.ServiceCellParas.cdma.latitude = info.serviceCells.cdma.latitude;
1035 }
1036 
FillTdscdmaCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_2::CurrentCellInfo_1_2 & info)1037 void TelRilNetwork::FillTdscdmaCurrentCellInformation(
1038     CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info)
1039 {
1040     cellInfo.ServiceCellParas.tdscdma.arfcn = info.serviceCells.tdscdma.arfcn;
1041     cellInfo.ServiceCellParas.tdscdma.syncId = info.serviceCells.tdscdma.syncId;
1042     cellInfo.ServiceCellParas.tdscdma.sc = info.serviceCells.tdscdma.sc;
1043     cellInfo.ServiceCellParas.tdscdma.cellId = info.serviceCells.tdscdma.cellId;
1044     cellInfo.ServiceCellParas.tdscdma.lac = info.serviceCells.tdscdma.lac;
1045     cellInfo.ServiceCellParas.tdscdma.rscp = info.serviceCells.tdscdma.rscp;
1046     cellInfo.ServiceCellParas.tdscdma.drx = info.serviceCells.tdscdma.drx;
1047     cellInfo.ServiceCellParas.tdscdma.rac = info.serviceCells.tdscdma.rac;
1048     cellInfo.ServiceCellParas.tdscdma.cpid = info.serviceCells.tdscdma.cpid;
1049 }
1050 
FillNrCurrentCellInformation(CurrentCellInformation & cellInfo,const HDI::Ril::V1_2::CurrentCellInfo_1_2 & info)1051 void TelRilNetwork::FillNrCurrentCellInformation(
1052     CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info)
1053 {
1054     cellInfo.ServiceCellParas.nr.nrArfcn = info.serviceCells.nr.nrArfcn;
1055     cellInfo.ServiceCellParas.nr.pci = info.serviceCells.nr.pci;
1056     cellInfo.ServiceCellParas.nr.tac = info.serviceCells.nr.tac;
1057     cellInfo.ServiceCellParas.nr.nci = info.serviceCells.nr.nci;
1058     cellInfo.ServiceCellParas.nr.rsrp = info.serviceCells.nr.rsrp;
1059     cellInfo.ServiceCellParas.nr.rsrq = info.serviceCells.nr.rsrq;
1060 }
1061 
BuildChannelConfigInfoList(std::shared_ptr<ChannelConfigInfoList> channelConfigList,const HDI::Ril::V1_1::ChannelConfigInfoList & channelConfigInfoList)1062 void TelRilNetwork::BuildChannelConfigInfoList(std::shared_ptr<ChannelConfigInfoList> channelConfigList,
1063     const HDI::Ril::V1_1::ChannelConfigInfoList &channelConfigInfoList)
1064 {
1065     channelConfigList->itemNum = channelConfigInfoList.itemNum;
1066     for (int32_t i = 0; i < channelConfigList->itemNum; i++) {
1067         PhysicalChannelConfig phyChnlCfg;
1068         phyChnlCfg.cellConnStatus =
1069             static_cast<CellConnectionStatus>(channelConfigInfoList.channelConfigInfos[i].cellConnStatus);
1070         phyChnlCfg.cellBandwidthDownlinkKhz = channelConfigInfoList.channelConfigInfos[i].cellBandwidthDownlinkKhz;
1071         phyChnlCfg.cellBandwidthUplinkKhz = channelConfigInfoList.channelConfigInfos[i].cellBandwidthUplinkKhz;
1072         phyChnlCfg.ratType = static_cast<TelRilRadioTech>(channelConfigInfoList.channelConfigInfos[i].ratType);
1073         phyChnlCfg.freqRange = channelConfigInfoList.channelConfigInfos[i].freqRange;
1074         phyChnlCfg.downlinkChannelNum = channelConfigInfoList.channelConfigInfos[i].downlinkChannelNum;
1075         phyChnlCfg.uplinkChannelNum = channelConfigInfoList.channelConfigInfos[i].uplinkChannelNum;
1076         phyChnlCfg.physicalCellId = channelConfigInfoList.channelConfigInfos[i].physicalCellId;
1077         phyChnlCfg.contextIdNum = channelConfigInfoList.channelConfigInfos[i].contextIdNum;
1078         for (int32_t j = 0; j < phyChnlCfg.contextIdNum; j++) {
1079             phyChnlCfg.contextIds.push_back(channelConfigInfoList.channelConfigInfos[i].contextIds[j]);
1080         }
1081         channelConfigList->channelConfigInfos.push_back(phyChnlCfg);
1082     }
1083 }
1084 } // namespace Telephony
1085 } // namespace OHOS
1086