Tomasz Wasilczyk | 9375f3a | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "structs.h" |
| 18 | |
| 19 | #include "commonStructs.h" |
| 20 | |
| 21 | #include "collections.h" |
| 22 | |
| 23 | #include <android-base/logging.h> |
| 24 | |
| 25 | namespace android::hardware::radio::compat { |
| 26 | |
| 27 | namespace aidl = ::aidl::android::hardware::radio::voice; |
| 28 | |
| 29 | V1_0::Dial toHidl(const aidl::Dial& info) { |
| 30 | return { |
| 31 | .address = info.address, |
| 32 | .clir = V1_0::Clir{info.clir}, |
| 33 | .uusInfo = toHidl(info.uusInfo), |
| 34 | }; |
| 35 | } |
| 36 | |
| 37 | V1_0::UusInfo toHidl(const aidl::UusInfo& info) { |
| 38 | return { |
| 39 | .uusType = V1_0::UusType{info.uusType}, |
| 40 | .uusDcs = V1_0::UusDcs{info.uusDcs}, |
| 41 | .uusData = info.uusData, |
| 42 | }; |
| 43 | } |
| 44 | |
| 45 | aidl::CallForwardInfo toAidl(const V1_0::CallForwardInfo& info) { |
| 46 | return { |
| 47 | .status = static_cast<int32_t>(info.status), |
| 48 | .reason = info.reason, |
| 49 | .serviceClass = info.serviceClass, |
| 50 | .toa = info.toa, |
| 51 | .number = info.number, |
| 52 | .timeSeconds = info.timeSeconds, |
| 53 | }; |
| 54 | } |
| 55 | |
| 56 | V1_0::CallForwardInfo toHidl(const aidl::CallForwardInfo& info) { |
| 57 | return { |
| 58 | .status = V1_0::CallForwardInfoStatus{info.status}, |
| 59 | .reason = info.reason, |
| 60 | .serviceClass = info.serviceClass, |
| 61 | .toa = info.toa, |
| 62 | .number = info.number, |
| 63 | .timeSeconds = info.timeSeconds, |
| 64 | }; |
| 65 | } |
| 66 | |
| 67 | aidl::CdmaSignalInfoRecord toAidl(const V1_0::CdmaSignalInfoRecord& record) { |
| 68 | return { |
| 69 | .isPresent = record.isPresent, |
| 70 | .signalType = record.signalType, |
| 71 | .alertPitch = record.alertPitch, |
| 72 | .signal = record.signal, |
| 73 | }; |
| 74 | } |
| 75 | |
| 76 | aidl::CdmaCallWaiting toAidl(const V1_0::CdmaCallWaiting& call) { |
| 77 | return { |
| 78 | .number = call.number, |
| 79 | .numberPresentation = static_cast<int32_t>(call.numberPresentation), |
| 80 | .name = call.name, |
| 81 | .signalInfoRecord = toAidl(call.signalInfoRecord), |
| 82 | .numberType = static_cast<int32_t>(call.numberType), |
| 83 | .numberPlan = static_cast<int32_t>(call.numberPlan), |
| 84 | }; |
| 85 | } |
| 86 | |
| 87 | aidl::CdmaInformationRecord toAidl(const V1_0::CdmaInformationRecord& record) { |
| 88 | return { |
| 89 | .name = static_cast<int32_t>(record.name), |
| 90 | .display = toAidl(record.display), |
| 91 | .number = toAidl(record.number), |
| 92 | .signal = toAidl(record.signal), |
| 93 | .redir = toAidl(record.redir), |
| 94 | .lineCtrl = toAidl(record.lineCtrl), |
| 95 | .clir = toAidl(record.clir), |
| 96 | .audioCtrl = toAidl(record.audioCtrl), |
| 97 | }; |
| 98 | } |
| 99 | |
| 100 | aidl::CdmaDisplayInfoRecord toAidl(const V1_0::CdmaDisplayInfoRecord& record) { |
| 101 | return { |
| 102 | .alphaBuf = record.alphaBuf, |
| 103 | }; |
| 104 | } |
| 105 | |
| 106 | aidl::CdmaNumberInfoRecord toAidl(const V1_0::CdmaNumberInfoRecord& record) { |
| 107 | return { |
| 108 | .number = record.number, |
| 109 | .numberType = static_cast<int8_t>(record.numberType), |
| 110 | .numberPlan = static_cast<int8_t>(record.numberPlan), |
| 111 | .pi = static_cast<int8_t>(record.pi), |
| 112 | .si = static_cast<int8_t>(record.si), |
| 113 | }; |
| 114 | } |
| 115 | |
| 116 | aidl::CdmaRedirectingNumberInfoRecord toAidl(const V1_0::CdmaRedirectingNumberInfoRecord& record) { |
| 117 | return { |
| 118 | .redirectingNumber = toAidl(record.redirectingNumber), |
| 119 | .redirectingReason = static_cast<int32_t>(record.redirectingReason), |
| 120 | }; |
| 121 | } |
| 122 | |
| 123 | aidl::CdmaLineControlInfoRecord toAidl(const V1_0::CdmaLineControlInfoRecord& record) { |
| 124 | return { |
| 125 | .lineCtrlPolarityIncluded = static_cast<int8_t>(record.lineCtrlPolarityIncluded), |
| 126 | .lineCtrlToggle = static_cast<int8_t>(record.lineCtrlToggle), |
| 127 | .lineCtrlReverse = static_cast<int8_t>(record.lineCtrlReverse), |
| 128 | .lineCtrlPowerDenial = static_cast<int8_t>(record.lineCtrlPowerDenial), |
| 129 | }; |
| 130 | } |
| 131 | |
| 132 | aidl::CdmaT53ClirInfoRecord toAidl(const V1_0::CdmaT53ClirInfoRecord& record) { |
| 133 | return { |
| 134 | .cause = static_cast<int8_t>(record.cause), |
| 135 | }; |
| 136 | } |
| 137 | |
| 138 | aidl::CdmaT53AudioControlInfoRecord toAidl(const V1_0::CdmaT53AudioControlInfoRecord& record) { |
| 139 | return { |
| 140 | .upLink = static_cast<int8_t>(record.upLink), |
| 141 | .downLink = static_cast<int8_t>(record.downLink), |
| 142 | }; |
| 143 | } |
| 144 | |
| 145 | aidl::EmergencyNumber toAidl(const V1_4::EmergencyNumber& num) { |
| 146 | return { |
| 147 | .number = num.number, |
| 148 | .mcc = num.mcc, |
| 149 | .mnc = num.mnc, |
Sarah Chin | 6d8e49a | 2021-12-23 16:41:58 -0800 | [diff] [blame] | 150 | .categories = num.categories, |
Tomasz Wasilczyk | 9375f3a | 2021-11-05 10:53:55 -0700 | [diff] [blame] | 151 | .urns = toAidl(num.urns), |
| 152 | .sources = num.sources, |
| 153 | }; |
| 154 | } |
| 155 | |
| 156 | aidl::StkCcUnsolSsResult toAidl(const V1_0::StkCcUnsolSsResult& res) { |
| 157 | return { |
| 158 | .serviceType = static_cast<int32_t>(res.serviceType), |
| 159 | .requestType = static_cast<int32_t>(res.requestType), |
| 160 | .teleserviceType = static_cast<int32_t>(res.teleserviceType), |
| 161 | .serviceClass = res.serviceClass, |
| 162 | .result = toAidl(res.result), |
| 163 | .ssInfo = toAidl(res.ssInfo), |
| 164 | .cfData = toAidl(res.cfData), |
| 165 | }; |
| 166 | } |
| 167 | |
| 168 | aidl::SsInfoData toAidl(const V1_0::SsInfoData& info) { |
| 169 | return { |
| 170 | .ssInfo = info.ssInfo, |
| 171 | }; |
| 172 | } |
| 173 | |
| 174 | aidl::CfData toAidl(const V1_0::CfData& data) { |
| 175 | return { |
| 176 | .cfInfo = toAidl(data.cfInfo), |
| 177 | }; |
| 178 | } |
| 179 | |
| 180 | aidl::Call toAidl(const V1_0::Call& call) { |
| 181 | return toAidl(V1_2::Call{call, {}}); |
| 182 | } |
| 183 | |
| 184 | aidl::Call toAidl(const V1_2::Call& call) { |
| 185 | return toAidl(V1_6::Call{call, {}}); |
| 186 | } |
| 187 | |
| 188 | aidl::Call toAidl(const V1_6::Call& call) { |
| 189 | return { |
| 190 | .state = static_cast<int32_t>(call.base.base.state), |
| 191 | .index = call.base.base.index, |
| 192 | .toa = call.base.base.toa, |
| 193 | .isMpty = call.base.base.isMpty, |
| 194 | .isMT = call.base.base.isMT, |
| 195 | .als = static_cast<int8_t>(call.base.base.als), |
| 196 | .isVoice = call.base.base.isVoice, |
| 197 | .isVoicePrivacy = call.base.base.isVoicePrivacy, |
| 198 | .number = call.base.base.number, |
| 199 | .numberPresentation = static_cast<int32_t>(call.base.base.numberPresentation), |
| 200 | .name = call.base.base.name, |
| 201 | .namePresentation = static_cast<int32_t>(call.base.base.namePresentation), |
| 202 | .uusInfo = toAidl(call.base.base.uusInfo), |
| 203 | .audioQuality = aidl::AudioQuality(call.base.audioQuality), |
| 204 | .forwardedNumber = call.forwardedNumber, |
| 205 | }; |
| 206 | } |
| 207 | |
| 208 | aidl::UusInfo toAidl(const V1_0::UusInfo& info) { |
| 209 | return { |
| 210 | .uusType = static_cast<int32_t>(info.uusType), |
| 211 | .uusDcs = static_cast<int32_t>(info.uusDcs), |
| 212 | .uusData = info.uusData, |
| 213 | }; |
| 214 | } |
| 215 | |
| 216 | aidl::LastCallFailCauseInfo toAidl(const V1_0::LastCallFailCauseInfo& info) { |
| 217 | return { |
| 218 | .causeCode = aidl::LastCallFailCause(info.causeCode), |
| 219 | .vendorCause = info.vendorCause, |
| 220 | }; |
| 221 | } |
| 222 | |
| 223 | } // namespace android::hardware::radio::compat |