From 535f30c8aceca7f9ba4640336d5bed0fa9aa0835 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Mon, 8 Nov 2021 16:10:28 -0800 Subject: [PATCH] Implement RadioModem for AIDL-HIDL Telephony HAL translator Bug: 203699028 Test: Boot and grep logcat against radiocompat Change-Id: I670f78af2cd7a0ce0b49dfc802fd363f47d9b6a6 --- radio/aidl/compat/libradiocompat/Android.bp | 6 +- .../compat/libradiocompat/RadioResponse.cpp | 81 +-------- .../aidl/compat/libradiocompat/collections.h | 16 ++ .../include/libradiocompat/RadioIndication.h | 4 + .../include/libradiocompat/RadioModem.h | 59 +++++++ .../include/libradiocompat/RadioResponse.h | 4 + .../RadioIndication-modem.cpp} | 45 +++-- .../libradiocompat/modem/RadioModem.cpp | 145 ++++++++++++++++ .../modem/RadioResponse-modem.cpp | 164 ++++++++++++++++++ .../compat/libradiocompat/modem/structs.cpp | 93 ++++++++++ .../compat/libradiocompat/modem/structs.h | 42 +++++ radio/aidl/compat/service/Android.bp | 1 + radio/aidl/compat/service/radio-compat.xml | 4 + radio/aidl/compat/service/service.cpp | 2 + 14 files changed, 575 insertions(+), 91 deletions(-) create mode 100644 radio/aidl/compat/libradiocompat/include/libradiocompat/RadioModem.h rename radio/aidl/compat/libradiocompat/{RadioIndication.cpp => modem/RadioIndication-modem.cpp} (60%) create mode 100644 radio/aidl/compat/libradiocompat/modem/RadioModem.cpp create mode 100644 radio/aidl/compat/libradiocompat/modem/RadioResponse-modem.cpp create mode 100644 radio/aidl/compat/libradiocompat/modem/structs.cpp create mode 100644 radio/aidl/compat/libradiocompat/modem/structs.h diff --git a/radio/aidl/compat/libradiocompat/Android.bp b/radio/aidl/compat/libradiocompat/Android.bp index 715a1c2d3b..43d9378364 100644 --- a/radio/aidl/compat/libradiocompat/Android.bp +++ b/radio/aidl/compat/libradiocompat/Android.bp @@ -39,6 +39,7 @@ cc_library { "android.hardware.radio.config@1.3", "android.hardware.radio.data-V1-ndk", "android.hardware.radio.messaging-V1-ndk", + "android.hardware.radio.modem-V1-ndk", "android.hardware.radio.network-V1-ndk", "android.hardware.radio.sim-V1-ndk", "android.hardware.radio.voice-V1-ndk", @@ -56,7 +57,6 @@ cc_library { ], srcs: [ "RadioCompatBase.cpp", - "RadioIndication.cpp", "RadioResponse.cpp", "commonStructs.cpp", "config/RadioConfig.cpp", @@ -71,6 +71,10 @@ cc_library { "messaging/RadioMessaging.cpp", "messaging/RadioResponse-messaging.cpp", "messaging/structs.cpp", + "modem/RadioIndication-modem.cpp", + "modem/RadioResponse-modem.cpp", + "modem/RadioModem.cpp", + "modem/structs.cpp", "network/RadioIndication-network.cpp", "network/RadioNetwork.cpp", "network/RadioResponse-network.cpp", diff --git a/radio/aidl/compat/libradiocompat/RadioResponse.cpp b/radio/aidl/compat/libradiocompat/RadioResponse.cpp index a39f575695..35b0ac1d82 100644 --- a/radio/aidl/compat/libradiocompat/RadioResponse.cpp +++ b/radio/aidl/compat/libradiocompat/RadioResponse.cpp @@ -18,9 +18,6 @@ #include "debug.h" -// TODO(b/203699028): remove when fully implemented -#pragma GCC diagnostic ignored "-Wunused-parameter" - #define RADIO_MODULE "Common" namespace android::hardware::radio::compat { @@ -30,87 +27,11 @@ Return RadioResponse::acknowledgeRequest(int32_t serial) { // TODO(b/203699028): send to correct requestor or confirm if spam is not a problem if (mDataCb) mDataCb->acknowledgeRequest(serial); if (mMessagingCb) mMessagingCb->acknowledgeRequest(serial); + if (mModemCb) mModemCb->acknowledgeRequest(serial); if (mNetworkCb) mNetworkCb->acknowledgeRequest(serial); if (mSimCb) mSimCb->acknowledgeRequest(serial); if (mVoiceCb) mVoiceCb->acknowledgeRequest(serial); return {}; } -Return RadioResponse::setRadioPowerResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getBasebandVersionResponse(const V1_0::RadioResponseInfo& info, - const hidl_string& version) { - return {}; -} - -Return RadioResponse::getDeviceIdentityResponse( // - const V1_0::RadioResponseInfo& info, const hidl_string& imei, const hidl_string& imeisv, - const hidl_string& esn, const hidl_string& meid) { - return {}; -} - -Return RadioResponse::nvReadItemResponse(const V1_0::RadioResponseInfo& info, - const hidl_string& result) { - return {}; -} - -Return RadioResponse::nvWriteItemResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::nvWriteCdmaPrlResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::nvResetConfigResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getHardwareConfigResponse( - const V1_0::RadioResponseInfo& info, const hidl_vec& config) { - return {}; -} - -Return RadioResponse::requestShutdownResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getRadioCapabilityResponse(const V1_0::RadioResponseInfo& info, - const V1_0::RadioCapability& rc) { - return {}; -} - -Return RadioResponse::setRadioCapabilityResponse(const V1_0::RadioResponseInfo& info, - const V1_0::RadioCapability& rc) { - return {}; -} - -Return RadioResponse::getModemActivityInfoResponse( - const V1_0::RadioResponseInfo& info, const V1_0::ActivityStatsInfo& activityInfo) { - return {}; -} - -Return RadioResponse::sendDeviceStateResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::enableModemResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getModemStackStatusResponse(const V1_0::RadioResponseInfo& info, - bool isEnabled) { - return {}; -} - -Return RadioResponse::setRadioPowerResponse_1_5(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setRadioPowerResponse_1_6(const V1_6::RadioResponseInfo& info) { - return {}; -} - } // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/collections.h b/radio/aidl/compat/libradiocompat/collections.h index e3439a75d7..082ef17d1d 100644 --- a/radio/aidl/compat/libradiocompat/collections.h +++ b/radio/aidl/compat/libradiocompat/collections.h @@ -54,6 +54,22 @@ auto toHidl(const std::vector& inp) { return out; } +/** + * Converts hidl_array HIDL list to std::vector AIDL list. + * + * To convert values, the template uses toAidl functions for a given type T, assuming it's defined. + * + * \param inp array to convert + */ +template +auto toAidl(const hidl_array& inp) { + std::vector out(N); + for (size_t i = 0; i < N; i++) { + out[i] = toAidl(inp[i]); + } + return out; +} + /** * Converts T=OptionalX HIDL value to std::optional AIDL value. * diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h index 51cdccbc38..20e09735e6 100644 --- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,7 @@ class RadioIndication : public V1_6::IRadioIndication { std::shared_ptr<::aidl::android::hardware::radio::data::IRadioDataIndication> mDataCb; std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingIndication> mMessagingCb; + std::shared_ptr<::aidl::android::hardware::radio::modem::IRadioModemIndication> mModemCb; std::shared_ptr<::aidl::android::hardware::radio::network::IRadioNetworkIndication> mNetworkCb; std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimIndication> mSimCb; std::shared_ptr<::aidl::android::hardware::radio::voice::IRadioVoiceIndication> mVoiceCb; @@ -184,6 +186,8 @@ class RadioIndication : public V1_6::IRadioIndication { void setResponseFunction( std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingIndication> radioMessagingIndication); + void setResponseFunction( + std::shared_ptr<::aidl::android::hardware::radio::modem::IRadioModemIndication> modmCb); void setResponseFunction( std::shared_ptr<::aidl::android::hardware::radio::network::IRadioNetworkIndication> ni); void setResponseFunction( diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioModem.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioModem.h new file mode 100644 index 0000000000..666ff472a0 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioModem.h @@ -0,0 +1,59 @@ +/* + * 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 "RadioCompatBase.h" + +#include + +namespace android::hardware::radio::compat { + +class RadioModem : public RadioCompatBase, + public aidl::android::hardware::radio::modem::BnRadioModem { + ::ndk::ScopedAStatus enableModem(int32_t serial, bool on) override; + ::ndk::ScopedAStatus getBasebandVersion(int32_t serial) override; + ::ndk::ScopedAStatus getDeviceIdentity(int32_t serial) override; + ::ndk::ScopedAStatus getHardwareConfig(int32_t serial) override; + ::ndk::ScopedAStatus getModemActivityInfo(int32_t serial) override; + ::ndk::ScopedAStatus getModemStackStatus(int32_t serial) override; + ::ndk::ScopedAStatus getRadioCapability(int32_t serial) override; + ::ndk::ScopedAStatus nvReadItem( + int32_t serial, ::aidl::android::hardware::radio::modem::NvItem itemId) override; + ::ndk::ScopedAStatus nvResetConfig( + int32_t serial, ::aidl::android::hardware::radio::modem::ResetNvType type) override; + ::ndk::ScopedAStatus nvWriteCdmaPrl(int32_t serial, const std::vector& prl) override; + ::ndk::ScopedAStatus nvWriteItem( + int32_t serial, const ::aidl::android::hardware::radio::modem::NvWriteItem& i) override; + ::ndk::ScopedAStatus requestShutdown(int32_t serial) override; + ::ndk::ScopedAStatus responseAcknowledgement() override; + ::ndk::ScopedAStatus sendDeviceState( + int32_t serial, ::aidl::android::hardware::radio::modem::DeviceStateType stateType, + bool state) override; + ::ndk::ScopedAStatus setRadioCapability( + int32_t s, const ::aidl::android::hardware::radio::modem::RadioCapability& rc) override; + ::ndk::ScopedAStatus setRadioPower(int32_t serial, bool powerOn, bool forEmergencyCall, + bool preferredForEmergencyCall) override; + ::ndk::ScopedAStatus setResponseFunctions( + const std::shared_ptr<::aidl::android::hardware::radio::modem::IRadioModemResponse>& + radioModemResponse, + const std::shared_ptr<::aidl::android::hardware::radio::modem::IRadioModemIndication>& + radioModemIndication) override; + + public: + using RadioCompatBase::RadioCompatBase; +}; + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h index 826d38566c..5db963f582 100644 --- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,7 @@ class RadioResponse : public V1_6::IRadioResponse { std::shared_ptr<::aidl::android::hardware::radio::data::IRadioDataResponse> mDataCb; std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingResponse> mMessagingCb; + std::shared_ptr<::aidl::android::hardware::radio::modem::IRadioModemResponse> mModemCb; std::shared_ptr<::aidl::android::hardware::radio::network::IRadioNetworkResponse> mNetworkCb; std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimResponse> mSimCb; std::shared_ptr<::aidl::android::hardware::radio::voice::IRadioVoiceResponse> mVoiceCb; @@ -412,6 +414,8 @@ class RadioResponse : public V1_6::IRadioResponse { void setResponseFunction( std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingResponse> radioMessagingResponse); + void setResponseFunction( + std::shared_ptr<::aidl::android::hardware::radio::modem::IRadioModemResponse> modemCb); void setResponseFunction( std::shared_ptr<::aidl::android::hardware::radio::network::IRadioNetworkResponse> nwCb); void setResponseFunction( diff --git a/radio/aidl/compat/libradiocompat/RadioIndication.cpp b/radio/aidl/compat/libradiocompat/modem/RadioIndication-modem.cpp similarity index 60% rename from radio/aidl/compat/libradiocompat/RadioIndication.cpp rename to radio/aidl/compat/libradiocompat/modem/RadioIndication-modem.cpp index df97841d16..8fc4da62d5 100644 --- a/radio/aidl/compat/libradiocompat/RadioIndication.cpp +++ b/radio/aidl/compat/libradiocompat/modem/RadioIndication-modem.cpp @@ -16,32 +16,57 @@ #include -// TODO(b/203699028): remove when fully implemented -#pragma GCC diagnostic ignored "-Wunused-parameter" +#include "commonStructs.h" +#include "debug.h" +#include "structs.h" + +#include "collections.h" + +#define RADIO_MODULE "ModemIndication" namespace android::hardware::radio::compat { -Return RadioIndication::radioStateChanged(V1_0::RadioIndicationType type, - V1_0::RadioState radioState) { - return {}; -} +namespace aidl = ::aidl::android::hardware::radio::modem; -Return RadioIndication::rilConnected(V1_0::RadioIndicationType type) { - return {}; +void RadioIndication::setResponseFunction(std::shared_ptr modemCb) { + CHECK(modemCb); + mModemCb = modemCb; } Return RadioIndication::hardwareConfigChanged(V1_0::RadioIndicationType type, const hidl_vec& configs) { + LOG_CALL << type; + CHECK_CB(mModemCb); + mModemCb->hardwareConfigChanged(toAidl(type), toAidl(configs)); + return {}; +} + +Return RadioIndication::modemReset(V1_0::RadioIndicationType type, const hidl_string& reasn) { + LOG_CALL << type; + CHECK_CB(mModemCb); + mModemCb->modemReset(toAidl(type), reasn); return {}; } Return RadioIndication::radioCapabilityIndication(V1_0::RadioIndicationType type, const V1_0::RadioCapability& rc) { + LOG_CALL << type; + CHECK_CB(mModemCb); + mModemCb->radioCapabilityIndication(toAidl(type), toAidl(rc)); return {}; } -Return RadioIndication::modemReset(V1_0::RadioIndicationType type, - const hidl_string& reason) { +Return RadioIndication::radioStateChanged(V1_0::RadioIndicationType t, V1_0::RadioState st) { + LOG_CALL << t; + CHECK_CB(mModemCb); + mModemCb->radioStateChanged(toAidl(t), aidl::RadioState(st)); + return {}; +} + +Return RadioIndication::rilConnected(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mModemCb); + mModemCb->rilConnected(toAidl(type)); return {}; } diff --git a/radio/aidl/compat/libradiocompat/modem/RadioModem.cpp b/radio/aidl/compat/libradiocompat/modem/RadioModem.cpp new file mode 100644 index 0000000000..660ae9f2ed --- /dev/null +++ b/radio/aidl/compat/libradiocompat/modem/RadioModem.cpp @@ -0,0 +1,145 @@ +/* + * 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 + +#include "debug.h" +#include "structs.h" + +#define RADIO_MODULE "Modem" + +namespace android::hardware::radio::compat { + +using ::ndk::ScopedAStatus; +namespace aidl = ::aidl::android::hardware::radio::modem; +constexpr auto ok = &ScopedAStatus::ok; + +ScopedAStatus RadioModem::enableModem(int32_t serial, bool on) { + LOG_CALL << serial; + mHal1_5->enableModem(serial, on); + return ok(); +} + +ScopedAStatus RadioModem::getBasebandVersion(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getBasebandVersion(serial); + return ok(); +} + +ScopedAStatus RadioModem::getDeviceIdentity(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getDeviceIdentity(serial); + return ok(); +} + +ScopedAStatus RadioModem::getHardwareConfig(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getHardwareConfig(serial); + return ok(); +} + +ScopedAStatus RadioModem::getModemActivityInfo(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getModemActivityInfo(serial); + return ok(); +} + +ScopedAStatus RadioModem::getModemStackStatus(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getModemStackStatus(serial); + return ok(); +} + +ScopedAStatus RadioModem::getRadioCapability(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getRadioCapability(serial); + return ok(); +} + +ScopedAStatus RadioModem::nvReadItem(int32_t serial, aidl::NvItem itemId) { + LOG_CALL << serial; + mHal1_5->nvReadItem(serial, V1_0::NvItem(itemId)); + return ok(); +} + +ScopedAStatus RadioModem::nvResetConfig(int32_t serial, aidl::ResetNvType resetType) { + LOG_CALL << serial; + mHal1_5->nvResetConfig(serial, V1_0::ResetNvType(resetType)); + return ok(); +} + +ScopedAStatus RadioModem::nvWriteCdmaPrl(int32_t serial, const std::vector& prl) { + LOG_CALL << serial; + mHal1_5->nvWriteCdmaPrl(serial, prl); + return ok(); +} + +ScopedAStatus RadioModem::nvWriteItem(int32_t serial, const aidl::NvWriteItem& item) { + LOG_CALL << serial; + mHal1_5->nvWriteItem(serial, toHidl(item)); + return ok(); +} + +ScopedAStatus RadioModem::requestShutdown(int32_t serial) { + LOG_CALL << serial; + mHal1_5->requestShutdown(serial); + return ok(); +} + +ScopedAStatus RadioModem::responseAcknowledgement() { + LOG_CALL; + mHal1_5->responseAcknowledgement(); + return ok(); +} + +ScopedAStatus RadioModem::sendDeviceState(int32_t serial, aidl::DeviceStateType type, bool state) { + LOG_CALL << serial; + mHal1_5->sendDeviceState(serial, V1_0::DeviceStateType(type), state); + return ok(); +} + +ScopedAStatus RadioModem::setRadioCapability(int32_t serial, const aidl::RadioCapability& rc) { + LOG_CALL << serial; + mHal1_5->setRadioCapability(serial, toHidl(rc)); + return ok(); +} + +ScopedAStatus RadioModem::setRadioPower(int32_t serial, bool powerOn, bool forEmergencyCall, + bool preferredForEmergencyCall) { + LOG_CALL << serial; + if (mHal1_6) { + mHal1_6->setRadioPower_1_6(serial, powerOn, forEmergencyCall, preferredForEmergencyCall); + } else { + mHal1_5->setRadioPower_1_5(serial, powerOn, forEmergencyCall, preferredForEmergencyCall); + } + return ok(); +} + +ScopedAStatus RadioModem::setResponseFunctions( + const std::shared_ptr& modemResponse, + const std::shared_ptr& modemIndication) { + LOG_CALL << modemResponse << ' ' << modemIndication; + + CHECK(modemResponse); + CHECK(modemIndication); + + mRadioResponse->setResponseFunction(modemResponse); + mRadioIndication->setResponseFunction(modemIndication); + + return ok(); +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/modem/RadioResponse-modem.cpp b/radio/aidl/compat/libradiocompat/modem/RadioResponse-modem.cpp new file mode 100644 index 0000000000..300627c0f4 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/modem/RadioResponse-modem.cpp @@ -0,0 +1,164 @@ +/* + * 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 + +#include "commonStructs.h" +#include "debug.h" +#include "structs.h" + +#include "collections.h" + +#define RADIO_MODULE "ModemResponse" + +namespace android::hardware::radio::compat { + +namespace aidl = ::aidl::android::hardware::radio::modem; + +void RadioResponse::setResponseFunction(std::shared_ptr modemCb) { + CHECK(modemCb); + mModemCb = modemCb; +} + +Return RadioResponse::enableModemResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->enableModemResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::getBasebandVersionResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& version) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->getBasebandVersionResponse(toAidl(info), version); + return {}; +} + +Return RadioResponse::getDeviceIdentityResponse( // + const V1_0::RadioResponseInfo& info, const hidl_string& imei, const hidl_string& imeisv, + const hidl_string& esn, const hidl_string& meid) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->getDeviceIdentityResponse(toAidl(info), imei, imeisv, esn, meid); + return {}; +} + +Return RadioResponse::getHardwareConfigResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& config) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->getHardwareConfigResponse(toAidl(info), toAidl(config)); + return {}; +} + +Return RadioResponse::getModemActivityInfoResponse( + const V1_0::RadioResponseInfo& info, const V1_0::ActivityStatsInfo& activityInfo) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->getModemActivityInfoResponse(toAidl(info), toAidl(activityInfo)); + return {}; +} + +Return RadioResponse::getModemStackStatusResponse(const V1_0::RadioResponseInfo& info, + bool isEnabled) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->getModemStackStatusResponse(toAidl(info), isEnabled); + return {}; +} + +Return RadioResponse::getRadioCapabilityResponse(const V1_0::RadioResponseInfo& info, + const V1_0::RadioCapability& rc) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->getRadioCapabilityResponse(toAidl(info), toAidl(rc)); + return {}; +} + +Return RadioResponse::nvReadItemResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& result) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->nvReadItemResponse(toAidl(info), result); + return {}; +} + +Return RadioResponse::nvResetConfigResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->nvResetConfigResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::nvWriteCdmaPrlResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->nvWriteCdmaPrlResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::nvWriteItemResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->nvWriteItemResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::requestShutdownResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->requestShutdownResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::sendDeviceStateResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->sendDeviceStateResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setRadioCapabilityResponse(const V1_0::RadioResponseInfo& info, + const V1_0::RadioCapability& rc) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->setRadioCapabilityResponse(toAidl(info), toAidl(rc)); + return {}; +} + +Return RadioResponse::setRadioPowerResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->setRadioPowerResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setRadioPowerResponse_1_5(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->setRadioPowerResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setRadioPowerResponse_1_6(const V1_6::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mModemCb); + mModemCb->setRadioPowerResponse(toAidl(info)); + return {}; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/modem/structs.cpp b/radio/aidl/compat/libradiocompat/modem/structs.cpp new file mode 100644 index 0000000000..c1cd64cf61 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/modem/structs.cpp @@ -0,0 +1,93 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +using ::aidl::android::hardware::radio::RadioAccessFamily; +using ::aidl::android::hardware::radio::RadioTechnology; +namespace aidl = ::aidl::android::hardware::radio::modem; + +V1_0::NvWriteItem toHidl(const aidl::NvWriteItem& item) { + return { + .itemId = V1_0::NvItem{item.itemId}, + .value = item.value, + }; +} + +aidl::RadioCapability toAidl(const V1_0::RadioCapability& capa) { + return { + .session = capa.session, + .phase = static_cast(capa.phase), + .raf = RadioAccessFamily(capa.raf), + .logicalModemUuid = capa.logicalModemUuid, + .status = static_cast(capa.status), + }; +} + +V1_0::RadioCapability toHidl(const aidl::RadioCapability& capa) { + return { + .session = capa.session, + .phase = V1_0::RadioCapabilityPhase{capa.phase}, + .raf = toHidlBitfield(capa.raf), + .logicalModemUuid = capa.logicalModemUuid, + .status = V1_0::RadioCapabilityStatus{capa.status}, + }; +} + +aidl::HardwareConfig toAidl(const V1_0::HardwareConfig& config) { + return { + .type = static_cast(config.type), + .uuid = config.uuid, + .state = static_cast(config.state), + .modem = toAidl(config.modem), + .sim = toAidl(config.sim), + }; +} + +aidl::HardwareConfigModem toAidl(const V1_0::HardwareConfigModem& modem) { + return { + .rilModel = modem.rilModel, + .rat = RadioTechnology(modem.rat), + .maxVoiceCalls = modem.maxVoice, + .maxDataCalls = modem.maxData, + .maxStandby = modem.maxStandby, + }; +} + +aidl::HardwareConfigSim toAidl(const V1_0::HardwareConfigSim& sim) { + return { + .modemUuid = sim.modemUuid, + }; +} + +aidl::ActivityStatsInfo toAidl(const V1_0::ActivityStatsInfo& info) { + return { + .sleepModeTimeMs = static_cast(info.sleepModeTimeMs), + .idleModeTimeMs = static_cast(info.idleModeTimeMs), + .txmModetimeMs = toAidl(info.txmModetimeMs), + .rxModeTimeMs = static_cast(info.rxModeTimeMs), + }; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/modem/structs.h b/radio/aidl/compat/libradiocompat/modem/structs.h new file mode 100644 index 0000000000..3ac1edbfcc --- /dev/null +++ b/radio/aidl/compat/libradiocompat/modem/structs.h @@ -0,0 +1,42 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +namespace android::hardware::radio::compat { + +V1_0::NvWriteItem toHidl(const ::aidl::android::hardware::radio::modem::NvWriteItem& item); + +::aidl::android::hardware::radio::modem::RadioCapability toAidl(const V1_0::RadioCapability& capa); +V1_0::RadioCapability toHidl(const ::aidl::android::hardware::radio::modem::RadioCapability& capa); + +::aidl::android::hardware::radio::modem::HardwareConfig toAidl(const V1_0::HardwareConfig& config); + +::aidl::android::hardware::radio::modem::HardwareConfigModem // +toAidl(const V1_0::HardwareConfigModem& modem); + +::aidl::android::hardware::radio::modem::HardwareConfigSim toAidl(const V1_0::HardwareConfigSim& s); + +::aidl::android::hardware::radio::modem::ActivityStatsInfo toAidl(const V1_0::ActivityStatsInfo& i); + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/service/Android.bp b/radio/aidl/compat/service/Android.bp index 0536c1c1b3..52eb71ff14 100644 --- a/radio/aidl/compat/service/Android.bp +++ b/radio/aidl/compat/service/Android.bp @@ -41,6 +41,7 @@ cc_binary { "android.hardware.radio.config@1.3", "android.hardware.radio.data-V1-ndk", "android.hardware.radio.messaging-V1-ndk", + "android.hardware.radio.modem-V1-ndk", "android.hardware.radio.network-V1-ndk", "android.hardware.radio.sim-V1-ndk", "android.hardware.radio.voice-V1-ndk", diff --git a/radio/aidl/compat/service/radio-compat.xml b/radio/aidl/compat/service/radio-compat.xml index d3f4212fcf..a7089e6984 100644 --- a/radio/aidl/compat/service/radio-compat.xml +++ b/radio/aidl/compat/service/radio-compat.xml @@ -17,6 +17,10 @@ android.hardware.radio.messaging IRadioMessaging/slot1 + + android.hardware.radio.modem + IRadioModem/slot1 + android.hardware.radio.network IRadioNetwork/slot1 diff --git a/radio/aidl/compat/service/service.cpp b/radio/aidl/compat/service/service.cpp index 3d60ffe129..2a67569452 100644 --- a/radio/aidl/compat/service/service.cpp +++ b/radio/aidl/compat/service/service.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -62,6 +63,7 @@ static void publishRadio(std::string slot) { publishRadioHal(radioHidl, responseCb, indicationCb, slot); publishRadioHal(radioHidl, responseCb, indicationCb, slot); + publishRadioHal(radioHidl, responseCb, indicationCb, slot); publishRadioHal(radioHidl, responseCb, indicationCb, slot); publishRadioHal(radioHidl, responseCb, indicationCb, slot); publishRadioHal(radioHidl, responseCb, indicationCb, slot);