Implement RadioMessaging for AIDL-HIDL Telephony HAL translator
Bug: 203699028
Test: Boot and grep logcat against radiocompat
Change-Id: I10f0fc0b871fbaf26145c83211770a82af6adc61
diff --git a/radio/aidl/compat/libradiocompat/messaging/RadioIndication-messaging.cpp b/radio/aidl/compat/libradiocompat/messaging/RadioIndication-messaging.cpp
new file mode 100644
index 0000000..c7342b1
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/messaging/RadioIndication-messaging.cpp
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <libradiocompat/RadioIndication.h>
+
+#include "commonStructs.h"
+#include "debug.h"
+#include "structs.h"
+
+#define RADIO_MODULE "MessagingIndication"
+
+namespace android::hardware::radio::compat {
+
+namespace aidl = ::aidl::android::hardware::radio::messaging;
+
+void RadioIndication::setResponseFunction(std::shared_ptr<aidl::IRadioMessagingIndication> rmiCb) {
+ CHECK(rmiCb);
+ mMessagingCb = rmiCb;
+}
+
+Return<void> RadioIndication::cdmaNewSms(V1_0::RadioIndicationType type,
+ const V1_0::CdmaSmsMessage& msg) {
+ LOG_CALL << type;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->cdmaNewSms(toAidl(type), toAidl(msg));
+ return {};
+}
+
+Return<void> RadioIndication::cdmaRuimSmsStorageFull(V1_0::RadioIndicationType type) {
+ LOG_CALL << type;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->cdmaRuimSmsStorageFull(toAidl(type));
+ return {};
+}
+
+Return<void> RadioIndication::newBroadcastSms(V1_0::RadioIndicationType type,
+ const hidl_vec<uint8_t>& data) {
+ LOG_CALL << type;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->newBroadcastSms(toAidl(type), data);
+ return {};
+}
+
+Return<void> RadioIndication::newSms(V1_0::RadioIndicationType type, const hidl_vec<uint8_t>& pdu) {
+ LOG_CALL << type;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->newSms(toAidl(type), pdu);
+ return {};
+}
+
+Return<void> RadioIndication::newSmsOnSim(V1_0::RadioIndicationType type, int32_t recordNumber) {
+ LOG_CALL << type;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->newSmsOnSim(toAidl(type), recordNumber);
+ return {};
+}
+
+Return<void> RadioIndication::newSmsStatusReport(V1_0::RadioIndicationType type,
+ const hidl_vec<uint8_t>& pdu) {
+ LOG_CALL << type;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->newSmsStatusReport(toAidl(type), pdu);
+ return {};
+}
+
+Return<void> RadioIndication::onUssd(V1_0::RadioIndicationType type, V1_0::UssdModeType modeType,
+ const hidl_string& msg) {
+ LOG_CALL << type;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->onUssd(toAidl(type), aidl::UssdModeType(modeType), msg);
+ return {};
+}
+
+Return<void> RadioIndication::simSmsStorageFull(V1_0::RadioIndicationType type) {
+ LOG_CALL << type;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->simSmsStorageFull(toAidl(type));
+ return {};
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/messaging/RadioMessaging.cpp b/radio/aidl/compat/libradiocompat/messaging/RadioMessaging.cpp
new file mode 100644
index 0000000..c1a82b5
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/messaging/RadioMessaging.cpp
@@ -0,0 +1,195 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <libradiocompat/RadioMessaging.h>
+
+#include "debug.h"
+#include "structs.h"
+
+#include "collections.h"
+
+#define RADIO_MODULE "Messaging"
+
+namespace android::hardware::radio::compat {
+
+using ::ndk::ScopedAStatus;
+namespace aidl = ::aidl::android::hardware::radio::messaging;
+constexpr auto ok = &ScopedAStatus::ok;
+
+ScopedAStatus RadioMessaging::acknowledgeIncomingGsmSmsWithPdu( //
+ int32_t serial, bool success, const std::string& ackPdu) {
+ LOG_CALL << serial << ' ' << success << ' ' << ackPdu;
+ mHal1_5->acknowledgeIncomingGsmSmsWithPdu(serial, success, ackPdu);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::acknowledgeLastIncomingCdmaSms( //
+ int32_t serial, const aidl::CdmaSmsAck& smsAck) {
+ LOG_CALL << serial;
+ mHal1_5->acknowledgeLastIncomingCdmaSms(serial, toHidl(smsAck));
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::acknowledgeLastIncomingGsmSms( //
+ int32_t serial, bool success, aidl::SmsAcknowledgeFailCause cause) {
+ LOG_CALL << serial << ' ' << success;
+ mHal1_5->acknowledgeLastIncomingGsmSms(serial, success, V1_0::SmsAcknowledgeFailCause(cause));
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::cancelPendingUssd(int32_t serial) {
+ LOG_CALL << serial;
+ mHal1_5->cancelPendingUssd(serial);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::deleteSmsOnRuim(int32_t serial, int32_t index) {
+ LOG_CALL << serial << ' ' << index;
+ mHal1_5->deleteSmsOnRuim(serial, index);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::deleteSmsOnSim(int32_t serial, int32_t index) {
+ LOG_CALL << serial << ' ' << index;
+ mHal1_5->deleteSmsOnSim(serial, index);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::getCdmaBroadcastConfig(int32_t serial) {
+ LOG_CALL << serial;
+ mHal1_5->getCdmaBroadcastConfig(serial);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::getGsmBroadcastConfig(int32_t serial) {
+ LOG_CALL << serial;
+ mHal1_5->getGsmBroadcastConfig(serial);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::getSmscAddress(int32_t serial) {
+ LOG_CALL << serial;
+ mHal1_5->getSmscAddress(serial);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::reportSmsMemoryStatus(int32_t serial, bool available) {
+ LOG_CALL << serial << ' ' << available;
+ mHal1_5->reportSmsMemoryStatus(serial, available);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::responseAcknowledgement() {
+ LOG_CALL;
+ mHal1_5->responseAcknowledgement();
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::sendCdmaSms(int32_t serial, const aidl::CdmaSmsMessage& sms) {
+ LOG_CALL << serial;
+ mHal1_5->sendCdmaSms(serial, toHidl(sms));
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::sendCdmaSmsExpectMore(int32_t serial, const aidl::CdmaSmsMessage& m) {
+ LOG_CALL << serial;
+ mHal1_5->sendCdmaSmsExpectMore(serial, toHidl(m));
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::sendImsSms(int32_t serial, const aidl::ImsSmsMessage& message) {
+ LOG_CALL << serial;
+ mHal1_5->sendImsSms(serial, toHidl(message));
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::sendSms(int32_t serial, const aidl::GsmSmsMessage& message) {
+ LOG_CALL << serial;
+ mHal1_5->sendSms(serial, toHidl(message));
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::sendSmsExpectMore(int32_t serial, const aidl::GsmSmsMessage& msg) {
+ LOG_CALL << serial;
+ mHal1_5->sendSMSExpectMore(serial, toHidl(msg));
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::sendUssd(int32_t serial, const std::string& ussd) {
+ LOG_CALL << serial << ' ' << ussd;
+ mHal1_5->sendUssd(serial, ussd);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::setCdmaBroadcastActivation(int32_t serial, bool activate) {
+ LOG_CALL << serial << ' ' << activate;
+ mHal1_5->setCdmaBroadcastActivation(serial, activate);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::setCdmaBroadcastConfig(
+ int32_t serial, const std::vector<aidl::CdmaBroadcastSmsConfigInfo>& cfgInfo) {
+ LOG_CALL << serial;
+ mHal1_5->setCdmaBroadcastConfig(serial, toHidl(cfgInfo));
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::setGsmBroadcastActivation(int32_t serial, bool activate) {
+ LOG_CALL << serial << ' ' << activate;
+ mHal1_5->setGsmBroadcastActivation(serial, activate);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::setGsmBroadcastConfig(
+ int32_t serial, const std::vector<aidl::GsmBroadcastSmsConfigInfo>& configInfo) {
+ LOG_CALL << serial;
+ mHal1_5->setGsmBroadcastConfig(serial, toHidl(configInfo));
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::setResponseFunctions(
+ const std::shared_ptr<aidl::IRadioMessagingResponse>& messagingResponse,
+ const std::shared_ptr<aidl::IRadioMessagingIndication>& messagingIndication) {
+ LOG_CALL << messagingResponse << ' ' << messagingIndication;
+
+ CHECK(messagingResponse);
+ CHECK(messagingIndication);
+
+ mRadioResponse->setResponseFunction(messagingResponse);
+ mRadioIndication->setResponseFunction(messagingIndication);
+
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::setSmscAddress(int32_t serial, const std::string& smsc) {
+ LOG_CALL << serial << ' ' << smsc;
+ mHal1_5->setSmscAddress(serial, smsc);
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::writeSmsToRuim(int32_t serial, const aidl::CdmaSmsWriteArgs& sms) {
+ LOG_CALL << serial;
+ mHal1_5->writeSmsToRuim(serial, toHidl(sms));
+ return ok();
+}
+
+ScopedAStatus RadioMessaging::writeSmsToSim(int32_t serial, const aidl::SmsWriteArgs& smsWrArgs) {
+ LOG_CALL << serial;
+ mHal1_5->writeSmsToSim(serial, toHidl(smsWrArgs));
+ return ok();
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/messaging/RadioResponse-messaging.cpp b/radio/aidl/compat/libradiocompat/messaging/RadioResponse-messaging.cpp
new file mode 100644
index 0000000..379e463
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/messaging/RadioResponse-messaging.cpp
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <libradiocompat/RadioResponse.h>
+
+#include "commonStructs.h"
+#include "debug.h"
+#include "structs.h"
+
+#include "collections.h"
+
+#define RADIO_MODULE "MessagingResponse"
+
+namespace android::hardware::radio::compat {
+
+namespace aidl = ::aidl::android::hardware::radio::messaging;
+
+void RadioResponse::setResponseFunction(std::shared_ptr<aidl::IRadioMessagingResponse> rmrCb) {
+ CHECK(rmrCb);
+ mMessagingCb = rmrCb;
+}
+
+Return<void> RadioResponse::acknowledgeIncomingGsmSmsWithPduResponse(
+ const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->acknowledgeIncomingGsmSmsWithPduResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::acknowledgeLastIncomingCdmaSmsResponse(
+ const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->acknowledgeLastIncomingCdmaSmsResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::acknowledgeLastIncomingGsmSmsResponse(
+ const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->acknowledgeLastIncomingGsmSmsResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::cancelPendingUssdResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->cancelPendingUssdResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::deleteSmsOnRuimResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->deleteSmsOnRuimResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::deleteSmsOnSimResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->deleteSmsOnSimResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::getCdmaBroadcastConfigResponse(
+ const V1_0::RadioResponseInfo& info,
+ const hidl_vec<V1_0::CdmaBroadcastSmsConfigInfo>& configs) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->getCdmaBroadcastConfigResponse(toAidl(info), toAidl(configs));
+ return {};
+}
+
+Return<void> RadioResponse::getGsmBroadcastConfigResponse(
+ const V1_0::RadioResponseInfo& info, const hidl_vec<V1_0::GsmBroadcastSmsConfigInfo>& cfg) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->getGsmBroadcastConfigResponse(toAidl(info), toAidl(cfg));
+ return {};
+}
+
+Return<void> RadioResponse::getSmscAddressResponse(const V1_0::RadioResponseInfo& info,
+ const hidl_string& smsc) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->getSmscAddressResponse(toAidl(info), smsc);
+ return {};
+}
+
+Return<void> RadioResponse::reportSmsMemoryStatusResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->reportSmsMemoryStatusResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::sendCdmaSmsExpectMoreResponse(const V1_0::RadioResponseInfo& info,
+ const V1_0::SendSmsResult& sms) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->sendCdmaSmsExpectMoreResponse(toAidl(info), toAidl(sms));
+ return {};
+}
+
+Return<void> RadioResponse::sendCdmaSmsExpectMoreResponse_1_6(const V1_6::RadioResponseInfo& info,
+ const V1_0::SendSmsResult& sms) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->sendCdmaSmsExpectMoreResponse(toAidl(info), toAidl(sms));
+ return {};
+}
+
+Return<void> RadioResponse::sendCdmaSmsResponse(const V1_0::RadioResponseInfo& info,
+ const V1_0::SendSmsResult& sms) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->sendCdmaSmsResponse(toAidl(info), toAidl(sms));
+ return {};
+}
+
+Return<void> RadioResponse::sendCdmaSmsResponse_1_6(const V1_6::RadioResponseInfo& info,
+ const V1_0::SendSmsResult& sms) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->sendCdmaSmsResponse(toAidl(info), toAidl(sms));
+ return {};
+}
+
+Return<void> RadioResponse::sendImsSmsResponse(const V1_0::RadioResponseInfo& info,
+ const V1_0::SendSmsResult& sms) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->sendImsSmsResponse(toAidl(info), toAidl(sms));
+ return {};
+}
+
+Return<void> RadioResponse::sendSMSExpectMoreResponse(const V1_0::RadioResponseInfo& info,
+ const V1_0::SendSmsResult& sms) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->sendSmsExpectMoreResponse(toAidl(info), toAidl(sms));
+ return {};
+}
+
+Return<void> RadioResponse::sendSmsExpectMoreResponse_1_6(const V1_6::RadioResponseInfo& info,
+ const V1_0::SendSmsResult& sms) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->sendSmsExpectMoreResponse(toAidl(info), toAidl(sms));
+ return {};
+}
+
+Return<void> RadioResponse::sendSmsResponse(const V1_0::RadioResponseInfo& info,
+ const V1_0::SendSmsResult& sms) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->sendSmsResponse(toAidl(info), toAidl(sms));
+ return {};
+}
+
+Return<void> RadioResponse::sendSmsResponse_1_6(const V1_6::RadioResponseInfo& info,
+ const V1_0::SendSmsResult& sms) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->sendSmsResponse(toAidl(info), toAidl(sms));
+ return {};
+}
+
+Return<void> RadioResponse::sendUssdResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->sendUssdResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setCdmaBroadcastActivationResponse(
+ const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->setCdmaBroadcastActivationResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setCdmaBroadcastConfigResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->setCdmaBroadcastConfigResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setGsmBroadcastActivationResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->setGsmBroadcastActivationResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setGsmBroadcastConfigResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->setGsmBroadcastConfigResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setSmscAddressResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->setSmscAddressResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::writeSmsToRuimResponse(const V1_0::RadioResponseInfo& info,
+ uint32_t index) {
+ LOG_CALL << info.serial << ' ' << index;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->writeSmsToRuimResponse(toAidl(info), index);
+ return {};
+}
+
+Return<void> RadioResponse::writeSmsToSimResponse(const V1_0::RadioResponseInfo& info,
+ int32_t index) {
+ LOG_CALL << info.serial << ' ' << index;
+ CHECK_CB(mMessagingCb);
+ mMessagingCb->writeSmsToSimResponse(toAidl(info), index);
+ return {};
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/messaging/structs.cpp b/radio/aidl/compat/libradiocompat/messaging/structs.cpp
new file mode 100644
index 0000000..9019680
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/messaging/structs.cpp
@@ -0,0 +1,172 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "structs.h"
+
+#include "collections.h"
+
+#include <aidl/android/hardware/radio/messaging/CdmaSmsAddress.h>
+#include <android-base/logging.h>
+
+namespace android::hardware::radio::compat {
+
+namespace aidl = ::aidl::android::hardware::radio::messaging;
+
+V1_0::CdmaSmsAck toHidl(const aidl::CdmaSmsAck& smsAck) {
+ return {
+ .errorClass = (smsAck.errorClass ? V1_0::CdmaSmsErrorClass::ERROR
+ : V1_0::CdmaSmsErrorClass::NO_ERROR),
+ .smsCauseCode = smsAck.smsCauseCode,
+ };
+}
+
+static aidl::CdmaSmsAddress toAidl(const V1_0::CdmaSmsAddress& addr) {
+ return {
+ .digitMode = static_cast<int32_t>(addr.digitMode),
+ .isNumberModeDataNetwork = addr.numberMode == V1_0::CdmaSmsNumberMode::DATA_NETWORK,
+ .numberType = static_cast<int32_t>(addr.numberType),
+ .numberPlan = static_cast<int32_t>(addr.numberPlan),
+ .digits = addr.digits,
+ };
+}
+
+static V1_0::CdmaSmsAddress toHidl(const aidl::CdmaSmsAddress& addr) {
+ return {
+ .digitMode = V1_0::CdmaSmsDigitMode{addr.digitMode},
+ .numberMode = addr.isNumberModeDataNetwork ? V1_0::CdmaSmsNumberMode::DATA_NETWORK
+ : V1_0::CdmaSmsNumberMode::NOT_DATA_NETWORK,
+ .numberType = V1_0::CdmaSmsNumberType{addr.numberType},
+ .numberPlan = V1_0::CdmaSmsNumberPlan{addr.numberPlan},
+ .digits = addr.digits,
+ };
+}
+
+static aidl::CdmaSmsSubaddress toAidl(const V1_0::CdmaSmsSubaddress& addr) {
+ return {
+ .subaddressType = static_cast<int32_t>(addr.subaddressType),
+ .odd = addr.odd,
+ .digits = addr.digits,
+ };
+}
+
+static V1_0::CdmaSmsSubaddress toHidl(const aidl::CdmaSmsSubaddress& addr) {
+ return {
+ .subaddressType = V1_0::CdmaSmsSubaddressType{addr.subaddressType},
+ .odd = addr.odd,
+ .digits = addr.digits,
+ };
+}
+
+::aidl::android::hardware::radio::messaging::CdmaSmsMessage toAidl(const V1_0::CdmaSmsMessage& m) {
+ return {
+ .teleserviceId = m.teleserviceId,
+ .isServicePresent = m.isServicePresent,
+ .serviceCategory = m.serviceCategory,
+ .address = toAidl(m.address),
+ .subAddress = toAidl(m.subAddress),
+ .bearerData = m.bearerData,
+ };
+}
+
+V1_0::CdmaSmsMessage toHidl(const aidl::CdmaSmsMessage& msg) {
+ return {
+ .teleserviceId = msg.teleserviceId,
+ .isServicePresent = msg.isServicePresent,
+ .serviceCategory = msg.serviceCategory,
+ .address = toHidl(msg.address),
+ .subAddress = toHidl(msg.subAddress),
+ .bearerData = msg.bearerData,
+ };
+}
+
+V1_0::ImsSmsMessage toHidl(const aidl::ImsSmsMessage& msg) {
+ return {
+ .tech = V1_0::RadioTechnologyFamily{msg.tech},
+ .retry = msg.retry,
+ .messageRef = msg.messageRef,
+ .cdmaMessage = toHidl(msg.cdmaMessage),
+ .gsmMessage = toHidl(msg.gsmMessage),
+ };
+}
+
+V1_0::GsmSmsMessage toHidl(const aidl::GsmSmsMessage& msg) {
+ return {
+ .smscPdu = msg.smscPdu,
+ .pdu = msg.pdu,
+ };
+}
+
+aidl::CdmaBroadcastSmsConfigInfo toAidl(const V1_0::CdmaBroadcastSmsConfigInfo& info) {
+ return {
+ .serviceCategory = info.serviceCategory,
+ .language = info.language,
+ .selected = info.selected,
+ };
+}
+
+V1_0::CdmaBroadcastSmsConfigInfo toHidl(const aidl::CdmaBroadcastSmsConfigInfo& info) {
+ return {
+ .serviceCategory = info.serviceCategory,
+ .language = info.language,
+ .selected = info.selected,
+ };
+}
+
+aidl::GsmBroadcastSmsConfigInfo toAidl(const V1_0::GsmBroadcastSmsConfigInfo& info) {
+ return {
+ .fromServiceId = info.fromServiceId,
+ .toServiceId = info.toServiceId,
+ .fromCodeScheme = info.fromCodeScheme,
+ .toCodeScheme = info.toCodeScheme,
+ .selected = info.selected,
+ };
+}
+
+V1_0::GsmBroadcastSmsConfigInfo toHidl(const aidl::GsmBroadcastSmsConfigInfo& info) {
+ return {
+ .fromServiceId = info.fromServiceId,
+ .toServiceId = info.toServiceId,
+ .fromCodeScheme = info.fromCodeScheme,
+ .toCodeScheme = info.toCodeScheme,
+ .selected = info.selected,
+ };
+}
+
+V1_0::CdmaSmsWriteArgs toHidl(const aidl::CdmaSmsWriteArgs& args) {
+ return {
+ .status = V1_0::CdmaSmsWriteArgsStatus{args.status},
+ .message = toHidl(args.message),
+ };
+}
+
+V1_0::SmsWriteArgs toHidl(const aidl::SmsWriteArgs& args) {
+ return {
+ .status = V1_0::SmsWriteArgsStatus{args.status},
+ .pdu = args.pdu,
+ .smsc = args.smsc,
+ };
+}
+
+::aidl::android::hardware::radio::messaging::SendSmsResult toAidl(
+ const V1_0::SendSmsResult& result) {
+ return {
+ .messageRef = result.messageRef,
+ .ackPDU = result.ackPDU,
+ .errorCode = result.errorCode,
+ };
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/messaging/structs.h b/radio/aidl/compat/libradiocompat/messaging/structs.h
new file mode 100644
index 0000000..afb4941
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/messaging/structs.h
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2021 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#pragma once
+
+#include <aidl/android/hardware/radio/messaging/CdmaBroadcastSmsConfigInfo.h>
+#include <aidl/android/hardware/radio/messaging/CdmaSmsAck.h>
+#include <aidl/android/hardware/radio/messaging/CdmaSmsMessage.h>
+#include <aidl/android/hardware/radio/messaging/CdmaSmsWriteArgs.h>
+#include <aidl/android/hardware/radio/messaging/GsmBroadcastSmsConfigInfo.h>
+#include <aidl/android/hardware/radio/messaging/GsmSmsMessage.h>
+#include <aidl/android/hardware/radio/messaging/ImsSmsMessage.h>
+#include <aidl/android/hardware/radio/messaging/SendSmsResult.h>
+#include <aidl/android/hardware/radio/messaging/SmsWriteArgs.h>
+#include <android/hardware/radio/1.0/types.h>
+
+namespace android::hardware::radio::compat {
+
+V1_0::CdmaSmsAck toHidl(const ::aidl::android::hardware::radio::messaging::CdmaSmsAck& ack);
+
+::aidl::android::hardware::radio::messaging::CdmaSmsMessage toAidl(const V1_0::CdmaSmsMessage& msg);
+V1_0::CdmaSmsMessage toHidl(const ::aidl::android::hardware::radio::messaging::CdmaSmsMessage& msg);
+
+V1_0::ImsSmsMessage toHidl(const ::aidl::android::hardware::radio::messaging::ImsSmsMessage& msg);
+
+V1_0::GsmSmsMessage toHidl(const ::aidl::android::hardware::radio::messaging::GsmSmsMessage& msg);
+
+::aidl::android::hardware::radio::messaging::CdmaBroadcastSmsConfigInfo //
+toAidl(const V1_0::CdmaBroadcastSmsConfigInfo& info);
+V1_0::CdmaBroadcastSmsConfigInfo //
+toHidl(const ::aidl::android::hardware::radio::messaging::CdmaBroadcastSmsConfigInfo& info);
+
+::aidl::android::hardware::radio::messaging::GsmBroadcastSmsConfigInfo //
+toAidl(const V1_0::GsmBroadcastSmsConfigInfo& info);
+V1_0::GsmBroadcastSmsConfigInfo //
+toHidl(const ::aidl::android::hardware::radio::messaging::GsmBroadcastSmsConfigInfo& info);
+
+V1_0::CdmaSmsWriteArgs //
+toHidl(const ::aidl::android::hardware::radio::messaging::CdmaSmsWriteArgs& args);
+
+V1_0::SmsWriteArgs toHidl(const ::aidl::android::hardware::radio::messaging::SmsWriteArgs& args);
+
+::aidl::android::hardware::radio::messaging::SendSmsResult toAidl(const V1_0::SendSmsResult& res);
+
+} // namespace android::hardware::radio::compat