Implement RadioData for AIDL-HIDL Telephony HAL translator
Bug: 203699028
Test: Boot and grep logcat against radiocompat
Change-Id: I5770ee4125cd9e6f118200ecee889ad785e8929f
diff --git a/radio/aidl/compat/libradiocompat/data/RadioData.cpp b/radio/aidl/compat/libradiocompat/data/RadioData.cpp
new file mode 100644
index 0000000..fdb1273
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/data/RadioData.cpp
@@ -0,0 +1,180 @@
+/*
+ * 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/RadioData.h>
+
+#include "commonStructs.h"
+#include "debug.h"
+#include "structs.h"
+
+#include "collections.h"
+
+#define RADIO_MODULE "Data"
+
+namespace android::hardware::radio::compat {
+
+using ::ndk::ScopedAStatus;
+namespace aidl = ::aidl::android::hardware::radio::data;
+namespace aidlCommon = ::aidl::android::hardware::radio;
+constexpr auto ok = &ScopedAStatus::ok;
+
+ScopedAStatus RadioData::allocatePduSessionId(int32_t serial) {
+ LOG_CALL << serial;
+ if (mHal1_6) {
+ mHal1_6->allocatePduSessionId(serial);
+ } else {
+ respond().allocatePduSessionIdResponse(notSupported(serial), 0);
+ }
+ return ok();
+}
+
+ScopedAStatus RadioData::cancelHandover(int32_t serial, int32_t callId) {
+ LOG_CALL << serial;
+ if (mHal1_6) {
+ mHal1_6->cancelHandover(serial, callId);
+ } else {
+ respond().cancelHandoverResponse(notSupported(serial));
+ }
+ return ok();
+}
+
+ScopedAStatus RadioData::deactivateDataCall(int32_t serial, int32_t cid,
+ aidl::DataRequestReason reason) {
+ LOG_CALL << serial;
+ mHal1_5->deactivateDataCall_1_2(serial, cid, V1_2::DataRequestReason(reason));
+ return ok();
+}
+
+ScopedAStatus RadioData::getDataCallList(int32_t serial) {
+ LOG_CALL << serial;
+ mHal1_5->getDataCallList(serial);
+ return ok();
+}
+
+ScopedAStatus RadioData::getSlicingConfig(int32_t serial) {
+ LOG_CALL << serial;
+ if (mHal1_6) {
+ mHal1_6->getSlicingConfig(serial);
+ } else {
+ respond().getSlicingConfigResponse(notSupported(serial), {});
+ }
+ return ok();
+}
+
+ScopedAStatus RadioData::releasePduSessionId(int32_t serial, int32_t id) {
+ LOG_CALL << serial;
+ if (mHal1_6) {
+ mHal1_6->releasePduSessionId(serial, id);
+ } else {
+ respond().releasePduSessionIdResponse(notSupported(serial));
+ }
+ return ok();
+}
+
+ScopedAStatus RadioData::responseAcknowledgement() {
+ LOG_CALL;
+ mHal1_5->responseAcknowledgement();
+ return ok();
+}
+
+ScopedAStatus RadioData::setDataAllowed(int32_t serial, bool allow) {
+ LOG_CALL << serial;
+ mHal1_5->setDataAllowed(serial, allow);
+ return ok();
+}
+
+ScopedAStatus RadioData::setDataProfile(int32_t serial,
+ const std::vector<aidl::DataProfileInfo>& profiles) {
+ LOG_CALL << serial;
+ mHal1_5->setDataProfile_1_5(serial, toHidl(profiles));
+ return ok();
+}
+
+ScopedAStatus RadioData::setDataThrottling(int32_t serial, aidl::DataThrottlingAction dta,
+ int64_t completionDurationMs) {
+ LOG_CALL << serial;
+ if (mHal1_6) {
+ mHal1_6->setDataThrottling(serial, V1_6::DataThrottlingAction(dta), completionDurationMs);
+ } else {
+ respond().setDataThrottlingResponse(notSupported(serial));
+ }
+ return ok();
+}
+
+ScopedAStatus RadioData::setInitialAttachApn(int32_t serial, const aidl::DataProfileInfo& info) {
+ LOG_CALL << serial;
+ mHal1_5->setInitialAttachApn_1_5(serial, toHidl(info));
+ return ok();
+}
+
+ScopedAStatus RadioData::setResponseFunctions(
+ const std::shared_ptr<aidl::IRadioDataResponse>& dataResponse,
+ const std::shared_ptr<aidl::IRadioDataIndication>& dataIndication) {
+ LOG_CALL << dataResponse << ' ' << dataIndication;
+
+ CHECK(dataResponse);
+ CHECK(dataIndication);
+
+ mRadioResponse->setResponseFunction(dataResponse);
+ mRadioIndication->setResponseFunction(dataIndication);
+
+ return ok();
+}
+
+ScopedAStatus RadioData::setupDataCall( //
+ int32_t serial, aidlCommon::AccessNetwork accessNetwork,
+ const aidl::DataProfileInfo& dataProfileInfo, bool roamingAllowed,
+ aidl::DataRequestReason reason, const std::vector<aidl::LinkAddress>& addresses,
+ const std::vector<std::string>& dnses, int32_t pduSessId,
+ const std::optional<aidl::SliceInfo>& sliceInfo,
+ const std::optional<aidl::TrafficDescriptor>& trDesc, bool matchAllRuleAllowed) {
+ if (mHal1_6) {
+ mHal1_6->setupDataCall_1_6( //
+ serial, V1_5::AccessNetwork(accessNetwork), toHidl(dataProfileInfo), roamingAllowed,
+ V1_2::DataRequestReason(reason), toHidl(addresses), toHidl(dnses), pduSessId,
+ toHidl<V1_6::OptionalSliceInfo>(sliceInfo),
+ toHidl<V1_6::OptionalTrafficDescriptor>(trDesc), matchAllRuleAllowed);
+ } else {
+ mHal1_5->setupDataCall_1_5( //
+ serial, V1_5::AccessNetwork(accessNetwork), toHidl(dataProfileInfo), roamingAllowed,
+ V1_2::DataRequestReason(reason), toHidl(addresses), toHidl(dnses));
+ }
+ return ok();
+}
+
+ScopedAStatus RadioData::startHandover(int32_t serial, int32_t callId) {
+ LOG_CALL << serial;
+ if (mHal1_6) {
+ mHal1_6->startHandover(serial, callId);
+ } else {
+ respond().startHandoverResponse(notSupported(serial));
+ }
+ return ok();
+}
+
+ScopedAStatus RadioData::startKeepalive(int32_t serial, const aidl::KeepaliveRequest& keepalive) {
+ LOG_CALL << serial;
+ mHal1_5->startKeepalive(serial, toHidl(keepalive));
+ return ok();
+}
+
+ScopedAStatus RadioData::stopKeepalive(int32_t serial, int32_t sessionHandle) {
+ LOG_CALL << serial;
+ mHal1_5->stopKeepalive(serial, sessionHandle);
+ return ok();
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/data/RadioIndication-data.cpp b/radio/aidl/compat/libradiocompat/data/RadioIndication-data.cpp
new file mode 100644
index 0000000..f51d1a8
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/data/RadioIndication-data.cpp
@@ -0,0 +1,90 @@
+/*
+ * 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"
+
+#include "collections.h"
+
+#define RADIO_MODULE "DataIndication"
+
+namespace android::hardware::radio::compat {
+
+namespace aidl = ::aidl::android::hardware::radio::data;
+
+void RadioIndication::setResponseFunction(std::shared_ptr<aidl::IRadioDataIndication> dataCb) {
+ CHECK(dataCb);
+ mDataCb = dataCb;
+}
+
+Return<void> RadioIndication::dataCallListChanged(V1_0::RadioIndicationType type,
+ const hidl_vec<V1_0::SetupDataCallResult>&) {
+ LOG_CALL << type;
+ LOG(ERROR) << "IRadio HAL 1.0 not supported";
+ return {};
+}
+
+Return<void> RadioIndication::dataCallListChanged_1_4(V1_0::RadioIndicationType type,
+ const hidl_vec<V1_4::SetupDataCallResult>&) {
+ LOG_CALL << type;
+ LOG(ERROR) << "IRadio HAL 1.4 not supported";
+ return {};
+}
+
+Return<void> RadioIndication::dataCallListChanged_1_5(
+ V1_0::RadioIndicationType type, const hidl_vec<V1_5::SetupDataCallResult>& dcList) {
+ LOG_CALL << type;
+ CHECK_CB(mDataCb);
+ mDataCb->dataCallListChanged(toAidl(type), toAidl(dcList));
+ return {};
+}
+
+Return<void> RadioIndication::dataCallListChanged_1_6(
+ V1_0::RadioIndicationType type, const hidl_vec<V1_6::SetupDataCallResult>& dcList) {
+ LOG_CALL << type;
+ CHECK_CB(mDataCb);
+ mDataCb->dataCallListChanged(toAidl(type), toAidl(dcList));
+ return {};
+}
+
+Return<void> RadioIndication::keepaliveStatus(V1_0::RadioIndicationType type,
+ const V1_1::KeepaliveStatus& status) {
+ LOG_CALL << type;
+ CHECK_CB(mDataCb);
+ mDataCb->keepaliveStatus(toAidl(type), toAidl(status));
+ return {};
+}
+
+Return<void> RadioIndication::pcoData(V1_0::RadioIndicationType type,
+ const V1_0::PcoDataInfo& pco) {
+ LOG_CALL << type;
+ CHECK_CB(mDataCb);
+ mDataCb->pcoData(toAidl(type), toAidl(pco));
+ return {};
+}
+
+Return<void> RadioIndication::unthrottleApn(V1_0::RadioIndicationType type,
+ const hidl_string& apn) {
+ LOG_CALL << type;
+ CHECK_CB(mDataCb);
+ mDataCb->unthrottleApn(toAidl(type), apn);
+ return {};
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/data/RadioResponse-data.cpp b/radio/aidl/compat/libradiocompat/data/RadioResponse-data.cpp
new file mode 100644
index 0000000..171f692
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/data/RadioResponse-data.cpp
@@ -0,0 +1,199 @@
+/*
+ * 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 "DataResponse"
+
+namespace android::hardware::radio::compat {
+
+namespace aidl = ::aidl::android::hardware::radio::data;
+
+void RadioResponse::setResponseFunction(std::shared_ptr<aidl::IRadioDataResponse> dataCb) {
+ CHECK(dataCb);
+ mDataCb = dataCb;
+}
+
+Return<void> RadioResponse::allocatePduSessionIdResponse(const V1_6::RadioResponseInfo& info,
+ int32_t id) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->allocatePduSessionIdResponse(toAidl(info), id);
+ return {};
+}
+
+Return<void> RadioResponse::cancelHandoverResponse(const V1_6::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->cancelHandoverResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::deactivateDataCallResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->deactivateDataCallResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::getDataCallListResponse(const V1_0::RadioResponseInfo& info,
+ const hidl_vec<V1_0::SetupDataCallResult>&) {
+ LOG_CALL << info.serial;
+ LOG(ERROR) << "IRadio HAL 1.0 not supported";
+ return {};
+}
+
+Return<void> RadioResponse::getDataCallListResponse_1_4(
+ const V1_0::RadioResponseInfo& info, const hidl_vec<V1_4::SetupDataCallResult>&) {
+ LOG_CALL << info.serial;
+ LOG(ERROR) << "IRadio HAL 1.4 not supported";
+ return {};
+}
+
+Return<void> RadioResponse::getDataCallListResponse_1_5(
+ const V1_0::RadioResponseInfo& info,
+ const hidl_vec<V1_5::SetupDataCallResult>& dcResponse) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->getDataCallListResponse(toAidl(info), toAidl(dcResponse));
+ return {};
+}
+
+Return<void> RadioResponse::getDataCallListResponse_1_6(
+ const V1_6::RadioResponseInfo& info,
+ const hidl_vec<V1_6::SetupDataCallResult>& dcResponse) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->getDataCallListResponse(toAidl(info), toAidl(dcResponse));
+ return {};
+}
+
+Return<void> RadioResponse::getSlicingConfigResponse(const V1_6::RadioResponseInfo& info,
+ const V1_6::SlicingConfig& slicingConfig) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->getSlicingConfigResponse(toAidl(info), toAidl(slicingConfig));
+ return {};
+}
+
+Return<void> RadioResponse::releasePduSessionIdResponse(const V1_6::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->releasePduSessionIdResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setDataAllowedResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->setDataAllowedResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setDataProfileResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->setDataProfileResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setDataProfileResponse_1_5(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->setDataProfileResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setDataThrottlingResponse(const V1_6::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->setDataThrottlingResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setInitialAttachApnResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->setInitialAttachApnResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setInitialAttachApnResponse_1_5(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->setInitialAttachApnResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::setupDataCallResponse(const V1_0::RadioResponseInfo& info,
+ const V1_0::SetupDataCallResult&) {
+ LOG_CALL << info.serial;
+ LOG(ERROR) << "IRadio HAL 1.0 not supported";
+ return {};
+}
+
+Return<void> RadioResponse::setupDataCallResponse_1_4(const V1_0::RadioResponseInfo& info,
+ const V1_4::SetupDataCallResult&) {
+ LOG_CALL << info.serial;
+ LOG(ERROR) << "IRadio HAL 1.0 not supported";
+ return {};
+}
+
+Return<void> RadioResponse::setupDataCallResponse_1_5(const V1_0::RadioResponseInfo& info,
+ const V1_5::SetupDataCallResult& dcResponse) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->setupDataCallResponse(toAidl(info), toAidl(dcResponse));
+ return {};
+}
+
+Return<void> RadioResponse::setupDataCallResponse_1_6(const V1_6::RadioResponseInfo& info,
+ const V1_6::SetupDataCallResult& dcResponse) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->setupDataCallResponse(toAidl(info), toAidl(dcResponse));
+ return {};
+}
+
+Return<void> RadioResponse::startHandoverResponse(const V1_6::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->startHandoverResponse(toAidl(info));
+ return {};
+}
+
+Return<void> RadioResponse::startKeepaliveResponse(const V1_0::RadioResponseInfo& info,
+ const V1_1::KeepaliveStatus& status) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->startKeepaliveResponse(toAidl(info), toAidl(status));
+ return {};
+}
+
+Return<void> RadioResponse::stopKeepaliveResponse(const V1_0::RadioResponseInfo& info) {
+ LOG_CALL << info.serial;
+ CHECK_CB(mDataCb);
+ mDataCb->stopKeepaliveResponse(toAidl(info));
+ return {};
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/data/structs.cpp b/radio/aidl/compat/libradiocompat/data/structs.cpp
new file mode 100644
index 0000000..4ff89a1
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/data/structs.cpp
@@ -0,0 +1,288 @@
+/*
+ * 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 "commonStructs.h"
+
+#include "collections.h"
+
+#include <android-base/logging.h>
+
+namespace android::hardware::radio::compat {
+
+namespace aidl = ::aidl::android::hardware::radio::data;
+
+V1_5::DataProfileInfo toHidl(const aidl::DataProfileInfo& info) {
+ return {
+ .profileId = V1_0::DataProfileId{info.profileId},
+ .apn = info.apn,
+ .protocol = V1_4::PdpProtocolType{info.protocol},
+ .roamingProtocol = V1_4::PdpProtocolType{info.roamingProtocol},
+ .authType = V1_0::ApnAuthType{info.authType},
+ .user = info.user,
+ .password = info.password,
+ .type = V1_0::DataProfileInfoType{info.type},
+ .maxConnsTime = info.maxConnsTime,
+ .maxConns = info.maxConns,
+ .waitTime = info.waitTime,
+ .enabled = info.enabled,
+ .supportedApnTypesBitmap = toHidlBitfield<V1_5::ApnTypes>(info.supportedApnTypesBitmap),
+ .bearerBitmap = toHidlBitfield<V1_4::RadioAccessFamily>(info.bearerBitmap),
+ .mtuV4 = info.mtuV4,
+ .mtuV6 = info.mtuV6,
+ .preferred = info.preferred,
+ .persistent = info.persistent,
+ };
+}
+
+V1_5::LinkAddress toHidl(const aidl::LinkAddress& addr) {
+ return {
+ .address = addr.address,
+ .properties = addr.addressProperties,
+ .deprecationTime = static_cast<uint64_t>(addr.deprecationTime),
+ .expirationTime = static_cast<uint64_t>(addr.expirationTime),
+ };
+}
+
+aidl::SliceInfo toAidl(const V1_6::SliceInfo& info) {
+ return {
+ .sliceServiceType = static_cast<int8_t>(info.sst),
+ .sliceDifferentiator = info.sliceDifferentiator,
+ .mappedHplmnSst = static_cast<int8_t>(info.mappedHplmnSst),
+ .mappedHplmnSd = info.mappedHplmnSD,
+ .status = static_cast<int8_t>(info.status),
+ };
+}
+
+V1_6::SliceInfo toHidl(const aidl::SliceInfo& info) {
+ return {
+ .sst = static_cast<V1_6::SliceServiceType>(info.sliceServiceType),
+ .sliceDifferentiator = info.sliceDifferentiator,
+ .mappedHplmnSst = static_cast<V1_6::SliceServiceType>(info.mappedHplmnSst),
+ .mappedHplmnSD = info.mappedHplmnSd,
+ .status = V1_6::SliceStatus{info.status},
+ };
+}
+
+aidl::TrafficDescriptor toAidl(const V1_6::TrafficDescriptor& descr) {
+ return {
+ .dnn = toAidl(descr.dnn),
+ .osAppId = toAidl(descr.osAppId),
+ };
+}
+
+V1_6::TrafficDescriptor toHidl(const aidl::TrafficDescriptor& descr) {
+ return {
+ .dnn = toHidl<V1_6::OptionalDnn>(descr.dnn),
+ .osAppId = toHidl<V1_6::OptionalOsAppId>(descr.osAppId),
+ };
+}
+
+aidl::OsAppId toAidl(const V1_6::OsAppId& appId) {
+ return {
+ .osAppId = appId.osAppId,
+ };
+}
+
+V1_6::OsAppId toHidl(const aidl::OsAppId& appId) {
+ return {
+ .osAppId = appId.osAppId,
+ };
+}
+
+V1_1::KeepaliveRequest toHidl(const aidl::KeepaliveRequest& keep) {
+ return {
+ .type = V1_1::KeepaliveType{keep.type},
+ .sourceAddress = keep.sourceAddress,
+ .sourcePort = keep.sourcePort,
+ .destinationAddress = keep.destinationAddress,
+ .destinationPort = keep.destinationPort,
+ .maxKeepaliveIntervalMillis = keep.maxKeepaliveIntervalMillis,
+ .cid = keep.cid,
+ };
+}
+
+static aidl::QosBandwidth toAidl(const V1_6::QosBandwidth& bw) {
+ return {
+ .maxBitrateKbps = static_cast<int32_t>(bw.maxBitrateKbps),
+ .guaranteedBitrateKbps = static_cast<int32_t>(bw.guaranteedBitrateKbps),
+ };
+}
+
+static aidl::EpsQos toAidl(const V1_6::EpsQos& qos) {
+ return {
+ .qci = qos.qci,
+ .downlink = toAidl(qos.downlink),
+ .uplink = toAidl(qos.uplink),
+ };
+}
+
+static aidl::NrQos toAidl(const V1_6::NrQos& qos) {
+ return {
+ .fiveQi = qos.fiveQi,
+ .downlink = toAidl(qos.downlink),
+ .uplink = toAidl(qos.uplink),
+ .qfi = static_cast<int8_t>(qos.qfi),
+ .averagingWindowMs = qos.averagingWindowMs,
+ };
+}
+
+static std::variant<bool, aidl::EpsQos, aidl::NrQos> toAidl(const V1_6::Qos& qos) {
+ if (qos.getDiscriminator() == V1_6::Qos::hidl_discriminator::eps) return toAidl(qos.eps());
+ if (qos.getDiscriminator() == V1_6::Qos::hidl_discriminator::nr) return toAidl(qos.nr());
+ return false;
+}
+
+aidl::SetupDataCallResult toAidl(const V1_5::SetupDataCallResult& res) {
+ return {
+ .cause = aidl::DataCallFailCause(res.cause),
+ .suggestedRetryTime = res.suggestedRetryTime,
+ .cid = res.cid,
+ .active = static_cast<int32_t>(res.active),
+ .type = aidl::PdpProtocolType(res.type),
+ .ifname = res.ifname,
+ .addresses = toAidl(res.addresses),
+ .dnses = toAidl(res.dnses),
+ .gateways = toAidl(res.gateways),
+ .pcscf = toAidl(res.pcscf),
+ .mtuV4 = res.mtuV4,
+ .mtuV6 = res.mtuV6,
+ };
+}
+
+aidl::SetupDataCallResult toAidl(const V1_6::SetupDataCallResult& res) {
+ return {
+ .cause = aidl::DataCallFailCause(res.cause),
+ .suggestedRetryTime = res.suggestedRetryTime,
+ .cid = res.cid,
+ .active = static_cast<int32_t>(res.active),
+ .type = aidl::PdpProtocolType(res.type),
+ .ifname = res.ifname,
+ .addresses = toAidl(res.addresses),
+ .dnses = toAidl(res.dnses),
+ .gateways = toAidl(res.gateways),
+ .pcscf = toAidl(res.pcscf),
+ .mtuV4 = res.mtuV4,
+ .mtuV6 = res.mtuV6,
+ .defaultQos = toAidl(res.defaultQos),
+ .qosSessions = toAidl(res.qosSessions),
+ .handoverFailureMode = static_cast<int8_t>(res.handoverFailureMode),
+ .pduSessionId = res.pduSessionId,
+ .sliceInfo = toAidl(res.sliceInfo),
+ .trafficDescriptors = toAidl(res.trafficDescriptors),
+ };
+}
+
+aidl::LinkAddress toAidl(const V1_5::LinkAddress& addr) {
+ return {
+ .address = addr.address,
+ .addressProperties = addr.properties,
+ .deprecationTime = static_cast<int64_t>(addr.deprecationTime),
+ .expirationTime = static_cast<int64_t>(addr.expirationTime),
+ };
+}
+
+aidl::QosSession toAidl(const V1_6::QosSession& sess) {
+ return {
+ .qosSessionId = sess.qosSessionId,
+ .qos = toAidl(sess.qos),
+ .qosFilters = toAidl(sess.qosFilters),
+ };
+}
+
+static aidl::PortRange toAidl(const V1_6::PortRange& range) {
+ return {
+ .start = range.start,
+ .end = range.end,
+ };
+}
+
+static std::optional<aidl::PortRange> toAidl(const V1_6::MaybePort& opt) {
+ if (opt.getDiscriminator() == V1_6::MaybePort::hidl_discriminator::noinit) return std::nullopt;
+ return toAidl(opt.range()); // can't use MaybeX template - this field is not named "value"
+}
+
+aidl::QosFilter toAidl(const V1_6::QosFilter& filter) {
+ return {
+ .localAddresses = toAidl(filter.localAddresses),
+ .remoteAddresses = toAidl(filter.remoteAddresses),
+ .localPort = toAidl(filter.localPort),
+ .remotePort = toAidl(filter.remotePort),
+ .protocol = static_cast<int8_t>(filter.protocol),
+ .tos = toAidlVariant(filter.tos),
+ .flowLabel = toAidlVariant(filter.flowLabel),
+ .spi = toAidlVariant(filter.spi),
+ .direction = static_cast<int8_t>(filter.direction),
+ .precedence = filter.precedence,
+ };
+}
+
+aidl::KeepaliveStatus toAidl(const V1_1::KeepaliveStatus& status) {
+ return {
+ .sessionHandle = status.sessionHandle,
+ .code = static_cast<int32_t>(status.code),
+ };
+}
+
+aidl::PcoDataInfo toAidl(const V1_0::PcoDataInfo& info) {
+ return {
+ .cid = info.cid,
+ .bearerProto = info.bearerProto,
+ .pcoId = info.pcoId,
+ .contents = info.contents,
+ };
+}
+
+aidl::SlicingConfig toAidl(const V1_6::SlicingConfig& cfg) {
+ return {
+ .urspRules = toAidl(cfg.urspRules),
+ .sliceInfo = toAidl(cfg.sliceInfo),
+ };
+}
+
+aidl::UrspRule toAidl(const V1_6::UrspRule& rule) {
+ return {
+ .precedence = rule.precedence,
+ .trafficDescriptors = toAidl(rule.trafficDescriptors),
+ .routeSelectionDescriptor = toAidl(rule.routeSelectionDescriptor),
+ };
+}
+
+static int8_t toAidl(const V1_6::OptionalSscMode& opt) {
+ if (opt.getDiscriminator() == V1_6::OptionalSscMode::hidl_discriminator::noinit) {
+ return aidl::RouteSelectionDescriptor::SSC_MODE_UNKNOWN;
+ }
+ return static_cast<int8_t>(opt.value());
+}
+
+static aidl::PdpProtocolType toAidl(const V1_6::OptionalPdpProtocolType& opt) {
+ using discriminator = V1_6::OptionalPdpProtocolType::hidl_discriminator;
+ if (opt.getDiscriminator() == discriminator::noinit) return aidl::PdpProtocolType::UNKNOWN;
+ return aidl::PdpProtocolType(opt.value());
+}
+
+aidl::RouteSelectionDescriptor toAidl(const V1_6::RouteSelectionDescriptor& descr) {
+ return {
+ .precedence = static_cast<int8_t>(descr.precedence),
+ .sessionType = toAidl(descr.sessionType),
+ .sscMode = toAidl(descr.sscMode),
+ .sliceInfo = toAidl(descr.sliceInfo),
+ .dnn = toAidl(descr.dnn),
+ };
+}
+
+} // namespace android::hardware::radio::compat
diff --git a/radio/aidl/compat/libradiocompat/data/structs.h b/radio/aidl/compat/libradiocompat/data/structs.h
new file mode 100644
index 0000000..60fad57
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/data/structs.h
@@ -0,0 +1,71 @@
+/*
+ * 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/data/DataProfileInfo.h>
+#include <aidl/android/hardware/radio/data/KeepaliveRequest.h>
+#include <aidl/android/hardware/radio/data/KeepaliveStatus.h>
+#include <aidl/android/hardware/radio/data/LinkAddress.h>
+#include <aidl/android/hardware/radio/data/OsAppId.h>
+#include <aidl/android/hardware/radio/data/PcoDataInfo.h>
+#include <aidl/android/hardware/radio/data/RouteSelectionDescriptor.h>
+#include <aidl/android/hardware/radio/data/SetupDataCallResult.h>
+#include <aidl/android/hardware/radio/data/SliceInfo.h>
+#include <aidl/android/hardware/radio/data/SlicingConfig.h>
+#include <aidl/android/hardware/radio/data/TrafficDescriptor.h>
+#include <aidl/android/hardware/radio/data/UrspRule.h>
+#include <android/hardware/radio/1.6/types.h>
+
+namespace android::hardware::radio::compat {
+
+V1_5::DataProfileInfo toHidl(const ::aidl::android::hardware::radio::data::DataProfileInfo& info);
+
+V1_5::LinkAddress toHidl(const ::aidl::android::hardware::radio::data::LinkAddress& addr);
+
+::aidl::android::hardware::radio::data::SliceInfo toAidl(const V1_6::SliceInfo& info);
+V1_6::SliceInfo toHidl(const ::aidl::android::hardware::radio::data::SliceInfo& info);
+
+::aidl::android::hardware::radio::data::TrafficDescriptor toAidl(const V1_6::TrafficDescriptor& td);
+V1_6::TrafficDescriptor toHidl(const ::aidl::android::hardware::radio::data::TrafficDescriptor& td);
+
+V1_1::KeepaliveRequest toHidl(const ::aidl::android::hardware::radio::data::KeepaliveRequest& keep);
+
+::aidl::android::hardware::radio::data::OsAppId toAidl(const V1_6::OsAppId& appId);
+V1_6::OsAppId toHidl(const ::aidl::android::hardware::radio::data::OsAppId& appId);
+
+::aidl::android::hardware::radio::data::SetupDataCallResult //
+toAidl(const V1_5::SetupDataCallResult& res);
+::aidl::android::hardware::radio::data::SetupDataCallResult //
+toAidl(const V1_6::SetupDataCallResult& res);
+
+::aidl::android::hardware::radio::data::LinkAddress toAidl(const V1_5::LinkAddress& addr);
+
+::aidl::android::hardware::radio::data::QosSession toAidl(const V1_6::QosSession& session);
+
+::aidl::android::hardware::radio::data::QosFilter toAidl(const V1_6::QosFilter& filter);
+
+::aidl::android::hardware::radio::data::KeepaliveStatus toAidl(const V1_1::KeepaliveStatus& status);
+
+::aidl::android::hardware::radio::data::PcoDataInfo toAidl(const V1_0::PcoDataInfo& info);
+
+::aidl::android::hardware::radio::data::SlicingConfig toAidl(const V1_6::SlicingConfig& cfg);
+
+::aidl::android::hardware::radio::data::UrspRule toAidl(const V1_6::UrspRule& rule);
+
+::aidl::android::hardware::radio::data::RouteSelectionDescriptor //
+toAidl(const V1_6::RouteSelectionDescriptor& descr);
+
+} // namespace android::hardware::radio::compat