Initial implementation of HIDL-AIDL Telephony HAL translator
Bug: 203699028
Test: Boot and grep logcat against radiocompat
Change-Id: I182edf3b1fa39b30818e79a68fc586f12b677d19
diff --git a/radio/aidl/compat/libradiocompat/config/RadioConfig.cpp b/radio/aidl/compat/libradiocompat/config/RadioConfig.cpp
new file mode 100644
index 0000000..d0d6f7a
--- /dev/null
+++ b/radio/aidl/compat/libradiocompat/config/RadioConfig.cpp
@@ -0,0 +1,103 @@
+/*
+ * 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/RadioConfig.h>
+
+#include "RadioConfigIndication.h"
+#include "RadioConfigResponse.h"
+#include "commonStructs.h"
+#include "debug.h"
+#include "structs.h"
+
+#define RADIO_MODULE "Config"
+
+namespace android::hardware::radio::compat {
+
+using ::ndk::ScopedAStatus;
+namespace aidl = ::aidl::android::hardware::radio::config;
+constexpr auto ok = &ScopedAStatus::ok;
+
+RadioConfig::RadioConfig(sp<config::V1_1::IRadioConfig> hidlHal)
+ : mHal1_1(hidlHal), mHal1_3(config::V1_3::IRadioConfig::castFrom(hidlHal)) {}
+
+config::V1_3::IRadioConfigResponse& RadioConfig::respond() {
+ CHECK(mRadioConfigResponse) << "setResponseFunctions was not called yet";
+ return *mRadioConfigResponse;
+}
+
+ScopedAStatus RadioConfig::getHalDeviceCapabilities(int32_t serial) {
+ LOG_CALL << serial;
+ if (mHal1_3) {
+ mHal1_3->getHalDeviceCapabilities(serial);
+ } else {
+ respond().getHalDeviceCapabilitiesResponse(notSupported(serial), false);
+ }
+ return ok();
+}
+
+ScopedAStatus RadioConfig::getNumOfLiveModems(int32_t serial) {
+ LOG_CALL << serial;
+ mHal1_1->getModemsConfig(serial);
+ return ok();
+}
+
+ScopedAStatus RadioConfig::getPhoneCapability(int32_t serial) {
+ LOG_CALL << serial;
+ mHal1_1->getPhoneCapability(serial);
+ return ok();
+}
+
+ScopedAStatus RadioConfig::getSimSlotsStatus(int32_t serial) {
+ LOG_CALL << serial;
+ mHal1_1->getSimSlotsStatus(serial);
+ return ok();
+}
+
+ScopedAStatus RadioConfig::setNumOfLiveModems(int32_t serial, int8_t numOfLiveModems) {
+ LOG_CALL << serial;
+ mHal1_1->setModemsConfig(serial, {static_cast<uint8_t>(numOfLiveModems)});
+ return ok();
+}
+
+ScopedAStatus RadioConfig::setPreferredDataModem(int32_t serial, int8_t modemId) {
+ LOG_CALL << serial;
+ mHal1_1->setPreferredDataModem(serial, modemId);
+ return ok();
+}
+
+ScopedAStatus RadioConfig::setResponseFunctions(
+ const std::shared_ptr<aidl::IRadioConfigResponse>& radioConfigResponse,
+ const std::shared_ptr<aidl::IRadioConfigIndication>& radioConfigIndication) {
+ LOG_CALL << radioConfigResponse << ' ' << radioConfigIndication;
+
+ CHECK(radioConfigResponse);
+ CHECK(radioConfigIndication);
+
+ mRadioConfigResponse = sp<RadioConfigResponse>::make(radioConfigResponse);
+ mRadioConfigIndication = sp<RadioConfigIndication>::make(radioConfigIndication);
+ mHal1_1->setResponseFunctions(mRadioConfigResponse, mRadioConfigIndication);
+
+ return ok();
+}
+
+ScopedAStatus RadioConfig::setSimSlotsMapping( //
+ int32_t serial, const std::vector<aidl::SlotPortMapping>& slotMap) {
+ LOG_CALL << serial;
+ mHal1_1->setSimSlotsMapping(serial, toHidl(slotMap));
+ return ok();
+}
+
+} // namespace android::hardware::radio::compat