Tomasz Wasilczyk | 9ddc87f | 2021-10-25 20:20:49 -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 "collections.h" |
| 20 | |
| 21 | #include <aidl/android/hardware/radio/messaging/CdmaSmsAddress.h> |
| 22 | #include <android-base/logging.h> |
| 23 | |
| 24 | namespace android::hardware::radio::compat { |
| 25 | |
| 26 | namespace aidl = ::aidl::android::hardware::radio::messaging; |
| 27 | |
| 28 | V1_0::CdmaSmsAck toHidl(const aidl::CdmaSmsAck& smsAck) { |
| 29 | return { |
| 30 | .errorClass = (smsAck.errorClass ? V1_0::CdmaSmsErrorClass::ERROR |
| 31 | : V1_0::CdmaSmsErrorClass::NO_ERROR), |
| 32 | .smsCauseCode = smsAck.smsCauseCode, |
| 33 | }; |
| 34 | } |
| 35 | |
| 36 | static aidl::CdmaSmsAddress toAidl(const V1_0::CdmaSmsAddress& addr) { |
| 37 | return { |
| 38 | .digitMode = static_cast<int32_t>(addr.digitMode), |
| 39 | .isNumberModeDataNetwork = addr.numberMode == V1_0::CdmaSmsNumberMode::DATA_NETWORK, |
| 40 | .numberType = static_cast<int32_t>(addr.numberType), |
| 41 | .numberPlan = static_cast<int32_t>(addr.numberPlan), |
| 42 | .digits = addr.digits, |
| 43 | }; |
| 44 | } |
| 45 | |
| 46 | static V1_0::CdmaSmsAddress toHidl(const aidl::CdmaSmsAddress& addr) { |
| 47 | return { |
Tomasz Wasilczyk | b542add | 2022-08-08 19:04:26 +0000 | [diff] [blame] | 48 | .digitMode = static_cast<V1_0::CdmaSmsDigitMode>(addr.digitMode), |
Tomasz Wasilczyk | 9ddc87f | 2021-10-25 20:20:49 -0700 | [diff] [blame] | 49 | .numberMode = addr.isNumberModeDataNetwork ? V1_0::CdmaSmsNumberMode::DATA_NETWORK |
| 50 | : V1_0::CdmaSmsNumberMode::NOT_DATA_NETWORK, |
Tomasz Wasilczyk | b542add | 2022-08-08 19:04:26 +0000 | [diff] [blame] | 51 | .numberType = static_cast<V1_0::CdmaSmsNumberType>(addr.numberType), |
| 52 | .numberPlan = static_cast<V1_0::CdmaSmsNumberPlan>(addr.numberPlan), |
Tomasz Wasilczyk | 9ddc87f | 2021-10-25 20:20:49 -0700 | [diff] [blame] | 53 | .digits = addr.digits, |
| 54 | }; |
| 55 | } |
| 56 | |
| 57 | static aidl::CdmaSmsSubaddress toAidl(const V1_0::CdmaSmsSubaddress& addr) { |
| 58 | return { |
| 59 | .subaddressType = static_cast<int32_t>(addr.subaddressType), |
| 60 | .odd = addr.odd, |
| 61 | .digits = addr.digits, |
| 62 | }; |
| 63 | } |
| 64 | |
| 65 | static V1_0::CdmaSmsSubaddress toHidl(const aidl::CdmaSmsSubaddress& addr) { |
| 66 | return { |
Tomasz Wasilczyk | b542add | 2022-08-08 19:04:26 +0000 | [diff] [blame] | 67 | .subaddressType = static_cast<V1_0::CdmaSmsSubaddressType>(addr.subaddressType), |
Tomasz Wasilczyk | 9ddc87f | 2021-10-25 20:20:49 -0700 | [diff] [blame] | 68 | .odd = addr.odd, |
| 69 | .digits = addr.digits, |
| 70 | }; |
| 71 | } |
| 72 | |
| 73 | ::aidl::android::hardware::radio::messaging::CdmaSmsMessage toAidl(const V1_0::CdmaSmsMessage& m) { |
| 74 | return { |
| 75 | .teleserviceId = m.teleserviceId, |
| 76 | .isServicePresent = m.isServicePresent, |
| 77 | .serviceCategory = m.serviceCategory, |
| 78 | .address = toAidl(m.address), |
| 79 | .subAddress = toAidl(m.subAddress), |
| 80 | .bearerData = m.bearerData, |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | V1_0::CdmaSmsMessage toHidl(const aidl::CdmaSmsMessage& msg) { |
| 85 | return { |
| 86 | .teleserviceId = msg.teleserviceId, |
| 87 | .isServicePresent = msg.isServicePresent, |
| 88 | .serviceCategory = msg.serviceCategory, |
| 89 | .address = toHidl(msg.address), |
| 90 | .subAddress = toHidl(msg.subAddress), |
| 91 | .bearerData = msg.bearerData, |
| 92 | }; |
| 93 | } |
| 94 | |
| 95 | V1_0::ImsSmsMessage toHidl(const aidl::ImsSmsMessage& msg) { |
| 96 | return { |
Tomasz Wasilczyk | b542add | 2022-08-08 19:04:26 +0000 | [diff] [blame] | 97 | .tech = static_cast<V1_0::RadioTechnologyFamily>(msg.tech), |
Tomasz Wasilczyk | 9ddc87f | 2021-10-25 20:20:49 -0700 | [diff] [blame] | 98 | .retry = msg.retry, |
| 99 | .messageRef = msg.messageRef, |
| 100 | .cdmaMessage = toHidl(msg.cdmaMessage), |
| 101 | .gsmMessage = toHidl(msg.gsmMessage), |
| 102 | }; |
| 103 | } |
| 104 | |
| 105 | V1_0::GsmSmsMessage toHidl(const aidl::GsmSmsMessage& msg) { |
| 106 | return { |
| 107 | .smscPdu = msg.smscPdu, |
| 108 | .pdu = msg.pdu, |
| 109 | }; |
| 110 | } |
| 111 | |
| 112 | aidl::CdmaBroadcastSmsConfigInfo toAidl(const V1_0::CdmaBroadcastSmsConfigInfo& info) { |
| 113 | return { |
| 114 | .serviceCategory = info.serviceCategory, |
| 115 | .language = info.language, |
| 116 | .selected = info.selected, |
| 117 | }; |
| 118 | } |
| 119 | |
| 120 | V1_0::CdmaBroadcastSmsConfigInfo toHidl(const aidl::CdmaBroadcastSmsConfigInfo& info) { |
| 121 | return { |
| 122 | .serviceCategory = info.serviceCategory, |
| 123 | .language = info.language, |
| 124 | .selected = info.selected, |
| 125 | }; |
| 126 | } |
| 127 | |
| 128 | aidl::GsmBroadcastSmsConfigInfo toAidl(const V1_0::GsmBroadcastSmsConfigInfo& info) { |
| 129 | return { |
| 130 | .fromServiceId = info.fromServiceId, |
| 131 | .toServiceId = info.toServiceId, |
| 132 | .fromCodeScheme = info.fromCodeScheme, |
| 133 | .toCodeScheme = info.toCodeScheme, |
| 134 | .selected = info.selected, |
| 135 | }; |
| 136 | } |
| 137 | |
| 138 | V1_0::GsmBroadcastSmsConfigInfo toHidl(const aidl::GsmBroadcastSmsConfigInfo& info) { |
| 139 | return { |
| 140 | .fromServiceId = info.fromServiceId, |
| 141 | .toServiceId = info.toServiceId, |
| 142 | .fromCodeScheme = info.fromCodeScheme, |
| 143 | .toCodeScheme = info.toCodeScheme, |
| 144 | .selected = info.selected, |
| 145 | }; |
| 146 | } |
| 147 | |
| 148 | V1_0::CdmaSmsWriteArgs toHidl(const aidl::CdmaSmsWriteArgs& args) { |
| 149 | return { |
Tomasz Wasilczyk | b542add | 2022-08-08 19:04:26 +0000 | [diff] [blame] | 150 | .status = static_cast<V1_0::CdmaSmsWriteArgsStatus>(args.status), |
Tomasz Wasilczyk | 9ddc87f | 2021-10-25 20:20:49 -0700 | [diff] [blame] | 151 | .message = toHidl(args.message), |
| 152 | }; |
| 153 | } |
| 154 | |
| 155 | V1_0::SmsWriteArgs toHidl(const aidl::SmsWriteArgs& args) { |
| 156 | return { |
Tomasz Wasilczyk | b542add | 2022-08-08 19:04:26 +0000 | [diff] [blame] | 157 | .status = static_cast<V1_0::SmsWriteArgsStatus>(args.status), |
Tomasz Wasilczyk | 9ddc87f | 2021-10-25 20:20:49 -0700 | [diff] [blame] | 158 | .pdu = args.pdu, |
| 159 | .smsc = args.smsc, |
| 160 | }; |
| 161 | } |
| 162 | |
| 163 | ::aidl::android::hardware::radio::messaging::SendSmsResult toAidl( |
| 164 | const V1_0::SendSmsResult& result) { |
| 165 | return { |
| 166 | .messageRef = result.messageRef, |
| 167 | .ackPDU = result.ackPDU, |
| 168 | .errorCode = result.errorCode, |
| 169 | }; |
| 170 | } |
| 171 | |
| 172 | } // namespace android::hardware::radio::compat |