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