1/* 2 * Copyright (C) 2021 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 "hril_data.h" 17 18#include "hril_notification.h" 19#include "hril_request.h" 20 21namespace OHOS { 22namespace Telephony { 23namespace { 24const int32_t HRILOPS_ACTIVE_VERSION = 13; 25} 26 27HRilData::HRilData(int32_t slotId) : HRilBase(slotId) 28{ 29 AddHandlerToMap(); 30} 31 32HRilData::~HRilData() 33{ 34 dataFuncs_ = nullptr; 35} 36 37bool HRilData::IsDataResponse(uint32_t code) 38{ 39 return ((code >= HREQ_DATA_BASE) && (code < HREQ_NETWORK_BASE)); 40} 41 42bool HRilData::IsDataNotification(uint32_t code) 43{ 44 return ((code >= HNOTI_DATA_BASE) && (code < HNOTI_NETWORK_BASE)); 45} 46 47bool HRilData::IsDataRespOrNotify(uint32_t code) 48{ 49 return IsDataResponse(code) || IsDataNotification(code); 50} 51 52void HRilData::AddHandlerToMap() 53{ 54 // Notification 55 notiMemberFuncMap_[HNOTI_DATA_PDP_CONTEXT_LIST_UPDATED] = 56 [this](int32_t notifyType, HRilErrNumber error, const void *response, 57 size_t responseLen) { return PdpContextListUpdated(notifyType, error, response, responseLen); }; 58 notiMemberFuncMap_[HNOTI_DATA_LINK_CAPABILITY_UPDATED] = 59 [this](int32_t notifyType, HRilErrNumber error, const void *response, 60 size_t responseLen) { return DataLinkCapabilityUpdated(notifyType, error, response, responseLen); }; 61 // response 62 respMemberFuncMap_[HREQ_DATA_SET_INIT_APN_INFO] = 63 [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, 64 size_t responseLen) { return SetInitApnInfoResponse(requestNum, responseInfo, response, responseLen); }; 65 respMemberFuncMap_[HREQ_DATA_SET_DATA_PROFILE_INFO] = 66 [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, 67 size_t responseLen) { return SetDataProfileInfoResponse(requestNum, responseInfo, response, responseLen); }; 68 respMemberFuncMap_[HREQ_DATA_ACTIVATE_PDP_CONTEXT] = 69 [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, 70 size_t responseLen) { return ActivatePdpContextResponse(requestNum, responseInfo, response, responseLen); }; 71 respMemberFuncMap_[HREQ_DATA_DEACTIVATE_PDP_CONTEXT] = 72 [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, 73 size_t responseLen) { return DeactivatePdpContextResponse(requestNum, responseInfo, response, responseLen); }; 74 respMemberFuncMap_[HREQ_DATA_GET_PDP_CONTEXT_LIST] = 75 [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, 76 size_t responseLen) { return GetPdpContextListResponse(requestNum, responseInfo, response, responseLen); }; 77 respMemberFuncMap_[HREQ_DATA_GET_LINK_BANDWIDTH_INFO] = 78 [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, 79 size_t responseLen) { return GetLinkBandwidthInfoResponse(requestNum, responseInfo, response, responseLen); }; 80 respMemberFuncMap_[HREQ_DATA_SET_LINK_BANDWIDTH_REPORTING_RULE] = [this](int32_t requestNum, 81 HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) { 82 return SetLinkBandwidthReportingRuleResponse(requestNum, responseInfo, response, responseLen); 83 }; 84 respMemberFuncMap_[HREQ_DATA_SET_DATA_PERMITTED] = 85 [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, 86 size_t responseLen) { return SetDataPermittedResponse(requestNum, responseInfo, response, responseLen); }; 87 respMemberFuncMap_[HREQ_DATA_GET_LINK_CAPABILITY] = 88 [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, 89 size_t responseLen) { return GetLinkCapabilityResponse(requestNum, responseInfo, response, responseLen); }; 90 respMemberFuncMap_[HREQ_DATA_CLEAN_ALL_CONNECTIONS] = 91 [this](int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, 92 size_t responseLen) { return CleanAllConnectionsResponse(requestNum, responseInfo, response, responseLen); }; 93} 94 95void HRilData::SwitchRilDataToHal(const HRilDataCallResponse *response, HDI::Ril::V1_1::SetupDataCallResultInfo &result) 96{ 97 if (response == nullptr) { 98 TELEPHONY_LOGE("SwitchRilDataToHal response is null!!!"); 99 return; 100 } 101 result.active = response->active; 102 result.reason = response->reason; 103 result.retryTime = response->retryTime; 104 result.cid = response->cid; 105 result.pduSessionId = response->pduSessionId; 106 result.maxTransferUnit = response->maxTransferUnit; 107 result.address = (response->address == nullptr) ? "" : response->address; 108 result.type = (response->type == nullptr) ? "" : response->type; 109 result.dns = (response->dns == nullptr) ? "" : response->dns; 110 result.dnsSec = (response->dnsSec == nullptr) ? "" : response->dnsSec; 111 result.netPortName = (response->netPortName == nullptr) ? "" : response->netPortName; 112 result.gateway = (response->gateway == nullptr) ? "" : response->gateway; 113 result.pCscfPrimAddr = (response->pCscfPrimAddr == nullptr) ? "" : response->pCscfPrimAddr; 114 result.pCscfSecAddr = (response->pCscfSecAddr == nullptr) ? "" : response->pCscfSecAddr; 115} 116 117void HRilData::SwitchHRilDataListToHal( 118 const void *response, size_t responseLen, std::vector<HDI::Ril::V1_1::SetupDataCallResultInfo> &dcResultList) 119{ 120 if (response == nullptr) { 121 TELEPHONY_LOGE("SwitchHRilDataListToHal response is null!!!"); 122 return; 123 } 124 size_t dataNum = responseLen / sizeof(HRilDataCallResponse); 125 const HRilDataCallResponse *dataCallResponse = (const HRilDataCallResponse *)response; 126 dcResultList.resize(dataNum); 127 128 size_t i = 0; 129 while (i < dataNum) { 130 SwitchRilDataToHal(&dataCallResponse[i], dcResultList[i]); 131 i++; 132 } 133} 134 135int32_t HRilData::DeactivatePdpContext(int32_t serialId, const OHOS::HDI::Ril::V1_1::UniInfo &uniInfo) 136{ 137 HRilDataInfo dataInfo = {}; 138 dataInfo.cid = uniInfo.gsmIndex; 139 dataInfo.reason = uniInfo.arg1; 140 return RequestVendor( 141 serialId, HREQ_DATA_DEACTIVATE_PDP_CONTEXT, dataFuncs_, &HRilDataReq::DeactivatePdpContext, &dataInfo); 142} 143 144int32_t HRilData::ActivatePdpContext(int32_t serialId, const OHOS::HDI::Ril::V1_1::DataCallInfo &dataCallInfo) 145{ 146 HRilDataInfo dataInfo; 147 dataInfo.apn = StringToCString(dataCallInfo.dataProfileInfo.apn); 148 dataInfo.type = StringToCString(dataCallInfo.dataProfileInfo.protocol); 149 dataInfo.roamingType = StringToCString(dataCallInfo.dataProfileInfo.roamingProtocol); 150 dataInfo.userName = StringToCString(dataCallInfo.dataProfileInfo.userName); 151 dataInfo.password = StringToCString(dataCallInfo.dataProfileInfo.password); 152 dataInfo.verType = dataCallInfo.dataProfileInfo.authenticationType; 153 dataInfo.rat = dataCallInfo.radioTechnology; 154 dataInfo.roamingEnable = dataCallInfo.roamingAllowed ? 1 : 0; 155 return RequestVendor( 156 serialId, HREQ_DATA_ACTIVATE_PDP_CONTEXT, dataFuncs_, &HRilDataReq::ActivatePdpContext, &dataInfo); 157} 158 159int32_t HRilData::ActivatePdpContextWithApnTypes(int32_t serialId, 160 const OHOS::HDI::Ril::V1_3::DataCallInfoWithApnTypes &dataCallInfoWithApnTypes, const int32_t version) 161{ 162 if (version < HRILOPS_ACTIVE_VERSION) { 163 TELEPHONY_LOGI("Call V1_1 ActivatePdpContext"); 164 OHOS::HDI::Ril::V1_1::DataCallInfo dataCallInfo; 165 dataCallInfo.dataProfileInfo.apn = dataCallInfoWithApnTypes.dataProfileInfo.apn; 166 dataCallInfo.dataProfileInfo.protocol = dataCallInfoWithApnTypes.dataProfileInfo.protocol; 167 dataCallInfo.dataProfileInfo.roamingProtocol = dataCallInfoWithApnTypes.dataProfileInfo.roamingProtocol; 168 dataCallInfo.dataProfileInfo.userName = dataCallInfoWithApnTypes.dataProfileInfo.userName; 169 dataCallInfo.dataProfileInfo.password = dataCallInfoWithApnTypes.dataProfileInfo.password; 170 dataCallInfo.dataProfileInfo.authenticationType = dataCallInfoWithApnTypes.dataProfileInfo.authenticationType; 171 dataCallInfo.isRoaming = dataCallInfoWithApnTypes.isRoaming; 172 dataCallInfo.roamingAllowed = dataCallInfoWithApnTypes.roamingAllowed; 173 dataCallInfo.radioTechnology = dataCallInfoWithApnTypes.radioTechnology; 174 return ActivatePdpContext(serialId, dataCallInfo); 175 } 176 TELEPHONY_LOGI("Call V1_3 ActivatePdpContextWithApnTypes"); 177 HRilDataInfoWithApnTypes dataInfoWithApnTypes; 178 dataInfoWithApnTypes.apn = StringToCString(dataCallInfoWithApnTypes.dataProfileInfo.apn); 179 dataInfoWithApnTypes.type = StringToCString(dataCallInfoWithApnTypes.dataProfileInfo.protocol); 180 dataInfoWithApnTypes.roamingType = StringToCString(dataCallInfoWithApnTypes.dataProfileInfo.roamingProtocol); 181 dataInfoWithApnTypes.userName = StringToCString(dataCallInfoWithApnTypes.dataProfileInfo.userName); 182 dataInfoWithApnTypes.password = StringToCString(dataCallInfoWithApnTypes.dataProfileInfo.password); 183 dataInfoWithApnTypes.verType = dataCallInfoWithApnTypes.dataProfileInfo.authenticationType; 184 dataInfoWithApnTypes.rat = dataCallInfoWithApnTypes.radioTechnology; 185 dataInfoWithApnTypes.roamingEnable = dataCallInfoWithApnTypes.roamingAllowed ? 1 : 0; 186 dataInfoWithApnTypes.supportedApnTypesBitmap = dataCallInfoWithApnTypes.dataProfileInfo.supportedApnTypesBitmap; 187 return RequestVendor(serialId, HREQ_DATA_ACTIVATE_PDP_CONTEXT, dataFuncs_, 188 &HRilDataReq::ActivatePdpContextWithApnTypes, &dataInfoWithApnTypes); 189} 190 191int32_t HRilData::GetPdpContextList(int32_t serialId, const OHOS::HDI::Ril::V1_1::UniInfo &uniInfo) 192{ 193 TELEPHONY_LOGD("serial %{public}d on %{public}d", uniInfo.serial, uniInfo.flag); 194 return RequestVendor(serialId, HREQ_DATA_GET_PDP_CONTEXT_LIST, dataFuncs_, &HRilDataReq::GetPdpContextList); 195} 196 197int32_t HRilData::SetInitApnInfo(int32_t serialId, const OHOS::HDI::Ril::V1_1::DataProfileDataInfo &dataProfileDataInfo) 198{ 199 HRilDataInfo dataInfo = BuildDataInfo(dataProfileDataInfo); 200 return RequestVendor(serialId, HREQ_DATA_SET_INIT_APN_INFO, dataFuncs_, &HRilDataReq::SetInitApnInfo, &dataInfo); 201} 202 203int32_t HRilData::SendDataPerformanceMode( 204 int32_t serialId, const OHOS::HDI::Ril::V1_1::DataPerformanceInfo &dataPerformanceInfo) 205{ 206 HRilDataPerformanceInfo hrilDataPerformanceInfo; 207 hrilDataPerformanceInfo.performanceEnable = dataPerformanceInfo.performanceEnable; 208 hrilDataPerformanceInfo.enforce = dataPerformanceInfo.enforce; 209 TELEPHONY_LOGI("SendDataPerformanceMode: performanceEnable=%{public}d enforce=%{public}d", 210 hrilDataPerformanceInfo.performanceEnable, hrilDataPerformanceInfo.enforce); 211 return RequestVendor(serialId, HREQ_DATA_SEND_DATA_PERFORMANCE_MODE, dataFuncs_, 212 &HRilDataReq::SendDataPerformanceMode, &hrilDataPerformanceInfo); 213} 214 215int32_t HRilData::SendDataSleepMode(int32_t serialId, const OHOS::HDI::Ril::V1_1::DataSleepInfo &dataSleepInfo) 216{ 217 HRilDataSleepInfo hrilDataSleepInfo; 218 hrilDataSleepInfo.sleepEnable = dataSleepInfo.sleepEnable; 219 TELEPHONY_LOGI("SendDataSleepMode: sleepEnable=%{public}d", hrilDataSleepInfo.sleepEnable); 220 return RequestVendor( 221 serialId, HREQ_DATA_SEND_DATA_SLEEP_MODE, dataFuncs_, &HRilDataReq::SendDataSleepMode, &hrilDataSleepInfo); 222} 223 224int32_t HRilData::SetDataProfileInfo(int32_t serialId, const OHOS::HDI::Ril::V1_1::DataProfilesInfo &dataProfilesInfo) 225{ 226 int32_t size = dataProfilesInfo.profilesSize; 227 if (size <= 0 || size != static_cast<int32_t>(dataProfilesInfo.profiles.size())) { 228 TELEPHONY_LOGE("RilAdapter failed to do ReadFromParcel!"); 229 return HRIL_ERR_INVALID_PARAMETER; 230 } 231 std::unique_ptr<HRilDataInfo[]> dataInfos = std::make_unique<HRilDataInfo[]>(size); 232 for (int32_t i = 0; i < size; i++) { 233 dataInfos[i] = BuildDataInfo(dataProfilesInfo.profiles[i]); 234 } 235 return RequestVendor( 236 serialId, HREQ_DATA_SET_DATA_PROFILE_INFO, dataFuncs_, &HRilDataReq::SetDataProfileInfo, dataInfos.get(), size); 237} 238 239HRilDataInfo HRilData::BuildDataInfo(const OHOS::HDI::Ril::V1_1::DataProfileDataInfo &dataProfileInfo) 240{ 241 HRilDataInfo dataInfo; 242 dataInfo.cid = dataProfileInfo.profileId; 243 dataInfo.apn = StringToCString(dataProfileInfo.apn); 244 dataInfo.type = StringToCString(dataProfileInfo.protocol); 245 dataInfo.roamingType = StringToCString(dataProfileInfo.roamingProtocol); 246 dataInfo.userName = StringToCString(dataProfileInfo.userName); 247 dataInfo.password = StringToCString(dataProfileInfo.password); 248 dataInfo.verType = dataProfileInfo.authenticationType; 249 return dataInfo; 250} 251 252int32_t HRilData::GetLinkCapability(int32_t serialId) 253{ 254 return RequestVendor(serialId, HREQ_DATA_GET_LINK_CAPABILITY, dataFuncs_, &HRilDataReq::GetLinkCapability); 255} 256 257int32_t HRilData::GetLinkBandwidthInfo(int32_t serialId, int32_t cid) 258{ 259 return RequestVendor( 260 serialId, HREQ_DATA_GET_LINK_BANDWIDTH_INFO, dataFuncs_, &HRilDataReq::GetLinkBandwidthInfo, cid); 261} 262 263int32_t HRilData::SetLinkBandwidthReportingRule( 264 int32_t serialId, const OHOS::HDI::Ril::V1_1::DataLinkBandwidthReportingRule &linkBandwidthRule) 265{ 266 HRilLinkBandwidthReportingRule hLinkBandwidthRule; 267 hLinkBandwidthRule.rat = (RatType)linkBandwidthRule.rat; 268 hLinkBandwidthRule.delayMs = linkBandwidthRule.delayMs; 269 hLinkBandwidthRule.delayUplinkKbps = linkBandwidthRule.delayUplinkKbps; 270 hLinkBandwidthRule.delayDownlinkKbps = linkBandwidthRule.delayDownlinkKbps; 271 hLinkBandwidthRule.maximumUplinkKbpsSize = linkBandwidthRule.maximumUplinkKbpsSize; 272 hLinkBandwidthRule.maximumDownlinkKbpsSize = linkBandwidthRule.maximumDownlinkKbpsSize; 273 hLinkBandwidthRule.maximumUplinkKbps = new int32_t[linkBandwidthRule.maximumUplinkKbpsSize]; 274 hLinkBandwidthRule.maximumDownlinkKbps = new int32_t[linkBandwidthRule.maximumDownlinkKbpsSize]; 275 TELEPHONY_LOGI("maximumUplinkKbpsSize:%{public}d, maximumDownlinkKbpsSize:%{public}d", 276 linkBandwidthRule.maximumUplinkKbpsSize, linkBandwidthRule.maximumDownlinkKbpsSize); 277 for (int32_t i = 0; i < hLinkBandwidthRule.maximumUplinkKbpsSize; i++) { 278 hLinkBandwidthRule.maximumUplinkKbps[i] = linkBandwidthRule.maximumUplinkKbps[i]; 279 } 280 for (int32_t i = 0; i < hLinkBandwidthRule.maximumDownlinkKbpsSize; i++) { 281 hLinkBandwidthRule.maximumDownlinkKbps[i] = linkBandwidthRule.maximumDownlinkKbps[i]; 282 } 283 int32_t resutlt = RequestVendor(serialId, HREQ_DATA_SET_LINK_BANDWIDTH_REPORTING_RULE, dataFuncs_, 284 &HRilDataReq::SetLinkBandwidthReportingRule, &hLinkBandwidthRule); 285 delete[] hLinkBandwidthRule.maximumUplinkKbps; 286 delete[] hLinkBandwidthRule.maximumDownlinkKbps; 287 return resutlt; 288} 289 290int32_t HRilData::SetDataPermitted(int32_t serialId, int32_t dataPermitted) 291{ 292 return RequestVendor( 293 serialId, HREQ_DATA_SET_DATA_PERMITTED, dataFuncs_, &HRilDataReq::SetDataPermitted, dataPermitted); 294} 295 296int32_t HRilData::CleanAllConnections(int32_t serialId) 297{ 298 return RequestVendor(serialId, HREQ_DATA_CLEAN_ALL_CONNECTIONS, dataFuncs_, &HRilDataReq::CleanAllConnections); 299} 300 301int32_t HRilData::CleanAllConnectionsResponse( 302 int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) 303{ 304 return Response(responseInfo, &HDI::Ril::V1_2::IRilCallback::CleanAllConnectionsResponse); 305} 306 307int32_t HRilData::DeactivatePdpContextResponse( 308 int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) 309{ 310 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::DeactivatePdpContextResponse); 311} 312 313int32_t HRilData::ActivatePdpContextResponse( 314 int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) 315{ 316 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilDataCallResponse)) != 0) { 317 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen); 318 return HRIL_ERR_INVALID_PARAMETER; 319 } 320 HDI::Ril::V1_1::SetupDataCallResultInfo result = {}; 321 result.reason = HRIL_ERROR_UNSPECIFIED_RSN; 322 result.cid = -1; 323 if (response != nullptr) { 324 SwitchRilDataToHal((HRilDataCallResponse *)response, result); 325 } 326 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::ActivatePdpContextResponse, result); 327} 328 329int32_t HRilData::GetPdpContextListResponse( 330 int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) 331{ 332 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilDataCallResponse)) != 0) { 333 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen); 334 return HRIL_ERR_INVALID_PARAMETER; 335 } 336 HDI::Ril::V1_1::DataCallResultList dataCallResultList = {}; 337 if (response != nullptr) { 338 SwitchHRilDataListToHal(response, responseLen, dataCallResultList.dcList); 339 } 340 dataCallResultList.size = dataCallResultList.dcList.size(); 341 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetPdpContextListResponse, dataCallResultList); 342} 343 344int32_t HRilData::SetInitApnInfoResponse( 345 int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) 346{ 347 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetInitApnInfoResponse); 348} 349 350int32_t HRilData::SetDataProfileInfoResponse( 351 int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) 352{ 353 return HRIL_ERR_SUCCESS; 354} 355 356int32_t HRilData::SetLinkBandwidthReportingRuleResponse( 357 int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) 358{ 359 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetLinkBandwidthReportingRuleResponse); 360} 361 362int32_t HRilData::PdpContextListUpdated( 363 int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen) 364{ 365 if ((response == nullptr) || (responseLen % sizeof(HRilDataCallResponse)) != 0) { 366 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen); 367 return HRIL_ERR_INVALID_PARAMETER; 368 } 369 HDI::Ril::V1_1::DataCallResultList dataCallResultList = {}; 370 SwitchHRilDataListToHal(response, responseLen, dataCallResultList.dcList); 371 dataCallResultList.size = dataCallResultList.dcList.size(); 372 return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::PdpContextListUpdated, dataCallResultList); 373} 374 375int32_t HRilData::DataLinkCapabilityUpdated( 376 int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen) 377{ 378 if ((response == nullptr) || (responseLen % sizeof(HRilDataLinkCapability)) != 0) { 379 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen); 380 return HRIL_ERR_INVALID_PARAMETER; 381 } 382 HDI::Ril::V1_1::DataLinkCapability dataLinkCapability = { 0 }; 383 const HRilDataLinkCapability *result = static_cast<const HRilDataLinkCapability *>(response); 384 dataLinkCapability.primaryDownlinkKbps = result->primaryDownlinkKbps; 385 dataLinkCapability.primaryUplinkKbps = result->primaryUplinkKbps; 386 dataLinkCapability.secondaryDownlinkKbps = result->secondaryDownlinkKbps; 387 dataLinkCapability.secondaryUplinkKbps = result->secondaryUplinkKbps; 388 return Notify(notifyType, error, &HDI::Ril::V1_1::IRilCallback::DataLinkCapabilityUpdated, dataLinkCapability); 389} 390 391int32_t HRilData::GetLinkCapabilityResponse( 392 int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) 393{ 394 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilDataLinkCapability)) != 0) { 395 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen); 396 return HRIL_ERR_INVALID_PARAMETER; 397 } 398 HDI::Ril::V1_1::DataLinkCapability dataLinkCapability = { 0 }; 399 if (response != nullptr) { 400 const HRilDataLinkCapability *result = static_cast<const HRilDataLinkCapability *>(response); 401 dataLinkCapability.primaryDownlinkKbps = result->primaryDownlinkKbps; 402 dataLinkCapability.primaryUplinkKbps = result->primaryUplinkKbps; 403 dataLinkCapability.secondaryDownlinkKbps = result->secondaryDownlinkKbps; 404 dataLinkCapability.secondaryUplinkKbps = result->secondaryUplinkKbps; 405 } 406 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::GetLinkCapabilityResponse, dataLinkCapability); 407} 408 409int32_t HRilData::GetLinkBandwidthInfoResponse( 410 int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) 411{ 412 if ((response == nullptr && responseLen != 0) || (responseLen % sizeof(HRilLinkBandwidthInfo)) != 0) { 413 TELEPHONY_LOGE("Invalid parameter, responseLen:%{public}zu", responseLen); 414 return HRIL_ERR_INVALID_PARAMETER; 415 } 416 HDI::Ril::V1_1::DataLinkBandwidthInfo uplinkAndDownlinkBandwidthInfo = {}; 417 if (response != nullptr) { 418 const HRilLinkBandwidthInfo *result = static_cast<const HRilLinkBandwidthInfo *>(response); 419 uplinkAndDownlinkBandwidthInfo.cid = result->cid; 420 uplinkAndDownlinkBandwidthInfo.qi = result->qi; 421 uplinkAndDownlinkBandwidthInfo.dlGfbr = result->dlGfbr; 422 uplinkAndDownlinkBandwidthInfo.ulGfbr = result->ulGfbr; 423 uplinkAndDownlinkBandwidthInfo.dlMfbr = result->dlMfbr; 424 uplinkAndDownlinkBandwidthInfo.ulMfbr = result->ulMfbr; 425 uplinkAndDownlinkBandwidthInfo.ulSambr = result->ulSambr; 426 uplinkAndDownlinkBandwidthInfo.dlSambr = result->dlSambr; 427 uplinkAndDownlinkBandwidthInfo.averagingWindow = result->averagingWindow; 428 } 429 return Response( 430 responseInfo, &HDI::Ril::V1_1::IRilCallback::GetLinkBandwidthInfoResponse, uplinkAndDownlinkBandwidthInfo); 431} 432 433int32_t HRilData::SetDataPermittedResponse( 434 int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen) 435{ 436 return Response(responseInfo, &HDI::Ril::V1_1::IRilCallback::SetDataPermittedResponse); 437} 438 439void HRilData::RegisterDataFuncs(const HRilDataReq *dataFuncs) 440{ 441 dataFuncs_ = dataFuncs; 442} 443} // namespace Telephony 444} // namespace OHOS 445