From bff3b5b4c38997abf29ac4b0d223529e5d08011c Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Mon, 18 Oct 2021 16:53:40 -0700 Subject: [PATCH 1/7] Initial implementation of HIDL-AIDL Telephony HAL translator Bug: 203699028 Test: Boot and grep logcat against radiocompat Change-Id: I182edf3b1fa39b30818e79a68fc586f12b677d19 --- radio/aidl/compat/libradiocompat/Android.bp | 53 +++++++++ .../aidl/compat/libradiocompat/collections.h | 54 +++++++++ .../compat/libradiocompat/commonStructs.cpp | 63 +++++++++++ .../compat/libradiocompat/commonStructs.h | 34 ++++++ .../libradiocompat/config/RadioConfig.cpp | 103 ++++++++++++++++++ .../config/RadioConfigIndication.cpp | 48 ++++++++ .../config/RadioConfigIndication.h | 38 +++++++ .../config/RadioConfigResponse.cpp | 90 +++++++++++++++ .../config/RadioConfigResponse.h | 48 ++++++++ .../compat/libradiocompat/config/structs.cpp | 69 ++++++++++++ .../compat/libradiocompat/config/structs.h | 39 +++++++ radio/aidl/compat/libradiocompat/debug.h | 35 ++++++ .../include/libradiocompat/RadioConfig.h | 66 +++++++++++ radio/aidl/compat/service/Android.bp | 51 +++++++++ radio/aidl/compat/service/hidl-utils.cpp | 36 ++++++ radio/aidl/compat/service/hidl-utils.h | 30 +++++ radio/aidl/compat/service/radio-compat.rc | 4 + radio/aidl/compat/service/radio-compat.xml | 6 + radio/aidl/compat/service/service.cpp | 60 ++++++++++ 19 files changed, 927 insertions(+) create mode 100644 radio/aidl/compat/libradiocompat/Android.bp create mode 100644 radio/aidl/compat/libradiocompat/collections.h create mode 100644 radio/aidl/compat/libradiocompat/commonStructs.cpp create mode 100644 radio/aidl/compat/libradiocompat/commonStructs.h create mode 100644 radio/aidl/compat/libradiocompat/config/RadioConfig.cpp create mode 100644 radio/aidl/compat/libradiocompat/config/RadioConfigIndication.cpp create mode 100644 radio/aidl/compat/libradiocompat/config/RadioConfigIndication.h create mode 100644 radio/aidl/compat/libradiocompat/config/RadioConfigResponse.cpp create mode 100644 radio/aidl/compat/libradiocompat/config/RadioConfigResponse.h create mode 100644 radio/aidl/compat/libradiocompat/config/structs.cpp create mode 100644 radio/aidl/compat/libradiocompat/config/structs.h create mode 100644 radio/aidl/compat/libradiocompat/debug.h create mode 100644 radio/aidl/compat/libradiocompat/include/libradiocompat/RadioConfig.h create mode 100644 radio/aidl/compat/service/Android.bp create mode 100644 radio/aidl/compat/service/hidl-utils.cpp create mode 100644 radio/aidl/compat/service/hidl-utils.h create mode 100644 radio/aidl/compat/service/radio-compat.rc create mode 100644 radio/aidl/compat/service/radio-compat.xml create mode 100644 radio/aidl/compat/service/service.cpp diff --git a/radio/aidl/compat/libradiocompat/Android.bp b/radio/aidl/compat/libradiocompat/Android.bp new file mode 100644 index 0000000000..ada7c7ed98 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/Android.bp @@ -0,0 +1,53 @@ +// 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. + +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "hardware_interfaces_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["hardware_interfaces_license"], +} + +cc_library { + name: "android.hardware.radio-library.compat", + relative_install_path: "hw", + vendor: true, + cflags: [ + "-Wall", + "-Wextra", + //"-Wold-style-cast", // TODO(b/203699028) enable after aosp/1900880 gets merged + "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION", + ], + shared_libs: [ + "android.hardware.radio.config-V1-ndk", + "android.hardware.radio.config@1.0", + "android.hardware.radio.config@1.1", + "android.hardware.radio.config@1.2", + "android.hardware.radio.config@1.3", + "libbase", + "libbinder_ndk", + "libhidlbase", + "libutils", + ], + srcs: [ + "commonStructs.cpp", + "config/RadioConfig.cpp", + "config/RadioConfigIndication.cpp", + "config/RadioConfigResponse.cpp", + "config/structs.cpp", + ], + export_include_dirs: ["include"], +} diff --git a/radio/aidl/compat/libradiocompat/collections.h b/radio/aidl/compat/libradiocompat/collections.h new file mode 100644 index 0000000000..9ef1351a8c --- /dev/null +++ b/radio/aidl/compat/libradiocompat/collections.h @@ -0,0 +1,54 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +/** + * Converts hidl_vec 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 vector to convert + */ +template +auto toAidl(const hidl_vec& inp) { + std::vector out(inp.size()); + for (size_t i = 0; i < inp.size(); i++) { + out[i] = toAidl(inp[i]); + } + return out; +} + +/** + * Converts std::vector AIDL list to hidl_vec HIDL list. + * + * To convert values, the template uses toHidl functions for a given type T, assuming it's defined. + * + * \param inp vector to convert + */ +template +auto toHidl(const std::vector& inp) { + hidl_vec out(inp.size()); + for (size_t i = 0; i < inp.size(); i++) { + out[i] = toHidl(inp[i]); + } + return out; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/commonStructs.cpp b/radio/aidl/compat/libradiocompat/commonStructs.cpp new file mode 100644 index 0000000000..e81562a89a --- /dev/null +++ b/radio/aidl/compat/libradiocompat/commonStructs.cpp @@ -0,0 +1,63 @@ +/* + * 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 "commonStructs.h" + +namespace android::hardware::radio::compat { + +namespace aidl = ::aidl::android::hardware::radio; + +V1_6::RadioResponseInfo notSupported(int32_t serial) { + return { + .type = V1_0::RadioResponseType::SOLICITED, + .serial = serial, + .error = V1_6::RadioError::REQUEST_NOT_SUPPORTED, + }; +} + +aidl::RadioIndicationType toAidl(V1_0::RadioIndicationType type) { + return aidl::RadioIndicationType(type); +} + +aidl::RadioResponseType toAidl(V1_0::RadioResponseType type) { + return aidl::RadioResponseType(type); +} + +aidl::RadioError toAidl(V1_0::RadioError err) { + return aidl::RadioError(err); +} + +aidl::RadioError toAidl(V1_6::RadioError err) { + return aidl::RadioError(err); +} + +aidl::RadioResponseInfo toAidl(const V1_0::RadioResponseInfo& info) { + return { + .type = toAidl(info.type), + .serial = info.serial, + .error = toAidl(info.error), + }; +} + +aidl::RadioResponseInfo toAidl(const V1_6::RadioResponseInfo& info) { + return { + .type = toAidl(info.type), + .serial = info.serial, + .error = toAidl(info.error), + }; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/commonStructs.h b/radio/aidl/compat/libradiocompat/commonStructs.h new file mode 100644 index 0000000000..cba307ebde --- /dev/null +++ b/radio/aidl/compat/libradiocompat/commonStructs.h @@ -0,0 +1,34 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +V1_6::RadioResponseInfo notSupported(int32_t serial); + +aidl::android::hardware::radio::RadioIndicationType toAidl(V1_0::RadioIndicationType type); +aidl::android::hardware::radio::RadioResponseType toAidl(V1_0::RadioResponseType type); +aidl::android::hardware::radio::RadioError toAidl(V1_0::RadioError type); +aidl::android::hardware::radio::RadioError toAidl(V1_6::RadioError type); + +aidl::android::hardware::radio::RadioResponseInfo toAidl(const V1_0::RadioResponseInfo& info); +aidl::android::hardware::radio::RadioResponseInfo toAidl(const V1_6::RadioResponseInfo& info); + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/config/RadioConfig.cpp b/radio/aidl/compat/libradiocompat/config/RadioConfig.cpp new file mode 100644 index 0000000000..d0d6f7af28 --- /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 + +#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 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(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& radioConfigResponse, + const std::shared_ptr& radioConfigIndication) { + LOG_CALL << radioConfigResponse << ' ' << radioConfigIndication; + + CHECK(radioConfigResponse); + CHECK(radioConfigIndication); + + mRadioConfigResponse = sp::make(radioConfigResponse); + mRadioConfigIndication = sp::make(radioConfigIndication); + mHal1_1->setResponseFunctions(mRadioConfigResponse, mRadioConfigIndication); + + return ok(); +} + +ScopedAStatus RadioConfig::setSimSlotsMapping( // + int32_t serial, const std::vector& slotMap) { + LOG_CALL << serial; + mHal1_1->setSimSlotsMapping(serial, toHidl(slotMap)); + return ok(); +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/config/RadioConfigIndication.cpp b/radio/aidl/compat/libradiocompat/config/RadioConfigIndication.cpp new file mode 100644 index 0000000000..0320ad77ca --- /dev/null +++ b/radio/aidl/compat/libradiocompat/config/RadioConfigIndication.cpp @@ -0,0 +1,48 @@ +/* + * 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 "RadioConfigIndication.h" + +#include "commonStructs.h" +#include "debug.h" +#include "structs.h" + +#include "collections.h" + +#define RADIO_MODULE "ConfigIndication" + +namespace android::hardware::radio::compat { + +namespace aidl = ::aidl::android::hardware::radio::config; + +RadioConfigIndication::RadioConfigIndication(std::shared_ptr callback) + : mCallback(callback) {} + +Return RadioConfigIndication::simSlotsStatusChanged( + V1_0::RadioIndicationType type, const hidl_vec& slotStatus) { + LOG_CALL << type; + mCallback->simSlotsStatusChanged(toAidl(type), toAidl(slotStatus)); + return {}; +} + +Return RadioConfigIndication::simSlotsStatusChanged_1_2( + V1_0::RadioIndicationType type, const hidl_vec& slotStatus) { + LOG_CALL << type; + mCallback->simSlotsStatusChanged(toAidl(type), toAidl(slotStatus)); + return {}; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/config/RadioConfigIndication.h b/radio/aidl/compat/libradiocompat/config/RadioConfigIndication.h new file mode 100644 index 0000000000..3d8d971694 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/config/RadioConfigIndication.h @@ -0,0 +1,38 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +class RadioConfigIndication : public config::V1_2::IRadioConfigIndication { + std::shared_ptr mCallback; + + Return simSlotsStatusChanged( + V1_0::RadioIndicationType type, + const hidl_vec& slotStatus) override; + Return simSlotsStatusChanged_1_2( + V1_0::RadioIndicationType type, + const hidl_vec& slotStatus) override; + + public: + RadioConfigIndication( + std::shared_ptr cb); +}; + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/config/RadioConfigResponse.cpp b/radio/aidl/compat/libradiocompat/config/RadioConfigResponse.cpp new file mode 100644 index 0000000000..7066ae46c6 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/config/RadioConfigResponse.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 "RadioConfigResponse.h" + +#include "commonStructs.h" +#include "debug.h" +#include "structs.h" + +#include "collections.h" + +#define RADIO_MODULE "ConfigResponse" + +namespace android::hardware::radio::compat { + +namespace aidl = ::aidl::android::hardware::radio::config; + +RadioConfigResponse::RadioConfigResponse(std::shared_ptr callback) + : mCallback(callback) {} + +Return RadioConfigResponse::getSimSlotsStatusResponse( + const V1_0::RadioResponseInfo& info, + const hidl_vec& slotStatus) { + LOG_CALL << info.serial; + mCallback->getSimSlotsStatusResponse(toAidl(info), toAidl(slotStatus)); + return {}; +}; + +Return RadioConfigResponse::getSimSlotsStatusResponse_1_2( + const V1_0::RadioResponseInfo& info, + const hidl_vec& slotStatus) { + LOG_CALL << info.serial; + mCallback->getSimSlotsStatusResponse(toAidl(info), toAidl(slotStatus)); + return {}; +}; + +Return RadioConfigResponse::setSimSlotsMappingResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + mCallback->setSimSlotsMappingResponse(toAidl(info)); + return {}; +}; + +Return RadioConfigResponse::getPhoneCapabilityResponse( + const V1_0::RadioResponseInfo& info, const config::V1_1::PhoneCapability& phoneCapability) { + LOG_CALL << info.serial; + mCallback->getPhoneCapabilityResponse(toAidl(info), toAidl(phoneCapability)); + return {}; +}; + +Return RadioConfigResponse::setPreferredDataModemResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + mCallback->setPreferredDataModemResponse(toAidl(info)); + return {}; +}; + +Return RadioConfigResponse::setModemsConfigResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + mCallback->setNumOfLiveModemsResponse(toAidl(info)); + return {}; +}; + +Return RadioConfigResponse::getModemsConfigResponse( + const V1_0::RadioResponseInfo& info, const config::V1_1::ModemsConfig& modemsConfig) { + LOG_CALL << info.serial; + mCallback->getNumOfLiveModemsResponse(toAidl(info), modemsConfig.numOfLiveModems); + return {}; +}; + +Return RadioConfigResponse::getHalDeviceCapabilitiesResponse( + const V1_6::RadioResponseInfo& info, bool modemReducedFeatureSet1) { + LOG_CALL << info.serial; + mCallback->getHalDeviceCapabilitiesResponse(toAidl(info), modemReducedFeatureSet1); + return {}; +}; + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/config/RadioConfigResponse.h b/radio/aidl/compat/libradiocompat/config/RadioConfigResponse.h new file mode 100644 index 0000000000..1461dd2035 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/config/RadioConfigResponse.h @@ -0,0 +1,48 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +class RadioConfigResponse : public config::V1_3::IRadioConfigResponse { + std::shared_ptr mCallback; + + Return getSimSlotsStatusResponse( + const V1_0::RadioResponseInfo& info, + const hidl_vec& slotStatus) override; + Return setSimSlotsMappingResponse(const V1_0::RadioResponseInfo& info) override; + Return getPhoneCapabilityResponse( + const V1_0::RadioResponseInfo& info, + const config::V1_1::PhoneCapability& phoneCapability) override; + Return setPreferredDataModemResponse(const V1_0::RadioResponseInfo& info) override; + Return setModemsConfigResponse(const V1_0::RadioResponseInfo& info) override; + Return getModemsConfigResponse(const V1_0::RadioResponseInfo& info, + const config::V1_1::ModemsConfig& modemsConfig) override; + Return getSimSlotsStatusResponse_1_2( + const V1_0::RadioResponseInfo& info, + const hidl_vec& slotStatus) override; + Return getHalDeviceCapabilitiesResponse(const V1_6::RadioResponseInfo& info, + bool modemReducedFeatureSet1) override; + + public: + RadioConfigResponse( + std::shared_ptr callback); +}; + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/config/structs.cpp b/radio/aidl/compat/libradiocompat/config/structs.cpp new file mode 100644 index 0000000000..9ba56231e2 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/config/structs.cpp @@ -0,0 +1,69 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +namespace aidl = ::aidl::android::hardware::radio::config; + +hidl_vec toHidl(const std::vector& slotMap) { + hidl_vec out(slotMap.size()); + for (const auto& el : slotMap) { + CHECK_GE(el.portId, 0); + CHECK_LT(static_cast(el.portId), out.size()); + out[el.portId] = el.physicalSlotId; + } + return out; +} + +aidl::SimSlotStatus toAidl(const config::V1_0::SimSlotStatus& sst) { + return toAidl({sst, ""}); +} + +aidl::SimSlotStatus toAidl(const config::V1_2::SimSlotStatus& sst) { + const aidl::SimPortInfo portInfo = { + .iccId = sst.base.iccid, + .logicalSlotId = static_cast(sst.base.logicalSlotId), + .portActive = sst.base.slotState == config::V1_0::SlotState::ACTIVE, + }; + + return { + .cardState = static_cast(sst.base.cardState), + .atr = sst.base.atr, + .eid = sst.eid, + .portInfo = {portInfo}, + }; +} + +uint8_t toAidl(const config::V1_1::ModemInfo& info) { + return info.modemId; +} + +aidl::PhoneCapability toAidl(const config::V1_1::PhoneCapability& phoneCapability) { + return { + .maxActiveData = static_cast(phoneCapability.maxActiveData), + .maxActiveInternetData = static_cast(phoneCapability.maxActiveInternetData), + .isInternetLingeringSupported = phoneCapability.isInternetLingeringSupported, + .logicalModemIds = toAidl(phoneCapability.logicalModemList), + }; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/config/structs.h b/radio/aidl/compat/libradiocompat/config/structs.h new file mode 100644 index 0000000000..b8a038588c --- /dev/null +++ b/radio/aidl/compat/libradiocompat/config/structs.h @@ -0,0 +1,39 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +hidl_vec // +toHidl(const std::vector& slotMap); + +aidl::android::hardware::radio::config::SimSlotStatus // +toAidl(const config::V1_0::SimSlotStatus& sst); +aidl::android::hardware::radio::config::SimSlotStatus // +toAidl(const config::V1_2::SimSlotStatus& sst); + +uint8_t toAidl(const config::V1_1::ModemInfo& info); + +aidl::android::hardware::radio::config::PhoneCapability // +toAidl(const config::V1_1::PhoneCapability& pc); + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/debug.h b/radio/aidl/compat/libradiocompat/debug.h new file mode 100644 index 0000000000..cb773bf27d --- /dev/null +++ b/radio/aidl/compat/libradiocompat/debug.h @@ -0,0 +1,35 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +namespace debug { + +static constexpr bool kSuperVerbose = true; + +#define LOG_CALL \ + if constexpr (debug::kSuperVerbose) LOG(VERBOSE) << (RADIO_MODULE ".") << __func__ << ' ' + +} // namespace debug + +inline std::ostream& operator<<(std::ostream& os, const V1_0::RadioIndicationType& type) { + return os << static_cast(type); +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioConfig.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioConfig.h new file mode 100644 index 0000000000..31ad207d40 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioConfig.h @@ -0,0 +1,66 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +/** + * HAL translator from HIDL IRadioConfig to AIDL IRadioConfig. + * + * This class wraps existing HIDL implementation (either a binder stub or real + * class implementing the HAL) and implements AIDL HAL. It's up to the caller to + * fetch source implementation and publish resulting HAL instance. + */ +class RadioConfig : public aidl::android::hardware::radio::config::BnRadioConfig { + sp mHal1_1; + sp mHal1_3; + + sp mRadioConfigResponse; + sp mRadioConfigIndication; + + ::ndk::ScopedAStatus getHalDeviceCapabilities(int32_t serial) override; + ::ndk::ScopedAStatus getNumOfLiveModems(int32_t serial) override; + ::ndk::ScopedAStatus getPhoneCapability(int32_t serial) override; + ::ndk::ScopedAStatus getSimSlotsStatus(int32_t serial) override; + ::ndk::ScopedAStatus setNumOfLiveModems(int32_t serial, int8_t numOfLiveModems) override; + ::ndk::ScopedAStatus setPreferredDataModem(int32_t serial, int8_t modemId) override; + ::ndk::ScopedAStatus setResponseFunctions( + const std::shared_ptr& + radioConfigResponse, + const std::shared_ptr& + radioConfigIndication) override; + ::ndk::ScopedAStatus setSimSlotsMapping( + int32_t serial, + const std::vector& slotMap) + override; + + config::V1_3::IRadioConfigResponse& respond(); + + public: + /** + * Constructs AIDL IRadioConfig instance wrapping existing HIDL IRadioConfig instance. + * + * \param hidlHal existing HIDL IRadioConfig HAL instance + */ + RadioConfig(sp hidlHal); +}; + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/service/Android.bp b/radio/aidl/compat/service/Android.bp new file mode 100644 index 0000000000..f708b84764 --- /dev/null +++ b/radio/aidl/compat/service/Android.bp @@ -0,0 +1,51 @@ +// 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. + +package { + // See: http://go/android-license-faq + // A large-scale-change added 'default_applicable_licenses' to import + // all of the 'license_kinds' from "hardware_interfaces_license" + // to get the below license kinds: + // SPDX-license-identifier-Apache-2.0 + default_applicable_licenses: ["hardware_interfaces_license"], +} + +cc_binary { + name: "android.hardware.radio-service.compat", + relative_install_path: "hw", + init_rc: ["radio-compat.rc"], + vintf_fragments: ["radio-compat.xml"], + vendor: true, + cflags: [ + "-Wall", + "-Wextra", + "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION", + ], + shared_libs: [ + "android.hardware.radio-library.compat", + "android.hardware.radio.config-V1-ndk", + "android.hardware.radio.config@1.0", + "android.hardware.radio.config@1.1", + "android.hardware.radio.config@1.2", + "android.hardware.radio.config@1.3", + "libbase", + "libbinder_ndk", + "libhidlbase", + "libutils", + ], + srcs: [ + "hidl-utils.cpp", + "service.cpp", + ], +} diff --git a/radio/aidl/compat/service/hidl-utils.cpp b/radio/aidl/compat/service/hidl-utils.cpp new file mode 100644 index 0000000000..d8949666af --- /dev/null +++ b/radio/aidl/compat/service/hidl-utils.cpp @@ -0,0 +1,36 @@ +/* + * 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 "hidl-utils.h" + +#include + +namespace android::hardware::hidl_utils { + +class HalDeathRecipient : public hidl_death_recipient { + void serviceDied(uint64_t /* cookie */, const wp& /* who */) override { + LOG(FATAL) << "One of the linked HALs died. Restarting..."; + } +}; + +static const auto gHalDeathRecipient = sp::make(); + +void linkDeathToDeath(sp<::android::hidl::base::V1_0::IBase> hal) { + const auto linkStatus = hal->linkToDeath(gHalDeathRecipient, 0); + CHECK(linkStatus.withDefault(false)) << "Failed to link to HAL death"; +} + +} // namespace android::hardware::hidl_utils diff --git a/radio/aidl/compat/service/hidl-utils.h b/radio/aidl/compat/service/hidl-utils.h new file mode 100644 index 0000000000..3f81a9b96f --- /dev/null +++ b/radio/aidl/compat/service/hidl-utils.h @@ -0,0 +1,30 @@ +/* + * 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 + +namespace android::hardware::hidl_utils { + +/** + * Link to a given HALs death and restart the current process in such a case. + * + * \param hal HAL to which death to link + */ +void linkDeathToDeath(sp hal); + +} // namespace android::hardware::hidl_utils diff --git a/radio/aidl/compat/service/radio-compat.rc b/radio/aidl/compat/service/radio-compat.rc new file mode 100644 index 0000000000..a1598760ff --- /dev/null +++ b/radio/aidl/compat/service/radio-compat.rc @@ -0,0 +1,4 @@ +service vendor.radio-compat /vendor/bin/hw/android.hardware.radio-service.compat + class hal + user nobody + group system diff --git a/radio/aidl/compat/service/radio-compat.xml b/radio/aidl/compat/service/radio-compat.xml new file mode 100644 index 0000000000..60f8ff5d7c --- /dev/null +++ b/radio/aidl/compat/service/radio-compat.xml @@ -0,0 +1,6 @@ + + + android.hardware.radio.config + IRadioConfig/default + + diff --git a/radio/aidl/compat/service/service.cpp b/radio/aidl/compat/service/service.cpp new file mode 100644 index 0000000000..c177dd1233 --- /dev/null +++ b/radio/aidl/compat/service/service.cpp @@ -0,0 +1,60 @@ +/* + * 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 "hidl-utils.h" + +#include +#include +#include +#include + +namespace android::hardware::radio::service { + +using namespace std::string_literals; + +static std::vector> gPublishedHals; + +static void publishRadioConfig() { + auto hidlHal = config::V1_1::IRadioConfig::getService(); + CHECK(hidlHal) << "HIDL IRadioConfig not present in VINTF"; + + hidl_utils::linkDeathToDeath(hidlHal); + + auto aidlHal = ndk::SharedRefBase::make(hidlHal); + gPublishedHals.push_back(aidlHal); + const auto instance = compat::RadioConfig::descriptor + "/default"s; + const auto status = AServiceManager_addService(aidlHal->asBinder().get(), instance.c_str()); + CHECK_EQ(status, STATUS_OK); +} + +static void main() { + base::SetDefaultTag("radiocompat"); + base::SetMinimumLogSeverity(base::VERBOSE); + LOG(DEBUG) << "Radio HAL compat service starting..."; + + publishRadioConfig(); + + LOG(DEBUG) << "Radio HAL compat service is operational"; + ABinderProcess_joinThreadPool(); + LOG(FATAL) << "Radio HAL compat service has stopped"; +} + +} // namespace android::hardware::radio::service + +int main() { + android::hardware::radio::service::main(); + return EXIT_FAILURE; // should not reach +} From 9ddc87f6af4c895d51a8e02b0bd5f05e19c1fde2 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Mon, 25 Oct 2021 20:20:49 -0700 Subject: [PATCH 2/7] Implement RadioMessaging for AIDL-HIDL Telephony HAL translator Bug: 203699028 Test: Boot and grep logcat against radiocompat Change-Id: I10f0fc0b871fbaf26145c83211770a82af6adc61 --- radio/aidl/compat/libradiocompat/Android.bp | 15 + .../compat/libradiocompat/RadioCompatBase.cpp | 35 + .../compat/libradiocompat/RadioIndication.cpp | 344 +++++++ .../compat/libradiocompat/RadioResponse.cpp | 866 ++++++++++++++++++ radio/aidl/compat/libradiocompat/debug.h | 6 + .../include/libradiocompat/RadioCompatBase.h | 40 + .../include/libradiocompat/RadioIndication.h | 179 ++++ .../include/libradiocompat/RadioMessaging.h | 89 ++ .../include/libradiocompat/RadioResponse.h | 407 ++++++++ .../messaging/RadioIndication-messaging.cpp | 94 ++ .../messaging/RadioMessaging.cpp | 195 ++++ .../messaging/RadioResponse-messaging.cpp | 244 +++++ .../libradiocompat/messaging/structs.cpp | 172 ++++ .../compat/libradiocompat/messaging/structs.h | 57 ++ radio/aidl/compat/service/Android.bp | 8 + radio/aidl/compat/service/hidl-utils.cpp | 10 + radio/aidl/compat/service/hidl-utils.h | 50 +- radio/aidl/compat/service/radio-compat.xml | 11 + radio/aidl/compat/service/service.cpp | 38 + 19 files changed, 2859 insertions(+), 1 deletion(-) create mode 100644 radio/aidl/compat/libradiocompat/RadioCompatBase.cpp create mode 100644 radio/aidl/compat/libradiocompat/RadioIndication.cpp create mode 100644 radio/aidl/compat/libradiocompat/RadioResponse.cpp create mode 100644 radio/aidl/compat/libradiocompat/include/libradiocompat/RadioCompatBase.h create mode 100644 radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h create mode 100644 radio/aidl/compat/libradiocompat/include/libradiocompat/RadioMessaging.h create mode 100644 radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h create mode 100644 radio/aidl/compat/libradiocompat/messaging/RadioIndication-messaging.cpp create mode 100644 radio/aidl/compat/libradiocompat/messaging/RadioMessaging.cpp create mode 100644 radio/aidl/compat/libradiocompat/messaging/RadioResponse-messaging.cpp create mode 100644 radio/aidl/compat/libradiocompat/messaging/structs.cpp create mode 100644 radio/aidl/compat/libradiocompat/messaging/structs.h diff --git a/radio/aidl/compat/libradiocompat/Android.bp b/radio/aidl/compat/libradiocompat/Android.bp index ada7c7ed98..00c1db658d 100644 --- a/radio/aidl/compat/libradiocompat/Android.bp +++ b/radio/aidl/compat/libradiocompat/Android.bp @@ -37,17 +37,32 @@ cc_library { "android.hardware.radio.config@1.1", "android.hardware.radio.config@1.2", "android.hardware.radio.config@1.3", + "android.hardware.radio.messaging-V1-ndk", + "android.hardware.radio@1.0", + "android.hardware.radio@1.1", + "android.hardware.radio@1.2", + "android.hardware.radio@1.3", + "android.hardware.radio@1.4", + "android.hardware.radio@1.5", + "android.hardware.radio@1.6", "libbase", "libbinder_ndk", "libhidlbase", "libutils", ], srcs: [ + "RadioCompatBase.cpp", + "RadioIndication.cpp", + "RadioResponse.cpp", "commonStructs.cpp", "config/RadioConfig.cpp", "config/RadioConfigIndication.cpp", "config/RadioConfigResponse.cpp", "config/structs.cpp", + "messaging/RadioIndication-messaging.cpp", + "messaging/RadioMessaging.cpp", + "messaging/RadioResponse-messaging.cpp", + "messaging/structs.cpp", ], export_include_dirs: ["include"], } diff --git a/radio/aidl/compat/libradiocompat/RadioCompatBase.cpp b/radio/aidl/compat/libradiocompat/RadioCompatBase.cpp new file mode 100644 index 0000000000..a9eac68d13 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/RadioCompatBase.cpp @@ -0,0 +1,35 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +RadioCompatBase::RadioCompatBase(sp hidlHal, sp radioResponse, + sp radioIndication) + : mHal1_5(hidlHal), + mHal1_6(V1_6::IRadio::castFrom(hidlHal)), + mRadioResponse(radioResponse), + mRadioIndication(radioIndication) {} + +V1_6::IRadioResponse& RadioCompatBase::respond() { + CHECK(mRadioResponse) << "This shouldn't happen (response functions are passed in constructor)"; + return *mRadioResponse; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/RadioIndication.cpp b/radio/aidl/compat/libradiocompat/RadioIndication.cpp new file mode 100644 index 0000000000..5cbb954229 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/RadioIndication.cpp @@ -0,0 +1,344 @@ +/* + * 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 + +// TODO(b/203699028): remove when fully implemented +#pragma GCC diagnostic ignored "-Wunused-parameter" + +namespace android::hardware::radio::compat { + +Return RadioIndication::radioStateChanged(V1_0::RadioIndicationType type, + V1_0::RadioState radioState) { + return {}; +} + +Return RadioIndication::callStateChanged(V1_0::RadioIndicationType type) { + return {}; +} + +Return RadioIndication::networkStateChanged(V1_0::RadioIndicationType type) { + return {}; +} + +Return RadioIndication::nitzTimeReceived(V1_0::RadioIndicationType type, + const hidl_string& nitzTime, uint64_t receivedTime) { + return {}; +} + +Return RadioIndication::currentSignalStrength(V1_0::RadioIndicationType type, + const V1_0::SignalStrength& signalStrength) { + return {}; +} + +Return RadioIndication::dataCallListChanged( + V1_0::RadioIndicationType type, const hidl_vec& dcList) { + return {}; +} + +Return RadioIndication::suppSvcNotify(V1_0::RadioIndicationType type, + const V1_0::SuppSvcNotification& suppSvc) { + return {}; +} + +Return RadioIndication::stkSessionEnd(V1_0::RadioIndicationType type) { + return {}; +} + +Return RadioIndication::stkProactiveCommand(V1_0::RadioIndicationType type, + const hidl_string& cmd) { + return {}; +} + +Return RadioIndication::stkEventNotify(V1_0::RadioIndicationType type, + const hidl_string& cmd) { + return {}; +} + +Return RadioIndication::stkCallSetup(V1_0::RadioIndicationType type, int64_t timeout) { + return {}; +} + +Return RadioIndication::simRefresh(V1_0::RadioIndicationType type, + const V1_0::SimRefreshResult& refreshResult) { + return {}; +} + +Return RadioIndication::callRing(V1_0::RadioIndicationType type, bool isGsm, + const V1_0::CdmaSignalInfoRecord& record) { + return {}; +} + +Return RadioIndication::simStatusChanged(V1_0::RadioIndicationType type) { + return {}; +} + +Return RadioIndication::restrictedStateChanged(V1_0::RadioIndicationType type, + V1_0::PhoneRestrictedState state) { + return {}; +} + +Return RadioIndication::enterEmergencyCallbackMode(V1_0::RadioIndicationType type) { + return {}; +} + +Return RadioIndication::cdmaCallWaiting(V1_0::RadioIndicationType type, + const V1_0::CdmaCallWaiting& callWaitingRecord) { + return {}; +} + +Return RadioIndication::cdmaOtaProvisionStatus(V1_0::RadioIndicationType type, + V1_0::CdmaOtaProvisionStatus status) { + return {}; +} + +Return RadioIndication::cdmaInfoRec(V1_0::RadioIndicationType type, + const V1_0::CdmaInformationRecords& records) { + return {}; +} + +Return RadioIndication::indicateRingbackTone(V1_0::RadioIndicationType type, bool start) { + return {}; +} + +Return RadioIndication::resendIncallMute(V1_0::RadioIndicationType type) { + return {}; +} + +Return RadioIndication::cdmaSubscriptionSourceChanged( + V1_0::RadioIndicationType type, V1_0::CdmaSubscriptionSource cdmaSource) { + return {}; +} + +Return RadioIndication::cdmaPrlChanged(V1_0::RadioIndicationType type, int32_t version) { + return {}; +} + +Return RadioIndication::exitEmergencyCallbackMode(V1_0::RadioIndicationType type) { + return {}; +} + +Return RadioIndication::rilConnected(V1_0::RadioIndicationType type) { + return {}; +} + +Return RadioIndication::voiceRadioTechChanged(V1_0::RadioIndicationType type, + V1_0::RadioTechnology rat) { + return {}; +} + +Return RadioIndication::cellInfoList(V1_0::RadioIndicationType type, + const hidl_vec& records) { + return {}; +} + +Return RadioIndication::imsNetworkStateChanged(V1_0::RadioIndicationType type) { + return {}; +} + +Return RadioIndication::subscriptionStatusChanged(V1_0::RadioIndicationType type, + bool activate) { + return {}; +} + +Return RadioIndication::srvccStateNotify(V1_0::RadioIndicationType type, + V1_0::SrvccState state) { + return {}; +} + +Return RadioIndication::hardwareConfigChanged(V1_0::RadioIndicationType type, + const hidl_vec& configs) { + return {}; +} + +Return RadioIndication::radioCapabilityIndication(V1_0::RadioIndicationType type, + const V1_0::RadioCapability& rc) { + return {}; +} + +Return RadioIndication::onSupplementaryServiceIndication(V1_0::RadioIndicationType type, + const V1_0::StkCcUnsolSsResult& ss) { + return {}; +} + +Return RadioIndication::stkCallControlAlphaNotify(V1_0::RadioIndicationType type, + const hidl_string& alpha) { + return {}; +} + +Return RadioIndication::lceData(V1_0::RadioIndicationType type, + const V1_0::LceDataInfo& lce) { + return {}; +} + +Return RadioIndication::pcoData(V1_0::RadioIndicationType type, + const V1_0::PcoDataInfo& pco) { + return {}; +} + +Return RadioIndication::modemReset(V1_0::RadioIndicationType type, + const hidl_string& reason) { + return {}; +} + +Return RadioIndication::carrierInfoForImsiEncryption(V1_0::RadioIndicationType info) { + return {}; +} + +Return RadioIndication::networkScanResult(V1_0::RadioIndicationType type, + const V1_1::NetworkScanResult& result) { + return {}; +} + +Return RadioIndication::keepaliveStatus(V1_0::RadioIndicationType type, + const V1_1::KeepaliveStatus& status) { + return {}; +} + +Return RadioIndication::networkScanResult_1_2(V1_0::RadioIndicationType type, + const V1_2::NetworkScanResult& result) { + return {}; +} + +Return RadioIndication::cellInfoList_1_2(V1_0::RadioIndicationType type, + const hidl_vec& records) { + return {}; +} + +Return RadioIndication::currentLinkCapacityEstimate(V1_0::RadioIndicationType type, + const V1_2::LinkCapacityEstimate& lce) { + return {}; +} + +Return RadioIndication::currentPhysicalChannelConfigs( + V1_0::RadioIndicationType type, const hidl_vec& configs) { + return {}; +} + +Return RadioIndication::currentSignalStrength_1_2( + V1_0::RadioIndicationType type, const V1_2::SignalStrength& signalStrength) { + return {}; +} + +Return RadioIndication::currentEmergencyNumberList( + V1_0::RadioIndicationType type, const hidl_vec& emergencyNumbers) { + return {}; +} + +Return RadioIndication::cellInfoList_1_4(V1_0::RadioIndicationType type, + const hidl_vec& records) { + return {}; +} + +Return RadioIndication::networkScanResult_1_4(V1_0::RadioIndicationType type, + const V1_4::NetworkScanResult& result) { + return {}; +} + +Return RadioIndication::currentPhysicalChannelConfigs_1_4( + V1_0::RadioIndicationType type, const hidl_vec& configs) { + return {}; +} + +Return RadioIndication::dataCallListChanged_1_4( + V1_0::RadioIndicationType type, const hidl_vec& dcList) { + return {}; +} + +Return RadioIndication::currentSignalStrength_1_4( + V1_0::RadioIndicationType type, const V1_4::SignalStrength& signalStrength) { + return {}; +} + +Return RadioIndication::uiccApplicationsEnablementChanged(V1_0::RadioIndicationType type, + bool enabled) { + return {}; +} + +Return RadioIndication::registrationFailed( // + V1_0::RadioIndicationType type, const V1_5::CellIdentity& cellIdentity, + const hidl_string& chosenPlmn, hidl_bitfield domain, int32_t causeCode, + int32_t additionalCauseCode) { + return {}; +} + +Return RadioIndication::barringInfoChanged(V1_0::RadioIndicationType type, + const V1_5::CellIdentity& cellIdentity, + const hidl_vec& barringInfos) { + return {}; +} + +Return RadioIndication::cellInfoList_1_5(V1_0::RadioIndicationType type, + const hidl_vec& records) { + return {}; +} + +Return RadioIndication::networkScanResult_1_5(V1_0::RadioIndicationType type, + const V1_5::NetworkScanResult& result) { + return {}; +} + +Return RadioIndication::dataCallListChanged_1_5( + V1_0::RadioIndicationType type, const hidl_vec& dcList) { + return {}; +} + +Return RadioIndication::dataCallListChanged_1_6( + V1_0::RadioIndicationType type, const hidl_vec& dcList) { + return {}; +} + +Return RadioIndication::unthrottleApn(V1_0::RadioIndicationType type, + const hidl_string& apn) { + return {}; +} + +Return RadioIndication::currentLinkCapacityEstimate_1_6( + V1_0::RadioIndicationType type, const V1_6::LinkCapacityEstimate& lce) { + return {}; +} + +Return RadioIndication::currentSignalStrength_1_6( + V1_0::RadioIndicationType type, const V1_6::SignalStrength& signalStrength) { + return {}; +} + +Return RadioIndication::cellInfoList_1_6(V1_0::RadioIndicationType type, + const hidl_vec& records) { + return {}; +} + +Return RadioIndication::networkScanResult_1_6(V1_0::RadioIndicationType type, + const V1_6::NetworkScanResult& result) { + return {}; +} + +Return RadioIndication::currentPhysicalChannelConfigs_1_6( + V1_0::RadioIndicationType type, const hidl_vec& configs) { + return {}; +} + +Return RadioIndication::simPhonebookChanged(V1_0::RadioIndicationType type) { + return {}; +} + +Return RadioIndication::simPhonebookRecordsReceived( + V1_0::RadioIndicationType type, V1_6::PbReceivedStatus status, + const hidl_vec& records) { + return {}; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/RadioResponse.cpp b/radio/aidl/compat/libradiocompat/RadioResponse.cpp new file mode 100644 index 0000000000..15002a8490 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/RadioResponse.cpp @@ -0,0 +1,866 @@ +/* + * 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" + +// TODO(b/203699028): remove when fully implemented +#pragma GCC diagnostic ignored "-Wunused-parameter" + +#define RADIO_MODULE "Common" + +namespace android::hardware::radio::compat { + +Return RadioResponse::acknowledgeRequest(int32_t serial) { + LOG_CALL << serial; + if (mMessagingCb) mMessagingCb->acknowledgeRequest(serial); + return {}; +} + +Return RadioResponse::getIccCardStatusResponse(const V1_0::RadioResponseInfo& info, + const V1_0::CardStatus& cardStatus) { + return {}; +} + +Return RadioResponse::supplyIccPinForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + return {}; +} + +Return RadioResponse::supplyIccPukForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + return {}; +} + +Return RadioResponse::supplyIccPin2ForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + return {}; +} + +Return RadioResponse::supplyIccPuk2ForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + return {}; +} + +Return RadioResponse::changeIccPinForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + return {}; +} + +Return RadioResponse::changeIccPin2ForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + return {}; +} + +Return RadioResponse::supplyNetworkDepersonalizationResponse( + const V1_0::RadioResponseInfo& info, int32_t remainingRetries) { + return {}; +} + +Return RadioResponse::getCurrentCallsResponse(const V1_0::RadioResponseInfo& info, + const hidl_vec& calls) { + return {}; +} + +Return RadioResponse::dialResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getIMSIForAppResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& imsi) { + return {}; +} + +Return RadioResponse::hangupConnectionResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::hangupWaitingOrBackgroundResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::hangupForegroundResumeBackgroundResponse( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::switchWaitingOrHoldingAndActiveResponse( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::conferenceResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::rejectCallResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getLastCallFailCauseResponse( + const V1_0::RadioResponseInfo& info, const V1_0::LastCallFailCauseInfo& failCauseinfo) { + return {}; +} + +Return RadioResponse::getSignalStrengthResponse(const V1_0::RadioResponseInfo& info, + const V1_0::SignalStrength& sigStrength) { + return {}; +} + +Return RadioResponse::getVoiceRegistrationStateResponse( + const V1_0::RadioResponseInfo& info, const V1_0::VoiceRegStateResult& voiceRegResponse) { + return {}; +} + +Return RadioResponse::getDataRegistrationStateResponse( + const V1_0::RadioResponseInfo& info, const V1_0::DataRegStateResult& dataRegResponse) { + return {}; +} + +Return RadioResponse::getOperatorResponse( // + const V1_0::RadioResponseInfo& info, const hidl_string& longName, + const hidl_string& shortName, const hidl_string& numeric) { + return {}; +} + +Return RadioResponse::setRadioPowerResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::sendDtmfResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setupDataCallResponse(const V1_0::RadioResponseInfo& info, + const V1_0::SetupDataCallResult& dcResponse) { + return {}; +} + +Return RadioResponse::iccIOForAppResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& iccIo) { + return {}; +} + +Return RadioResponse::getClirResponse(const V1_0::RadioResponseInfo& info, int32_t n, + int32_t m) { + return {}; +} + +Return RadioResponse::setClirResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getCallForwardStatusResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& callFwdInfos) { + return {}; +} + +Return RadioResponse::setCallForwardResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getCallWaitingResponse(const V1_0::RadioResponseInfo& info, bool enable, + int32_t serviceClass) { + return {}; +} + +Return RadioResponse::setCallWaitingResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::acceptCallResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::deactivateDataCallResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getFacilityLockForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t response) { + return {}; +} + +Return RadioResponse::setFacilityLockForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t retry) { + return {}; +} + +Return RadioResponse::setBarringPasswordResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getNetworkSelectionModeResponse(const V1_0::RadioResponseInfo& info, + bool manual) { + return {}; +} + +Return RadioResponse::setNetworkSelectionModeAutomaticResponse( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setNetworkSelectionModeManualResponse( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getAvailableNetworksResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& networkInfos) { + return {}; +} + +Return RadioResponse::startDtmfResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::stopDtmfResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getBasebandVersionResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& version) { + return {}; +} + +Return RadioResponse::separateConnectionResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setMuteResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getMuteResponse(const V1_0::RadioResponseInfo& info, bool enable) { + return {}; +} + +Return RadioResponse::getClipResponse(const V1_0::RadioResponseInfo& info, + V1_0::ClipStatus status) { + return {}; +} + +Return RadioResponse::getDataCallListResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& dcResp) { + return {}; +} + +Return RadioResponse::setSuppServiceNotificationsResponse( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setBandModeResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getAvailableBandModesResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& bandModes) { + return {}; +} + +Return RadioResponse::sendEnvelopeResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& commandResponse) { + return {}; +} + +Return RadioResponse::sendTerminalResponseToSimResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::handleStkCallSetupRequestFromSimResponse( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::explicitCallTransferResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setPreferredNetworkTypeResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getPreferredNetworkTypeResponse(const V1_0::RadioResponseInfo& info, + V1_0::PreferredNetworkType nwType) { + return {}; +} + +Return RadioResponse::getNeighboringCidsResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& cells) { + return {}; +} + +Return RadioResponse::setLocationUpdatesResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setCdmaRoamingPreferenceResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getCdmaRoamingPreferenceResponse(const V1_0::RadioResponseInfo& info, + V1_0::CdmaRoamingType type) { + return {}; +} + +Return RadioResponse::setTTYModeResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getTTYModeResponse(const V1_0::RadioResponseInfo& info, + V1_0::TtyMode mode) { + return {}; +} + +Return RadioResponse::setPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo& info, + bool enable) { + return {}; +} + +Return RadioResponse::sendCDMAFeatureCodeResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::sendBurstDtmfResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getCDMASubscriptionResponse( + const V1_0::RadioResponseInfo& info, const hidl_string& mdn, const hidl_string& hSid, + const hidl_string& hNid, const hidl_string& min, const hidl_string& prl) { + 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::exitEmergencyCallbackModeResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::reportStkServiceIsRunningResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo& info, + V1_0::CdmaSubscriptionSource source) { + return {}; +} + +Return RadioResponse::requestIsimAuthenticationResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& response) { + return {}; +} + +Return RadioResponse::sendEnvelopeWithStatusResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& iccIo) { + return {}; +} + +Return RadioResponse::getVoiceRadioTechnologyResponse(const V1_0::RadioResponseInfo& info, + V1_0::RadioTechnology rat) { + return {}; +} + +Return RadioResponse::getCellInfoListResponse(const V1_0::RadioResponseInfo& info, + const hidl_vec& cellInfo) { + return {}; +} + +Return RadioResponse::setCellInfoListRateResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setInitialAttachApnResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getImsRegistrationStateResponse( // + const V1_0::RadioResponseInfo& info, bool isRegd, V1_0::RadioTechnologyFamily ratFamily) { + return {}; +} + +Return RadioResponse::iccTransmitApduBasicChannelResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& result) { + return {}; +} + +Return RadioResponse::iccOpenLogicalChannelResponse( // + const V1_0::RadioResponseInfo& info, int32_t chanId, const hidl_vec& selectResp) { + return {}; +} + +Return RadioResponse::iccCloseLogicalChannelResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::iccTransmitApduLogicalChannelResponse( + const V1_0::RadioResponseInfo& info, const V1_0::IccIoResult& result) { + 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::setUiccSubscriptionResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setDataAllowedResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getHardwareConfigResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& config) { + return {}; +} + +Return RadioResponse::requestIccSimAuthenticationResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& result) { + return {}; +} + +Return RadioResponse::setDataProfileResponse(const V1_0::RadioResponseInfo& info) { + 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::startLceServiceResponse(const V1_0::RadioResponseInfo& info, + const V1_0::LceStatusInfo& statusInfo) { + return {}; +} + +Return RadioResponse::stopLceServiceResponse(const V1_0::RadioResponseInfo& info, + const V1_0::LceStatusInfo& statusInfo) { + return {}; +} + +Return RadioResponse::pullLceDataResponse(const V1_0::RadioResponseInfo& info, + const V1_0::LceDataInfo& lceInfo) { + return {}; +} + +Return RadioResponse::getModemActivityInfoResponse( + const V1_0::RadioResponseInfo& info, const V1_0::ActivityStatsInfo& activityInfo) { + return {}; +} + +Return RadioResponse::setAllowedCarriersResponse(const V1_0::RadioResponseInfo& info, + int32_t numAllowed) { + return {}; +} + +Return RadioResponse::getAllowedCarriersResponse( // + const V1_0::RadioResponseInfo& info, bool allAllowed, const V1_0::CarrierRestrictions& cr) { + return {}; +} + +Return RadioResponse::sendDeviceStateResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setIndicationFilterResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setSimCardPowerResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setCarrierInfoForImsiEncryptionResponse( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setSimCardPowerResponse_1_1(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::startNetworkScanResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::stopNetworkScanResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::startKeepaliveResponse(const V1_0::RadioResponseInfo& info, + const V1_1::KeepaliveStatus& status) { + return {}; +} + +Return RadioResponse::stopKeepaliveResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getCellInfoListResponse_1_2(const V1_0::RadioResponseInfo& info, + const hidl_vec& cellInfo) { + return {}; +} + +Return RadioResponse::getIccCardStatusResponse_1_2(const V1_0::RadioResponseInfo& info, + const V1_2::CardStatus& cardStatus) { + return {}; +} + +Return RadioResponse::setSignalStrengthReportingCriteriaResponse( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setLinkCapacityReportingCriteriaResponse( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getCurrentCallsResponse_1_2(const V1_0::RadioResponseInfo& info, + const hidl_vec& calls) { + return {}; +} + +Return RadioResponse::getSignalStrengthResponse_1_2( + const V1_0::RadioResponseInfo& info, const V1_2::SignalStrength& signalStrength) { + return {}; +} + +Return RadioResponse::getVoiceRegistrationStateResponse_1_2( + const V1_0::RadioResponseInfo& info, const V1_2::VoiceRegStateResult& voiceRegResponse) { + return {}; +} + +Return RadioResponse::getDataRegistrationStateResponse_1_2( + const V1_0::RadioResponseInfo& info, const V1_2::DataRegStateResult& dataRegResponse) { + return {}; +} + +Return RadioResponse::setSystemSelectionChannelsResponse( + 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::emergencyDialResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::startNetworkScanResponse_1_4(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getCellInfoListResponse_1_4(const V1_0::RadioResponseInfo& info, + const hidl_vec& cellInfo) { + return {}; +} + +Return RadioResponse::getDataRegistrationStateResponse_1_4( + const V1_0::RadioResponseInfo& info, const V1_4::DataRegStateResult& dataRegResponse) { + return {}; +} + +Return RadioResponse::getIccCardStatusResponse_1_4(const V1_0::RadioResponseInfo& info, + const V1_4::CardStatus& cardStatus) { + return {}; +} + +Return RadioResponse::getPreferredNetworkTypeBitmapResponse( + const V1_0::RadioResponseInfo& info, + hidl_bitfield networkTypeBitmap) { + return {}; +} + +Return RadioResponse::setPreferredNetworkTypeBitmapResponse( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getDataCallListResponse_1_4( + const V1_0::RadioResponseInfo& info, + const hidl_vec& dcResponse) { + return {}; +} + +Return RadioResponse::setupDataCallResponse_1_4(const V1_0::RadioResponseInfo& info, + const V1_4::SetupDataCallResult& dcResponse) { + return {}; +} + +Return RadioResponse::setAllowedCarriersResponse_1_4(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getAllowedCarriersResponse_1_4( + const V1_0::RadioResponseInfo& info, const V1_4::CarrierRestrictionsWithPriority& carriers, + V1_4::SimLockMultiSimPolicy multiSimPolicy) { + return {}; +} + +Return RadioResponse::getSignalStrengthResponse_1_4( + const V1_0::RadioResponseInfo& info, const V1_4::SignalStrength& signalStrength) { + return {}; +} + +Return RadioResponse::setSignalStrengthReportingCriteriaResponse_1_5( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setLinkCapacityReportingCriteriaResponse_1_5( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::enableUiccApplicationsResponse(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::areUiccApplicationsEnabledResponse(const V1_0::RadioResponseInfo& info, + bool enabled) { + return {}; +} + +Return RadioResponse::setSystemSelectionChannelsResponse_1_5( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::startNetworkScanResponse_1_5(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setupDataCallResponse_1_5(const V1_0::RadioResponseInfo& info, + const V1_5::SetupDataCallResult& dcResponse) { + return {}; +} + +Return RadioResponse::getDataCallListResponse_1_5( + const V1_0::RadioResponseInfo& info, + const hidl_vec& dcResponse) { + return {}; +} + +Return RadioResponse::setInitialAttachApnResponse_1_5(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setDataProfileResponse_1_5(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setRadioPowerResponse_1_5(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setIndicationFilterResponse_1_5(const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getBarringInfoResponse( + const V1_0::RadioResponseInfo& info, const V1_5::CellIdentity& cellIdentity, + const hidl_vec& barringInfos) { + return {}; +} + +Return RadioResponse::getVoiceRegistrationStateResponse_1_5( + const V1_0::RadioResponseInfo& info, const V1_5::RegStateResult& voiceRegResponse) { + return {}; +} + +Return RadioResponse::getDataRegistrationStateResponse_1_5( + const V1_0::RadioResponseInfo& info, const V1_5::RegStateResult& dataRegResponse) { + return {}; +} + +Return RadioResponse::getCellInfoListResponse_1_5(const V1_0::RadioResponseInfo& info, + const hidl_vec& cellInfo) { + return {}; +} + +Return RadioResponse::setNetworkSelectionModeManualResponse_1_5( + const V1_0::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::supplySimDepersonalizationResponse(const V1_0::RadioResponseInfo& info, + V1_5::PersoSubstate persoType, + int32_t remainingRetries) { + return {}; +} + +Return RadioResponse::getIccCardStatusResponse_1_5(const V1_0::RadioResponseInfo& info, + const V1_5::CardStatus& cardStatus) { + return {}; +} + +Return RadioResponse::setRadioPowerResponse_1_6(const V1_6::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setupDataCallResponse_1_6(const V1_6::RadioResponseInfo& info, + const V1_6::SetupDataCallResult& dcResponse) { + return {}; +} + +Return RadioResponse::getDataCallListResponse_1_6( + const V1_6::RadioResponseInfo& info, + const hidl_vec& dcResponse) { + return {}; +} + +Return RadioResponse::setSimCardPowerResponse_1_6(const V1_6::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setNrDualConnectivityStateResponse( + const V1_6::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::isNrDualConnectivityEnabledResponse(const V1_6::RadioResponseInfo& info, + bool isEnabled) { + return {}; +} + +Return RadioResponse::allocatePduSessionIdResponse(const V1_6::RadioResponseInfo& info, + int32_t id) { + return {}; +} + +Return RadioResponse::releasePduSessionIdResponse(const V1_6::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::startHandoverResponse(const V1_6::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::cancelHandoverResponse(const V1_6::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::setAllowedNetworkTypesBitmapResponse( + const V1_6::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getAllowedNetworkTypesBitmapResponse( + const V1_6::RadioResponseInfo& info, + hidl_bitfield networkTypeBitmap) { + return {}; +} + +Return RadioResponse::setDataThrottlingResponse(const V1_6::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getSystemSelectionChannelsResponse( + const V1_6::RadioResponseInfo& info, + const hidl_vec& specifiers) { + return {}; +} + +Return RadioResponse::getCellInfoListResponse_1_6(const V1_6::RadioResponseInfo& info, + const hidl_vec& cellInfo) { + return {}; +} + +Return RadioResponse::getSignalStrengthResponse_1_6( + const V1_6::RadioResponseInfo& info, const V1_6::SignalStrength& signalStrength) { + return {}; +} + +Return RadioResponse::getVoiceRegistrationStateResponse_1_6( + const V1_6::RadioResponseInfo& info, const V1_6::RegStateResult& voiceRegResponse) { + return {}; +} + +Return RadioResponse::getDataRegistrationStateResponse_1_6( + const V1_6::RadioResponseInfo& info, const V1_6::RegStateResult& dataRegResponse) { + return {}; +} + +Return RadioResponse::getCurrentCallsResponse_1_6(const V1_6::RadioResponseInfo& info, + const hidl_vec& calls) { + return {}; +} + +Return RadioResponse::getSlicingConfigResponse(const V1_6::RadioResponseInfo& info, + const V1_6::SlicingConfig& slicingConfig) { + return {}; +} + +Return RadioResponse::getSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo& info) { + return {}; +} + +Return RadioResponse::getSimPhonebookCapacityResponse( + const V1_6::RadioResponseInfo& info, const V1_6::PhonebookCapacity& capacity) { + return {}; +} + +Return RadioResponse::updateSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo& info, + int32_t updatedRecordIndex) { + return {}; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/debug.h b/radio/aidl/compat/libradiocompat/debug.h index cb773bf27d..4158059f88 100644 --- a/radio/aidl/compat/libradiocompat/debug.h +++ b/radio/aidl/compat/libradiocompat/debug.h @@ -26,6 +26,12 @@ static constexpr bool kSuperVerbose = true; #define LOG_CALL \ if constexpr (debug::kSuperVerbose) LOG(VERBOSE) << (RADIO_MODULE ".") << __func__ << ' ' +#define CHECK_CB(field) \ + if (!field) { \ + LOG(WARNING) << "Callback not set"; \ + return {}; \ + } + } // namespace debug inline std::ostream& operator<<(std::ostream& os, const V1_0::RadioIndicationType& type) { diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioCompatBase.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioCompatBase.h new file mode 100644 index 0000000000..a412c34abc --- /dev/null +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioCompatBase.h @@ -0,0 +1,40 @@ +/* + * 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 "RadioIndication.h" +#include "RadioResponse.h" + +#include + +namespace android::hardware::radio::compat { + +class RadioCompatBase { + protected: + sp mHal1_5; + sp mHal1_6; + + sp mRadioResponse; + sp mRadioIndication; + + V1_6::IRadioResponse& respond(); + + public: + RadioCompatBase(sp hidlHal, sp radioResponse, + sp radioIndication); +}; + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h new file mode 100644 index 0000000000..991ae0637e --- /dev/null +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h @@ -0,0 +1,179 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +class RadioIndication : public V1_6::IRadioIndication { + std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingIndication> + mMessagingCb; + + // IRadioIndication @ 1.0 + Return radioStateChanged(V1_0::RadioIndicationType type, + V1_0::RadioState radioState) override; + Return callStateChanged(V1_0::RadioIndicationType type) override; + Return networkStateChanged(V1_0::RadioIndicationType type) override; + Return newSms(V1_0::RadioIndicationType type, const hidl_vec& pdu) override; + Return newSmsStatusReport(V1_0::RadioIndicationType type, + const hidl_vec& pdu) override; + Return newSmsOnSim(V1_0::RadioIndicationType type, int32_t recordNumber) override; + Return onUssd(V1_0::RadioIndicationType type, V1_0::UssdModeType modeType, + const hidl_string& msg) override; + Return nitzTimeReceived(V1_0::RadioIndicationType type, const hidl_string& nitzTime, + uint64_t receivedTime) override; + Return currentSignalStrength(V1_0::RadioIndicationType type, + const V1_0::SignalStrength& signalStrength) override; + Return dataCallListChanged(V1_0::RadioIndicationType type, + const hidl_vec& dcList) override; + Return suppSvcNotify(V1_0::RadioIndicationType type, + const V1_0::SuppSvcNotification& suppSvc) override; + Return stkSessionEnd(V1_0::RadioIndicationType type) override; + Return stkProactiveCommand(V1_0::RadioIndicationType type, + const hidl_string& cmd) override; + Return stkEventNotify(V1_0::RadioIndicationType type, const hidl_string& cmd) override; + Return stkCallSetup(V1_0::RadioIndicationType type, int64_t timeout) override; + Return simSmsStorageFull(V1_0::RadioIndicationType type) override; + Return simRefresh(V1_0::RadioIndicationType type, + const V1_0::SimRefreshResult& refreshResult) override; + Return callRing(V1_0::RadioIndicationType type, bool isGsm, + const V1_0::CdmaSignalInfoRecord& record) override; + Return simStatusChanged(V1_0::RadioIndicationType type) override; + Return cdmaNewSms(V1_0::RadioIndicationType type, + const V1_0::CdmaSmsMessage& msg) override; + Return newBroadcastSms(V1_0::RadioIndicationType type, + const hidl_vec& data) override; + Return cdmaRuimSmsStorageFull(V1_0::RadioIndicationType type) override; + Return restrictedStateChanged(V1_0::RadioIndicationType type, + V1_0::PhoneRestrictedState state) override; + Return enterEmergencyCallbackMode(V1_0::RadioIndicationType type) override; + Return cdmaCallWaiting(V1_0::RadioIndicationType type, + const V1_0::CdmaCallWaiting& callWaitingRecord) override; + Return cdmaOtaProvisionStatus(V1_0::RadioIndicationType type, + V1_0::CdmaOtaProvisionStatus status) override; + Return cdmaInfoRec(V1_0::RadioIndicationType type, + const V1_0::CdmaInformationRecords& records) override; + Return indicateRingbackTone(V1_0::RadioIndicationType type, bool start) override; + Return resendIncallMute(V1_0::RadioIndicationType type) override; + Return cdmaSubscriptionSourceChanged(V1_0::RadioIndicationType type, + V1_0::CdmaSubscriptionSource cdmaSource) override; + Return cdmaPrlChanged(V1_0::RadioIndicationType type, int32_t version) override; + Return exitEmergencyCallbackMode(V1_0::RadioIndicationType type) override; + Return rilConnected(V1_0::RadioIndicationType type) override; + Return voiceRadioTechChanged(V1_0::RadioIndicationType type, + V1_0::RadioTechnology rat) override; + Return cellInfoList(V1_0::RadioIndicationType type, + const hidl_vec& records) override; + Return imsNetworkStateChanged(V1_0::RadioIndicationType type) override; + Return subscriptionStatusChanged(V1_0::RadioIndicationType type, bool activate) override; + Return srvccStateNotify(V1_0::RadioIndicationType type, V1_0::SrvccState state) override; + Return hardwareConfigChanged(V1_0::RadioIndicationType type, + const hidl_vec& configs) override; + Return radioCapabilityIndication(V1_0::RadioIndicationType type, + const V1_0::RadioCapability& rc) override; + Return onSupplementaryServiceIndication(V1_0::RadioIndicationType type, + const V1_0::StkCcUnsolSsResult& ss) override; + Return stkCallControlAlphaNotify(V1_0::RadioIndicationType type, + const hidl_string& alpha) override; + Return lceData(V1_0::RadioIndicationType type, const V1_0::LceDataInfo& lce) override; + Return pcoData(V1_0::RadioIndicationType type, const V1_0::PcoDataInfo& pco) override; + Return modemReset(V1_0::RadioIndicationType type, const hidl_string& reason) override; + + // IRadioIndication @ 1.1 + Return carrierInfoForImsiEncryption(V1_0::RadioIndicationType info) override; + Return networkScanResult(V1_0::RadioIndicationType type, + const V1_1::NetworkScanResult& result) override; + Return keepaliveStatus(V1_0::RadioIndicationType type, + const V1_1::KeepaliveStatus& status) override; + + // IRadioIndication @ 1.2 + Return networkScanResult_1_2(V1_0::RadioIndicationType type, + const V1_2::NetworkScanResult& result) override; + Return cellInfoList_1_2(V1_0::RadioIndicationType type, + const hidl_vec& records) override; + Return currentLinkCapacityEstimate(V1_0::RadioIndicationType type, + const V1_2::LinkCapacityEstimate& lce) override; + Return currentPhysicalChannelConfigs( + V1_0::RadioIndicationType type, + const hidl_vec& configs) override; + Return currentSignalStrength_1_2(V1_0::RadioIndicationType type, + const V1_2::SignalStrength& signalStrength) override; + + // IRadioIndication @ 1.4 + Return currentEmergencyNumberList( + V1_0::RadioIndicationType type, + const hidl_vec& emergencyNumberList) override; + Return cellInfoList_1_4(V1_0::RadioIndicationType type, + const hidl_vec& records) override; + Return networkScanResult_1_4(V1_0::RadioIndicationType type, + const V1_4::NetworkScanResult& result) override; + Return currentPhysicalChannelConfigs_1_4( + V1_0::RadioIndicationType type, + const hidl_vec& configs) override; + Return dataCallListChanged_1_4( + V1_0::RadioIndicationType type, + const hidl_vec& dcList) override; + Return currentSignalStrength_1_4(V1_0::RadioIndicationType type, + const V1_4::SignalStrength& signalStrength) override; + + // IRadioIndication @ 1.5 + Return uiccApplicationsEnablementChanged(V1_0::RadioIndicationType type, + bool enabled) override; + Return registrationFailed( // + V1_0::RadioIndicationType type, const V1_5::CellIdentity& cellIdentity, + const hidl_string& chosenPlmn, hidl_bitfield domain, int32_t causeCode, + int32_t additionalCauseCode) override; + Return barringInfoChanged( // + V1_0::RadioIndicationType type, const V1_5::CellIdentity& cellIdentity, + const hidl_vec& barringInfos) override; + Return cellInfoList_1_5(V1_0::RadioIndicationType type, + const hidl_vec& records) override; + Return networkScanResult_1_5(V1_0::RadioIndicationType type, + const V1_5::NetworkScanResult& result) override; + Return dataCallListChanged_1_5( + V1_0::RadioIndicationType type, + const hidl_vec& dcList) override; + + // IRadioIndication @ 1.6 + Return dataCallListChanged_1_6( + V1_0::RadioIndicationType type, + const hidl_vec& dcList) override; + Return unthrottleApn(V1_0::RadioIndicationType type, const hidl_string& apn) override; + Return currentLinkCapacityEstimate_1_6(V1_0::RadioIndicationType type, + const V1_6::LinkCapacityEstimate& lce) override; + Return currentSignalStrength_1_6(V1_0::RadioIndicationType type, + const V1_6::SignalStrength& signalStrength) override; + Return cellInfoList_1_6(V1_0::RadioIndicationType type, + const hidl_vec& records) override; + Return networkScanResult_1_6(V1_0::RadioIndicationType type, + const V1_6::NetworkScanResult& result) override; + Return currentPhysicalChannelConfigs_1_6( + V1_0::RadioIndicationType type, + const hidl_vec& configs) override; + Return simPhonebookChanged(V1_0::RadioIndicationType type) override; + Return simPhonebookRecordsReceived( + V1_0::RadioIndicationType type, V1_6::PbReceivedStatus status, + const hidl_vec& records) override; + + public: + void setResponseFunction( + std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingIndication> + radioMessagingIndication); +}; + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioMessaging.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioMessaging.h new file mode 100644 index 0000000000..0cd3381983 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioMessaging.h @@ -0,0 +1,89 @@ +/* + * 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 RadioMessaging : public RadioCompatBase, + public aidl::android::hardware::radio::messaging::BnRadioMessaging { + ::ndk::ScopedAStatus acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success, + const std::string& ackPdu) override; + ::ndk::ScopedAStatus acknowledgeLastIncomingCdmaSms( + int32_t serial, + const ::aidl::android::hardware::radio::messaging::CdmaSmsAck& smsAck) override; + ::ndk::ScopedAStatus acknowledgeLastIncomingGsmSms( + int32_t serial, bool success, + ::aidl::android::hardware::radio::messaging::SmsAcknowledgeFailCause cause) override; + ::ndk::ScopedAStatus cancelPendingUssd(int32_t serial) override; + ::ndk::ScopedAStatus deleteSmsOnRuim(int32_t serial, int32_t index) override; + ::ndk::ScopedAStatus deleteSmsOnSim(int32_t serial, int32_t index) override; + ::ndk::ScopedAStatus getCdmaBroadcastConfig(int32_t serial) override; + ::ndk::ScopedAStatus getGsmBroadcastConfig(int32_t serial) override; + ::ndk::ScopedAStatus getSmscAddress(int32_t serial) override; + ::ndk::ScopedAStatus reportSmsMemoryStatus(int32_t serial, bool available) override; + ::ndk::ScopedAStatus responseAcknowledgement() override; + ::ndk::ScopedAStatus sendCdmaSms( + int32_t serial, + const ::aidl::android::hardware::radio::messaging::CdmaSmsMessage& sms) override; + ::ndk::ScopedAStatus sendCdmaSmsExpectMore( + int32_t serial, + const ::aidl::android::hardware::radio::messaging::CdmaSmsMessage& sms) override; + ::ndk::ScopedAStatus sendImsSms( + int32_t serial, + const ::aidl::android::hardware::radio::messaging::ImsSmsMessage& message) override; + ::ndk::ScopedAStatus sendSms( + int32_t serial, + const ::aidl::android::hardware::radio::messaging::GsmSmsMessage& message) override; + ::ndk::ScopedAStatus sendSmsExpectMore( + int32_t serial, + const ::aidl::android::hardware::radio::messaging::GsmSmsMessage& message) override; + ::ndk::ScopedAStatus sendUssd(int32_t serial, const std::string& ussd) override; + ::ndk::ScopedAStatus setCdmaBroadcastActivation(int32_t serial, bool activate) override; + ::ndk::ScopedAStatus setCdmaBroadcastConfig( + int32_t serial, + const std::vector< + ::aidl::android::hardware::radio::messaging::CdmaBroadcastSmsConfigInfo>& + configInfo) override; + ::ndk::ScopedAStatus setGsmBroadcastActivation(int32_t serial, bool activate) override; + ::ndk::ScopedAStatus setGsmBroadcastConfig( + int32_t serial, + const std::vector< + ::aidl::android::hardware::radio::messaging::GsmBroadcastSmsConfigInfo>& + configInfo) override; + ::ndk::ScopedAStatus setResponseFunctions( + const std::shared_ptr< + ::aidl::android::hardware::radio::messaging::IRadioMessagingResponse>& + radioMessagingResponse, + const std::shared_ptr< + ::aidl::android::hardware::radio::messaging::IRadioMessagingIndication>& + radioMessagingIndication) override; + ::ndk::ScopedAStatus setSmscAddress(int32_t serial, const std::string& smsc) override; + ::ndk::ScopedAStatus writeSmsToRuim( + int32_t serial, + const ::aidl::android::hardware::radio::messaging::CdmaSmsWriteArgs& cdmaSms) override; + ::ndk::ScopedAStatus writeSmsToSim( + int32_t serial, + const ::aidl::android::hardware::radio::messaging::SmsWriteArgs& smsWriteArgs) 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 new file mode 100644 index 0000000000..121cc45687 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h @@ -0,0 +1,407 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +class RadioResponse : public V1_6::IRadioResponse { + std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingResponse> + mMessagingCb; + + // IRadioResponse @ 1.0 + Return getIccCardStatusResponse(const V1_0::RadioResponseInfo& info, + const V1_0::CardStatus& cardStatus) override; + Return supplyIccPinForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) override; + Return supplyIccPukForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) override; + Return supplyIccPin2ForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) override; + Return supplyIccPuk2ForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) override; + Return changeIccPinForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) override; + Return changeIccPin2ForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) override; + Return supplyNetworkDepersonalizationResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) override; + Return getCurrentCallsResponse(const V1_0::RadioResponseInfo& info, + const hidl_vec& calls) override; + Return dialResponse(const V1_0::RadioResponseInfo& info) override; + Return getIMSIForAppResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& imsi) override; + Return hangupConnectionResponse(const V1_0::RadioResponseInfo& info) override; + Return hangupWaitingOrBackgroundResponse(const V1_0::RadioResponseInfo& info) override; + Return hangupForegroundResumeBackgroundResponse( + const V1_0::RadioResponseInfo& info) override; + Return switchWaitingOrHoldingAndActiveResponse( + const V1_0::RadioResponseInfo& info) override; + Return conferenceResponse(const V1_0::RadioResponseInfo& info) override; + Return rejectCallResponse(const V1_0::RadioResponseInfo& info) override; + Return getLastCallFailCauseResponse( + const V1_0::RadioResponseInfo& info, + const V1_0::LastCallFailCauseInfo& failCauseinfo) override; + Return getSignalStrengthResponse(const V1_0::RadioResponseInfo& info, + const V1_0::SignalStrength& sigStrength) override; + Return getVoiceRegistrationStateResponse( + const V1_0::RadioResponseInfo& info, + const V1_0::VoiceRegStateResult& voiceRegResponse) override; + Return getDataRegistrationStateResponse( + const V1_0::RadioResponseInfo& info, + const V1_0::DataRegStateResult& dataRegResponse) override; + Return getOperatorResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& longName, const hidl_string& shortName, + const hidl_string& numeric) override; + Return setRadioPowerResponse(const V1_0::RadioResponseInfo& info) override; + Return sendDtmfResponse(const V1_0::RadioResponseInfo& info) override; + Return sendSmsResponse(const V1_0::RadioResponseInfo& info, + const V1_0::SendSmsResult& sms) override; + Return sendSMSExpectMoreResponse(const V1_0::RadioResponseInfo& info, + const V1_0::SendSmsResult& sms) override; + Return setupDataCallResponse(const V1_0::RadioResponseInfo& info, + const V1_0::SetupDataCallResult& dcResponse) override; + Return iccIOForAppResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& iccIo) override; + Return sendUssdResponse(const V1_0::RadioResponseInfo& info) override; + Return cancelPendingUssdResponse(const V1_0::RadioResponseInfo& info) override; + Return getClirResponse(const V1_0::RadioResponseInfo& info, int32_t n, + int32_t m) override; + Return setClirResponse(const V1_0::RadioResponseInfo& info) override; + Return getCallForwardStatusResponse( + const V1_0::RadioResponseInfo& info, + const hidl_vec& callForwardInfos) override; + Return setCallForwardResponse(const V1_0::RadioResponseInfo& info) override; + Return getCallWaitingResponse(const V1_0::RadioResponseInfo& info, bool enable, + int32_t serviceClass) override; + Return setCallWaitingResponse(const V1_0::RadioResponseInfo& info) override; + Return acknowledgeLastIncomingGsmSmsResponse( + const V1_0::RadioResponseInfo& info) override; + Return acceptCallResponse(const V1_0::RadioResponseInfo& info) override; + Return deactivateDataCallResponse(const V1_0::RadioResponseInfo& info) override; + Return getFacilityLockForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t response) override; + Return setFacilityLockForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t retry) override; + Return setBarringPasswordResponse(const V1_0::RadioResponseInfo& info) override; + Return getNetworkSelectionModeResponse(const V1_0::RadioResponseInfo& info, + bool manual) override; + Return setNetworkSelectionModeAutomaticResponse( + const V1_0::RadioResponseInfo& info) override; + Return setNetworkSelectionModeManualResponse( + const V1_0::RadioResponseInfo& info) override; + Return getAvailableNetworksResponse( + const V1_0::RadioResponseInfo& info, + const hidl_vec& networkInfos) override; + Return startDtmfResponse(const V1_0::RadioResponseInfo& info) override; + Return stopDtmfResponse(const V1_0::RadioResponseInfo& info) override; + Return getBasebandVersionResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& version) override; + Return separateConnectionResponse(const V1_0::RadioResponseInfo& info) override; + Return setMuteResponse(const V1_0::RadioResponseInfo& info) override; + Return getMuteResponse(const V1_0::RadioResponseInfo& info, bool enable) override; + Return getClipResponse(const V1_0::RadioResponseInfo& info, + V1_0::ClipStatus status) override; + Return getDataCallListResponse( + const V1_0::RadioResponseInfo& info, + const hidl_vec& dcResponse) override; + Return setSuppServiceNotificationsResponse(const V1_0::RadioResponseInfo& info) override; + Return writeSmsToSimResponse(const V1_0::RadioResponseInfo& info, int32_t index) override; + Return deleteSmsOnSimResponse(const V1_0::RadioResponseInfo& info) override; + Return setBandModeResponse(const V1_0::RadioResponseInfo& info) override; + Return getAvailableBandModesResponse( + const V1_0::RadioResponseInfo& info, + const hidl_vec& bandModes) override; + Return sendEnvelopeResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& commandResponse) override; + Return sendTerminalResponseToSimResponse(const V1_0::RadioResponseInfo& info) override; + Return handleStkCallSetupRequestFromSimResponse( + const V1_0::RadioResponseInfo& info) override; + Return explicitCallTransferResponse(const V1_0::RadioResponseInfo& info) override; + Return setPreferredNetworkTypeResponse(const V1_0::RadioResponseInfo& info) override; + Return getPreferredNetworkTypeResponse(const V1_0::RadioResponseInfo& info, + V1_0::PreferredNetworkType nwType) override; + Return getNeighboringCidsResponse(const V1_0::RadioResponseInfo& info, + const hidl_vec& cells) override; + Return setLocationUpdatesResponse(const V1_0::RadioResponseInfo& info) override; + Return setCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo& info) override; + Return setCdmaRoamingPreferenceResponse(const V1_0::RadioResponseInfo& info) override; + Return getCdmaRoamingPreferenceResponse(const V1_0::RadioResponseInfo& info, + V1_0::CdmaRoamingType type) override; + Return setTTYModeResponse(const V1_0::RadioResponseInfo& info) override; + Return getTTYModeResponse(const V1_0::RadioResponseInfo& info, + V1_0::TtyMode mode) override; + Return setPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo& info) override; + Return getPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo& info, + bool enable) override; + Return sendCDMAFeatureCodeResponse(const V1_0::RadioResponseInfo& info) override; + Return sendBurstDtmfResponse(const V1_0::RadioResponseInfo& info) override; + Return sendCdmaSmsResponse(const V1_0::RadioResponseInfo& info, + const V1_0::SendSmsResult& sms) override; + Return acknowledgeLastIncomingCdmaSmsResponse( + const V1_0::RadioResponseInfo& info) override; + Return getGsmBroadcastConfigResponse( + const V1_0::RadioResponseInfo& info, + const hidl_vec& configs) override; + Return setGsmBroadcastConfigResponse(const V1_0::RadioResponseInfo& info) override; + Return setGsmBroadcastActivationResponse(const V1_0::RadioResponseInfo& info) override; + Return getCdmaBroadcastConfigResponse( + const V1_0::RadioResponseInfo& info, + const hidl_vec& configs) override; + Return setCdmaBroadcastConfigResponse(const V1_0::RadioResponseInfo& info) override; + Return setCdmaBroadcastActivationResponse(const V1_0::RadioResponseInfo& info) override; + Return getCDMASubscriptionResponse( // + const V1_0::RadioResponseInfo& info, const hidl_string& mdn, const hidl_string& hSid, + const hidl_string& hNid, const hidl_string& min, const hidl_string& prl) override; + Return writeSmsToRuimResponse(const V1_0::RadioResponseInfo& info, + uint32_t index) override; + Return deleteSmsOnRuimResponse(const V1_0::RadioResponseInfo& info) override; + Return getDeviceIdentityResponse( // + const V1_0::RadioResponseInfo& info, const hidl_string& imei, const hidl_string& imeisv, + const hidl_string& esn, const hidl_string& meid) override; + Return exitEmergencyCallbackModeResponse(const V1_0::RadioResponseInfo& info) override; + Return getSmscAddressResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& smsc) override; + Return setSmscAddressResponse(const V1_0::RadioResponseInfo& info) override; + Return reportSmsMemoryStatusResponse(const V1_0::RadioResponseInfo& info) override; + Return reportStkServiceIsRunningResponse(const V1_0::RadioResponseInfo& info) override; + Return getCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo& info, + V1_0::CdmaSubscriptionSource source) override; + Return requestIsimAuthenticationResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& response) override; + Return acknowledgeIncomingGsmSmsWithPduResponse( + const V1_0::RadioResponseInfo& info) override; + Return sendEnvelopeWithStatusResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& iccIo) override; + Return getVoiceRadioTechnologyResponse(const V1_0::RadioResponseInfo& info, + V1_0::RadioTechnology rat) override; + Return getCellInfoListResponse(const V1_0::RadioResponseInfo& info, + const hidl_vec& cellInfo) override; + Return setCellInfoListRateResponse(const V1_0::RadioResponseInfo& info) override; + Return setInitialAttachApnResponse(const V1_0::RadioResponseInfo& info) override; + Return getImsRegistrationStateResponse(const V1_0::RadioResponseInfo& info, + bool isRegistered, + V1_0::RadioTechnologyFamily ratFamily) override; + Return sendImsSmsResponse(const V1_0::RadioResponseInfo& info, + const V1_0::SendSmsResult& sms) override; + Return iccTransmitApduBasicChannelResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& result) override; + Return iccOpenLogicalChannelResponse(const V1_0::RadioResponseInfo& info, + int32_t channelId, + const hidl_vec& selectResponse) override; + Return iccCloseLogicalChannelResponse(const V1_0::RadioResponseInfo& info) override; + Return iccTransmitApduLogicalChannelResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& result) override; + Return nvReadItemResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& result) override; + Return nvWriteItemResponse(const V1_0::RadioResponseInfo& info) override; + Return nvWriteCdmaPrlResponse(const V1_0::RadioResponseInfo& info) override; + Return nvResetConfigResponse(const V1_0::RadioResponseInfo& info) override; + Return setUiccSubscriptionResponse(const V1_0::RadioResponseInfo& info) override; + Return setDataAllowedResponse(const V1_0::RadioResponseInfo& info) override; + Return getHardwareConfigResponse(const V1_0::RadioResponseInfo& info, + const hidl_vec& config) override; + Return requestIccSimAuthenticationResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& result) override; + Return setDataProfileResponse(const V1_0::RadioResponseInfo& info) override; + Return requestShutdownResponse(const V1_0::RadioResponseInfo& info) override; + Return getRadioCapabilityResponse(const V1_0::RadioResponseInfo& info, + const V1_0::RadioCapability& rc) override; + Return setRadioCapabilityResponse(const V1_0::RadioResponseInfo& info, + const V1_0::RadioCapability& rc) override; + Return startLceServiceResponse(const V1_0::RadioResponseInfo& info, + const V1_0::LceStatusInfo& statusInfo) override; + Return stopLceServiceResponse(const V1_0::RadioResponseInfo& info, + const V1_0::LceStatusInfo& statusInfo) override; + Return pullLceDataResponse(const V1_0::RadioResponseInfo& info, + const V1_0::LceDataInfo& lceInfo) override; + Return getModemActivityInfoResponse(const V1_0::RadioResponseInfo& info, + const V1_0::ActivityStatsInfo& activityInfo) override; + Return setAllowedCarriersResponse(const V1_0::RadioResponseInfo& info, + int32_t numAllowed) override; + Return getAllowedCarriersResponse(const V1_0::RadioResponseInfo& info, bool allAllowed, + const V1_0::CarrierRestrictions& carriers) override; + Return sendDeviceStateResponse(const V1_0::RadioResponseInfo& info) override; + Return setIndicationFilterResponse(const V1_0::RadioResponseInfo& info) override; + Return setSimCardPowerResponse(const V1_0::RadioResponseInfo& info) override; + Return acknowledgeRequest(int32_t serial) override; + + // IRadioResponse @ 1.1 + Return setCarrierInfoForImsiEncryptionResponse( + const V1_0::RadioResponseInfo& info) override; + Return setSimCardPowerResponse_1_1(const V1_0::RadioResponseInfo& info) override; + Return startNetworkScanResponse(const V1_0::RadioResponseInfo& info) override; + Return stopNetworkScanResponse(const V1_0::RadioResponseInfo& info) override; + Return startKeepaliveResponse(const V1_0::RadioResponseInfo& info, + const V1_1::KeepaliveStatus& status) override; + Return stopKeepaliveResponse(const V1_0::RadioResponseInfo& info) override; + + // IRadioResponse @ 1.2 + Return getCellInfoListResponse_1_2(const V1_0::RadioResponseInfo& info, + const hidl_vec& cellInfo) override; + Return getIccCardStatusResponse_1_2(const V1_0::RadioResponseInfo& info, + const V1_2::CardStatus& cardStatus) override; + Return setSignalStrengthReportingCriteriaResponse( + const V1_0::RadioResponseInfo& info) override; + Return setLinkCapacityReportingCriteriaResponse( + const V1_0::RadioResponseInfo& info) override; + Return getCurrentCallsResponse_1_2(const V1_0::RadioResponseInfo& info, + const hidl_vec& calls) override; + Return getSignalStrengthResponse_1_2(const V1_0::RadioResponseInfo& info, + const V1_2::SignalStrength& signalStrength) override; + Return getVoiceRegistrationStateResponse_1_2( + const V1_0::RadioResponseInfo& info, + const V1_2::VoiceRegStateResult& voiceRegResponse) override; + Return getDataRegistrationStateResponse_1_2( + const V1_0::RadioResponseInfo& info, + const V1_2::DataRegStateResult& dataRegResponse) override; + + // IRadioResponse @ 1.3 + Return setSystemSelectionChannelsResponse(const V1_0::RadioResponseInfo& info) override; + Return enableModemResponse(const V1_0::RadioResponseInfo& info) override; + Return getModemStackStatusResponse(const V1_0::RadioResponseInfo& info, + bool isEnabled) override; + + // IRadioResponse @ 1.4 + Return emergencyDialResponse(const V1_0::RadioResponseInfo& info) override; + Return startNetworkScanResponse_1_4(const V1_0::RadioResponseInfo& info) override; + Return getCellInfoListResponse_1_4(const V1_0::RadioResponseInfo& info, + const hidl_vec& cellInfo) override; + Return getDataRegistrationStateResponse_1_4( + const V1_0::RadioResponseInfo& info, + const V1_4::DataRegStateResult& dataRegResponse) override; + Return getIccCardStatusResponse_1_4(const V1_0::RadioResponseInfo& info, + const V1_4::CardStatus& cardStatus) override; + Return getPreferredNetworkTypeBitmapResponse( + const V1_0::RadioResponseInfo& info, + hidl_bitfield networkTypeBitmap) override; + Return setPreferredNetworkTypeBitmapResponse( + const V1_0::RadioResponseInfo& info) override; + Return getDataCallListResponse_1_4( + const V1_0::RadioResponseInfo& info, + const hidl_vec& dcResponse) override; + Return setupDataCallResponse_1_4(const V1_0::RadioResponseInfo& info, + const V1_4::SetupDataCallResult& dcResponse) override; + Return setAllowedCarriersResponse_1_4(const V1_0::RadioResponseInfo& info) override; + Return getAllowedCarriersResponse_1_4( + const V1_0::RadioResponseInfo& info, + const V1_4::CarrierRestrictionsWithPriority& carriers, + V1_4::SimLockMultiSimPolicy multiSimPolicy) override; + Return getSignalStrengthResponse_1_4(const V1_0::RadioResponseInfo& info, + const V1_4::SignalStrength& signalStrength) override; + + // IRadioResponse @ 1.5 + Return setSignalStrengthReportingCriteriaResponse_1_5( + const V1_0::RadioResponseInfo& info) override; + Return setLinkCapacityReportingCriteriaResponse_1_5( + const V1_0::RadioResponseInfo& info) override; + Return enableUiccApplicationsResponse(const V1_0::RadioResponseInfo& info) override; + Return areUiccApplicationsEnabledResponse(const V1_0::RadioResponseInfo& info, + bool enabled) override; + Return setSystemSelectionChannelsResponse_1_5( + const V1_0::RadioResponseInfo& info) override; + Return startNetworkScanResponse_1_5(const V1_0::RadioResponseInfo& info) override; + Return setupDataCallResponse_1_5(const V1_0::RadioResponseInfo& info, + const V1_5::SetupDataCallResult& dcResponse) override; + Return getDataCallListResponse_1_5( + const V1_0::RadioResponseInfo& info, + const hidl_vec& dcResponse) override; + Return setInitialAttachApnResponse_1_5(const V1_0::RadioResponseInfo& info) override; + Return setDataProfileResponse_1_5(const V1_0::RadioResponseInfo& info) override; + Return setRadioPowerResponse_1_5(const V1_0::RadioResponseInfo& info) override; + Return setIndicationFilterResponse_1_5(const V1_0::RadioResponseInfo& info) override; + Return getBarringInfoResponse(const V1_0::RadioResponseInfo& info, + const V1_5::CellIdentity& cellIdentity, + const hidl_vec& barringInfos) override; + Return getVoiceRegistrationStateResponse_1_5( + const V1_0::RadioResponseInfo& info, + const V1_5::RegStateResult& voiceRegResponse) override; + Return getDataRegistrationStateResponse_1_5( + const V1_0::RadioResponseInfo& info, + const V1_5::RegStateResult& dataRegResponse) override; + Return getCellInfoListResponse_1_5(const V1_0::RadioResponseInfo& info, + const hidl_vec& cellInfo) override; + Return setNetworkSelectionModeManualResponse_1_5( + const V1_0::RadioResponseInfo& info) override; + Return sendCdmaSmsExpectMoreResponse(const V1_0::RadioResponseInfo& info, + const V1_0::SendSmsResult& sms) override; + Return supplySimDepersonalizationResponse(const V1_0::RadioResponseInfo& info, + V1_5::PersoSubstate persoType, + int32_t remainingRetries) override; + Return getIccCardStatusResponse_1_5(const V1_0::RadioResponseInfo& info, + const V1_5::CardStatus& cardStatus) override; + + // IRadioResponse @ 1.6 + Return setRadioPowerResponse_1_6(const V1_6::RadioResponseInfo& info) override; + Return setupDataCallResponse_1_6(const V1_6::RadioResponseInfo& info, + const V1_6::SetupDataCallResult& dcResponse) override; + Return getDataCallListResponse_1_6( + const V1_6::RadioResponseInfo& info, + const hidl_vec& dcResponse) override; + Return sendSmsResponse_1_6(const V1_6::RadioResponseInfo& info, + const V1_0::SendSmsResult& sms) override; + Return sendSmsExpectMoreResponse_1_6(const V1_6::RadioResponseInfo& info, + const V1_0::SendSmsResult& sms) override; + Return sendCdmaSmsResponse_1_6(const V1_6::RadioResponseInfo& info, + const V1_0::SendSmsResult& sms) override; + Return sendCdmaSmsExpectMoreResponse_1_6(const V1_6::RadioResponseInfo& info, + const V1_0::SendSmsResult& sms) override; + Return setSimCardPowerResponse_1_6(const V1_6::RadioResponseInfo& info) override; + Return setNrDualConnectivityStateResponse(const V1_6::RadioResponseInfo& info) override; + Return isNrDualConnectivityEnabledResponse(const V1_6::RadioResponseInfo& info, + bool isEnabled) override; + Return allocatePduSessionIdResponse(const V1_6::RadioResponseInfo& info, + int32_t id) override; + Return releasePduSessionIdResponse(const V1_6::RadioResponseInfo& info) override; + Return startHandoverResponse(const V1_6::RadioResponseInfo& info) override; + Return cancelHandoverResponse(const V1_6::RadioResponseInfo& info) override; + Return setAllowedNetworkTypesBitmapResponse(const V1_6::RadioResponseInfo& info) override; + Return getAllowedNetworkTypesBitmapResponse( + const V1_6::RadioResponseInfo& info, + hidl_bitfield networkTypeBitmap) override; + Return setDataThrottlingResponse(const V1_6::RadioResponseInfo& info) override; + Return getSystemSelectionChannelsResponse( + const V1_6::RadioResponseInfo& info, + const hidl_vec& specifiers) override; + Return getCellInfoListResponse_1_6(const V1_6::RadioResponseInfo& info, + const hidl_vec& cellInfo) override; + Return getSignalStrengthResponse_1_6(const V1_6::RadioResponseInfo& info, + const V1_6::SignalStrength& signalStrength) override; + Return getVoiceRegistrationStateResponse_1_6( + const V1_6::RadioResponseInfo& info, + const V1_6::RegStateResult& voiceRegResponse) override; + Return getDataRegistrationStateResponse_1_6( + const V1_6::RadioResponseInfo& info, + const V1_6::RegStateResult& dataRegResponse) override; + Return getCurrentCallsResponse_1_6(const V1_6::RadioResponseInfo& info, + const hidl_vec& calls) override; + Return getSlicingConfigResponse(const V1_6::RadioResponseInfo& info, + const V1_6::SlicingConfig& slicingConfig) override; + Return getSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo& info) override; + Return getSimPhonebookCapacityResponse(const V1_6::RadioResponseInfo& info, + const V1_6::PhonebookCapacity& capacity) override; + Return updateSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo& info, + int32_t updatedRecordIndex) override; + + public: + void setResponseFunction( + std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingResponse> + radioMessagingResponse); +}; + +} // namespace android::hardware::radio::compat 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 0000000000..c7342b1146 --- /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 + +#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 rmiCb) { + CHECK(rmiCb); + mMessagingCb = rmiCb; +} + +Return 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 RadioIndication::cdmaRuimSmsStorageFull(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mMessagingCb); + mMessagingCb->cdmaRuimSmsStorageFull(toAidl(type)); + return {}; +} + +Return RadioIndication::newBroadcastSms(V1_0::RadioIndicationType type, + const hidl_vec& data) { + LOG_CALL << type; + CHECK_CB(mMessagingCb); + mMessagingCb->newBroadcastSms(toAidl(type), data); + return {}; +} + +Return RadioIndication::newSms(V1_0::RadioIndicationType type, const hidl_vec& pdu) { + LOG_CALL << type; + CHECK_CB(mMessagingCb); + mMessagingCb->newSms(toAidl(type), pdu); + return {}; +} + +Return RadioIndication::newSmsOnSim(V1_0::RadioIndicationType type, int32_t recordNumber) { + LOG_CALL << type; + CHECK_CB(mMessagingCb); + mMessagingCb->newSmsOnSim(toAidl(type), recordNumber); + return {}; +} + +Return RadioIndication::newSmsStatusReport(V1_0::RadioIndicationType type, + const hidl_vec& pdu) { + LOG_CALL << type; + CHECK_CB(mMessagingCb); + mMessagingCb->newSmsStatusReport(toAidl(type), pdu); + return {}; +} + +Return 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 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 0000000000..c1a82b566f --- /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 + +#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& 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& configInfo) { + LOG_CALL << serial; + mHal1_5->setGsmBroadcastConfig(serial, toHidl(configInfo)); + return ok(); +} + +ScopedAStatus RadioMessaging::setResponseFunctions( + const std::shared_ptr& messagingResponse, + const std::shared_ptr& 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 0000000000..379e4630af --- /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 + +#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 rmrCb) { + CHECK(rmrCb); + mMessagingCb = rmrCb; +} + +Return RadioResponse::acknowledgeIncomingGsmSmsWithPduResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->acknowledgeIncomingGsmSmsWithPduResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::acknowledgeLastIncomingCdmaSmsResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->acknowledgeLastIncomingCdmaSmsResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::acknowledgeLastIncomingGsmSmsResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->acknowledgeLastIncomingGsmSmsResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::cancelPendingUssdResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->cancelPendingUssdResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::deleteSmsOnRuimResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->deleteSmsOnRuimResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::deleteSmsOnSimResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->deleteSmsOnSimResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::getCdmaBroadcastConfigResponse( + const V1_0::RadioResponseInfo& info, + const hidl_vec& configs) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->getCdmaBroadcastConfigResponse(toAidl(info), toAidl(configs)); + return {}; +} + +Return RadioResponse::getGsmBroadcastConfigResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& cfg) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->getGsmBroadcastConfigResponse(toAidl(info), toAidl(cfg)); + return {}; +} + +Return 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 RadioResponse::reportSmsMemoryStatusResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->reportSmsMemoryStatusResponse(toAidl(info)); + return {}; +} + +Return 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 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 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 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 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 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 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 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 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 RadioResponse::sendUssdResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->sendUssdResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setCdmaBroadcastActivationResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->setCdmaBroadcastActivationResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setCdmaBroadcastConfigResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->setCdmaBroadcastConfigResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setGsmBroadcastActivationResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->setGsmBroadcastActivationResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setGsmBroadcastConfigResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->setGsmBroadcastConfigResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setSmscAddressResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mMessagingCb); + mMessagingCb->setSmscAddressResponse(toAidl(info)); + return {}; +} + +Return 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 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 0000000000..90196802e1 --- /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 +#include + +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(addr.digitMode), + .isNumberModeDataNetwork = addr.numberMode == V1_0::CdmaSmsNumberMode::DATA_NETWORK, + .numberType = static_cast(addr.numberType), + .numberPlan = static_cast(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(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 0000000000..afb49419f7 --- /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 +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 diff --git a/radio/aidl/compat/service/Android.bp b/radio/aidl/compat/service/Android.bp index f708b84764..82ab81f7a4 100644 --- a/radio/aidl/compat/service/Android.bp +++ b/radio/aidl/compat/service/Android.bp @@ -39,6 +39,14 @@ cc_binary { "android.hardware.radio.config@1.1", "android.hardware.radio.config@1.2", "android.hardware.radio.config@1.3", + "android.hardware.radio.messaging-V1-ndk", + "android.hardware.radio@1.0", + "android.hardware.radio@1.1", + "android.hardware.radio@1.2", + "android.hardware.radio@1.3", + "android.hardware.radio@1.4", + "android.hardware.radio@1.5", + "android.hardware.radio@1.6", "libbase", "libbinder_ndk", "libhidlbase", diff --git a/radio/aidl/compat/service/hidl-utils.cpp b/radio/aidl/compat/service/hidl-utils.cpp index d8949666af..fc0d54db9f 100644 --- a/radio/aidl/compat/service/hidl-utils.cpp +++ b/radio/aidl/compat/service/hidl-utils.cpp @@ -17,6 +17,7 @@ #include "hidl-utils.h" #include +#include namespace android::hardware::hidl_utils { @@ -33,4 +34,13 @@ void linkDeathToDeath(sp<::android::hidl::base::V1_0::IBase> hal) { CHECK(linkStatus.withDefault(false)) << "Failed to link to HAL death"; } +hidl_vec listManifestByInterface(const char* descriptor) { + auto manager = hidl::manager::V1_2::IServiceManager::getService(); + hidl_vec services; + manager->listManifestByInterface(descriptor, hidl_utils::fill(&services)); + CHECK_GT(services.size(), 0u) << "No " << descriptor + << " services in manifest (missing privileges?)" << std::endl; + return services; +} + } // namespace android::hardware::hidl_utils diff --git a/radio/aidl/compat/service/hidl-utils.h b/radio/aidl/compat/service/hidl-utils.h index 3f81a9b96f..be3386fb6e 100644 --- a/radio/aidl/compat/service/hidl-utils.h +++ b/radio/aidl/compat/service/hidl-utils.h @@ -18,13 +18,61 @@ #include +#include + namespace android::hardware::hidl_utils { /** - * Link to a given HALs death and restart the current process in such a case. + * Helper functor to fetch results from multi-return HIDL calls. + * It's meant to be used in place of _hidl_cb callbacks. * + * Please note extracting these return variables outside of the callback scope requires making + * a copy of each return variable. This may be costly for frequently called HIDL methods with + * non-negligible return object size. Please be cautious about performance when using this. + * + * Example usage: + * Result result; + * sp iface; + * hidlObject->someMethod(arg1, arg2, hidl_utils::fill(&result, &iface)).assertOk(); + * // use result and iface + */ +template +struct fill : public std::function { + /** + * Create _hidl_cb functor that copies the call arguments to specified pointers. + * + * \param args... Targets to copy the call arguments to + */ + fill(T*... args) : mTargets(args...) {} + + void operator()(const T&... args) { copy<0, T...>(args...); } + + private: + std::tuple mTargets; + + template + inline void copy(const First& first) { + *std::get(mTargets) = first; + } + + template + inline void copy(const First& first, const Rest&... rest) { + *std::get(mTargets) = first; + copy(rest...); + } +}; + +/** + * Link to a given HALs death and restart the current process in such a case. * \param hal HAL to which death to link */ void linkDeathToDeath(sp hal); +/** + * List HAL instances of a given interface. + * + * \descriptor HIDL HAL descriptor + */ +hidl_vec listManifestByInterface(const char* descriptor); + } // namespace android::hardware::hidl_utils diff --git a/radio/aidl/compat/service/radio-compat.xml b/radio/aidl/compat/service/radio-compat.xml index 60f8ff5d7c..781f2f41c8 100644 --- a/radio/aidl/compat/service/radio-compat.xml +++ b/radio/aidl/compat/service/radio-compat.xml @@ -3,4 +3,15 @@ android.hardware.radio.config IRadioConfig/default + diff --git a/radio/aidl/compat/service/service.cpp b/radio/aidl/compat/service/service.cpp index c177dd1233..4d34cf120e 100644 --- a/radio/aidl/compat/service/service.cpp +++ b/radio/aidl/compat/service/service.cpp @@ -20,6 +20,9 @@ #include #include #include +#include +#include +#include namespace android::hardware::radio::service { @@ -27,6 +30,35 @@ using namespace std::string_literals; static std::vector> gPublishedHals; +template +static void publishRadioHal(sp hidlHal, sp responseCb, + sp indicationCb, const std::string& slot) { + const auto instance = T::descriptor + "/"s + slot; + if (!AServiceManager_isDeclared(instance.c_str())) { + LOG(INFO) << instance << " is not declared in VINTF (this may be intentional)"; + return; + } + LOG(DEBUG) << "Publishing " << instance; + + auto aidlHal = ndk::SharedRefBase::make(hidlHal, responseCb, indicationCb); + gPublishedHals.push_back(aidlHal); + const auto status = AServiceManager_addService(aidlHal->asBinder().get(), instance.c_str()); + CHECK_EQ(status, STATUS_OK); +} + +static void publishRadio(std::string slot) { + auto radioHidl = V1_5::IRadio::getService(slot); + CHECK(radioHidl) << "HIDL IRadio not present in VINTF"; + + hidl_utils::linkDeathToDeath(radioHidl); + + auto responseCb = sp::make(); + auto indicationCb = sp::make(); + radioHidl->setResponseFunctions(responseCb, indicationCb).assertOk(); + + publishRadioHal(radioHidl, responseCb, indicationCb, slot); +} + static void publishRadioConfig() { auto hidlHal = config::V1_1::IRadioConfig::getService(); CHECK(hidlHal) << "HIDL IRadioConfig not present in VINTF"; @@ -47,6 +79,12 @@ static void main() { publishRadioConfig(); + const auto slots = hidl_utils::listManifestByInterface(V1_0::IRadio::descriptor); + LOG(INFO) << "Found " << slots.size() << " slot(s)"; + for (const auto& slot : slots) { + publishRadio(slot); + } + LOG(DEBUG) << "Radio HAL compat service is operational"; ABinderProcess_joinThreadPool(); LOG(FATAL) << "Radio HAL compat service has stopped"; From 7f51a9ad1e2c487cd916dae7eb891bbdbc32ab18 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Thu, 28 Oct 2021 13:22:47 -0700 Subject: [PATCH 3/7] Implement RadioSim for AIDL-HIDL Telephony HAL translator Bug: 203699028 Test: Boot and grep logcat against radiocompat Change-Id: I82d27049858e578522b83811a787b259e67d00a4 --- radio/aidl/compat/libradiocompat/Android.bp | 5 + .../compat/libradiocompat/RadioIndication.cpp | 52 --- .../compat/libradiocompat/RadioResponse.cpp | 204 +--------- .../compat/libradiocompat/commonStructs.cpp | 12 + .../compat/libradiocompat/commonStructs.h | 4 + .../include/libradiocompat/RadioIndication.h | 4 + .../include/libradiocompat/RadioResponse.h | 4 + .../include/libradiocompat/RadioSim.h | 107 +++++ .../sim/RadioIndication-sim.cpp | 121 ++++++ .../libradiocompat/sim/RadioResponse-sim.cpp | 366 ++++++++++++++++++ .../compat/libradiocompat/sim/RadioSim.cpp | 295 ++++++++++++++ .../compat/libradiocompat/sim/structs.cpp | 221 +++++++++++ .../aidl/compat/libradiocompat/sim/structs.h | 75 ++++ radio/aidl/compat/service/Android.bp | 1 + radio/aidl/compat/service/radio-compat.xml | 4 + radio/aidl/compat/service/service.cpp | 2 + 16 files changed, 1223 insertions(+), 254 deletions(-) create mode 100644 radio/aidl/compat/libradiocompat/include/libradiocompat/RadioSim.h create mode 100644 radio/aidl/compat/libradiocompat/sim/RadioIndication-sim.cpp create mode 100644 radio/aidl/compat/libradiocompat/sim/RadioResponse-sim.cpp create mode 100644 radio/aidl/compat/libradiocompat/sim/RadioSim.cpp create mode 100644 radio/aidl/compat/libradiocompat/sim/structs.cpp create mode 100644 radio/aidl/compat/libradiocompat/sim/structs.h diff --git a/radio/aidl/compat/libradiocompat/Android.bp b/radio/aidl/compat/libradiocompat/Android.bp index 00c1db658d..bf2c80c824 100644 --- a/radio/aidl/compat/libradiocompat/Android.bp +++ b/radio/aidl/compat/libradiocompat/Android.bp @@ -38,6 +38,7 @@ cc_library { "android.hardware.radio.config@1.2", "android.hardware.radio.config@1.3", "android.hardware.radio.messaging-V1-ndk", + "android.hardware.radio.sim-V1-ndk", "android.hardware.radio@1.0", "android.hardware.radio@1.1", "android.hardware.radio@1.2", @@ -63,6 +64,10 @@ cc_library { "messaging/RadioMessaging.cpp", "messaging/RadioResponse-messaging.cpp", "messaging/structs.cpp", + "sim/RadioIndication-sim.cpp", + "sim/RadioResponse-sim.cpp", + "sim/RadioSim.cpp", + "sim/structs.cpp", ], export_include_dirs: ["include"], } diff --git a/radio/aidl/compat/libradiocompat/RadioIndication.cpp b/radio/aidl/compat/libradiocompat/RadioIndication.cpp index 5cbb954229..69836e2990 100644 --- a/radio/aidl/compat/libradiocompat/RadioIndication.cpp +++ b/radio/aidl/compat/libradiocompat/RadioIndication.cpp @@ -54,38 +54,15 @@ Return RadioIndication::suppSvcNotify(V1_0::RadioIndicationType type, return {}; } -Return RadioIndication::stkSessionEnd(V1_0::RadioIndicationType type) { - return {}; -} - -Return RadioIndication::stkProactiveCommand(V1_0::RadioIndicationType type, - const hidl_string& cmd) { - return {}; -} - -Return RadioIndication::stkEventNotify(V1_0::RadioIndicationType type, - const hidl_string& cmd) { - return {}; -} - Return RadioIndication::stkCallSetup(V1_0::RadioIndicationType type, int64_t timeout) { return {}; } -Return RadioIndication::simRefresh(V1_0::RadioIndicationType type, - const V1_0::SimRefreshResult& refreshResult) { - return {}; -} - Return RadioIndication::callRing(V1_0::RadioIndicationType type, bool isGsm, const V1_0::CdmaSignalInfoRecord& record) { return {}; } -Return RadioIndication::simStatusChanged(V1_0::RadioIndicationType type) { - return {}; -} - Return RadioIndication::restrictedStateChanged(V1_0::RadioIndicationType type, V1_0::PhoneRestrictedState state) { return {}; @@ -118,11 +95,6 @@ Return RadioIndication::resendIncallMute(V1_0::RadioIndicationType type) { return {}; } -Return RadioIndication::cdmaSubscriptionSourceChanged( - V1_0::RadioIndicationType type, V1_0::CdmaSubscriptionSource cdmaSource) { - return {}; -} - Return RadioIndication::cdmaPrlChanged(V1_0::RadioIndicationType type, int32_t version) { return {}; } @@ -149,11 +121,6 @@ Return RadioIndication::imsNetworkStateChanged(V1_0::RadioIndicationType t return {}; } -Return RadioIndication::subscriptionStatusChanged(V1_0::RadioIndicationType type, - bool activate) { - return {}; -} - Return RadioIndication::srvccStateNotify(V1_0::RadioIndicationType type, V1_0::SrvccState state) { return {}; @@ -194,10 +161,6 @@ Return RadioIndication::modemReset(V1_0::RadioIndicationType type, return {}; } -Return RadioIndication::carrierInfoForImsiEncryption(V1_0::RadioIndicationType info) { - return {}; -} - Return RadioIndication::networkScanResult(V1_0::RadioIndicationType type, const V1_1::NetworkScanResult& result) { return {}; @@ -263,11 +226,6 @@ Return RadioIndication::currentSignalStrength_1_4( return {}; } -Return RadioIndication::uiccApplicationsEnablementChanged(V1_0::RadioIndicationType type, - bool enabled) { - return {}; -} - Return RadioIndication::registrationFailed( // V1_0::RadioIndicationType type, const V1_5::CellIdentity& cellIdentity, const hidl_string& chosenPlmn, hidl_bitfield domain, int32_t causeCode, @@ -331,14 +289,4 @@ Return RadioIndication::currentPhysicalChannelConfigs_1_6( return {}; } -Return RadioIndication::simPhonebookChanged(V1_0::RadioIndicationType type) { - return {}; -} - -Return RadioIndication::simPhonebookRecordsReceived( - V1_0::RadioIndicationType type, V1_6::PbReceivedStatus status, - const hidl_vec& records) { - return {}; -} - } // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/RadioResponse.cpp b/radio/aidl/compat/libradiocompat/RadioResponse.cpp index 15002a8490..587e497693 100644 --- a/radio/aidl/compat/libradiocompat/RadioResponse.cpp +++ b/radio/aidl/compat/libradiocompat/RadioResponse.cpp @@ -27,42 +27,9 @@ namespace android::hardware::radio::compat { Return RadioResponse::acknowledgeRequest(int32_t serial) { LOG_CALL << serial; + // TODO(b/203699028): send to correct requestor or confirm if spam is not a problem if (mMessagingCb) mMessagingCb->acknowledgeRequest(serial); - return {}; -} - -Return RadioResponse::getIccCardStatusResponse(const V1_0::RadioResponseInfo& info, - const V1_0::CardStatus& cardStatus) { - return {}; -} - -Return RadioResponse::supplyIccPinForAppResponse(const V1_0::RadioResponseInfo& info, - int32_t remainingRetries) { - return {}; -} - -Return RadioResponse::supplyIccPukForAppResponse(const V1_0::RadioResponseInfo& info, - int32_t remainingRetries) { - return {}; -} - -Return RadioResponse::supplyIccPin2ForAppResponse(const V1_0::RadioResponseInfo& info, - int32_t remainingRetries) { - return {}; -} - -Return RadioResponse::supplyIccPuk2ForAppResponse(const V1_0::RadioResponseInfo& info, - int32_t remainingRetries) { - return {}; -} - -Return RadioResponse::changeIccPinForAppResponse(const V1_0::RadioResponseInfo& info, - int32_t remainingRetries) { - return {}; -} - -Return RadioResponse::changeIccPin2ForAppResponse(const V1_0::RadioResponseInfo& info, - int32_t remainingRetries) { + if (mSimCb) mSimCb->acknowledgeRequest(serial); return {}; } @@ -80,11 +47,6 @@ Return RadioResponse::dialResponse(const V1_0::RadioResponseInfo& info) { return {}; } -Return RadioResponse::getIMSIForAppResponse(const V1_0::RadioResponseInfo& info, - const hidl_string& imsi) { - return {}; -} - Return RadioResponse::hangupConnectionResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -150,11 +112,6 @@ Return RadioResponse::setupDataCallResponse(const V1_0::RadioResponseInfo& return {}; } -Return RadioResponse::iccIOForAppResponse(const V1_0::RadioResponseInfo& info, - const V1_0::IccIoResult& iccIo) { - return {}; -} - Return RadioResponse::getClirResponse(const V1_0::RadioResponseInfo& info, int32_t n, int32_t m) { return {}; @@ -190,16 +147,6 @@ Return RadioResponse::deactivateDataCallResponse(const V1_0::RadioResponse return {}; } -Return RadioResponse::getFacilityLockForAppResponse(const V1_0::RadioResponseInfo& info, - int32_t response) { - return {}; -} - -Return RadioResponse::setFacilityLockForAppResponse(const V1_0::RadioResponseInfo& info, - int32_t retry) { - return {}; -} - Return RadioResponse::setBarringPasswordResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -273,15 +220,6 @@ Return RadioResponse::getAvailableBandModesResponse( return {}; } -Return RadioResponse::sendEnvelopeResponse(const V1_0::RadioResponseInfo& info, - const hidl_string& commandResponse) { - return {}; -} - -Return RadioResponse::sendTerminalResponseToSimResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::handleStkCallSetupRequestFromSimResponse( const V1_0::RadioResponseInfo& info) { return {}; @@ -309,10 +247,6 @@ Return RadioResponse::setLocationUpdatesResponse(const V1_0::RadioResponse return {}; } -Return RadioResponse::setCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::setCdmaRoamingPreferenceResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -348,12 +282,6 @@ Return RadioResponse::sendBurstDtmfResponse(const V1_0::RadioResponseInfo& return {}; } -Return RadioResponse::getCDMASubscriptionResponse( - const V1_0::RadioResponseInfo& info, const hidl_string& mdn, const hidl_string& hSid, - const hidl_string& hNid, const hidl_string& min, const hidl_string& prl) { - 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) { @@ -364,25 +292,6 @@ Return RadioResponse::exitEmergencyCallbackModeResponse(const V1_0::RadioR return {}; } -Return RadioResponse::reportStkServiceIsRunningResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo& info, - V1_0::CdmaSubscriptionSource source) { - return {}; -} - -Return RadioResponse::requestIsimAuthenticationResponse(const V1_0::RadioResponseInfo& info, - const hidl_string& response) { - return {}; -} - -Return RadioResponse::sendEnvelopeWithStatusResponse(const V1_0::RadioResponseInfo& info, - const V1_0::IccIoResult& iccIo) { - return {}; -} - Return RadioResponse::getVoiceRadioTechnologyResponse(const V1_0::RadioResponseInfo& info, V1_0::RadioTechnology rat) { return {}; @@ -406,25 +315,6 @@ Return RadioResponse::getImsRegistrationStateResponse( // return {}; } -Return RadioResponse::iccTransmitApduBasicChannelResponse(const V1_0::RadioResponseInfo& info, - const V1_0::IccIoResult& result) { - return {}; -} - -Return RadioResponse::iccOpenLogicalChannelResponse( // - const V1_0::RadioResponseInfo& info, int32_t chanId, const hidl_vec& selectResp) { - return {}; -} - -Return RadioResponse::iccCloseLogicalChannelResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::iccTransmitApduLogicalChannelResponse( - const V1_0::RadioResponseInfo& info, const V1_0::IccIoResult& result) { - return {}; -} - Return RadioResponse::nvReadItemResponse(const V1_0::RadioResponseInfo& info, const hidl_string& result) { return {}; @@ -442,10 +332,6 @@ Return RadioResponse::nvResetConfigResponse(const V1_0::RadioResponseInfo& return {}; } -Return RadioResponse::setUiccSubscriptionResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::setDataAllowedResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -455,11 +341,6 @@ Return RadioResponse::getHardwareConfigResponse( return {}; } -Return RadioResponse::requestIccSimAuthenticationResponse(const V1_0::RadioResponseInfo& info, - const V1_0::IccIoResult& result) { - return {}; -} - Return RadioResponse::setDataProfileResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -498,16 +379,6 @@ Return RadioResponse::getModemActivityInfoResponse( return {}; } -Return RadioResponse::setAllowedCarriersResponse(const V1_0::RadioResponseInfo& info, - int32_t numAllowed) { - return {}; -} - -Return RadioResponse::getAllowedCarriersResponse( // - const V1_0::RadioResponseInfo& info, bool allAllowed, const V1_0::CarrierRestrictions& cr) { - return {}; -} - Return RadioResponse::sendDeviceStateResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -516,19 +387,6 @@ Return RadioResponse::setIndicationFilterResponse(const V1_0::RadioRespons return {}; } -Return RadioResponse::setSimCardPowerResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setCarrierInfoForImsiEncryptionResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setSimCardPowerResponse_1_1(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::startNetworkScanResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -551,11 +409,6 @@ Return RadioResponse::getCellInfoListResponse_1_2(const V1_0::RadioRespons return {}; } -Return RadioResponse::getIccCardStatusResponse_1_2(const V1_0::RadioResponseInfo& info, - const V1_2::CardStatus& cardStatus) { - return {}; -} - Return RadioResponse::setSignalStrengthReportingCriteriaResponse( const V1_0::RadioResponseInfo& info) { return {}; @@ -618,11 +471,6 @@ Return RadioResponse::getDataRegistrationStateResponse_1_4( return {}; } -Return RadioResponse::getIccCardStatusResponse_1_4(const V1_0::RadioResponseInfo& info, - const V1_4::CardStatus& cardStatus) { - return {}; -} - Return RadioResponse::getPreferredNetworkTypeBitmapResponse( const V1_0::RadioResponseInfo& info, hidl_bitfield networkTypeBitmap) { @@ -645,16 +493,6 @@ Return RadioResponse::setupDataCallResponse_1_4(const V1_0::RadioResponseI return {}; } -Return RadioResponse::setAllowedCarriersResponse_1_4(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getAllowedCarriersResponse_1_4( - const V1_0::RadioResponseInfo& info, const V1_4::CarrierRestrictionsWithPriority& carriers, - V1_4::SimLockMultiSimPolicy multiSimPolicy) { - return {}; -} - Return RadioResponse::getSignalStrengthResponse_1_4( const V1_0::RadioResponseInfo& info, const V1_4::SignalStrength& signalStrength) { return {}; @@ -670,15 +508,6 @@ Return RadioResponse::setLinkCapacityReportingCriteriaResponse_1_5( return {}; } -Return RadioResponse::enableUiccApplicationsResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::areUiccApplicationsEnabledResponse(const V1_0::RadioResponseInfo& info, - bool enabled) { - return {}; -} - Return RadioResponse::setSystemSelectionChannelsResponse_1_5( const V1_0::RadioResponseInfo& info) { return {}; @@ -741,17 +570,6 @@ Return RadioResponse::setNetworkSelectionModeManualResponse_1_5( return {}; } -Return RadioResponse::supplySimDepersonalizationResponse(const V1_0::RadioResponseInfo& info, - V1_5::PersoSubstate persoType, - int32_t remainingRetries) { - return {}; -} - -Return RadioResponse::getIccCardStatusResponse_1_5(const V1_0::RadioResponseInfo& info, - const V1_5::CardStatus& cardStatus) { - return {}; -} - Return RadioResponse::setRadioPowerResponse_1_6(const V1_6::RadioResponseInfo& info) { return {}; } @@ -767,10 +585,6 @@ Return RadioResponse::getDataCallListResponse_1_6( return {}; } -Return RadioResponse::setSimCardPowerResponse_1_6(const V1_6::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::setNrDualConnectivityStateResponse( const V1_6::RadioResponseInfo& info) { return {}; @@ -849,18 +663,4 @@ Return RadioResponse::getSlicingConfigResponse(const V1_6::RadioResponseIn return {}; } -Return RadioResponse::getSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getSimPhonebookCapacityResponse( - const V1_6::RadioResponseInfo& info, const V1_6::PhonebookCapacity& capacity) { - return {}; -} - -Return RadioResponse::updateSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo& info, - int32_t updatedRecordIndex) { - return {}; -} - } // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/commonStructs.cpp b/radio/aidl/compat/libradiocompat/commonStructs.cpp index e81562a89a..affd00a7ab 100644 --- a/radio/aidl/compat/libradiocompat/commonStructs.cpp +++ b/radio/aidl/compat/libradiocompat/commonStructs.cpp @@ -28,6 +28,18 @@ V1_6::RadioResponseInfo notSupported(int32_t serial) { }; } +std::string toAidl(const hidl_string& str) { + return str; +} + +hidl_string toHidl(const std::string& str) { + return str; +} + +uint8_t toAidl(int8_t v) { + return v; +} + aidl::RadioIndicationType toAidl(V1_0::RadioIndicationType type) { return aidl::RadioIndicationType(type); } diff --git a/radio/aidl/compat/libradiocompat/commonStructs.h b/radio/aidl/compat/libradiocompat/commonStructs.h index cba307ebde..9b3115d7f8 100644 --- a/radio/aidl/compat/libradiocompat/commonStructs.h +++ b/radio/aidl/compat/libradiocompat/commonStructs.h @@ -23,6 +23,10 @@ namespace android::hardware::radio::compat { V1_6::RadioResponseInfo notSupported(int32_t serial); +std::string toAidl(const hidl_string& str); +hidl_string toHidl(const std::string& str); +uint8_t toAidl(int8_t v); + aidl::android::hardware::radio::RadioIndicationType toAidl(V1_0::RadioIndicationType type); aidl::android::hardware::radio::RadioResponseType toAidl(V1_0::RadioResponseType type); aidl::android::hardware::radio::RadioError toAidl(V1_0::RadioError type); diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h index 991ae0637e..bc2b84107a 100644 --- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h @@ -16,6 +16,7 @@ #pragma once #include +#include #include namespace android::hardware::radio::compat { @@ -23,6 +24,7 @@ namespace android::hardware::radio::compat { class RadioIndication : public V1_6::IRadioIndication { std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingIndication> mMessagingCb; + std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimIndication> mSimCb; // IRadioIndication @ 1.0 Return radioStateChanged(V1_0::RadioIndicationType type, @@ -174,6 +176,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::sim::IRadioSimIndication> simCb); }; } // 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 121cc45687..f87e8a6d21 100644 --- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h @@ -16,6 +16,7 @@ #pragma once #include +#include #include namespace android::hardware::radio::compat { @@ -23,6 +24,7 @@ namespace android::hardware::radio::compat { class RadioResponse : public V1_6::IRadioResponse { std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingResponse> mMessagingCb; + std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimResponse> mSimCb; // IRadioResponse @ 1.0 Return getIccCardStatusResponse(const V1_0::RadioResponseInfo& info, @@ -402,6 +404,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::sim::IRadioSimResponse> simCb); }; } // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioSim.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioSim.h new file mode 100644 index 0000000000..a6b77fd507 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioSim.h @@ -0,0 +1,107 @@ +/* + * 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 RadioSim : public RadioCompatBase, public aidl::android::hardware::radio::sim::BnRadioSim { + ::ndk::ScopedAStatus areUiccApplicationsEnabled(int32_t serial) override; + ::ndk::ScopedAStatus changeIccPin2ForApp(int32_t serial, const std::string& oldPin2, + const std::string& newPin2, + const std::string& aid) override; + ::ndk::ScopedAStatus changeIccPinForApp(int32_t serial, const std::string& oldPin, + const std::string& newPin, + const std::string& aid) override; + ::ndk::ScopedAStatus enableUiccApplications(int32_t serial, bool enable) override; + ::ndk::ScopedAStatus getAllowedCarriers(int32_t serial) override; + ::ndk::ScopedAStatus getCdmaSubscription(int32_t serial) override; + ::ndk::ScopedAStatus getCdmaSubscriptionSource(int32_t serial) override; + ::ndk::ScopedAStatus getFacilityLockForApp(int32_t serial, const std::string& facility, + const std::string& password, int32_t serviceClass, + const std::string& appId) override; + ::ndk::ScopedAStatus getIccCardStatus(int32_t serial) override; + ::ndk::ScopedAStatus getImsiForApp(int32_t serial, const std::string& aid) override; + ::ndk::ScopedAStatus getSimPhonebookCapacity(int32_t serial) override; + ::ndk::ScopedAStatus getSimPhonebookRecords(int32_t serial) override; + ::ndk::ScopedAStatus iccCloseLogicalChannel(int32_t serial, int32_t channelId) override; + ::ndk::ScopedAStatus iccIoForApp( + int32_t serial, const ::aidl::android::hardware::radio::sim::IccIo& iccIo) override; + ::ndk::ScopedAStatus iccOpenLogicalChannel(int32_t serial, const std::string& aid, + int32_t p2) override; + ::ndk::ScopedAStatus iccTransmitApduBasicChannel( + int32_t serial, const ::aidl::android::hardware::radio::sim::SimApdu& message) override; + ::ndk::ScopedAStatus iccTransmitApduLogicalChannel( + int32_t serial, const ::aidl::android::hardware::radio::sim::SimApdu& message) override; + ::ndk::ScopedAStatus reportStkServiceIsRunning(int32_t serial) override; + ::ndk::ScopedAStatus requestIccSimAuthentication(int32_t serial, int32_t authContext, + const std::string& authData, + const std::string& aid) override; + ::ndk::ScopedAStatus responseAcknowledgement() override; + ::ndk::ScopedAStatus sendEnvelope(int32_t serial, const std::string& command) override; + ::ndk::ScopedAStatus sendEnvelopeWithStatus(int32_t serial, + const std::string& contents) override; + ::ndk::ScopedAStatus sendTerminalResponseToSim(int32_t serial, + const std::string& commandResponse) override; + ::ndk::ScopedAStatus setAllowedCarriers( + int32_t serial, + const ::aidl::android::hardware::radio::sim::CarrierRestrictions& carriers, + ::aidl::android::hardware::radio::sim::SimLockMultiSimPolicy multiSimPolicy) override; + ::ndk::ScopedAStatus setCarrierInfoForImsiEncryption( + int32_t serial, + const ::aidl::android::hardware::radio::sim::ImsiEncryptionInfo& imsiEncryptionInfo) + override; + ::ndk::ScopedAStatus setCdmaSubscriptionSource( + int32_t serial, + ::aidl::android::hardware::radio::sim::CdmaSubscriptionSource cdmaSub) override; + ::ndk::ScopedAStatus setFacilityLockForApp( // + int32_t serial, const std::string& facility, bool lockState, const std::string& passwd, + int32_t serviceClass, const std::string& appId) override; + ::ndk::ScopedAStatus setResponseFunctions( + const std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimResponse>& + radioSimResponse, + const std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimIndication>& + radioSimIndication) override; + ::ndk::ScopedAStatus setSimCardPower( + int32_t serial, ::aidl::android::hardware::radio::sim::CardPowerState powerUp) override; + ::ndk::ScopedAStatus setUiccSubscription( + int32_t serial, + const ::aidl::android::hardware::radio::sim::SelectUiccSub& uiccSub) override; + ::ndk::ScopedAStatus supplyIccPin2ForApp(int32_t serial, const std::string& pin2, + const std::string& aid) override; + ::ndk::ScopedAStatus supplyIccPinForApp(int32_t serial, const std::string& pin, + const std::string& aid) override; + ::ndk::ScopedAStatus supplyIccPuk2ForApp(int32_t serial, const std::string& puk2, + const std::string& pin2, + const std::string& aid) override; + ::ndk::ScopedAStatus supplyIccPukForApp(int32_t serial, const std::string& puk, + const std::string& pin, + const std::string& aid) override; + ::ndk::ScopedAStatus supplySimDepersonalization( + int32_t serial, ::aidl::android::hardware::radio::sim::PersoSubstate persoType, + const std::string& controlKey) override; + ::ndk::ScopedAStatus updateSimPhonebookRecords( + int32_t serial, + const ::aidl::android::hardware::radio::sim::PhonebookRecordInfo& recordInfo) override; + + public: + using RadioCompatBase::RadioCompatBase; +}; + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/sim/RadioIndication-sim.cpp b/radio/aidl/compat/libradiocompat/sim/RadioIndication-sim.cpp new file mode 100644 index 0000000000..6b906c62f3 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/sim/RadioIndication-sim.cpp @@ -0,0 +1,121 @@ +/* + * 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 "SimIndication" + +namespace android::hardware::radio::compat { + +namespace aidl = ::aidl::android::hardware::radio::sim; + +void RadioIndication::setResponseFunction(std::shared_ptr simCb) { + CHECK(simCb); + mSimCb = simCb; +} + +Return RadioIndication::carrierInfoForImsiEncryption(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->carrierInfoForImsiEncryption(toAidl(type)); + return {}; +} + +Return RadioIndication::cdmaSubscriptionSourceChanged( + V1_0::RadioIndicationType type, V1_0::CdmaSubscriptionSource cdmaSource) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->cdmaSubscriptionSourceChanged(toAidl(type), aidl::CdmaSubscriptionSource(cdmaSource)); + return {}; +} + +Return RadioIndication::simPhonebookChanged(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->simPhonebookChanged(toAidl(type)); + return {}; +} + +Return RadioIndication::simPhonebookRecordsReceived( + V1_0::RadioIndicationType type, V1_6::PbReceivedStatus status, + const hidl_vec& rec) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->simPhonebookRecordsReceived(toAidl(type), aidl::PbReceivedStatus(status), toAidl(rec)); + return {}; +} + +Return RadioIndication::simRefresh(V1_0::RadioIndicationType type, + const V1_0::SimRefreshResult& refreshResult) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->simRefresh(toAidl(type), toAidl(refreshResult)); + return {}; +} + +Return RadioIndication::simStatusChanged(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->simStatusChanged(toAidl(type)); + return {}; +} + +Return RadioIndication::stkEventNotify(V1_0::RadioIndicationType type, + const hidl_string& cmd) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->stkEventNotify(toAidl(type), cmd); + return {}; +} + +Return RadioIndication::stkProactiveCommand(V1_0::RadioIndicationType type, + const hidl_string& cmd) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->stkProactiveCommand(toAidl(type), cmd); + return {}; +} + +Return RadioIndication::stkSessionEnd(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->stkSessionEnd(toAidl(type)); + return {}; +} + +Return RadioIndication::subscriptionStatusChanged(V1_0::RadioIndicationType type, + bool activate) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->subscriptionStatusChanged(toAidl(type), activate); + return {}; +} + +Return RadioIndication::uiccApplicationsEnablementChanged(V1_0::RadioIndicationType type, + bool enabled) { + LOG_CALL << type; + CHECK_CB(mSimCb); + mSimCb->uiccApplicationsEnablementChanged(toAidl(type), enabled); + return {}; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/sim/RadioResponse-sim.cpp b/radio/aidl/compat/libradiocompat/sim/RadioResponse-sim.cpp new file mode 100644 index 0000000000..2dfbc50fcd --- /dev/null +++ b/radio/aidl/compat/libradiocompat/sim/RadioResponse-sim.cpp @@ -0,0 +1,366 @@ +/* + * 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 "SimResponse" + +namespace android::hardware::radio::compat { + +namespace aidl = ::aidl::android::hardware::radio::sim; + +void RadioResponse::setResponseFunction(std::shared_ptr simCb) { + CHECK(simCb); + mSimCb = simCb; +} + +Return RadioResponse::areUiccApplicationsEnabledResponse(const V1_0::RadioResponseInfo& info, + bool enabled) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->areUiccApplicationsEnabledResponse(toAidl(info), enabled); + return {}; +} + +Return RadioResponse::changeIccPin2ForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->changeIccPin2ForAppResponse(toAidl(info), remainingRetries); + return {}; +} + +Return RadioResponse::changeIccPinForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->changeIccPinForAppResponse(toAidl(info), remainingRetries); + return {}; +} + +Return RadioResponse::enableUiccApplicationsResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->enableUiccApplicationsResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::getAllowedCarriersResponse( // + const V1_0::RadioResponseInfo& info, bool allAllowed, const V1_0::CarrierRestrictions& cr) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + aidl::CarrierRestrictions aidlCr = toAidl(cr); + if (allAllowed) aidlCr = {}; + mSimCb->getAllowedCarriersResponse(toAidl(info), aidlCr, {}); + return {}; +} + +Return RadioResponse::getAllowedCarriersResponse_1_4( + const V1_0::RadioResponseInfo& info, const V1_4::CarrierRestrictionsWithPriority& carriers, + V1_4::SimLockMultiSimPolicy multiSimPolicy) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getAllowedCarriersResponse(toAidl(info), toAidl(carriers), + aidl::SimLockMultiSimPolicy(multiSimPolicy)); + return {}; +} + +Return RadioResponse::getCDMASubscriptionResponse( + const V1_0::RadioResponseInfo& info, const hidl_string& mdn, const hidl_string& hSid, + const hidl_string& hNid, const hidl_string& min, const hidl_string& prl) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getCdmaSubscriptionResponse(toAidl(info), mdn, hSid, hNid, min, prl); + return {}; +} + +Return RadioResponse::getCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo& info, + V1_0::CdmaSubscriptionSource s) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getCdmaSubscriptionSourceResponse(toAidl(info), aidl::CdmaSubscriptionSource(s)); + return {}; +} + +Return RadioResponse::getFacilityLockForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t response) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getFacilityLockForAppResponse(toAidl(info), response); + return {}; +} + +Return RadioResponse::getIccCardStatusResponse(const V1_0::RadioResponseInfo& info, + const V1_0::CardStatus& cardStatus) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getIccCardStatusResponse(toAidl(info), toAidl(cardStatus)); + return {}; +} + +Return RadioResponse::getIccCardStatusResponse_1_2(const V1_0::RadioResponseInfo& info, + const V1_2::CardStatus& cardStatus) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getIccCardStatusResponse(toAidl(info), toAidl(cardStatus)); + return {}; +} + +Return RadioResponse::getIccCardStatusResponse_1_4(const V1_0::RadioResponseInfo& info, + const V1_4::CardStatus& cardStatus) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getIccCardStatusResponse(toAidl(info), toAidl(cardStatus)); + return {}; +} + +Return RadioResponse::getIccCardStatusResponse_1_5(const V1_0::RadioResponseInfo& info, + const V1_5::CardStatus& cardStatus) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getIccCardStatusResponse(toAidl(info), toAidl(cardStatus)); + return {}; +} + +Return RadioResponse::getIMSIForAppResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& imsi) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getImsiForAppResponse(toAidl(info), imsi); + return {}; +} + +Return RadioResponse::getSimPhonebookCapacityResponse( + const V1_6::RadioResponseInfo& info, const V1_6::PhonebookCapacity& capacity) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getSimPhonebookCapacityResponse(toAidl(info), toAidl(capacity)); + return {}; +} + +Return RadioResponse::getSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->getSimPhonebookRecordsResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::iccCloseLogicalChannelResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->iccCloseLogicalChannelResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::iccIOForAppResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& iccIo) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->iccIoForAppResponse(toAidl(info), toAidl(iccIo)); + return {}; +} + +Return RadioResponse::iccOpenLogicalChannelResponse( // + const V1_0::RadioResponseInfo& info, int32_t chanId, const hidl_vec& selectResp) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->iccOpenLogicalChannelResponse(toAidl(info), chanId, toAidl(selectResp)); + return {}; +} + +Return RadioResponse::iccTransmitApduBasicChannelResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& result) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->iccTransmitApduBasicChannelResponse(toAidl(info), toAidl(result)); + return {}; +} + +Return RadioResponse::iccTransmitApduLogicalChannelResponse( + const V1_0::RadioResponseInfo& info, const V1_0::IccIoResult& result) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->iccTransmitApduLogicalChannelResponse(toAidl(info), toAidl(result)); + return {}; +} + +Return RadioResponse::reportStkServiceIsRunningResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->reportStkServiceIsRunningResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::requestIccSimAuthenticationResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& result) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->requestIccSimAuthenticationResponse(toAidl(info), toAidl(result)); + return {}; +} + +Return RadioResponse::requestIsimAuthenticationResponse(const V1_0::RadioResponseInfo& info, + const hidl_string&) { + LOG_CALL << info.serial; + LOG(ERROR) << "requestIsimAuthenticationResponse is not supposed to be called"; + return {}; +} + +Return RadioResponse::sendEnvelopeResponse(const V1_0::RadioResponseInfo& info, + const hidl_string& commandResponse) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->sendEnvelopeResponse(toAidl(info), commandResponse); + return {}; +} + +Return RadioResponse::sendEnvelopeWithStatusResponse(const V1_0::RadioResponseInfo& info, + const V1_0::IccIoResult& iccIo) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->sendEnvelopeWithStatusResponse(toAidl(info), toAidl(iccIo)); + return {}; +} + +Return RadioResponse::sendTerminalResponseToSimResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->sendTerminalResponseToSimResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setAllowedCarriersResponse(const V1_0::RadioResponseInfo& info, + int32_t numAllowed) { + LOG_CALL << info.serial << ' ' << numAllowed; + CHECK_CB(mSimCb); + mSimCb->setAllowedCarriersResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setAllowedCarriersResponse_1_4(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->setAllowedCarriersResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setCarrierInfoForImsiEncryptionResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->setCarrierInfoForImsiEncryptionResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setCdmaSubscriptionSourceResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->setCdmaSubscriptionSourceResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setFacilityLockForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t retry) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->setFacilityLockForAppResponse(toAidl(info), retry); + return {}; +} + +Return RadioResponse::setSimCardPowerResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->setSimCardPowerResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setSimCardPowerResponse_1_1(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->setSimCardPowerResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setSimCardPowerResponse_1_6(const V1_6::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->setSimCardPowerResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setUiccSubscriptionResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->setUiccSubscriptionResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::supplyIccPin2ForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->supplyIccPin2ForAppResponse(toAidl(info), remainingRetries); + return {}; +} + +Return RadioResponse::supplyIccPinForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->supplyIccPinForAppResponse(toAidl(info), remainingRetries); + return {}; +} + +Return RadioResponse::supplyIccPuk2ForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->supplyIccPuk2ForAppResponse(toAidl(info), remainingRetries); + return {}; +} + +Return RadioResponse::supplyIccPukForAppResponse(const V1_0::RadioResponseInfo& info, + int32_t remainingRetries) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->supplyIccPukForAppResponse(toAidl(info), remainingRetries); + return {}; +} + +Return RadioResponse::supplySimDepersonalizationResponse(const V1_0::RadioResponseInfo& info, + V1_5::PersoSubstate persoType, + int32_t rRet) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->supplySimDepersonalizationResponse(toAidl(info), aidl::PersoSubstate(persoType), rRet); + return {}; +} + +Return RadioResponse::updateSimPhonebookRecordsResponse(const V1_6::RadioResponseInfo& info, + int32_t updatedRecordIndex) { + LOG_CALL << info.serial; + CHECK_CB(mSimCb); + mSimCb->updateSimPhonebookRecordsResponse(toAidl(info), updatedRecordIndex); + return {}; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/sim/RadioSim.cpp b/radio/aidl/compat/libradiocompat/sim/RadioSim.cpp new file mode 100644 index 0000000000..ca27918024 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/sim/RadioSim.cpp @@ -0,0 +1,295 @@ +/* + * 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 "Sim" + +namespace android::hardware::radio::compat { + +using ::ndk::ScopedAStatus; +namespace aidl = ::aidl::android::hardware::radio::sim; +constexpr auto ok = &ScopedAStatus::ok; + +ScopedAStatus RadioSim::areUiccApplicationsEnabled(int32_t serial) { + LOG_CALL << serial; + mHal1_5->areUiccApplicationsEnabled(serial); + return ok(); +} + +ScopedAStatus RadioSim::changeIccPin2ForApp(int32_t serial, const std::string& oldPin2, + const std::string& newPin2, const std::string& aid) { + LOG_CALL << serial; + mHal1_5->changeIccPin2ForApp(serial, oldPin2, newPin2, aid); + return ok(); +} + +ScopedAStatus RadioSim::changeIccPinForApp(int32_t serial, const std::string& oldPin, + const std::string& newPin, const std::string& aid) { + LOG_CALL << serial; + mHal1_5->changeIccPinForApp(serial, oldPin, newPin, aid); + return ok(); +} + +ScopedAStatus RadioSim::enableUiccApplications(int32_t serial, bool enable) { + LOG_CALL << serial; + mHal1_5->enableUiccApplications(serial, enable); + return ok(); +} + +ScopedAStatus RadioSim::getAllowedCarriers(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getAllowedCarriers(serial); + return ok(); +} + +ScopedAStatus RadioSim::getCdmaSubscription(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getCDMASubscription(serial); + return ok(); +} + +ScopedAStatus RadioSim::getCdmaSubscriptionSource(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getCdmaSubscriptionSource(serial); + return ok(); +} + +ScopedAStatus RadioSim::getFacilityLockForApp( // + int32_t serial, const std::string& facility, const std::string& password, + int32_t serviceClass, const std::string& appId) { + LOG_CALL << serial; + mHal1_5->getFacilityLockForApp(serial, facility, password, serviceClass, appId); + return ok(); +} + +ScopedAStatus RadioSim::getIccCardStatus(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getIccCardStatus(serial); + return ok(); +} + +ScopedAStatus RadioSim::getImsiForApp(int32_t serial, const std::string& aid) { + LOG_CALL << serial; + mHal1_5->getImsiForApp(serial, aid); + return ok(); +} + +ScopedAStatus RadioSim::getSimPhonebookCapacity(int32_t serial) { + LOG_CALL << serial; + if (mHal1_6) { + mHal1_6->getSimPhonebookCapacity(serial); + } else { + respond().getSimPhonebookCapacityResponse(notSupported(serial), {}); + } + return ok(); +} + +ScopedAStatus RadioSim::getSimPhonebookRecords(int32_t serial) { + LOG_CALL << serial; + if (mHal1_6) { + mHal1_6->getSimPhonebookRecords(serial); + } else { + respond().getSimPhonebookRecordsResponse(notSupported(serial)); + } + return ok(); +} + +ScopedAStatus RadioSim::iccCloseLogicalChannel(int32_t serial, int32_t channelId) { + LOG_CALL << serial; + mHal1_5->iccCloseLogicalChannel(serial, channelId); + return ok(); +} + +ScopedAStatus RadioSim::iccIoForApp(int32_t serial, const aidl::IccIo& iccIo) { + LOG_CALL << serial; + mHal1_5->iccIOForApp(serial, toHidl(iccIo)); + return ok(); +} + +ScopedAStatus RadioSim::iccOpenLogicalChannel(int32_t serial, const std::string& aid, int32_t p2) { + LOG_CALL << serial; + mHal1_5->iccOpenLogicalChannel(serial, aid, p2); + return ok(); +} + +ScopedAStatus RadioSim::iccTransmitApduBasicChannel(int32_t serial, const aidl::SimApdu& message) { + LOG_CALL << serial; + mHal1_5->iccTransmitApduBasicChannel(serial, toHidl(message)); + return ok(); +} + +ScopedAStatus RadioSim::iccTransmitApduLogicalChannel(int32_t serial, + const aidl::SimApdu& message) { + LOG_CALL << serial; + mHal1_5->iccTransmitApduLogicalChannel(serial, toHidl(message)); + return ok(); +} + +ScopedAStatus RadioSim::reportStkServiceIsRunning(int32_t serial) { + LOG_CALL << serial; + mHal1_5->reportStkServiceIsRunning(serial); + return ok(); +} + +ScopedAStatus RadioSim::requestIccSimAuthentication( // + int32_t serial, int32_t authContext, const std::string& authData, const std::string& aid) { + LOG_CALL << serial; + mHal1_5->requestIccSimAuthentication(serial, authContext, authData, aid); + return ok(); +} + +ScopedAStatus RadioSim::responseAcknowledgement() { + LOG_CALL; + mHal1_5->responseAcknowledgement(); + return ok(); +} + +ScopedAStatus RadioSim::sendEnvelope(int32_t serial, const std::string& command) { + LOG_CALL << serial; + mHal1_5->sendEnvelope(serial, command); + return ok(); +} + +ScopedAStatus RadioSim::sendEnvelopeWithStatus(int32_t serial, const std::string& contents) { + LOG_CALL << serial; + mHal1_5->sendEnvelopeWithStatus(serial, contents); + return ok(); +} + +ScopedAStatus RadioSim::sendTerminalResponseToSim(int32_t serial, + const std::string& commandResponse) { + LOG_CALL << serial; + mHal1_5->sendTerminalResponseToSim(serial, commandResponse); + return ok(); +} + +ScopedAStatus RadioSim::setAllowedCarriers( // + int32_t serial, const aidl::CarrierRestrictions& carriers, aidl::SimLockMultiSimPolicy mp) { + LOG_CALL << serial; + mHal1_5->setAllowedCarriers_1_4(serial, toHidl(carriers), V1_4::SimLockMultiSimPolicy(mp)); + return ok(); +} + +ScopedAStatus RadioSim::setCarrierInfoForImsiEncryption( + int32_t serial, const aidl::ImsiEncryptionInfo& imsiEncryptionInfo) { + LOG_CALL << serial; + if (mHal1_6) { + mHal1_6->setCarrierInfoForImsiEncryption_1_6(serial, toHidl_1_6(imsiEncryptionInfo)); + } else { + mHal1_5->setCarrierInfoForImsiEncryption(serial, toHidl(imsiEncryptionInfo)); + } + return ok(); +} + +ScopedAStatus RadioSim::setCdmaSubscriptionSource(int32_t serial, + aidl::CdmaSubscriptionSource cdmaSub) { + LOG_CALL << serial; + mHal1_5->setCdmaSubscriptionSource(serial, V1_0::CdmaSubscriptionSource(cdmaSub)); + return ok(); +} + +ScopedAStatus RadioSim::setFacilityLockForApp( // + int32_t serial, const std::string& facility, bool lockState, const std::string& password, + int32_t serviceClass, const std::string& appId) { + LOG_CALL << serial; + mHal1_5->setFacilityLockForApp(serial, facility, lockState, password, serviceClass, appId); + return ok(); +} + +ScopedAStatus RadioSim::setResponseFunctions( + const std::shared_ptr& simResponse, + const std::shared_ptr& simIndication) { + LOG_CALL << simResponse << ' ' << simIndication; + + CHECK(simResponse); + CHECK(simIndication); + + mRadioResponse->setResponseFunction(simResponse); + mRadioIndication->setResponseFunction(simIndication); + + return ok(); +} + +ScopedAStatus RadioSim::setSimCardPower(int32_t serial, aidl::CardPowerState powerUp) { + LOG_CALL << serial; + if (mHal1_6) { + mHal1_6->setSimCardPower_1_6(serial, V1_1::CardPowerState(powerUp)); + } else { + mHal1_5->setSimCardPower_1_1(serial, V1_1::CardPowerState(powerUp)); + } + return ok(); +} + +ScopedAStatus RadioSim::setUiccSubscription(int32_t serial, const aidl::SelectUiccSub& uiccSub) { + LOG_CALL << serial; + mHal1_5->setUiccSubscription(serial, toHidl(uiccSub)); + return ok(); +} + +ScopedAStatus RadioSim::supplyIccPin2ForApp(int32_t serial, const std::string& pin2, + const std::string& aid) { + LOG_CALL << serial; + mHal1_5->supplyIccPin2ForApp(serial, pin2, aid); + return ok(); +} + +ScopedAStatus RadioSim::supplyIccPinForApp(int32_t serial, const std::string& pin, + const std::string& aid) { + LOG_CALL << serial; + mHal1_5->supplyIccPinForApp(serial, pin, aid); + return ok(); +} + +ScopedAStatus RadioSim::supplyIccPuk2ForApp(int32_t serial, const std::string& puk2, + const std::string& pin2, const std::string& aid) { + LOG_CALL << serial; + mHal1_5->supplyIccPuk2ForApp(serial, puk2, pin2, aid); + return ok(); +} + +ScopedAStatus RadioSim::supplyIccPukForApp(int32_t serial, const std::string& puk, + const std::string& pin, const std::string& aid) { + LOG_CALL << serial; + mHal1_5->supplyIccPukForApp(serial, puk, pin, aid); + return ok(); +} + +ScopedAStatus RadioSim::supplySimDepersonalization(int32_t serial, aidl::PersoSubstate pss, + const std::string& controlKey) { + LOG_CALL << serial; + mHal1_5->supplySimDepersonalization(serial, V1_5::PersoSubstate(pss), controlKey); + return ok(); +} + +ScopedAStatus RadioSim::updateSimPhonebookRecords(int32_t serial, + const aidl::PhonebookRecordInfo& recordInfo) { + LOG_CALL << serial; + if (mHal1_6) { + mHal1_6->updateSimPhonebookRecords(serial, toHidl(recordInfo)); + } else { + respond().updateSimPhonebookRecordsResponse(notSupported(serial), 0); + } + return ok(); +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/sim/structs.cpp b/radio/aidl/compat/libradiocompat/sim/structs.cpp new file mode 100644 index 0000000000..97a21a1e79 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/sim/structs.cpp @@ -0,0 +1,221 @@ +/* + * 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 { + +namespace aidl = ::aidl::android::hardware::radio::sim; + +V1_0::IccIo toHidl(const aidl::IccIo& icc) { + return { + .command = icc.command, + .fileId = icc.fileId, + .path = icc.path, + .p1 = icc.p1, + .p2 = icc.p2, + .p3 = icc.p3, + .data = icc.data, + .pin2 = icc.pin2, + .aid = icc.aid, + }; +} + +V1_0::SimApdu toHidl(const aidl::SimApdu& apdu) { + return { + .sessionId = apdu.sessionId, + .cla = apdu.cla, + .instruction = apdu.instruction, + .p1 = apdu.p1, + .p2 = apdu.p2, + .p3 = apdu.p3, + .data = apdu.data, + }; +} + +aidl::Carrier toAidl(const V1_0::Carrier& carrier) { + return { + .mcc = carrier.mcc, + .mnc = carrier.mnc, + .matchType = static_cast(carrier.matchType), + .matchData = carrier.matchData, + }; +} + +V1_0::Carrier toHidl(const aidl::Carrier& carrier) { + return { + .mcc = carrier.mcc, + .mnc = carrier.mnc, + .matchType = V1_0::CarrierMatchType{carrier.matchType}, + .matchData = carrier.matchData, + }; +} + +aidl::CarrierRestrictions toAidl(const V1_0::CarrierRestrictions& cr) { + return { + .allowedCarriers = toAidl(cr.allowedCarriers), + .excludedCarriers = toAidl(cr.excludedCarriers), + .allowedCarriersPrioritized = true, + }; +} + +aidl::CarrierRestrictions toAidl(const V1_4::CarrierRestrictionsWithPriority& cr) { + return { + .allowedCarriers = toAidl(cr.allowedCarriers), + .excludedCarriers = toAidl(cr.excludedCarriers), + .allowedCarriersPrioritized = cr.allowedCarriersPrioritized, + }; +} + +V1_4::CarrierRestrictionsWithPriority toHidl(const aidl::CarrierRestrictions& cr) { + return { + .allowedCarriers = toHidl(cr.allowedCarriers), + .excludedCarriers = toHidl(cr.excludedCarriers), + .allowedCarriersPrioritized = cr.allowedCarriersPrioritized, + }; +} + +V1_1::ImsiEncryptionInfo toHidl(const aidl::ImsiEncryptionInfo& info) { + return { + .mcc = info.mcc, + .mnc = info.mnc, + .carrierKey = info.carrierKey, + .keyIdentifier = info.keyIdentifier, + .expirationTime = info.expirationTime, + }; +} + +V1_6::ImsiEncryptionInfo toHidl_1_6(const aidl::ImsiEncryptionInfo& info) { + return { + .base = toHidl(info), + .keyType = V1_6::PublicKeyType{info.keyType}, + }; +} + +V1_0::SelectUiccSub toHidl(const aidl::SelectUiccSub& sub) { + return { + .slot = sub.slot, + .appIndex = sub.appIndex, + .subType = {}, + .actStatus = {}, + }; +} + +aidl::PhonebookRecordInfo toAidl(const V1_6::PhonebookRecordInfo& info) { + return { + .recordId = static_cast(info.recordId), + .name = info.name, + .number = info.number, + .emails = toAidl(info.emails), + .additionalNumbers = toAidl(info.additionalNumbers), + }; +} + +V1_6::PhonebookRecordInfo toHidl(const aidl::PhonebookRecordInfo& info) { + return { + .recordId = static_cast(info.recordId), + .name = info.name, + .number = info.number, + .emails = toHidl(info.emails), + .additionalNumbers = toHidl(info.additionalNumbers), + }; +} + +aidl::SimRefreshResult toAidl(const V1_0::SimRefreshResult& res) { + return { + .type = static_cast(res.type), + .efId = res.efId, + .aid = res.aid, + }; +} + +aidl::CardStatus toAidl(const V1_0::CardStatus& status) { + return toAidl(V1_2::CardStatus{status, 0, "", ""}); +} + +aidl::CardStatus toAidl(const V1_2::CardStatus& status) { + return toAidl(V1_4::CardStatus{status, ""}); +} + +aidl::CardStatus toAidl(const V1_4::CardStatus& status) { + auto aidlStatus = toAidl(V1_5::CardStatus{status, {}}); + aidlStatus.applications = toAidl(status.base.base.applications); + return aidlStatus; +} + +aidl::CardStatus toAidl(const V1_5::CardStatus& status) { + return { + .cardState = static_cast(status.base.base.base.cardState), + .universalPinState = aidl::PinState(status.base.base.base.universalPinState), + .gsmUmtsSubscriptionAppIndex = status.base.base.base.gsmUmtsSubscriptionAppIndex, + .cdmaSubscriptionAppIndex = status.base.base.base.cdmaSubscriptionAppIndex, + .imsSubscriptionAppIndex = status.base.base.base.imsSubscriptionAppIndex, + .applications = toAidl(status.applications), + .atr = status.base.base.atr, + .iccid = status.base.base.iccid, + .eid = status.base.eid, + // TODO(b/203699028): we don't know portId here (but we can get it from RadioConfig) + .slotMap = {static_cast(status.base.base.physicalSlotId), 0}, + }; +} + +aidl::AppStatus toAidl(const V1_0::AppStatus& status) { + return toAidl({status, V1_5::PersoSubstate(status.persoSubstate)}); +} + +aidl::AppStatus toAidl(const V1_5::AppStatus& status) { + return { + .appType = static_cast(status.base.appType), + .appState = static_cast(status.base.appState), + .persoSubstate = aidl::PersoSubstate(status.persoSubstate), + .aidPtr = status.base.aidPtr, + .appLabelPtr = status.base.appLabelPtr, + .pin1Replaced = (status.base.pin1Replaced != 0), + .pin1 = aidl::PinState(status.base.pin1), + .pin2 = aidl::PinState(status.base.pin2), + }; +} + +aidl::PhonebookCapacity toAidl(const V1_6::PhonebookCapacity& c) { + return { + .maxAdnRecords = c.maxAdnRecords, + .usedAdnRecords = c.usedAdnRecords, + .maxEmailRecords = c.maxEmailRecords, + .usedEmailRecords = c.usedEmailRecords, + .maxAdditionalNumberRecords = c.maxAdditionalNumberRecords, + .usedAdditionalNumberRecords = c.usedAdditionalNumberRecords, + .maxNameLen = c.maxNameLen, + .maxNumberLen = c.maxNumberLen, + .maxEmailLen = c.maxEmailLen, + .maxAdditionalNumberLen = c.maxAdditionalNumberLen, + }; +} + +aidl::IccIoResult toAidl(const V1_0::IccIoResult& iir) { + return { + .sw1 = iir.sw1, + .sw2 = iir.sw2, + .simResponse = iir.simResponse, + }; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/sim/structs.h b/radio/aidl/compat/libradiocompat/sim/structs.h new file mode 100644 index 0000000000..54099b7ca9 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/sim/structs.h @@ -0,0 +1,75 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +namespace android::hardware::radio::compat { + +V1_0::IccIo toHidl(const ::aidl::android::hardware::radio::sim::IccIo& icc); + +V1_0::SimApdu toHidl(const ::aidl::android::hardware::radio::sim::SimApdu& apdu); + +::aidl::android::hardware::radio::sim::Carrier toAidl(const V1_0::Carrier& carrier); +V1_0::Carrier toHidl(const ::aidl::android::hardware::radio::sim::Carrier& carrier); + +::aidl::android::hardware::radio::sim::CarrierRestrictions // +toAidl(const V1_0::CarrierRestrictions& cr); +::aidl::android::hardware::radio::sim::CarrierRestrictions // +toAidl(const V1_4::CarrierRestrictionsWithPriority& cr); +V1_4::CarrierRestrictionsWithPriority // +toHidl(const ::aidl::android::hardware::radio::sim::CarrierRestrictions& cr); + +V1_1::ImsiEncryptionInfo // +toHidl(const ::aidl::android::hardware::radio::sim::ImsiEncryptionInfo& info); +V1_6::ImsiEncryptionInfo // +toHidl_1_6(const ::aidl::android::hardware::radio::sim::ImsiEncryptionInfo& info); + +V1_0::SelectUiccSub toHidl(const ::aidl::android::hardware::radio::sim::SelectUiccSub& sub); + +::aidl::android::hardware::radio::sim::PhonebookRecordInfo // +toAidl(const V1_6::PhonebookRecordInfo& info); +V1_6::PhonebookRecordInfo // +toHidl(const ::aidl::android::hardware::radio::sim::PhonebookRecordInfo& info); + +::aidl::android::hardware::radio::sim::SimRefreshResult // +toAidl(const V1_0::SimRefreshResult& res); + +::aidl::android::hardware::radio::sim::CardStatus toAidl(const V1_0::CardStatus& status); +::aidl::android::hardware::radio::sim::CardStatus toAidl(const V1_2::CardStatus& status); +::aidl::android::hardware::radio::sim::CardStatus toAidl(const V1_4::CardStatus& status); +::aidl::android::hardware::radio::sim::CardStatus toAidl(const V1_5::CardStatus& status); + +::aidl::android::hardware::radio::sim::AppStatus toAidl(const V1_0::AppStatus& status); +::aidl::android::hardware::radio::sim::AppStatus toAidl(const V1_5::AppStatus& status); + +::aidl::android::hardware::radio::sim::PhonebookCapacity toAidl(const V1_6::PhonebookCapacity& c); + +::aidl::android::hardware::radio::sim::IccIoResult toAidl(const V1_0::IccIoResult& iir); + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/service/Android.bp b/radio/aidl/compat/service/Android.bp index 82ab81f7a4..6a1cad546c 100644 --- a/radio/aidl/compat/service/Android.bp +++ b/radio/aidl/compat/service/Android.bp @@ -40,6 +40,7 @@ cc_binary { "android.hardware.radio.config@1.2", "android.hardware.radio.config@1.3", "android.hardware.radio.messaging-V1-ndk", + "android.hardware.radio.sim-V1-ndk", "android.hardware.radio@1.0", "android.hardware.radio@1.1", "android.hardware.radio@1.2", diff --git a/radio/aidl/compat/service/radio-compat.xml b/radio/aidl/compat/service/radio-compat.xml index 781f2f41c8..2164b28b46 100644 --- a/radio/aidl/compat/service/radio-compat.xml +++ b/radio/aidl/compat/service/radio-compat.xml @@ -13,5 +13,9 @@ android.hardware.radio.messaging IRadioMessaging/slot1 + + android.hardware.radio.sim + IRadioSim/slot1 + --> diff --git a/radio/aidl/compat/service/service.cpp b/radio/aidl/compat/service/service.cpp index 4d34cf120e..e6dd03d2c9 100644 --- a/radio/aidl/compat/service/service.cpp +++ b/radio/aidl/compat/service/service.cpp @@ -23,6 +23,7 @@ #include #include #include +#include namespace android::hardware::radio::service { @@ -57,6 +58,7 @@ static void publishRadio(std::string slot) { radioHidl->setResponseFunctions(responseCb, indicationCb).assertOk(); publishRadioHal(radioHidl, responseCb, indicationCb, slot); + publishRadioHal(radioHidl, responseCb, indicationCb, slot); } static void publishRadioConfig() { From 0716169065050c3bfb04d861f2cfa3e5839cb45c Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Tue, 2 Nov 2021 12:14:52 -0700 Subject: [PATCH 4/7] Implement RadioData for AIDL-HIDL Telephony HAL translator Bug: 203699028 Test: Boot and grep logcat against radiocompat Change-Id: I5770ee4125cd9e6f118200ecee889ad785e8929f --- radio/aidl/compat/libradiocompat/Android.bp | 5 + .../compat/libradiocompat/RadioIndication.cpp | 35 --- .../compat/libradiocompat/RadioResponse.cpp | 103 +------ .../aidl/compat/libradiocompat/collections.h | 52 ++++ .../compat/libradiocompat/commonStructs.cpp | 8 + .../compat/libradiocompat/commonStructs.h | 2 + .../compat/libradiocompat/data/RadioData.cpp | 180 +++++++++++ .../data/RadioIndication-data.cpp | 90 ++++++ .../data/RadioResponse-data.cpp | 199 ++++++++++++ .../compat/libradiocompat/data/structs.cpp | 288 ++++++++++++++++++ .../aidl/compat/libradiocompat/data/structs.h | 71 +++++ .../include/libradiocompat/RadioData.h | 70 +++++ .../include/libradiocompat/RadioIndication.h | 4 + .../include/libradiocompat/RadioResponse.h | 4 + radio/aidl/compat/service/Android.bp | 1 + radio/aidl/compat/service/radio-compat.xml | 4 + radio/aidl/compat/service/service.cpp | 2 + 17 files changed, 981 insertions(+), 137 deletions(-) create mode 100644 radio/aidl/compat/libradiocompat/data/RadioData.cpp create mode 100644 radio/aidl/compat/libradiocompat/data/RadioIndication-data.cpp create mode 100644 radio/aidl/compat/libradiocompat/data/RadioResponse-data.cpp create mode 100644 radio/aidl/compat/libradiocompat/data/structs.cpp create mode 100644 radio/aidl/compat/libradiocompat/data/structs.h create mode 100644 radio/aidl/compat/libradiocompat/include/libradiocompat/RadioData.h diff --git a/radio/aidl/compat/libradiocompat/Android.bp b/radio/aidl/compat/libradiocompat/Android.bp index bf2c80c824..0e6496aeb3 100644 --- a/radio/aidl/compat/libradiocompat/Android.bp +++ b/radio/aidl/compat/libradiocompat/Android.bp @@ -37,6 +37,7 @@ cc_library { "android.hardware.radio.config@1.1", "android.hardware.radio.config@1.2", "android.hardware.radio.config@1.3", + "android.hardware.radio.data-V1-ndk", "android.hardware.radio.messaging-V1-ndk", "android.hardware.radio.sim-V1-ndk", "android.hardware.radio@1.0", @@ -60,6 +61,10 @@ cc_library { "config/RadioConfigIndication.cpp", "config/RadioConfigResponse.cpp", "config/structs.cpp", + "data/RadioIndication-data.cpp", + "data/RadioResponse-data.cpp", + "data/RadioData.cpp", + "data/structs.cpp", "messaging/RadioIndication-messaging.cpp", "messaging/RadioMessaging.cpp", "messaging/RadioResponse-messaging.cpp", diff --git a/radio/aidl/compat/libradiocompat/RadioIndication.cpp b/radio/aidl/compat/libradiocompat/RadioIndication.cpp index 69836e2990..b6a7e72619 100644 --- a/radio/aidl/compat/libradiocompat/RadioIndication.cpp +++ b/radio/aidl/compat/libradiocompat/RadioIndication.cpp @@ -44,11 +44,6 @@ Return RadioIndication::currentSignalStrength(V1_0::RadioIndicationType ty return {}; } -Return RadioIndication::dataCallListChanged( - V1_0::RadioIndicationType type, const hidl_vec& dcList) { - return {}; -} - Return RadioIndication::suppSvcNotify(V1_0::RadioIndicationType type, const V1_0::SuppSvcNotification& suppSvc) { return {}; @@ -151,11 +146,6 @@ Return RadioIndication::lceData(V1_0::RadioIndicationType type, return {}; } -Return RadioIndication::pcoData(V1_0::RadioIndicationType type, - const V1_0::PcoDataInfo& pco) { - return {}; -} - Return RadioIndication::modemReset(V1_0::RadioIndicationType type, const hidl_string& reason) { return {}; @@ -166,11 +156,6 @@ Return RadioIndication::networkScanResult(V1_0::RadioIndicationType type, return {}; } -Return RadioIndication::keepaliveStatus(V1_0::RadioIndicationType type, - const V1_1::KeepaliveStatus& status) { - return {}; -} - Return RadioIndication::networkScanResult_1_2(V1_0::RadioIndicationType type, const V1_2::NetworkScanResult& result) { return {}; @@ -216,11 +201,6 @@ Return RadioIndication::currentPhysicalChannelConfigs_1_4( return {}; } -Return RadioIndication::dataCallListChanged_1_4( - V1_0::RadioIndicationType type, const hidl_vec& dcList) { - return {}; -} - Return RadioIndication::currentSignalStrength_1_4( V1_0::RadioIndicationType type, const V1_4::SignalStrength& signalStrength) { return {}; @@ -249,21 +229,6 @@ Return RadioIndication::networkScanResult_1_5(V1_0::RadioIndicationType ty return {}; } -Return RadioIndication::dataCallListChanged_1_5( - V1_0::RadioIndicationType type, const hidl_vec& dcList) { - return {}; -} - -Return RadioIndication::dataCallListChanged_1_6( - V1_0::RadioIndicationType type, const hidl_vec& dcList) { - return {}; -} - -Return RadioIndication::unthrottleApn(V1_0::RadioIndicationType type, - const hidl_string& apn) { - return {}; -} - Return RadioIndication::currentLinkCapacityEstimate_1_6( V1_0::RadioIndicationType type, const V1_6::LinkCapacityEstimate& lce) { return {}; diff --git a/radio/aidl/compat/libradiocompat/RadioResponse.cpp b/radio/aidl/compat/libradiocompat/RadioResponse.cpp index 587e497693..0a38d8cff3 100644 --- a/radio/aidl/compat/libradiocompat/RadioResponse.cpp +++ b/radio/aidl/compat/libradiocompat/RadioResponse.cpp @@ -28,6 +28,7 @@ namespace android::hardware::radio::compat { Return RadioResponse::acknowledgeRequest(int32_t serial) { LOG_CALL << 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 (mSimCb) mSimCb->acknowledgeRequest(serial); return {}; @@ -107,11 +108,6 @@ Return RadioResponse::sendDtmfResponse(const V1_0::RadioResponseInfo& info return {}; } -Return RadioResponse::setupDataCallResponse(const V1_0::RadioResponseInfo& info, - const V1_0::SetupDataCallResult& dcResponse) { - return {}; -} - Return RadioResponse::getClirResponse(const V1_0::RadioResponseInfo& info, int32_t n, int32_t m) { return {}; @@ -143,10 +139,6 @@ Return RadioResponse::acceptCallResponse(const V1_0::RadioResponseInfo& in return {}; } -Return RadioResponse::deactivateDataCallResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::setBarringPasswordResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -201,11 +193,6 @@ Return RadioResponse::getClipResponse(const V1_0::RadioResponseInfo& info, return {}; } -Return RadioResponse::getDataCallListResponse( - const V1_0::RadioResponseInfo& info, const hidl_vec& dcResp) { - return {}; -} - Return RadioResponse::setSuppServiceNotificationsResponse( const V1_0::RadioResponseInfo& info) { return {}; @@ -306,10 +293,6 @@ Return RadioResponse::setCellInfoListRateResponse(const V1_0::RadioRespons return {}; } -Return RadioResponse::setInitialAttachApnResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::getImsRegistrationStateResponse( // const V1_0::RadioResponseInfo& info, bool isRegd, V1_0::RadioTechnologyFamily ratFamily) { return {}; @@ -332,19 +315,11 @@ Return RadioResponse::nvResetConfigResponse(const V1_0::RadioResponseInfo& return {}; } -Return RadioResponse::setDataAllowedResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::getHardwareConfigResponse( const V1_0::RadioResponseInfo& info, const hidl_vec& config) { return {}; } -Return RadioResponse::setDataProfileResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::requestShutdownResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -395,15 +370,6 @@ Return RadioResponse::stopNetworkScanResponse(const V1_0::RadioResponseInf return {}; } -Return RadioResponse::startKeepaliveResponse(const V1_0::RadioResponseInfo& info, - const V1_1::KeepaliveStatus& status) { - return {}; -} - -Return RadioResponse::stopKeepaliveResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::getCellInfoListResponse_1_2(const V1_0::RadioResponseInfo& info, const hidl_vec& cellInfo) { return {}; @@ -482,17 +448,6 @@ Return RadioResponse::setPreferredNetworkTypeBitmapResponse( return {}; } -Return RadioResponse::getDataCallListResponse_1_4( - const V1_0::RadioResponseInfo& info, - const hidl_vec& dcResponse) { - return {}; -} - -Return RadioResponse::setupDataCallResponse_1_4(const V1_0::RadioResponseInfo& info, - const V1_4::SetupDataCallResult& dcResponse) { - return {}; -} - Return RadioResponse::getSignalStrengthResponse_1_4( const V1_0::RadioResponseInfo& info, const V1_4::SignalStrength& signalStrength) { return {}; @@ -517,25 +472,6 @@ Return RadioResponse::startNetworkScanResponse_1_5(const V1_0::RadioRespon return {}; } -Return RadioResponse::setupDataCallResponse_1_5(const V1_0::RadioResponseInfo& info, - const V1_5::SetupDataCallResult& dcResponse) { - return {}; -} - -Return RadioResponse::getDataCallListResponse_1_5( - const V1_0::RadioResponseInfo& info, - const hidl_vec& dcResponse) { - return {}; -} - -Return RadioResponse::setInitialAttachApnResponse_1_5(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setDataProfileResponse_1_5(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::setRadioPowerResponse_1_5(const V1_0::RadioResponseInfo& info) { return {}; } @@ -574,17 +510,6 @@ Return RadioResponse::setRadioPowerResponse_1_6(const V1_6::RadioResponseI return {}; } -Return RadioResponse::setupDataCallResponse_1_6(const V1_6::RadioResponseInfo& info, - const V1_6::SetupDataCallResult& dcResponse) { - return {}; -} - -Return RadioResponse::getDataCallListResponse_1_6( - const V1_6::RadioResponseInfo& info, - const hidl_vec& dcResponse) { - return {}; -} - Return RadioResponse::setNrDualConnectivityStateResponse( const V1_6::RadioResponseInfo& info) { return {}; @@ -595,23 +520,6 @@ Return RadioResponse::isNrDualConnectivityEnabledResponse(const V1_6::Radi return {}; } -Return RadioResponse::allocatePduSessionIdResponse(const V1_6::RadioResponseInfo& info, - int32_t id) { - return {}; -} - -Return RadioResponse::releasePduSessionIdResponse(const V1_6::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::startHandoverResponse(const V1_6::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::cancelHandoverResponse(const V1_6::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::setAllowedNetworkTypesBitmapResponse( const V1_6::RadioResponseInfo& info) { return {}; @@ -623,10 +531,6 @@ Return RadioResponse::getAllowedNetworkTypesBitmapResponse( return {}; } -Return RadioResponse::setDataThrottlingResponse(const V1_6::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::getSystemSelectionChannelsResponse( const V1_6::RadioResponseInfo& info, const hidl_vec& specifiers) { @@ -658,9 +562,4 @@ Return RadioResponse::getCurrentCallsResponse_1_6(const V1_6::RadioRespons return {}; } -Return RadioResponse::getSlicingConfigResponse(const V1_6::RadioResponseInfo& info, - const V1_6::SlicingConfig& slicingConfig) { - return {}; -} - } // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/collections.h b/radio/aidl/compat/libradiocompat/collections.h index 9ef1351a8c..e3439a75d7 100644 --- a/radio/aidl/compat/libradiocompat/collections.h +++ b/radio/aidl/compat/libradiocompat/collections.h @@ -17,6 +17,9 @@ #include +#include +#include + namespace android::hardware::radio::compat { /** @@ -51,4 +54,53 @@ auto toHidl(const std::vector& inp) { return out; } +/** + * Converts T=OptionalX HIDL value to std::optional AIDL value. + * + * To convert values, the template uses toAidl functions for a given type T.value. + */ +template +std::optional toAidl(const T& opt) { + if (opt.getDiscriminator() == T::hidl_discriminator::noinit) return std::nullopt; + return toAidl(opt.value()); +} + +/** + * Converts T=OptionalX HIDL value to std::variant AIDL value. + * + * For some reason, not every OptionalX gets generated into a std::optional. + */ +template +std::variant toAidlVariant(const T& opt) { + if (opt.getDiscriminator() == T::hidl_discriminator::noinit) return false; + return toAidl(opt.value()); +} + +/** + * Converts std::optional AIDL value to T=OptionalX HIDL value. + * + * X is inferred from toAidl(T.value) declaration. Please note that toAidl(T.value) doesn't have to + * be implemented if it's not needed for anything else than giving this hint to type system. + * + * To convert values, the template uses toHidl functions for a given type T, assuming it's defined. + * + * \param opt value to convert + */ +template +T toHidl(const std::optional& opt) { + T hidl; + if (opt.has_value()) hidl.value(toHidl(*opt)); + return hidl; +} + +/** + * Converts U AIDL bitfield value to HIDL T bitfield value. + * + * \param val value to convert + */ +template +hidl_bitfield toHidlBitfield(U val) { + return static_cast(val); +} + } // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/commonStructs.cpp b/radio/aidl/compat/libradiocompat/commonStructs.cpp index affd00a7ab..c25768dc27 100644 --- a/radio/aidl/compat/libradiocompat/commonStructs.cpp +++ b/radio/aidl/compat/libradiocompat/commonStructs.cpp @@ -40,6 +40,14 @@ uint8_t toAidl(int8_t v) { return v; } +int8_t toAidl(uint8_t v) { + return v; +} + +int32_t toAidl(uint32_t v) { + return v; +} + aidl::RadioIndicationType toAidl(V1_0::RadioIndicationType type) { return aidl::RadioIndicationType(type); } diff --git a/radio/aidl/compat/libradiocompat/commonStructs.h b/radio/aidl/compat/libradiocompat/commonStructs.h index 9b3115d7f8..b8599167c9 100644 --- a/radio/aidl/compat/libradiocompat/commonStructs.h +++ b/radio/aidl/compat/libradiocompat/commonStructs.h @@ -26,6 +26,8 @@ V1_6::RadioResponseInfo notSupported(int32_t serial); std::string toAidl(const hidl_string& str); hidl_string toHidl(const std::string& str); uint8_t toAidl(int8_t v); +int8_t toAidl(uint8_t v); +int32_t toAidl(uint32_t v); aidl::android::hardware::radio::RadioIndicationType toAidl(V1_0::RadioIndicationType type); aidl::android::hardware::radio::RadioResponseType toAidl(V1_0::RadioResponseType type); diff --git a/radio/aidl/compat/libradiocompat/data/RadioData.cpp b/radio/aidl/compat/libradiocompat/data/RadioData.cpp new file mode 100644 index 0000000000..fdb127318e --- /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 + +#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& 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& dataResponse, + const std::shared_ptr& 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& addresses, + const std::vector& dnses, int32_t pduSessId, + const std::optional& sliceInfo, + const std::optional& 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(sliceInfo), + toHidl(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 0000000000..f51d1a8d37 --- /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 + +#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 dataCb) { + CHECK(dataCb); + mDataCb = dataCb; +} + +Return RadioIndication::dataCallListChanged(V1_0::RadioIndicationType type, + const hidl_vec&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.0 not supported"; + return {}; +} + +Return RadioIndication::dataCallListChanged_1_4(V1_0::RadioIndicationType type, + const hidl_vec&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.4 not supported"; + return {}; +} + +Return RadioIndication::dataCallListChanged_1_5( + V1_0::RadioIndicationType type, const hidl_vec& dcList) { + LOG_CALL << type; + CHECK_CB(mDataCb); + mDataCb->dataCallListChanged(toAidl(type), toAidl(dcList)); + return {}; +} + +Return RadioIndication::dataCallListChanged_1_6( + V1_0::RadioIndicationType type, const hidl_vec& dcList) { + LOG_CALL << type; + CHECK_CB(mDataCb); + mDataCb->dataCallListChanged(toAidl(type), toAidl(dcList)); + return {}; +} + +Return 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 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 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 0000000000..171f692d41 --- /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 + +#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 dataCb) { + CHECK(dataCb); + mDataCb = dataCb; +} + +Return RadioResponse::allocatePduSessionIdResponse(const V1_6::RadioResponseInfo& info, + int32_t id) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->allocatePduSessionIdResponse(toAidl(info), id); + return {}; +} + +Return RadioResponse::cancelHandoverResponse(const V1_6::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->cancelHandoverResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::deactivateDataCallResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->deactivateDataCallResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::getDataCallListResponse(const V1_0::RadioResponseInfo& info, + const hidl_vec&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.0 not supported"; + return {}; +} + +Return RadioResponse::getDataCallListResponse_1_4( + const V1_0::RadioResponseInfo& info, const hidl_vec&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.4 not supported"; + return {}; +} + +Return RadioResponse::getDataCallListResponse_1_5( + const V1_0::RadioResponseInfo& info, + const hidl_vec& dcResponse) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->getDataCallListResponse(toAidl(info), toAidl(dcResponse)); + return {}; +} + +Return RadioResponse::getDataCallListResponse_1_6( + const V1_6::RadioResponseInfo& info, + const hidl_vec& dcResponse) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->getDataCallListResponse(toAidl(info), toAidl(dcResponse)); + return {}; +} + +Return 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 RadioResponse::releasePduSessionIdResponse(const V1_6::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->releasePduSessionIdResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setDataAllowedResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->setDataAllowedResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setDataProfileResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->setDataProfileResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setDataProfileResponse_1_5(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->setDataProfileResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setDataThrottlingResponse(const V1_6::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->setDataThrottlingResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setInitialAttachApnResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->setInitialAttachApnResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setInitialAttachApnResponse_1_5(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->setInitialAttachApnResponse(toAidl(info)); + return {}; +} + +Return 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 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 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 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 RadioResponse::startHandoverResponse(const V1_6::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mDataCb); + mDataCb->startHandoverResponse(toAidl(info)); + return {}; +} + +Return 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 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 0000000000..4ff89a1491 --- /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 + +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(info.supportedApnTypesBitmap), + .bearerBitmap = toHidlBitfield(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(addr.deprecationTime), + .expirationTime = static_cast(addr.expirationTime), + }; +} + +aidl::SliceInfo toAidl(const V1_6::SliceInfo& info) { + return { + .sliceServiceType = static_cast(info.sst), + .sliceDifferentiator = info.sliceDifferentiator, + .mappedHplmnSst = static_cast(info.mappedHplmnSst), + .mappedHplmnSd = info.mappedHplmnSD, + .status = static_cast(info.status), + }; +} + +V1_6::SliceInfo toHidl(const aidl::SliceInfo& info) { + return { + .sst = static_cast(info.sliceServiceType), + .sliceDifferentiator = info.sliceDifferentiator, + .mappedHplmnSst = static_cast(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(descr.dnn), + .osAppId = toHidl(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(bw.maxBitrateKbps), + .guaranteedBitrateKbps = static_cast(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(qos.qfi), + .averagingWindowMs = qos.averagingWindowMs, + }; +} + +static std::variant 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(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(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(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(addr.deprecationTime), + .expirationTime = static_cast(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 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(filter.protocol), + .tos = toAidlVariant(filter.tos), + .flowLabel = toAidlVariant(filter.flowLabel), + .spi = toAidlVariant(filter.spi), + .direction = static_cast(filter.direction), + .precedence = filter.precedence, + }; +} + +aidl::KeepaliveStatus toAidl(const V1_1::KeepaliveStatus& status) { + return { + .sessionHandle = status.sessionHandle, + .code = static_cast(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(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(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 0000000000..60fad57f51 --- /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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioData.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioData.h new file mode 100644 index 0000000000..900a669064 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioData.h @@ -0,0 +1,70 @@ +/* + * 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 RadioData : public RadioCompatBase, public aidl::android::hardware::radio::data::BnRadioData { + ::ndk::ScopedAStatus allocatePduSessionId(int32_t serial) override; + ::ndk::ScopedAStatus cancelHandover(int32_t serial, int32_t callId) override; + ::ndk::ScopedAStatus deactivateDataCall( + int32_t serial, int32_t cid, + ::aidl::android::hardware::radio::data::DataRequestReason reason) override; + ::ndk::ScopedAStatus getDataCallList(int32_t serial) override; + ::ndk::ScopedAStatus getSlicingConfig(int32_t serial) override; + ::ndk::ScopedAStatus releasePduSessionId(int32_t serial, int32_t id) override; + ::ndk::ScopedAStatus responseAcknowledgement() override; + ::ndk::ScopedAStatus setDataAllowed(int32_t serial, bool allow) override; + ::ndk::ScopedAStatus setDataProfile( + int32_t serial, + const std::vector<::aidl::android::hardware::radio::data::DataProfileInfo>& profiles) + override; + ::ndk::ScopedAStatus setDataThrottling( + int32_t serial, + ::aidl::android::hardware::radio::data::DataThrottlingAction dataThrottlingAction, + int64_t completionDurationMillis) override; + ::ndk::ScopedAStatus setInitialAttachApn( + int32_t serial, + const ::aidl::android::hardware::radio::data::DataProfileInfo& dpInfo) override; + ::ndk::ScopedAStatus setResponseFunctions( + const std::shared_ptr<::aidl::android::hardware::radio::data::IRadioDataResponse>& + radioDataResponse, + const std::shared_ptr<::aidl::android::hardware::radio::data::IRadioDataIndication>& + radioDataIndication) override; + ::ndk::ScopedAStatus setupDataCall( + int32_t serial, ::aidl::android::hardware::radio::AccessNetwork accessNetwork, + const ::aidl::android::hardware::radio::data::DataProfileInfo& dataProfileInfo, + bool roamingAllowed, ::aidl::android::hardware::radio::data::DataRequestReason reason, + const std::vector<::aidl::android::hardware::radio::data::LinkAddress>& addresses, + const std::vector& dnses, int32_t pduSessionId, + const std::optional<::aidl::android::hardware::radio::data::SliceInfo>& sliceInfo, + const std::optional<::aidl::android::hardware::radio::data::TrafficDescriptor>& trDescr, + bool matchAllRuleAllowed) override; + ::ndk::ScopedAStatus startHandover(int32_t serial, int32_t callId) override; + ::ndk::ScopedAStatus startKeepalive( + int32_t serial, + const ::aidl::android::hardware::radio::data::KeepaliveRequest& keepalive) override; + ::ndk::ScopedAStatus stopKeepalive(int32_t serial, int32_t sessionHandle) override; + + public: + using RadioCompatBase::RadioCompatBase; +}; + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h index bc2b84107a..63142d690e 100644 --- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include #include @@ -22,6 +23,7 @@ namespace android::hardware::radio::compat { 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::sim::IRadioSimIndication> mSimCb; @@ -173,6 +175,8 @@ class RadioIndication : public V1_6::IRadioIndication { const hidl_vec& records) override; public: + void setResponseFunction( + std::shared_ptr<::aidl::android::hardware::radio::data::IRadioDataIndication> dataCb); void setResponseFunction( std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingIndication> radioMessagingIndication); diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h index f87e8a6d21..d06abb9624 100644 --- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h @@ -15,6 +15,7 @@ */ #pragma once +#include #include #include #include @@ -22,6 +23,7 @@ namespace android::hardware::radio::compat { 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::sim::IRadioSimResponse> mSimCb; @@ -401,6 +403,8 @@ class RadioResponse : public V1_6::IRadioResponse { int32_t updatedRecordIndex) override; public: + void setResponseFunction( + std::shared_ptr<::aidl::android::hardware::radio::data::IRadioDataResponse> dataCb); void setResponseFunction( std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingResponse> radioMessagingResponse); diff --git a/radio/aidl/compat/service/Android.bp b/radio/aidl/compat/service/Android.bp index 6a1cad546c..e97e2db73e 100644 --- a/radio/aidl/compat/service/Android.bp +++ b/radio/aidl/compat/service/Android.bp @@ -39,6 +39,7 @@ cc_binary { "android.hardware.radio.config@1.1", "android.hardware.radio.config@1.2", "android.hardware.radio.config@1.3", + "android.hardware.radio.data-V1-ndk", "android.hardware.radio.messaging-V1-ndk", "android.hardware.radio.sim-V1-ndk", "android.hardware.radio@1.0", diff --git a/radio/aidl/compat/service/radio-compat.xml b/radio/aidl/compat/service/radio-compat.xml index 2164b28b46..ac812fb91f 100644 --- a/radio/aidl/compat/service/radio-compat.xml +++ b/radio/aidl/compat/service/radio-compat.xml @@ -9,6 +9,10 @@ You can either copy the following tags to device manifest or simply uncomment them here for quick testing. + + android.hardware.radio.data + IRadioData/slot1 + android.hardware.radio.messaging IRadioMessaging/slot1 diff --git a/radio/aidl/compat/service/service.cpp b/radio/aidl/compat/service/service.cpp index e6dd03d2c9..c97b47a097 100644 --- a/radio/aidl/compat/service/service.cpp +++ b/radio/aidl/compat/service/service.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -57,6 +58,7 @@ static void publishRadio(std::string slot) { auto indicationCb = sp::make(); radioHidl->setResponseFunctions(responseCb, indicationCb).assertOk(); + publishRadioHal(radioHidl, responseCb, indicationCb, slot); publishRadioHal(radioHidl, responseCb, indicationCb, slot); publishRadioHal(radioHidl, responseCb, indicationCb, slot); } From 70ac7bfb86c5bf9e69777470b7018873ecfddf75 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Wed, 3 Nov 2021 15:15:48 -0700 Subject: [PATCH 5/7] Implement RadioNetwork for AIDL-HIDL Telephony HAL translator Bug: 203699028 Test: Boot and grep logcat against radiocompat Change-Id: Ic44227c9e2cd38ead97d3f3dda2e028052876568 --- radio/aidl/compat/libradiocompat/Android.bp | 6 + .../compat/libradiocompat/RadioIndication.cpp | 145 ---- .../compat/libradiocompat/RadioResponse.cpp | 299 +------- .../include/libradiocompat/RadioIndication.h | 4 + .../include/libradiocompat/RadioNetwork.h | 96 +++ .../include/libradiocompat/RadioResponse.h | 4 + .../network/RadioIndication-network.cpp | 259 +++++++ .../libradiocompat/network/RadioNetwork.cpp | 281 ++++++++ .../network/RadioResponse-network.cpp | 506 +++++++++++++ .../compat/libradiocompat/network/structs.cpp | 668 ++++++++++++++++++ .../compat/libradiocompat/network/structs.h | 99 +++ .../compat/libradiocompat/network/utils.cpp | 196 +++++ .../compat/libradiocompat/network/utils.h | 25 + radio/aidl/compat/service/Android.bp | 1 + radio/aidl/compat/service/radio-compat.xml | 4 + radio/aidl/compat/service/service.cpp | 2 + 16 files changed, 2152 insertions(+), 443 deletions(-) create mode 100644 radio/aidl/compat/libradiocompat/include/libradiocompat/RadioNetwork.h create mode 100644 radio/aidl/compat/libradiocompat/network/RadioIndication-network.cpp create mode 100644 radio/aidl/compat/libradiocompat/network/RadioNetwork.cpp create mode 100644 radio/aidl/compat/libradiocompat/network/RadioResponse-network.cpp create mode 100644 radio/aidl/compat/libradiocompat/network/structs.cpp create mode 100644 radio/aidl/compat/libradiocompat/network/structs.h create mode 100644 radio/aidl/compat/libradiocompat/network/utils.cpp create mode 100644 radio/aidl/compat/libradiocompat/network/utils.h diff --git a/radio/aidl/compat/libradiocompat/Android.bp b/radio/aidl/compat/libradiocompat/Android.bp index 0e6496aeb3..fdee336f4f 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.network-V1-ndk", "android.hardware.radio.sim-V1-ndk", "android.hardware.radio@1.0", "android.hardware.radio@1.1", @@ -69,6 +70,11 @@ cc_library { "messaging/RadioMessaging.cpp", "messaging/RadioResponse-messaging.cpp", "messaging/structs.cpp", + "network/RadioIndication-network.cpp", + "network/RadioNetwork.cpp", + "network/RadioResponse-network.cpp", + "network/structs.cpp", + "network/utils.cpp", "sim/RadioIndication-sim.cpp", "sim/RadioResponse-sim.cpp", "sim/RadioSim.cpp", diff --git a/radio/aidl/compat/libradiocompat/RadioIndication.cpp b/radio/aidl/compat/libradiocompat/RadioIndication.cpp index b6a7e72619..90b9e752d8 100644 --- a/radio/aidl/compat/libradiocompat/RadioIndication.cpp +++ b/radio/aidl/compat/libradiocompat/RadioIndication.cpp @@ -30,25 +30,6 @@ Return RadioIndication::callStateChanged(V1_0::RadioIndicationType type) { return {}; } -Return RadioIndication::networkStateChanged(V1_0::RadioIndicationType type) { - return {}; -} - -Return RadioIndication::nitzTimeReceived(V1_0::RadioIndicationType type, - const hidl_string& nitzTime, uint64_t receivedTime) { - return {}; -} - -Return RadioIndication::currentSignalStrength(V1_0::RadioIndicationType type, - const V1_0::SignalStrength& signalStrength) { - return {}; -} - -Return RadioIndication::suppSvcNotify(V1_0::RadioIndicationType type, - const V1_0::SuppSvcNotification& suppSvc) { - return {}; -} - Return RadioIndication::stkCallSetup(V1_0::RadioIndicationType type, int64_t timeout) { return {}; } @@ -58,11 +39,6 @@ Return RadioIndication::callRing(V1_0::RadioIndicationType type, bool isGs return {}; } -Return RadioIndication::restrictedStateChanged(V1_0::RadioIndicationType type, - V1_0::PhoneRestrictedState state) { - return {}; -} - Return RadioIndication::enterEmergencyCallbackMode(V1_0::RadioIndicationType type) { return {}; } @@ -90,10 +66,6 @@ Return RadioIndication::resendIncallMute(V1_0::RadioIndicationType type) { return {}; } -Return RadioIndication::cdmaPrlChanged(V1_0::RadioIndicationType type, int32_t version) { - return {}; -} - Return RadioIndication::exitEmergencyCallbackMode(V1_0::RadioIndicationType type) { return {}; } @@ -102,20 +74,6 @@ Return RadioIndication::rilConnected(V1_0::RadioIndicationType type) { return {}; } -Return RadioIndication::voiceRadioTechChanged(V1_0::RadioIndicationType type, - V1_0::RadioTechnology rat) { - return {}; -} - -Return RadioIndication::cellInfoList(V1_0::RadioIndicationType type, - const hidl_vec& records) { - return {}; -} - -Return RadioIndication::imsNetworkStateChanged(V1_0::RadioIndicationType type) { - return {}; -} - Return RadioIndication::srvccStateNotify(V1_0::RadioIndicationType type, V1_0::SrvccState state) { return {}; @@ -141,117 +99,14 @@ Return RadioIndication::stkCallControlAlphaNotify(V1_0::RadioIndicationTyp return {}; } -Return RadioIndication::lceData(V1_0::RadioIndicationType type, - const V1_0::LceDataInfo& lce) { - return {}; -} - Return RadioIndication::modemReset(V1_0::RadioIndicationType type, const hidl_string& reason) { return {}; } -Return RadioIndication::networkScanResult(V1_0::RadioIndicationType type, - const V1_1::NetworkScanResult& result) { - return {}; -} - -Return RadioIndication::networkScanResult_1_2(V1_0::RadioIndicationType type, - const V1_2::NetworkScanResult& result) { - return {}; -} - -Return RadioIndication::cellInfoList_1_2(V1_0::RadioIndicationType type, - const hidl_vec& records) { - return {}; -} - -Return RadioIndication::currentLinkCapacityEstimate(V1_0::RadioIndicationType type, - const V1_2::LinkCapacityEstimate& lce) { - return {}; -} - -Return RadioIndication::currentPhysicalChannelConfigs( - V1_0::RadioIndicationType type, const hidl_vec& configs) { - return {}; -} - -Return RadioIndication::currentSignalStrength_1_2( - V1_0::RadioIndicationType type, const V1_2::SignalStrength& signalStrength) { - return {}; -} - Return RadioIndication::currentEmergencyNumberList( V1_0::RadioIndicationType type, const hidl_vec& emergencyNumbers) { return {}; } -Return RadioIndication::cellInfoList_1_4(V1_0::RadioIndicationType type, - const hidl_vec& records) { - return {}; -} - -Return RadioIndication::networkScanResult_1_4(V1_0::RadioIndicationType type, - const V1_4::NetworkScanResult& result) { - return {}; -} - -Return RadioIndication::currentPhysicalChannelConfigs_1_4( - V1_0::RadioIndicationType type, const hidl_vec& configs) { - return {}; -} - -Return RadioIndication::currentSignalStrength_1_4( - V1_0::RadioIndicationType type, const V1_4::SignalStrength& signalStrength) { - return {}; -} - -Return RadioIndication::registrationFailed( // - V1_0::RadioIndicationType type, const V1_5::CellIdentity& cellIdentity, - const hidl_string& chosenPlmn, hidl_bitfield domain, int32_t causeCode, - int32_t additionalCauseCode) { - return {}; -} - -Return RadioIndication::barringInfoChanged(V1_0::RadioIndicationType type, - const V1_5::CellIdentity& cellIdentity, - const hidl_vec& barringInfos) { - return {}; -} - -Return RadioIndication::cellInfoList_1_5(V1_0::RadioIndicationType type, - const hidl_vec& records) { - return {}; -} - -Return RadioIndication::networkScanResult_1_5(V1_0::RadioIndicationType type, - const V1_5::NetworkScanResult& result) { - return {}; -} - -Return RadioIndication::currentLinkCapacityEstimate_1_6( - V1_0::RadioIndicationType type, const V1_6::LinkCapacityEstimate& lce) { - return {}; -} - -Return RadioIndication::currentSignalStrength_1_6( - V1_0::RadioIndicationType type, const V1_6::SignalStrength& signalStrength) { - return {}; -} - -Return RadioIndication::cellInfoList_1_6(V1_0::RadioIndicationType type, - const hidl_vec& records) { - return {}; -} - -Return RadioIndication::networkScanResult_1_6(V1_0::RadioIndicationType type, - const V1_6::NetworkScanResult& result) { - return {}; -} - -Return RadioIndication::currentPhysicalChannelConfigs_1_6( - V1_0::RadioIndicationType type, const hidl_vec& configs) { - return {}; -} - } // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/RadioResponse.cpp b/radio/aidl/compat/libradiocompat/RadioResponse.cpp index 0a38d8cff3..001330fbd9 100644 --- a/radio/aidl/compat/libradiocompat/RadioResponse.cpp +++ b/radio/aidl/compat/libradiocompat/RadioResponse.cpp @@ -30,15 +30,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 (mNetworkCb) mNetworkCb->acknowledgeRequest(serial); if (mSimCb) mSimCb->acknowledgeRequest(serial); return {}; } -Return RadioResponse::supplyNetworkDepersonalizationResponse( - const V1_0::RadioResponseInfo& info, int32_t remainingRetries) { - return {}; -} - Return RadioResponse::getCurrentCallsResponse(const V1_0::RadioResponseInfo& info, const hidl_vec& calls) { return {}; @@ -79,27 +75,6 @@ Return RadioResponse::getLastCallFailCauseResponse( return {}; } -Return RadioResponse::getSignalStrengthResponse(const V1_0::RadioResponseInfo& info, - const V1_0::SignalStrength& sigStrength) { - return {}; -} - -Return RadioResponse::getVoiceRegistrationStateResponse( - const V1_0::RadioResponseInfo& info, const V1_0::VoiceRegStateResult& voiceRegResponse) { - return {}; -} - -Return RadioResponse::getDataRegistrationStateResponse( - const V1_0::RadioResponseInfo& info, const V1_0::DataRegStateResult& dataRegResponse) { - return {}; -} - -Return RadioResponse::getOperatorResponse( // - const V1_0::RadioResponseInfo& info, const hidl_string& longName, - const hidl_string& shortName, const hidl_string& numeric) { - return {}; -} - Return RadioResponse::setRadioPowerResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -139,30 +114,6 @@ Return RadioResponse::acceptCallResponse(const V1_0::RadioResponseInfo& in return {}; } -Return RadioResponse::setBarringPasswordResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getNetworkSelectionModeResponse(const V1_0::RadioResponseInfo& info, - bool manual) { - return {}; -} - -Return RadioResponse::setNetworkSelectionModeAutomaticResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setNetworkSelectionModeManualResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getAvailableNetworksResponse( - const V1_0::RadioResponseInfo& info, const hidl_vec& networkInfos) { - return {}; -} - Return RadioResponse::startDtmfResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -193,20 +144,6 @@ Return RadioResponse::getClipResponse(const V1_0::RadioResponseInfo& info, return {}; } -Return RadioResponse::setSuppServiceNotificationsResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setBandModeResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getAvailableBandModesResponse( - const V1_0::RadioResponseInfo& info, const hidl_vec& bandModes) { - return {}; -} - Return RadioResponse::handleStkCallSetupRequestFromSimResponse( const V1_0::RadioResponseInfo& info) { return {}; @@ -216,33 +153,6 @@ Return RadioResponse::explicitCallTransferResponse(const V1_0::RadioRespon return {}; } -Return RadioResponse::setPreferredNetworkTypeResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getPreferredNetworkTypeResponse(const V1_0::RadioResponseInfo& info, - V1_0::PreferredNetworkType nwType) { - return {}; -} - -Return RadioResponse::getNeighboringCidsResponse( - const V1_0::RadioResponseInfo& info, const hidl_vec& cells) { - return {}; -} - -Return RadioResponse::setLocationUpdatesResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setCdmaRoamingPreferenceResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getCdmaRoamingPreferenceResponse(const V1_0::RadioResponseInfo& info, - V1_0::CdmaRoamingType type) { - return {}; -} - Return RadioResponse::setTTYModeResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -279,25 +189,6 @@ Return RadioResponse::exitEmergencyCallbackModeResponse(const V1_0::RadioR return {}; } -Return RadioResponse::getVoiceRadioTechnologyResponse(const V1_0::RadioResponseInfo& info, - V1_0::RadioTechnology rat) { - return {}; -} - -Return RadioResponse::getCellInfoListResponse(const V1_0::RadioResponseInfo& info, - const hidl_vec& cellInfo) { - return {}; -} - -Return RadioResponse::setCellInfoListRateResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getImsRegistrationStateResponse( // - const V1_0::RadioResponseInfo& info, bool isRegd, V1_0::RadioTechnologyFamily ratFamily) { - return {}; -} - Return RadioResponse::nvReadItemResponse(const V1_0::RadioResponseInfo& info, const hidl_string& result) { return {}; @@ -334,21 +225,6 @@ Return RadioResponse::setRadioCapabilityResponse(const V1_0::RadioResponse return {}; } -Return RadioResponse::startLceServiceResponse(const V1_0::RadioResponseInfo& info, - const V1_0::LceStatusInfo& statusInfo) { - return {}; -} - -Return RadioResponse::stopLceServiceResponse(const V1_0::RadioResponseInfo& info, - const V1_0::LceStatusInfo& statusInfo) { - return {}; -} - -Return RadioResponse::pullLceDataResponse(const V1_0::RadioResponseInfo& info, - const V1_0::LceDataInfo& lceInfo) { - return {}; -} - Return RadioResponse::getModemActivityInfoResponse( const V1_0::RadioResponseInfo& info, const V1_0::ActivityStatsInfo& activityInfo) { return {}; @@ -358,58 +234,11 @@ Return RadioResponse::sendDeviceStateResponse(const V1_0::RadioResponseInf return {}; } -Return RadioResponse::setIndicationFilterResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::startNetworkScanResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::stopNetworkScanResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getCellInfoListResponse_1_2(const V1_0::RadioResponseInfo& info, - const hidl_vec& cellInfo) { - return {}; -} - -Return RadioResponse::setSignalStrengthReportingCriteriaResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setLinkCapacityReportingCriteriaResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::getCurrentCallsResponse_1_2(const V1_0::RadioResponseInfo& info, const hidl_vec& calls) { return {}; } -Return RadioResponse::getSignalStrengthResponse_1_2( - const V1_0::RadioResponseInfo& info, const V1_2::SignalStrength& signalStrength) { - return {}; -} - -Return RadioResponse::getVoiceRegistrationStateResponse_1_2( - const V1_0::RadioResponseInfo& info, const V1_2::VoiceRegStateResult& voiceRegResponse) { - return {}; -} - -Return RadioResponse::getDataRegistrationStateResponse_1_2( - const V1_0::RadioResponseInfo& info, const V1_2::DataRegStateResult& dataRegResponse) { - return {}; -} - -Return RadioResponse::setSystemSelectionChannelsResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::enableModemResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -423,140 +252,14 @@ Return RadioResponse::emergencyDialResponse(const V1_0::RadioResponseInfo& return {}; } -Return RadioResponse::startNetworkScanResponse_1_4(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getCellInfoListResponse_1_4(const V1_0::RadioResponseInfo& info, - const hidl_vec& cellInfo) { - return {}; -} - -Return RadioResponse::getDataRegistrationStateResponse_1_4( - const V1_0::RadioResponseInfo& info, const V1_4::DataRegStateResult& dataRegResponse) { - return {}; -} - -Return RadioResponse::getPreferredNetworkTypeBitmapResponse( - const V1_0::RadioResponseInfo& info, - hidl_bitfield networkTypeBitmap) { - return {}; -} - -Return RadioResponse::setPreferredNetworkTypeBitmapResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getSignalStrengthResponse_1_4( - const V1_0::RadioResponseInfo& info, const V1_4::SignalStrength& signalStrength) { - return {}; -} - -Return RadioResponse::setSignalStrengthReportingCriteriaResponse_1_5( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setLinkCapacityReportingCriteriaResponse_1_5( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setSystemSelectionChannelsResponse_1_5( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::startNetworkScanResponse_1_5(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::setRadioPowerResponse_1_5(const V1_0::RadioResponseInfo& info) { return {}; } -Return RadioResponse::setIndicationFilterResponse_1_5(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getBarringInfoResponse( - const V1_0::RadioResponseInfo& info, const V1_5::CellIdentity& cellIdentity, - const hidl_vec& barringInfos) { - return {}; -} - -Return RadioResponse::getVoiceRegistrationStateResponse_1_5( - const V1_0::RadioResponseInfo& info, const V1_5::RegStateResult& voiceRegResponse) { - return {}; -} - -Return RadioResponse::getDataRegistrationStateResponse_1_5( - const V1_0::RadioResponseInfo& info, const V1_5::RegStateResult& dataRegResponse) { - return {}; -} - -Return RadioResponse::getCellInfoListResponse_1_5(const V1_0::RadioResponseInfo& info, - const hidl_vec& cellInfo) { - return {}; -} - -Return RadioResponse::setNetworkSelectionModeManualResponse_1_5( - const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::setRadioPowerResponse_1_6(const V1_6::RadioResponseInfo& info) { return {}; } -Return RadioResponse::setNrDualConnectivityStateResponse( - const V1_6::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::isNrDualConnectivityEnabledResponse(const V1_6::RadioResponseInfo& info, - bool isEnabled) { - return {}; -} - -Return RadioResponse::setAllowedNetworkTypesBitmapResponse( - const V1_6::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getAllowedNetworkTypesBitmapResponse( - const V1_6::RadioResponseInfo& info, - hidl_bitfield networkTypeBitmap) { - return {}; -} - -Return RadioResponse::getSystemSelectionChannelsResponse( - const V1_6::RadioResponseInfo& info, - const hidl_vec& specifiers) { - return {}; -} - -Return RadioResponse::getCellInfoListResponse_1_6(const V1_6::RadioResponseInfo& info, - const hidl_vec& cellInfo) { - return {}; -} - -Return RadioResponse::getSignalStrengthResponse_1_6( - const V1_6::RadioResponseInfo& info, const V1_6::SignalStrength& signalStrength) { - return {}; -} - -Return RadioResponse::getVoiceRegistrationStateResponse_1_6( - const V1_6::RadioResponseInfo& info, const V1_6::RegStateResult& voiceRegResponse) { - return {}; -} - -Return RadioResponse::getDataRegistrationStateResponse_1_6( - const V1_6::RadioResponseInfo& info, const V1_6::RegStateResult& dataRegResponse) { - return {}; -} - Return RadioResponse::getCurrentCallsResponse_1_6(const V1_6::RadioResponseInfo& info, const hidl_vec& calls) { return {}; diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h index 63142d690e..c7a2629b7d 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 @@ -26,6 +27,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::network::IRadioNetworkIndication> mNetworkCb; std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimIndication> mSimCb; // IRadioIndication @ 1.0 @@ -180,6 +182,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::network::IRadioNetworkIndication> ni); void setResponseFunction( std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimIndication> simCb); }; diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioNetwork.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioNetwork.h new file mode 100644 index 0000000000..c776fd1f09 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioNetwork.h @@ -0,0 +1,96 @@ +/* + * 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 RadioNetwork : public RadioCompatBase, + public aidl::android::hardware::radio::network::BnRadioNetwork { + ::ndk::ScopedAStatus getAllowedNetworkTypesBitmap(int32_t serial) override; + ::ndk::ScopedAStatus getAvailableBandModes(int32_t serial) override; + ::ndk::ScopedAStatus getAvailableNetworks(int32_t serial) override; + ::ndk::ScopedAStatus getBarringInfo(int32_t serial) override; + ::ndk::ScopedAStatus getCdmaRoamingPreference(int32_t serial) override; + ::ndk::ScopedAStatus getCellInfoList(int32_t serial) override; + ::ndk::ScopedAStatus getDataRegistrationState(int32_t serial) override; + ::ndk::ScopedAStatus getImsRegistrationState(int32_t serial) override; + ::ndk::ScopedAStatus getNetworkSelectionMode(int32_t serial) override; + ::ndk::ScopedAStatus getOperator(int32_t serial) override; + ::ndk::ScopedAStatus getSignalStrength(int32_t serial) override; + ::ndk::ScopedAStatus getSystemSelectionChannels(int32_t serial) override; + ::ndk::ScopedAStatus getVoiceRadioTechnology(int32_t serial) override; + ::ndk::ScopedAStatus getVoiceRegistrationState(int32_t serial) override; + ::ndk::ScopedAStatus isNrDualConnectivityEnabled(int32_t serial) override; + ::ndk::ScopedAStatus responseAcknowledgement() override; + ::ndk::ScopedAStatus setAllowedNetworkTypesBitmap( + int32_t serial, + ::aidl::android::hardware::radio::RadioAccessFamily networkTypeBitmap) override; + ::ndk::ScopedAStatus setBandMode( + int32_t serial, ::aidl::android::hardware::radio::network::RadioBandMode mode) override; + ::ndk::ScopedAStatus setBarringPassword(int32_t serial, const std::string& facility, + const std::string& oldPassword, + const std::string& newPassword) override; + ::ndk::ScopedAStatus setCdmaRoamingPreference( + int32_t serial, + ::aidl::android::hardware::radio::network::CdmaRoamingType type) override; + ::ndk::ScopedAStatus setCellInfoListRate(int32_t serial, int32_t rate) override; + ::ndk::ScopedAStatus setIndicationFilter( + int32_t serial, + ::aidl::android::hardware::radio::network::IndicationFilter indicationFilter) override; + ::ndk::ScopedAStatus setLinkCapacityReportingCriteria( + int32_t serial, int32_t hysteresisMs, int32_t hysteresisDlKbps, + int32_t hysteresisUlKbps, const std::vector& thresholdsDownlinkKbps, + const std::vector& thresholdsUplinkKbps, + ::aidl::android::hardware::radio::AccessNetwork accessNetwork) override; + ::ndk::ScopedAStatus setLocationUpdates(int32_t serial, bool enable) override; + ::ndk::ScopedAStatus setNetworkSelectionModeAutomatic(int32_t serial) override; + ::ndk::ScopedAStatus setNetworkSelectionModeManual( + int32_t serial, const std::string& operatorNumeric, + ::aidl::android::hardware::radio::AccessNetwork ran) override; + ::ndk::ScopedAStatus setNrDualConnectivityState( + int32_t serial, + ::aidl::android::hardware::radio::network::NrDualConnectivityState nrSt) override; + ::ndk::ScopedAStatus setResponseFunctions( + const std::shared_ptr<::aidl::android::hardware::radio::network::IRadioNetworkResponse>& + radioNetworkResponse, + const std::shared_ptr< + ::aidl::android::hardware::radio::network::IRadioNetworkIndication>& + radioNetworkIndication) override; + ::ndk::ScopedAStatus setSignalStrengthReportingCriteria( + int32_t serial, + const std::vector<::aidl::android::hardware::radio::network::SignalThresholdInfo>& + signalThresholdInfos) override; + ::ndk::ScopedAStatus setSuppServiceNotifications(int32_t serial, bool enable) override; + ::ndk::ScopedAStatus setSystemSelectionChannels( + int32_t serial, bool specifyChannels, + const std::vector<::aidl::android::hardware::radio::network::RadioAccessSpecifier>& + specifiers) override; + ::ndk::ScopedAStatus startNetworkScan( + int32_t serial, + const ::aidl::android::hardware::radio::network::NetworkScanRequest& request) override; + ::ndk::ScopedAStatus stopNetworkScan(int32_t serial) override; + ::ndk::ScopedAStatus supplyNetworkDepersonalization(int32_t serial, + const std::string& netPin) 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 d06abb9624..b87ca6e235 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 @@ -26,6 +27,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::network::IRadioNetworkResponse> mNetworkCb; std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimResponse> mSimCb; // IRadioResponse @ 1.0 @@ -408,6 +410,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::network::IRadioNetworkResponse> nwCb); void setResponseFunction( std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimResponse> simCb); }; diff --git a/radio/aidl/compat/libradiocompat/network/RadioIndication-network.cpp b/radio/aidl/compat/libradiocompat/network/RadioIndication-network.cpp new file mode 100644 index 0000000000..899b133bfe --- /dev/null +++ b/radio/aidl/compat/libradiocompat/network/RadioIndication-network.cpp @@ -0,0 +1,259 @@ +/* + * 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 "NetworkIndication" + +namespace android::hardware::radio::compat { + +using ::aidl::android::hardware::radio::RadioTechnology; +namespace aidl = ::aidl::android::hardware::radio::network; + +void RadioIndication::setResponseFunction(std::shared_ptr netCb) { + CHECK(netCb); + mNetworkCb = netCb; +} + +Return RadioIndication::barringInfoChanged(V1_0::RadioIndicationType type, + const V1_5::CellIdentity& cellIdentity, + const hidl_vec& barringInfos) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->barringInfoChanged(toAidl(type), toAidl(cellIdentity), toAidl(barringInfos)); + return {}; +} + +Return RadioIndication::cdmaPrlChanged(V1_0::RadioIndicationType type, int32_t version) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->cdmaPrlChanged(toAidl(type), version); + return {}; +} + +Return RadioIndication::cellInfoList(V1_0::RadioIndicationType type, + const hidl_vec&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.0 not supported"; + return {}; +} + +Return RadioIndication::cellInfoList_1_2(V1_0::RadioIndicationType type, + const hidl_vec&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.2 not supported"; + return {}; +} + +Return RadioIndication::cellInfoList_1_4(V1_0::RadioIndicationType type, + const hidl_vec&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.4 not supported"; + return {}; +} + +Return RadioIndication::cellInfoList_1_5(V1_0::RadioIndicationType type, + const hidl_vec& records) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->cellInfoList(toAidl(type), toAidl(records)); + return {}; +} + +Return RadioIndication::cellInfoList_1_6(V1_0::RadioIndicationType type, + const hidl_vec& records) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->cellInfoList(toAidl(type), toAidl(records)); + return {}; +} + +Return RadioIndication::currentLinkCapacityEstimate(V1_0::RadioIndicationType type, + const V1_2::LinkCapacityEstimate& lce) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->currentLinkCapacityEstimate(toAidl(type), toAidl(lce)); + return {}; +} + +Return RadioIndication::currentLinkCapacityEstimate_1_6( + V1_0::RadioIndicationType type, const V1_6::LinkCapacityEstimate& lce) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->currentLinkCapacityEstimate(toAidl(type), toAidl(lce)); + return {}; +} + +Return RadioIndication::currentPhysicalChannelConfigs( + V1_0::RadioIndicationType type, const hidl_vec&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.0 not supported"; + return {}; +} + +Return RadioIndication::currentPhysicalChannelConfigs_1_4( + V1_0::RadioIndicationType type, const hidl_vec& configs) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->currentPhysicalChannelConfigs(toAidl(type), toAidl(configs)); + return {}; +} + +Return RadioIndication::currentPhysicalChannelConfigs_1_6( + V1_0::RadioIndicationType type, const hidl_vec& configs) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->currentPhysicalChannelConfigs(toAidl(type), toAidl(configs)); + return {}; +} + +Return RadioIndication::currentSignalStrength(V1_0::RadioIndicationType type, + const V1_0::SignalStrength&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.0 not supported"; + return {}; +} + +Return RadioIndication::currentSignalStrength_1_2(V1_0::RadioIndicationType type, + const V1_2::SignalStrength&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.2 not supported"; + return {}; +} + +Return RadioIndication::currentSignalStrength_1_4( + V1_0::RadioIndicationType type, const V1_4::SignalStrength& signalStrength) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->currentSignalStrength(toAidl(type), toAidl(signalStrength)); + return {}; +} + +Return RadioIndication::currentSignalStrength_1_6( + V1_0::RadioIndicationType type, const V1_6::SignalStrength& signalStrength) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->currentSignalStrength(toAidl(type), toAidl(signalStrength)); + return {}; +} + +Return RadioIndication::imsNetworkStateChanged(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->imsNetworkStateChanged(toAidl(type)); + return {}; +} + +Return RadioIndication::networkScanResult(V1_0::RadioIndicationType type, + const V1_1::NetworkScanResult&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.0 not supported"; + return {}; +} + +Return RadioIndication::networkScanResult_1_2(V1_0::RadioIndicationType type, + const V1_2::NetworkScanResult&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.2 not supported"; + return {}; +} + +Return RadioIndication::networkScanResult_1_4(V1_0::RadioIndicationType type, + const V1_4::NetworkScanResult&) { + LOG_CALL << type; + LOG(ERROR) << "IRadio HAL 1.4 not supported"; + return {}; +} + +Return RadioIndication::networkScanResult_1_5(V1_0::RadioIndicationType type, + const V1_5::NetworkScanResult& result) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->networkScanResult(toAidl(type), toAidl(result)); + return {}; +} + +Return RadioIndication::networkScanResult_1_6(V1_0::RadioIndicationType type, + const V1_6::NetworkScanResult& result) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->networkScanResult(toAidl(type), toAidl(result)); + return {}; +} + +Return RadioIndication::networkStateChanged(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->networkStateChanged(toAidl(type)); + return {}; +} + +Return RadioIndication::nitzTimeReceived(V1_0::RadioIndicationType type, + const hidl_string& nitzTime, uint64_t receivedTime) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->nitzTimeReceived(toAidl(type), nitzTime, receivedTime, 0); + return {}; +} + +Return RadioIndication::registrationFailed( // + V1_0::RadioIndicationType type, const V1_5::CellIdentity& cellIdentity, + const hidl_string& chosenPlmn, hidl_bitfield domain, int32_t causeCode, + int32_t additionalCauseCode) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->registrationFailed(toAidl(type), toAidl(cellIdentity), chosenPlmn, + aidl::Domain(domain), causeCode, additionalCauseCode); + return {}; +} + +Return RadioIndication::restrictedStateChanged(V1_0::RadioIndicationType type, + V1_0::PhoneRestrictedState state) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->restrictedStateChanged(toAidl(type), aidl::PhoneRestrictedState(state)); + return {}; +} + +Return RadioIndication::suppSvcNotify(V1_0::RadioIndicationType type, + const V1_0::SuppSvcNotification& suppSvc) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->suppSvcNotify(toAidl(type), toAidl(suppSvc)); + return {}; +} + +Return RadioIndication::voiceRadioTechChanged(V1_0::RadioIndicationType type, + V1_0::RadioTechnology rat) { + LOG_CALL << type; + CHECK_CB(mNetworkCb); + mNetworkCb->voiceRadioTechChanged(toAidl(type), RadioTechnology(rat)); + return {}; +} + +Return RadioIndication::lceData(V1_0::RadioIndicationType type, const V1_0::LceDataInfo&) { + LOG_CALL << type; + LOG(WARNING) << "lceData indication is deprecated"; + return {}; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/network/RadioNetwork.cpp b/radio/aidl/compat/libradiocompat/network/RadioNetwork.cpp new file mode 100644 index 0000000000..af0bc4619f --- /dev/null +++ b/radio/aidl/compat/libradiocompat/network/RadioNetwork.cpp @@ -0,0 +1,281 @@ +/* + * 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 "utils.h" + +#include "collections.h" + +#define RADIO_MODULE "Network" + +namespace android::hardware::radio::compat { + +using ::aidl::android::hardware::radio::AccessNetwork; +using ::aidl::android::hardware::radio::RadioAccessFamily; +using ::ndk::ScopedAStatus; +namespace aidl = ::aidl::android::hardware::radio::network; +constexpr auto ok = &ScopedAStatus::ok; + +ScopedAStatus RadioNetwork::getAllowedNetworkTypesBitmap(int32_t serial) { + LOG_CALL << serial; + if (mHal1_6) { + mHal1_6->getAllowedNetworkTypesBitmap(serial); + } else { + mHal1_5->getPreferredNetworkType(serial); + } + return ok(); +} + +ScopedAStatus RadioNetwork::getAvailableBandModes(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getAvailableBandModes(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getAvailableNetworks(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getAvailableNetworks(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getBarringInfo(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getBarringInfo(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getCdmaRoamingPreference(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getCdmaRoamingPreference(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getCellInfoList(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getCellInfoList(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getDataRegistrationState(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getDataRegistrationState(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getImsRegistrationState(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getImsRegistrationState(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getNetworkSelectionMode(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getNetworkSelectionMode(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getOperator(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getOperator(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getSignalStrength(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getSignalStrength(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getSystemSelectionChannels(int32_t serial) { + LOG_CALL << serial; + if (mHal1_6) { + mHal1_6->getSystemSelectionChannels(serial); + } else { + respond().getSystemSelectionChannelsResponse(notSupported(serial), {}); + } + return ok(); +} + +ScopedAStatus RadioNetwork::getVoiceRadioTechnology(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getVoiceRadioTechnology(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::getVoiceRegistrationState(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getVoiceRegistrationState(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::isNrDualConnectivityEnabled(int32_t serial) { + LOG_CALL << serial; + if (mHal1_6) { + mHal1_6->isNrDualConnectivityEnabled(serial); + } else { + respond().isNrDualConnectivityEnabledResponse(notSupported(serial), false); + } + return ok(); +} + +ScopedAStatus RadioNetwork::responseAcknowledgement() { + LOG_CALL; + mHal1_5->responseAcknowledgement(); + return ok(); +} + +ScopedAStatus RadioNetwork::setAllowedNetworkTypesBitmap(int32_t serial, RadioAccessFamily ntype) { + LOG_CALL << serial; + const auto raf = toHidlBitfield(ntype); + if (mHal1_6) { + mHal1_6->setAllowedNetworkTypesBitmap(serial, raf); + } else { + mHal1_5->setPreferredNetworkType(serial, getNetworkTypeFromRaf(raf)); + } + return ok(); +} + +ScopedAStatus RadioNetwork::setBandMode(int32_t serial, aidl::RadioBandMode mode) { + LOG_CALL << serial; + mHal1_5->setBandMode(serial, V1_0::RadioBandMode(mode)); + return ok(); +} + +ScopedAStatus RadioNetwork::setBarringPassword(int32_t serial, const std::string& facility, + const std::string& oldPw, const std::string& newPw) { + LOG_CALL << serial; + mHal1_5->setBarringPassword(serial, facility, oldPw, newPw); + return ok(); +} + +ScopedAStatus RadioNetwork::setCdmaRoamingPreference(int32_t serial, aidl::CdmaRoamingType type) { + LOG_CALL << serial; + mHal1_5->setCdmaRoamingPreference(serial, V1_0::CdmaRoamingType(type)); + return ok(); +} + +ScopedAStatus RadioNetwork::setCellInfoListRate(int32_t serial, int32_t rate) { + LOG_CALL << serial; + mHal1_5->setCellInfoListRate(serial, rate); + return ok(); +} + +ScopedAStatus RadioNetwork::setIndicationFilter(int32_t serial, aidl::IndicationFilter indFilter) { + LOG_CALL << serial; + mHal1_5->setIndicationFilter(serial, toHidlBitfield(indFilter)); + return ok(); +} + +ScopedAStatus RadioNetwork::setLinkCapacityReportingCriteria( // + int32_t serial, int32_t hysteresisMs, int32_t hysteresisDlKbps, int32_t hysteresisUlKbps, + const std::vector& thrDownlinkKbps, const std::vector& thrUplinkKbps, + AccessNetwork accessNetwork) { + LOG_CALL << serial; + mHal1_5->setLinkCapacityReportingCriteria( // + serial, hysteresisMs, hysteresisDlKbps, hysteresisUlKbps, thrDownlinkKbps, + thrUplinkKbps, V1_2::AccessNetwork(accessNetwork)); + return ok(); +} + +ScopedAStatus RadioNetwork::setLocationUpdates(int32_t serial, bool enable) { + LOG_CALL << serial; + mHal1_5->setLocationUpdates(serial, enable); + return ok(); +} + +ScopedAStatus RadioNetwork::setNetworkSelectionModeAutomatic(int32_t serial) { + LOG_CALL << serial; + mHal1_5->setNetworkSelectionModeAutomatic(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::setNetworkSelectionModeManual( // + int32_t serial, const std::string& opNumeric, AccessNetwork ran) { + LOG_CALL << serial; + mHal1_5->setNetworkSelectionModeManual_1_5(serial, opNumeric, V1_5::RadioAccessNetworks(ran)); + return ok(); +} + +ScopedAStatus RadioNetwork::setNrDualConnectivityState(int32_t serial, + aidl::NrDualConnectivityState st) { + LOG_CALL << serial; + if (mHal1_6) { + mHal1_6->setNrDualConnectivityState(serial, V1_6::NrDualConnectivityState(st)); + } else { + respond().setNrDualConnectivityStateResponse(notSupported(serial)); + } + return ok(); +} + +ScopedAStatus RadioNetwork::setResponseFunctions( + const std::shared_ptr& networkResponse, + const std::shared_ptr& networkIndication) { + LOG_CALL << networkResponse << ' ' << networkIndication; + + CHECK(networkResponse); + CHECK(networkIndication); + + mRadioResponse->setResponseFunction(networkResponse); + mRadioIndication->setResponseFunction(networkIndication); + + return ok(); +} + +ScopedAStatus RadioNetwork::setSignalStrengthReportingCriteria( + int32_t serial, const std::vector& infos) { + LOG_CALL << serial; + // TODO(b/203699028): how about other infos? + mHal1_5->setSignalStrengthReportingCriteria_1_5(serial, toHidl(infos[0]), + V1_5::AccessNetwork(infos[0].ran)); + return ok(); +} + +ScopedAStatus RadioNetwork::setSuppServiceNotifications(int32_t serial, bool enable) { + LOG_CALL << serial; + mHal1_5->setSuppServiceNotifications(serial, enable); + return ok(); +} + +ScopedAStatus RadioNetwork::setSystemSelectionChannels( // + int32_t serial, bool specifyCh, const std::vector& specifiers) { + LOG_CALL << serial; + mHal1_5->setSystemSelectionChannels_1_5(serial, specifyCh, toHidl(specifiers)); + return ok(); +} + +ScopedAStatus RadioNetwork::startNetworkScan(int32_t serial, const aidl::NetworkScanRequest& req) { + LOG_CALL << serial; + mHal1_5->startNetworkScan_1_5(serial, toHidl(req)); + return ok(); +} + +ScopedAStatus RadioNetwork::stopNetworkScan(int32_t serial) { + LOG_CALL << serial; + mHal1_5->stopNetworkScan(serial); + return ok(); +} + +ScopedAStatus RadioNetwork::supplyNetworkDepersonalization(int32_t ser, const std::string& nPin) { + LOG_CALL << ser; + mHal1_5->supplyNetworkDepersonalization(ser, nPin); + return ok(); +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/network/RadioResponse-network.cpp b/radio/aidl/compat/libradiocompat/network/RadioResponse-network.cpp new file mode 100644 index 0000000000..81f7775e19 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/network/RadioResponse-network.cpp @@ -0,0 +1,506 @@ +/* + * 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 "utils.h" + +#include "collections.h" + +#define RADIO_MODULE "NetworkResponse" + +namespace android::hardware::radio::compat { + +using ::aidl::android::hardware::radio::RadioAccessFamily; +using ::aidl::android::hardware::radio::RadioTechnology; +using ::aidl::android::hardware::radio::RadioTechnologyFamily; +namespace aidl = ::aidl::android::hardware::radio::network; + +void RadioResponse::setResponseFunction(std::shared_ptr netCb) { + CHECK(netCb); + mNetworkCb = netCb; +} + +Return RadioResponse::getAllowedNetworkTypesBitmapResponse( + const V1_6::RadioResponseInfo& info, + hidl_bitfield networkTypeBitmap) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getAllowedNetworkTypesBitmapResponse(toAidl(info), + RadioAccessFamily(networkTypeBitmap)); + return {}; +} + +Return RadioResponse::getPreferredNetworkTypeResponse(const V1_0::RadioResponseInfo& info, + V1_0::PreferredNetworkType nwType) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getAllowedNetworkTypesBitmapResponse( // + toAidl(info), RadioAccessFamily(getRafFromNetworkType(nwType))); + return {}; +} + +Return RadioResponse::getPreferredNetworkTypeBitmapResponse( + const V1_0::RadioResponseInfo& info, hidl_bitfield) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.4 not supported"; + return {}; +} + +Return RadioResponse::getAvailableBandModesResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& bandModes) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getAvailableBandModesResponse(toAidl(info), toAidl(bandModes)); + return {}; +} + +Return RadioResponse::getAvailableNetworksResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& networkInfos) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getAvailableNetworksResponse(toAidl(info), toAidl(networkInfos)); + return {}; +} + +Return RadioResponse::getBarringInfoResponse( + const V1_0::RadioResponseInfo& info, const V1_5::CellIdentity& cellIdentity, + const hidl_vec& barringInfos) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getBarringInfoResponse(toAidl(info), toAidl(cellIdentity), toAidl(barringInfos)); + return {}; +} + +Return RadioResponse::getCdmaRoamingPreferenceResponse(const V1_0::RadioResponseInfo& info, + V1_0::CdmaRoamingType type) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getCdmaRoamingPreferenceResponse(toAidl(info), aidl::CdmaRoamingType(type)); + return {}; +} + +Return RadioResponse::getCellInfoListResponse(const V1_0::RadioResponseInfo& info, + const hidl_vec&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.0 not supported"; + return {}; +} + +Return RadioResponse::getCellInfoListResponse_1_2(const V1_0::RadioResponseInfo& info, + const hidl_vec&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.2 not supported"; + return {}; +} + +Return RadioResponse::getCellInfoListResponse_1_4(const V1_0::RadioResponseInfo& info, + const hidl_vec&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.4 not supported"; + return {}; +} + +Return RadioResponse::getCellInfoListResponse_1_5(const V1_0::RadioResponseInfo& info, + const hidl_vec& cellInfo) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getCellInfoListResponse(toAidl(info), toAidl(cellInfo)); + return {}; +} + +Return RadioResponse::getCellInfoListResponse_1_6(const V1_6::RadioResponseInfo& info, + const hidl_vec& cellInfo) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getCellInfoListResponse(toAidl(info), toAidl(cellInfo)); + return {}; +} + +Return RadioResponse::getDataRegistrationStateResponse(const V1_0::RadioResponseInfo& info, + const V1_0::DataRegStateResult&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.0 not supported"; + return {}; +} + +Return RadioResponse::getDataRegistrationStateResponse_1_2( + const V1_0::RadioResponseInfo& info, const V1_2::DataRegStateResult&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.2 not supported"; + return {}; +} + +Return RadioResponse::getDataRegistrationStateResponse_1_4( + const V1_0::RadioResponseInfo& info, const V1_4::DataRegStateResult&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.4 not supported"; + return {}; +} + +Return RadioResponse::getDataRegistrationStateResponse_1_5( + const V1_0::RadioResponseInfo& info, const V1_5::RegStateResult& dataRegResponse) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getDataRegistrationStateResponse(toAidl(info), toAidl(dataRegResponse)); + return {}; +} + +Return RadioResponse::getDataRegistrationStateResponse_1_6( + const V1_6::RadioResponseInfo& info, const V1_6::RegStateResult& dataRegResponse) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getDataRegistrationStateResponse(toAidl(info), toAidl(dataRegResponse)); + return {}; +} + +Return RadioResponse::getImsRegistrationStateResponse( // + const V1_0::RadioResponseInfo& info, bool isRegd, V1_0::RadioTechnologyFamily ratFamily) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getImsRegistrationStateResponse(toAidl(info), isRegd, + RadioTechnologyFamily(ratFamily)); + return {}; +} + +Return RadioResponse::getNeighboringCidsResponse(const V1_0::RadioResponseInfo& info, + const hidl_vec&) { + LOG_CALL << info.serial; + LOG(ERROR) << "getNeighboringCidsResponse is not supposed to be called"; + return {}; +} + +Return RadioResponse::getNetworkSelectionModeResponse(const V1_0::RadioResponseInfo& info, + bool manual) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getNetworkSelectionModeResponse(toAidl(info), manual); + return {}; +} + +Return RadioResponse::getOperatorResponse( // + const V1_0::RadioResponseInfo& info, const hidl_string& longName, + const hidl_string& shortName, const hidl_string& numeric) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getOperatorResponse(toAidl(info), longName, shortName, numeric); + return {}; +} + +Return RadioResponse::getSignalStrengthResponse(const V1_0::RadioResponseInfo& info, + const V1_0::SignalStrength&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.0 not supported"; + return {}; +} + +Return RadioResponse::getSignalStrengthResponse_1_2(const V1_0::RadioResponseInfo& info, + const V1_2::SignalStrength&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.2 not supported"; + return {}; +} + +Return RadioResponse::getSignalStrengthResponse_1_4( + const V1_0::RadioResponseInfo& info, const V1_4::SignalStrength& signalStrength) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getSignalStrengthResponse(toAidl(info), toAidl(signalStrength)); + return {}; +} + +Return RadioResponse::getSignalStrengthResponse_1_6( + const V1_6::RadioResponseInfo& info, const V1_6::SignalStrength& signalStrength) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getSignalStrengthResponse(toAidl(info), toAidl(signalStrength)); + return {}; +} + +Return RadioResponse::getSystemSelectionChannelsResponse( + const V1_6::RadioResponseInfo& info, + const hidl_vec& specifiers) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getSystemSelectionChannelsResponse(toAidl(info), toAidl(specifiers)); + return {}; +} + +Return RadioResponse::getVoiceRadioTechnologyResponse(const V1_0::RadioResponseInfo& info, + V1_0::RadioTechnology rat) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getVoiceRadioTechnologyResponse(toAidl(info), RadioTechnology(rat)); + return {}; +} + +Return RadioResponse::getVoiceRegistrationStateResponse(const V1_0::RadioResponseInfo& info, + const V1_0::VoiceRegStateResult&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.0 not supported"; + return {}; +} + +Return RadioResponse::getVoiceRegistrationStateResponse_1_2( + const V1_0::RadioResponseInfo& info, const V1_2::VoiceRegStateResult&) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.2 not supported"; + return {}; +} + +Return RadioResponse::getVoiceRegistrationStateResponse_1_5( + const V1_0::RadioResponseInfo& info, const V1_5::RegStateResult& voiceRegResponse) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getVoiceRegistrationStateResponse(toAidl(info), toAidl(voiceRegResponse)); + return {}; +} + +Return RadioResponse::getVoiceRegistrationStateResponse_1_6( + const V1_6::RadioResponseInfo& info, const V1_6::RegStateResult& voiceRegResponse) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->getVoiceRegistrationStateResponse(toAidl(info), toAidl(voiceRegResponse)); + return {}; +} + +Return RadioResponse::isNrDualConnectivityEnabledResponse(const V1_6::RadioResponseInfo& info, + bool isEnabled) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->isNrDualConnectivityEnabledResponse(toAidl(info), isEnabled); + return {}; +} + +Return RadioResponse::pullLceDataResponse(const V1_0::RadioResponseInfo& info, + const V1_0::LceDataInfo&) { + LOG_CALL << info.serial; + LOG(ERROR) << "pullLceDataResponse is not supposed to be called"; + return {}; +} + +Return RadioResponse::setAllowedNetworkTypesBitmapResponse(const V1_6::RadioResponseInfo& i) { + LOG_CALL << i.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setAllowedNetworkTypesBitmapResponse(toAidl(i)); + return {}; +} + +Return RadioResponse::setPreferredNetworkTypeResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setAllowedNetworkTypesBitmapResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setPreferredNetworkTypeBitmapResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + LOG(ERROR) << "IRadio HAL 1.4 not supported"; + return {}; +} + +Return RadioResponse::setBandModeResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setBandModeResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setBarringPasswordResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setBarringPasswordResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setCdmaRoamingPreferenceResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setCdmaRoamingPreferenceResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setCellInfoListRateResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setCellInfoListRateResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setIndicationFilterResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setIndicationFilterResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setIndicationFilterResponse_1_5(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setIndicationFilterResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setLinkCapacityReportingCriteriaResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setLinkCapacityReportingCriteriaResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setLinkCapacityReportingCriteriaResponse_1_5( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setLinkCapacityReportingCriteriaResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setLocationUpdatesResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setLocationUpdatesResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setNetworkSelectionModeAutomaticResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setNetworkSelectionModeAutomaticResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setNetworkSelectionModeManualResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setNetworkSelectionModeManualResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setNetworkSelectionModeManualResponse_1_5( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setNetworkSelectionModeManualResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setNrDualConnectivityStateResponse( + const V1_6::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setNrDualConnectivityStateResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setSignalStrengthReportingCriteriaResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setSignalStrengthReportingCriteriaResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setSignalStrengthReportingCriteriaResponse_1_5( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setSignalStrengthReportingCriteriaResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setSuppServiceNotificationsResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setSuppServiceNotificationsResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setSystemSelectionChannelsResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setSystemSelectionChannelsResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setSystemSelectionChannelsResponse_1_5( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->setSystemSelectionChannelsResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::startNetworkScanResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->startNetworkScanResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::startNetworkScanResponse_1_4(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->startNetworkScanResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::startNetworkScanResponse_1_5(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->startNetworkScanResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::stopNetworkScanResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->stopNetworkScanResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::supplyNetworkDepersonalizationResponse( + const V1_0::RadioResponseInfo& info, int32_t remainingRetries) { + LOG_CALL << info.serial; + CHECK_CB(mNetworkCb); + mNetworkCb->supplyNetworkDepersonalizationResponse(toAidl(info), remainingRetries); + return {}; +} + +Return RadioResponse::startLceServiceResponse(const V1_0::RadioResponseInfo& info, + const V1_0::LceStatusInfo&) { + LOG_CALL << info.serial; + LOG(WARNING) << "startLceServiceResponse is deprecated"; + return {}; +} + +Return RadioResponse::stopLceServiceResponse(const V1_0::RadioResponseInfo& info, + const V1_0::LceStatusInfo&) { + LOG_CALL << info.serial; + LOG(WARNING) << "stopLceServiceResponse is deprecated"; + return {}; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/network/structs.cpp b/radio/aidl/compat/libradiocompat/network/structs.cpp new file mode 100644 index 0000000000..87a021f03d --- /dev/null +++ b/radio/aidl/compat/libradiocompat/network/structs.cpp @@ -0,0 +1,668 @@ +/* + * 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 { + +namespace aidl = ::aidl::android::hardware::radio::network; +using ::aidl::android::hardware::radio::AccessNetwork; +using ::aidl::android::hardware::radio::RadioTechnology; + +aidl::RadioBandMode toAidl(V1_0::RadioBandMode mode) { + return aidl::RadioBandMode(mode); +} + +aidl::GeranBands toAidl(V1_1::GeranBands band) { + return aidl::GeranBands(band); +} + +V1_1::GeranBands toHidl(aidl::GeranBands band) { + return V1_1::GeranBands(band); +} + +aidl::UtranBands toAidl(V1_5::UtranBands band) { + return aidl::UtranBands(band); +} + +V1_5::UtranBands toHidl(aidl::UtranBands band) { + return V1_5::UtranBands(band); +} + +aidl::EutranBands toAidl(V1_5::EutranBands band) { + return aidl::EutranBands(band); +} + +V1_5::EutranBands toHidl(aidl::EutranBands band) { + return V1_5::EutranBands(band); +} + +aidl::NgranBands toAidl(V1_5::NgranBands band) { + return aidl::NgranBands(band); +} + +V1_5::NgranBands toHidl(aidl::NgranBands band) { + return V1_5::NgranBands(band); +} + +V1_5::SignalThresholdInfo toHidl(const aidl::SignalThresholdInfo& info) { + return { + .signalMeasurement = V1_5::SignalMeasurementType{info.signalMeasurement}, + .hysteresisMs = info.hysteresisMs, + .hysteresisDb = info.hysteresisDb, + .thresholds = info.thresholds, + .isEnabled = info.isEnabled, + }; +} + +static aidl::RadioAccessSpecifierBands toAidl(const V1_5::RadioAccessSpecifier::Bands& bands) { + using Discr = V1_5::RadioAccessSpecifier::Bands::hidl_discriminator; + const auto discr = bands.getDiscriminator(); + + if (discr == Discr::geranBands) return toAidl(bands.geranBands()); + if (discr == Discr::utranBands) return toAidl(bands.utranBands()); + if (discr == Discr::eutranBands) return toAidl(bands.eutranBands()); + if (discr == Discr::ngranBands) return toAidl(bands.ngranBands()); + + return {}; +} + +static V1_5::RadioAccessSpecifier::Bands toHidl(const aidl::RadioAccessSpecifierBands& bands) { + V1_5::RadioAccessSpecifier::Bands hidl; + using Tag = aidl::RadioAccessSpecifierBands::Tag; + + if (bands.getTag() == Tag::geranBands) hidl.geranBands(toHidl(bands.get())); + if (bands.getTag() == Tag::utranBands) hidl.utranBands(toHidl(bands.get())); + if (bands.getTag() == Tag::eutranBands) hidl.eutranBands(toHidl(bands.get())); + if (bands.getTag() == Tag::ngranBands) hidl.ngranBands(toHidl(bands.get())); + + return hidl; +} + +aidl::RadioAccessSpecifier toAidl(const V1_5::RadioAccessSpecifier& spec) { + return { + .accessNetwork = AccessNetwork(spec.radioAccessNetwork), + .bands = toAidl(spec.bands), + .channels = spec.channels, + }; +} + +V1_5::RadioAccessSpecifier toHidl(const aidl::RadioAccessSpecifier& spec) { + return { + .radioAccessNetwork = V1_5::RadioAccessNetworks{spec.accessNetwork}, + .bands = toHidl(spec.bands), + .channels = spec.channels, + }; +} + +V1_5::NetworkScanRequest toHidl(const aidl::NetworkScanRequest& req) { + return { + .type = V1_1::ScanType{req.type}, + .interval = req.interval, + .specifiers = toHidl(req.specifiers), + .maxSearchTime = req.maxSearchTime, + .incrementalResults = req.incrementalResults, + .incrementalResultsPeriodicity = req.incrementalResultsPeriodicity, + .mccMncs = toHidl(req.mccMncs), + }; +} + +static aidl::OperatorInfo toAidl(const V1_2::CellIdentityOperatorNames& names) { + return { + .alphaLong = names.alphaLong, + .alphaShort = names.alphaShort, + .operatorNumeric = "", + .status = aidl::OperatorInfo::STATUS_UNKNOWN, + }; +} + +static aidl::CellIdentityGsm toAidl(const V1_5::CellIdentityGsm& ci) { + return { + .mcc = ci.base.base.mcc, + .mnc = ci.base.base.mnc, + .lac = ci.base.base.lac, + .cid = ci.base.base.cid, + .arfcn = ci.base.base.arfcn, + .bsic = static_cast(ci.base.base.bsic), + .operatorNames = toAidl(ci.base.operatorNames), + .additionalPlmns = toAidl(ci.additionalPlmns), + }; +} + +aidl::ClosedSubscriberGroupInfo toAidl(const V1_5::ClosedSubscriberGroupInfo& info) { + return { + .csgIndication = info.csgIndication, + .homeNodebName = info.homeNodebName, + .csgIdentity = info.csgIdentity, + }; +} + +static std::optional toAidl(const V1_5::OptionalCsgInfo& opt) { + using descr = V1_5::OptionalCsgInfo::hidl_discriminator; + if (opt.getDiscriminator() == descr::noinit) return std::nullopt; + return toAidl(opt.csgInfo()); +} + +static aidl::CellIdentityWcdma toAidl(const V1_5::CellIdentityWcdma& ci) { + return { + .mcc = ci.base.base.mcc, + .mnc = ci.base.base.mnc, + .lac = ci.base.base.lac, + .cid = ci.base.base.cid, + .psc = ci.base.base.psc, + .uarfcn = ci.base.base.uarfcn, + .operatorNames = toAidl(ci.base.operatorNames), + .additionalPlmns = toAidl(ci.additionalPlmns), + .csgInfo = toAidl(ci.optionalCsgInfo), + }; +} + +static aidl::CellIdentityTdscdma toAidl(const V1_5::CellIdentityTdscdma& ci) { + return { + .mcc = ci.base.base.mcc, + .mnc = ci.base.base.mnc, + .lac = ci.base.base.lac, + .cid = ci.base.base.cid, + .cpid = ci.base.base.cpid, + .uarfcn = ci.base.uarfcn, + .operatorNames = toAidl(ci.base.operatorNames), + .additionalPlmns = toAidl(ci.additionalPlmns), + .csgInfo = toAidl(ci.optionalCsgInfo), + }; +} + +static aidl::CellIdentityCdma toAidl(const V1_2::CellIdentityCdma& ci) { + return { + .networkId = ci.base.networkId, + .systemId = ci.base.systemId, + .baseStationId = ci.base.baseStationId, + .longitude = ci.base.longitude, + .latitude = ci.base.latitude, + .operatorNames = toAidl(ci.operatorNames), + }; +} + +static aidl::CellIdentityLte toAidl(const V1_5::CellIdentityLte& ci) { + return { + .mcc = ci.base.base.mcc, + .mnc = ci.base.base.mnc, + .ci = ci.base.base.ci, + .pci = ci.base.base.pci, + .tac = ci.base.base.tac, + .earfcn = ci.base.base.earfcn, + .operatorNames = toAidl(ci.base.operatorNames), + .bandwidth = ci.base.bandwidth, + .additionalPlmns = toAidl(ci.additionalPlmns), + .csgInfo = toAidl(ci.optionalCsgInfo), + .bands = toAidl(ci.bands), + }; +} + +static aidl::CellIdentityNr toAidl(const V1_5::CellIdentityNr& ci) { + return { + .mcc = ci.base.mcc, + .mnc = ci.base.mnc, + .nci = static_cast(ci.base.nci), + .pci = static_cast(ci.base.pci), + .tac = ci.base.tac, + .nrarfcn = ci.base.nrarfcn, + .operatorNames = toAidl(ci.base.operatorNames), + .additionalPlmns = toAidl(ci.additionalPlmns), + .bands = toAidl(ci.bands), + }; +} + +aidl::CellIdentity toAidl(const V1_5::CellIdentity& ci) { + using Discr = V1_5::CellIdentity::hidl_discriminator; + const auto discr = ci.getDiscriminator(); + + if (discr == Discr::gsm) return toAidl(ci.gsm()); + if (discr == Discr::wcdma) return toAidl(ci.wcdma()); + if (discr == Discr::tdscdma) return toAidl(ci.tdscdma()); + if (discr == Discr::cdma) return toAidl(ci.cdma()); + if (discr == Discr::lte) return toAidl(ci.lte()); + if (discr == Discr::nr) return toAidl(ci.nr()); + + return {}; +} + +static std::optional // +toAidl(const V1_5::BarringInfo::BarringTypeSpecificInfo& opt) { + using discr = V1_5::BarringInfo::BarringTypeSpecificInfo::hidl_discriminator; + if (opt.getDiscriminator() == discr::noinit) return std::nullopt; + + const auto& info = opt.conditional(); + return aidl::BarringTypeSpecificInfo{ + .factor = info.factor, + .timeSeconds = info.timeSeconds, + .isBarred = info.isBarred, + }; +} + +aidl::BarringInfo toAidl(const V1_5::BarringInfo& info) { + return { + .serviceType = static_cast(info.serviceType), + .barringType = static_cast(info.barringType), + .barringTypeSpecificInfo = toAidl(info.barringTypeSpecificInfo), + }; +} + +static aidl::GsmSignalStrength toAidl(const V1_0::GsmSignalStrength& sig) { + return { + .signalStrength = static_cast(sig.signalStrength), + .bitErrorRate = static_cast(sig.bitErrorRate), + .timingAdvance = sig.timingAdvance, + }; +} + +static aidl::CellInfoGsm toAidl(const V1_5::CellInfoGsm& info) { + return { + .cellIdentityGsm = toAidl(info.cellIdentityGsm), + .signalStrengthGsm = toAidl(info.signalStrengthGsm), + }; +} + +static aidl::WcdmaSignalStrength toAidl(const V1_2::WcdmaSignalStrength& sig) { + return { + .signalStrength = sig.base.signalStrength, + .bitErrorRate = sig.base.bitErrorRate, + .rscp = static_cast(sig.rscp), + .ecno = static_cast(sig.ecno), + }; +} + +static aidl::CellInfoWcdma toAidl(const V1_5::CellInfoWcdma& info) { + return { + .cellIdentityWcdma = toAidl(info.cellIdentityWcdma), + .signalStrengthWcdma = toAidl(info.signalStrengthWcdma), + }; +} + +static aidl::TdscdmaSignalStrength toAidl(const V1_2::TdscdmaSignalStrength& sig) { + return { + .signalStrength = static_cast(sig.signalStrength), + .bitErrorRate = static_cast(sig.bitErrorRate), + .rscp = static_cast(sig.rscp), + }; +} + +static aidl::CellInfoTdscdma toAidl(const V1_5::CellInfoTdscdma& info) { + return { + .cellIdentityTdscdma = toAidl(info.cellIdentityTdscdma), + .signalStrengthTdscdma = toAidl(info.signalStrengthTdscdma), + }; +} + +static aidl::LteSignalStrength toAidl(const V1_6::LteSignalStrength& sig) { + return { + .signalStrength = static_cast(sig.base.signalStrength), + .rsrp = static_cast(sig.base.rsrp), + .rsrq = static_cast(sig.base.rsrq), + .rssnr = sig.base.rssnr, + .cqi = static_cast(sig.base.cqi), + .timingAdvance = static_cast(sig.base.timingAdvance), + .cqiTableIndex = static_cast(sig.cqiTableIndex), + }; +} + +static aidl::LteSignalStrength toAidl(const V1_0::LteSignalStrength& sig) { + return toAidl({sig, 0}); +} + +static aidl::CellInfoLte toAidl(const V1_5::CellInfoLte& info) { + return { + .cellIdentityLte = toAidl(info.cellIdentityLte), + .signalStrengthLte = toAidl(info.signalStrengthLte), + }; +} + +static aidl::CellInfoLte toAidl(const V1_6::CellInfoLte& info) { + return { + .cellIdentityLte = toAidl(info.cellIdentityLte), + .signalStrengthLte = toAidl(info.signalStrengthLte), + }; +} + +static aidl::NrSignalStrength toAidl(const V1_6::NrSignalStrength& sig) { + return { + .ssRsrp = sig.base.ssRsrp, + .ssRsrq = sig.base.ssRsrq, + .ssSinr = sig.base.ssSinr, + .csiRsrp = sig.base.csiRsrp, + .csiRsrq = sig.base.csiRsrq, + .csiSinr = sig.base.csiSinr, + .csiCqiTableIndex = static_cast(sig.csiCqiTableIndex), + .csiCqiReport = sig.csiCqiReport, + }; +} + +static aidl::NrSignalStrength toAidl(const V1_4::NrSignalStrength& sig) { + return toAidl({sig, 0, 0}); +} + +static aidl::CellInfoNr toAidl(const V1_5::CellInfoNr& info) { + return { + .cellIdentityNr = toAidl(info.cellIdentityNr), + .signalStrengthNr = toAidl(info.signalStrengthNr), + }; +} + +static aidl::CellInfoNr toAidl(const V1_6::CellInfoNr& info) { + return { + .cellIdentityNr = toAidl(info.cellIdentityNr), + .signalStrengthNr = toAidl(info.signalStrengthNr), + }; +} + +static aidl::CdmaSignalStrength toAidl(const V1_0::CdmaSignalStrength& sig) { + return { + .dbm = static_cast(sig.dbm), + .ecio = static_cast(sig.ecio), + }; +} + +static aidl::EvdoSignalStrength toAidl(const V1_0::EvdoSignalStrength& sig) { + return { + .dbm = static_cast(sig.dbm), + .ecio = static_cast(sig.ecio), + .signalNoiseRatio = static_cast(sig.signalNoiseRatio), + }; +} + +static aidl::CellInfoCdma toAidl(const V1_2::CellInfoCdma& info) { + return { + .cellIdentityCdma = toAidl(info.cellIdentityCdma), + .signalStrengthCdma = toAidl(info.signalStrengthCdma), + .signalStrengthEvdo = toAidl(info.signalStrengthEvdo), + }; +} + +static aidl::CellInfoRatSpecificInfo toAidl(const V1_5::CellInfo::CellInfoRatSpecificInfo& ci) { + using Discr = V1_5::CellInfo::CellInfoRatSpecificInfo::hidl_discriminator; + const auto discr = ci.getDiscriminator(); + + if (discr == Discr::gsm) return toAidl(ci.gsm()); + if (discr == Discr::wcdma) return toAidl(ci.wcdma()); + if (discr == Discr::tdscdma) return toAidl(ci.tdscdma()); + if (discr == Discr::lte) return toAidl(ci.lte()); + if (discr == Discr::nr) return toAidl(ci.nr()); + if (discr == Discr::cdma) return toAidl(ci.cdma()); + + return {}; +} + +static aidl::CellInfoRatSpecificInfo toAidl(const V1_6::CellInfo::CellInfoRatSpecificInfo& ci) { + using Discr = V1_6::CellInfo::CellInfoRatSpecificInfo::hidl_discriminator; + const auto discr = ci.getDiscriminator(); + + if (discr == Discr::gsm) return toAidl(ci.gsm()); + if (discr == Discr::wcdma) return toAidl(ci.wcdma()); + if (discr == Discr::tdscdma) return toAidl(ci.tdscdma()); + if (discr == Discr::lte) return toAidl(ci.lte()); + if (discr == Discr::nr) return toAidl(ci.nr()); + if (discr == Discr::cdma) return toAidl(ci.cdma()); + + return {}; +} + +aidl::CellInfo toAidl(const V1_5::CellInfo& info) { + return { + .registered = info.registered, + // ignored: timeStampType and timeStamp + .connectionStatus = aidl::CellConnectionStatus(info.connectionStatus), + .ratSpecificInfo = toAidl(info.ratSpecificInfo), + }; +} + +aidl::CellInfo toAidl(const V1_6::CellInfo& info) { + return { + .registered = info.registered, + .connectionStatus = aidl::CellConnectionStatus(info.connectionStatus), + .ratSpecificInfo = toAidl(info.ratSpecificInfo), + }; +} + +aidl::LinkCapacityEstimate toAidl(const V1_2::LinkCapacityEstimate& e) { + return { + .downlinkCapacityKbps = static_cast(e.downlinkCapacityKbps), + .uplinkCapacityKbps = static_cast(e.uplinkCapacityKbps), + }; +} + +aidl::LinkCapacityEstimate toAidl(const V1_6::LinkCapacityEstimate& e) { + return { + .downlinkCapacityKbps = static_cast(e.downlinkCapacityKbps), + .uplinkCapacityKbps = static_cast(e.uplinkCapacityKbps), + .secondaryDownlinkCapacityKbps = static_cast(e.secondaryDownlinkCapacityKbps), + .secondaryUplinkCapacityKbps = static_cast(e.secondaryUplinkCapacityKbps), + }; +} + +static aidl::PhysicalChannelConfigBand toAidl(const V1_6::PhysicalChannelConfig::Band& band) { + using Discr = V1_6::PhysicalChannelConfig::Band::hidl_discriminator; + const auto discr = band.getDiscriminator(); + + if (discr == Discr::geranBand) return aidl::GeranBands(band.geranBand()); + if (discr == Discr::utranBand) return aidl::UtranBands(band.utranBand()); + if (discr == Discr::eutranBand) return aidl::EutranBands(band.eutranBand()); + if (discr == Discr::ngranBand) return aidl::NgranBands(band.ngranBand()); + + return {}; +} + +aidl::PhysicalChannelConfig toAidl(const V1_4::PhysicalChannelConfig& cfg) { + int32_t downlinkChannelNumber = 0; + // ignored rfInfo.range + using Discr = V1_4::RadioFrequencyInfo::hidl_discriminator; + if (cfg.rfInfo.getDiscriminator() == Discr::channelNumber) { + downlinkChannelNumber = cfg.rfInfo.channelNumber(); + } + + return { + .status = aidl::CellConnectionStatus(cfg.base.status), + .rat = RadioTechnology(cfg.rat), + .downlinkChannelNumber = downlinkChannelNumber, + .cellBandwidthDownlinkKhz = cfg.base.cellBandwidthDownlink, + .contextIds = cfg.contextIds, + .physicalCellId = static_cast(cfg.physicalCellId), + }; +} + +aidl::PhysicalChannelConfig toAidl(const V1_6::PhysicalChannelConfig& cfg) { + return { + .status = aidl::CellConnectionStatus(cfg.status), + .rat = RadioTechnology(cfg.rat), + .downlinkChannelNumber = cfg.downlinkChannelNumber, + .uplinkChannelNumber = cfg.uplinkChannelNumber, + .cellBandwidthDownlinkKhz = cfg.cellBandwidthDownlinkKhz, + .cellBandwidthUplinkKhz = cfg.cellBandwidthUplinkKhz, + .contextIds = cfg.contextIds, + .physicalCellId = static_cast(cfg.physicalCellId), + .band = toAidl(cfg.band), + }; +} + +aidl::SignalStrength toAidl(const V1_4::SignalStrength& sig) { + return { + .gsm = toAidl(sig.gsm), + .cdma = toAidl(sig.cdma), + .evdo = toAidl(sig.evdo), + .lte = toAidl(sig.lte), + .tdscdma = toAidl(sig.tdscdma), + .wcdma = toAidl(sig.wcdma), + .nr = toAidl(sig.nr), + }; +} + +aidl::SignalStrength toAidl(const V1_6::SignalStrength& sig) { + return { + .gsm = toAidl(sig.gsm), + .cdma = toAidl(sig.cdma), + .evdo = toAidl(sig.evdo), + .lte = toAidl(sig.lte), + .tdscdma = toAidl(sig.tdscdma), + .wcdma = toAidl(sig.wcdma), + .nr = toAidl(sig.nr), + }; +} + +aidl::NetworkScanResult toAidl(const V1_5::NetworkScanResult& res) { + return { + .status = static_cast(res.status), + .error = toAidl(res.error), + .networkInfos = toAidl(res.networkInfos), + }; +} + +aidl::NetworkScanResult toAidl(const V1_6::NetworkScanResult& res) { + return { + .status = static_cast(res.status), + .error = toAidl(res.error), + .networkInfos = toAidl(res.networkInfos), + }; +} + +aidl::SuppSvcNotification toAidl(const V1_0::SuppSvcNotification& svc) { + return { + .isMT = svc.isMT, + .code = svc.code, + .index = svc.index, + .type = svc.type, + .number = svc.number, + }; +} + +aidl::OperatorInfo toAidl(const V1_0::OperatorInfo& info) { + return { + .alphaLong = info.alphaLong, + .alphaShort = info.alphaShort, + .operatorNumeric = info.operatorNumeric, + .status = static_cast(info.status), + }; +} + +static aidl::Cdma2000RegistrationInfo // +toAidl(const V1_5::RegStateResult::AccessTechnologySpecificInfo::Cdma2000RegistrationInfo& info) { + return { + .cssSupported = info.cssSupported, + .roamingIndicator = info.roamingIndicator, + .systemIsInPrl = static_cast(info.systemIsInPrl), + .defaultRoamingIndicator = info.defaultRoamingIndicator, + }; +} + +static aidl::LteVopsInfo toAidl(const V1_4::LteVopsInfo& info) { + return { + .isVopsSupported = info.isVopsSupported, + .isEmcBearerSupported = info.isEmcBearerSupported, + }; +} + +static aidl::NrIndicators toAidl(const V1_4::NrIndicators& info) { + return { + .isEndcAvailable = info.isEndcAvailable, + .isDcNrRestricted = info.isDcNrRestricted, + .isNrAvailable = info.isNrAvailable, + }; +} + +static aidl::EutranRegistrationInfo // +toAidl(const V1_5::RegStateResult::AccessTechnologySpecificInfo::EutranRegistrationInfo& info) { + return { + .lteVopsInfo = toAidl(info.lteVopsInfo), + .nrIndicators = toAidl(info.nrIndicators), + }; +} + +static aidl::NrVopsInfo toAidl(const V1_6::NrVopsInfo& info) { + return { + .vopsSupported = static_cast(info.vopsSupported), + .emcSupported = static_cast(info.emcSupported), + .emfSupported = static_cast(info.emfSupported), + }; +} + +static aidl::AccessTechnologySpecificInfo // +toAidl(const V1_5::RegStateResult::AccessTechnologySpecificInfo& info) { + using Discr = V1_5::RegStateResult::AccessTechnologySpecificInfo::hidl_discriminator; + const auto discr = info.getDiscriminator(); + + if (discr == Discr::cdmaInfo) return toAidl(info.cdmaInfo()); + if (discr == Discr::eutranInfo) return toAidl(info.eutranInfo()); + + return {}; +} + +static aidl::AccessTechnologySpecificInfo // +toAidl(const V1_6::RegStateResult::AccessTechnologySpecificInfo& info) { + using Discr = V1_6::RegStateResult::AccessTechnologySpecificInfo::hidl_discriminator; + const auto discr = info.getDiscriminator(); + + if (discr == Discr::cdmaInfo) return toAidl(info.cdmaInfo()); + if (discr == Discr::eutranInfo) return toAidl(info.eutranInfo()); + if (discr == Discr::ngranNrVopsInfo) return toAidl(info.ngranNrVopsInfo()); + if (discr == Discr::geranDtmSupported) { + using T = aidl::AccessTechnologySpecificInfo; + return T::make(info.geranDtmSupported()); + } + + return {}; +} + +aidl::RegStateResult toAidl(const V1_5::RegStateResult& res) { + return { + .regState = aidl::RegState(res.regState), + .rat = RadioTechnology(res.rat), + .reasonForDenial = aidl::RegistrationFailCause(res.reasonForDenial), + .cellIdentity = toAidl(res.cellIdentity), + .registeredPlmn = res.registeredPlmn, + .accessTechnologySpecificInfo = toAidl(res.accessTechnologySpecificInfo), + }; +} + +aidl::RegStateResult toAidl(const V1_6::RegStateResult& res) { + return { + .regState = aidl::RegState(res.regState), + .rat = RadioTechnology(res.rat), + .reasonForDenial = aidl::RegistrationFailCause(res.reasonForDenial), + .cellIdentity = toAidl(res.cellIdentity), + .registeredPlmn = res.registeredPlmn, + .accessTechnologySpecificInfo = toAidl(res.accessTechnologySpecificInfo), + }; +} + +aidl::NeighboringCell toAidl(const V1_0::NeighboringCell& cell) { + return { + .cid = cell.cid, + .rssi = cell.rssi, + }; +} + +aidl::LceDataInfo toAidl(const V1_0::LceDataInfo& info) { + return { + .lastHopCapacityKbps = static_cast(info.lastHopCapacityKbps), + .confidenceLevel = static_cast(info.confidenceLevel), + .lceSuspended = info.lceSuspended, + }; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/network/structs.h b/radio/aidl/compat/libradiocompat/network/structs.h new file mode 100644 index 0000000000..854cb38058 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/network/structs.h @@ -0,0 +1,99 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace android::hardware::radio::compat { + +::aidl::android::hardware::radio::network::RadioBandMode toAidl(V1_0::RadioBandMode mode); +::aidl::android::hardware::radio::network::GeranBands toAidl(V1_1::GeranBands band); +V1_1::GeranBands toHidl(::aidl::android::hardware::radio::network::GeranBands band); +::aidl::android::hardware::radio::network::UtranBands toAidl(V1_5::UtranBands band); +V1_5::UtranBands toHidl(::aidl::android::hardware::radio::network::UtranBands band); +::aidl::android::hardware::radio::network::EutranBands toAidl(V1_5::EutranBands band); +V1_5::EutranBands toHidl(::aidl::android::hardware::radio::network::EutranBands band); +::aidl::android::hardware::radio::network::NgranBands toAidl(V1_5::NgranBands band); +V1_5::NgranBands toHidl(::aidl::android::hardware::radio::network::NgranBands band); + +V1_5::SignalThresholdInfo // +toHidl(const ::aidl::android::hardware::radio::network::SignalThresholdInfo& info); + +::aidl::android::hardware::radio::network::RadioAccessSpecifier // +toAidl(const V1_5::RadioAccessSpecifier& spec); +V1_5::RadioAccessSpecifier // +toHidl(const ::aidl::android::hardware::radio::network::RadioAccessSpecifier& spec); + +V1_5::NetworkScanRequest // +toHidl(const ::aidl::android::hardware::radio::network::NetworkScanRequest& req); + +::aidl::android::hardware::radio::network::CellIdentity toAidl(const V1_5::CellIdentity& ci); + +::aidl::android::hardware::radio::network::BarringInfo toAidl(const V1_5::BarringInfo& info); + +::aidl::android::hardware::radio::network::ClosedSubscriberGroupInfo // +toAidl(const V1_5::ClosedSubscriberGroupInfo& info); + +::aidl::android::hardware::radio::network::CellInfo toAidl(const V1_5::CellInfo& info); +::aidl::android::hardware::radio::network::CellInfo toAidl(const V1_6::CellInfo& info); + +::aidl::android::hardware::radio::network::LinkCapacityEstimate // +toAidl(const V1_2::LinkCapacityEstimate& lce); +::aidl::android::hardware::radio::network::LinkCapacityEstimate // +toAidl(const V1_6::LinkCapacityEstimate& lce); + +::aidl::android::hardware::radio::network::PhysicalChannelConfig // +toAidl(const V1_4::PhysicalChannelConfig& cfg); +::aidl::android::hardware::radio::network::PhysicalChannelConfig // +toAidl(const V1_6::PhysicalChannelConfig& cfg); + +::aidl::android::hardware::radio::network::SignalStrength toAidl(const V1_4::SignalStrength& sig); +::aidl::android::hardware::radio::network::SignalStrength toAidl(const V1_6::SignalStrength& sig); + +::aidl::android::hardware::radio::network::NetworkScanResult // +toAidl(const V1_5::NetworkScanResult& res); +::aidl::android::hardware::radio::network::NetworkScanResult // +toAidl(const V1_6::NetworkScanResult& res); + +::aidl::android::hardware::radio::network::SuppSvcNotification // +toAidl(const V1_0::SuppSvcNotification& svc); + +::aidl::android::hardware::radio::network::OperatorInfo toAidl(const V1_0::OperatorInfo& info); + +::aidl::android::hardware::radio::network::RegStateResult toAidl(const V1_5::RegStateResult& res); +::aidl::android::hardware::radio::network::RegStateResult toAidl(const V1_6::RegStateResult& res); + +::aidl::android::hardware::radio::network::NeighboringCell toAidl(const V1_0::NeighboringCell& c); + +::aidl::android::hardware::radio::network::LceDataInfo toAidl(const V1_0::LceDataInfo& info); + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/network/utils.cpp b/radio/aidl/compat/libradiocompat/network/utils.cpp new file mode 100644 index 0000000000..6fe3e6e8bf --- /dev/null +++ b/radio/aidl/compat/libradiocompat/network/utils.cpp @@ -0,0 +1,196 @@ +/* + * 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 "utils.h" + +namespace android::hardware::radio::compat { + +namespace RAF { +using E = V1_4::RadioAccessFamily; +constexpr auto GSM = E::GSM | E::GPRS; +constexpr auto CDMA = E::IS95A | E::IS95B | E::ONE_X_RTT; +constexpr auto EVDO = E::EVDO_0 | E::EVDO_A | E::EVDO_B | E::EHRPD; +constexpr auto HS = E::HSUPA | E::HSDPA | E::HSPA | E::HSPAP; +constexpr auto WCDMA = HS | E::UMTS; +constexpr auto LTE = E::LTE | E::LTE_CA; +constexpr auto NR = E::NR; +} // namespace RAF + +static hidl_bitfield // +getAdjustedRaf(hidl_bitfield raf) { + if (raf & RAF::GSM) raf |= RAF::GSM; + if (raf & RAF::WCDMA) raf |= RAF::WCDMA; + if (raf & RAF::CDMA) raf |= RAF::CDMA; + if (raf & RAF::EVDO) raf |= RAF::EVDO; + if (raf & RAF::LTE) raf |= RAF::LTE; + if (raf & RAF::NR) raf |= RAF::NR; + + return raf; +} + +V1_0::PreferredNetworkType getNetworkTypeFromRaf(hidl_bitfield raf) { + raf = getAdjustedRaf(raf); + switch (raf) { + case RAF::GSM | RAF::WCDMA: + return V1_0::PreferredNetworkType::GSM_WCDMA_AUTO; + case RAF::GSM: + return V1_0::PreferredNetworkType::GSM_ONLY; + case RAF::WCDMA: + return V1_0::PreferredNetworkType::WCDMA; + case (RAF::CDMA | RAF::EVDO): + return V1_0::PreferredNetworkType::CDMA_EVDO_AUTO; + case (RAF::LTE | RAF::CDMA | RAF::EVDO): + return V1_0::PreferredNetworkType::LTE_CDMA_EVDO; + case (RAF::LTE | RAF::GSM | RAF::WCDMA): + return V1_0::PreferredNetworkType::LTE_GSM_WCDMA; + case (RAF::LTE | RAF::CDMA | RAF::EVDO | RAF::GSM | RAF::WCDMA): + return V1_0::PreferredNetworkType::LTE_CMDA_EVDO_GSM_WCDMA; // CDMA typo + case RAF::LTE: + return V1_0::PreferredNetworkType::LTE_ONLY; + case (RAF::LTE | RAF::WCDMA): + return V1_0::PreferredNetworkType::LTE_WCDMA; + case RAF::CDMA: + return V1_0::PreferredNetworkType::CDMA_ONLY; + case RAF::EVDO: + return V1_0::PreferredNetworkType::EVDO_ONLY; + case (RAF::GSM | RAF::WCDMA | RAF::CDMA | RAF::EVDO): + return V1_0::PreferredNetworkType::GSM_WCDMA_CDMA_EVDO_AUTO; + case static_cast(RAF::E::TD_SCDMA): + return V1_0::PreferredNetworkType::TD_SCDMA_ONLY; + case (RAF::E::TD_SCDMA | RAF::WCDMA): + return V1_0::PreferredNetworkType::TD_SCDMA_WCDMA; + case (RAF::LTE | RAF::E::TD_SCDMA): + return V1_0::PreferredNetworkType::TD_SCDMA_LTE; + case (RAF::E::TD_SCDMA | RAF::GSM): + return V1_0::PreferredNetworkType::TD_SCDMA_GSM; + case (RAF::LTE | RAF::E::TD_SCDMA | RAF::GSM): + return V1_0::PreferredNetworkType::TD_SCDMA_GSM_LTE; + case (RAF::E::TD_SCDMA | RAF::GSM | RAF::WCDMA): + return V1_0::PreferredNetworkType::TD_SCDMA_GSM_WCDMA; + case (RAF::LTE | RAF::E::TD_SCDMA | RAF::WCDMA): + return V1_0::PreferredNetworkType::TD_SCDMA_WCDMA_LTE; + case (RAF::LTE | RAF::E::TD_SCDMA | RAF::GSM | RAF::WCDMA): + return V1_0::PreferredNetworkType::TD_SCDMA_GSM_WCDMA_LTE; + case (RAF::E::TD_SCDMA | RAF::CDMA | RAF::EVDO | RAF::GSM | RAF::WCDMA): + return V1_0::PreferredNetworkType::TD_SCDMA_GSM_WCDMA_CDMA_EVDO_AUTO; + case (RAF::LTE | RAF::E::TD_SCDMA | RAF::CDMA | RAF::EVDO | RAF::GSM | RAF::WCDMA): + return V1_0::PreferredNetworkType::TD_SCDMA_LTE_CDMA_EVDO_GSM_WCDMA; + case static_cast(RAF::NR): + return V1_0::PreferredNetworkType(23); // NR_ONLY + case (RAF::NR | RAF::LTE): + return V1_0::PreferredNetworkType(24); // NR_LTE + case (RAF::NR | RAF::LTE | RAF::CDMA | RAF::EVDO): + return V1_0::PreferredNetworkType(25); // NR_LTE_CDMA_EVDO + case (RAF::NR | RAF::LTE | RAF::GSM | RAF::WCDMA): + return V1_0::PreferredNetworkType(26); // NR_LTE_GSM_WCDMA + case (RAF::NR | RAF::LTE | RAF::CDMA | RAF::EVDO | RAF::GSM | RAF::WCDMA): + return V1_0::PreferredNetworkType(27); // NR_LTE_CDMA_EVDO_GSM_WCDMA + case (RAF::NR | RAF::LTE | RAF::WCDMA): + return V1_0::PreferredNetworkType(28); // NR_LTE_WCDMA + case (RAF::NR | RAF::LTE | RAF::E::TD_SCDMA): + return V1_0::PreferredNetworkType(29); // NR_LTE_TDSCDMA + case (RAF::NR | RAF::LTE | RAF::E::TD_SCDMA | RAF::GSM): + return V1_0::PreferredNetworkType(30); // NR_LTE_TDSCDMA_GSM + case (RAF::NR | RAF::LTE | RAF::E::TD_SCDMA | RAF::WCDMA): + return V1_0::PreferredNetworkType(31); // NR_LTE_TDSCDMA_WCDMA + case (RAF::NR | RAF::LTE | RAF::E::TD_SCDMA | RAF::GSM | RAF::WCDMA): + return V1_0::PreferredNetworkType(32); // NR_LTE_TDSCDMA_GSM_WCDMA + case (RAF::NR | RAF::LTE | RAF::E::TD_SCDMA | RAF::CDMA | RAF::EVDO | RAF::GSM | + RAF::WCDMA): + return V1_0::PreferredNetworkType(33); // NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA + default: + return V1_0::PreferredNetworkType::WCDMA; + } +} + +hidl_bitfield getRafFromNetworkType(V1_0::PreferredNetworkType type) { + switch (type) { + case V1_0::PreferredNetworkType::GSM_WCDMA_AUTO: + return RAF::GSM | RAF::WCDMA; + case V1_0::PreferredNetworkType::GSM_ONLY: + return RAF::GSM; + case V1_0::PreferredNetworkType::WCDMA: + return RAF::WCDMA; + case V1_0::PreferredNetworkType::CDMA_EVDO_AUTO: + return (RAF::CDMA | RAF::EVDO); + case V1_0::PreferredNetworkType::LTE_CDMA_EVDO: + return (RAF::LTE | RAF::CDMA | RAF::EVDO); + case V1_0::PreferredNetworkType::LTE_GSM_WCDMA: + return (RAF::LTE | RAF::GSM | RAF::WCDMA); + case V1_0::PreferredNetworkType::LTE_CMDA_EVDO_GSM_WCDMA: + return (RAF::LTE | RAF::CDMA | RAF::EVDO | RAF::GSM | RAF::WCDMA); + case V1_0::PreferredNetworkType::LTE_ONLY: + return RAF::LTE; + case V1_0::PreferredNetworkType::LTE_WCDMA: + return (RAF::LTE | RAF::WCDMA); + case V1_0::PreferredNetworkType::CDMA_ONLY: + return RAF::CDMA; + case V1_0::PreferredNetworkType::EVDO_ONLY: + return RAF::EVDO; + case V1_0::PreferredNetworkType::GSM_WCDMA_CDMA_EVDO_AUTO: + return (RAF::GSM | RAF::WCDMA | RAF::CDMA | RAF::EVDO); + case V1_0::PreferredNetworkType::TD_SCDMA_ONLY: + return static_cast(RAF::E::TD_SCDMA); + case V1_0::PreferredNetworkType::TD_SCDMA_WCDMA: + return (RAF::E::TD_SCDMA | RAF::WCDMA); + case V1_0::PreferredNetworkType::TD_SCDMA_LTE: + return (RAF::LTE | RAF::E::TD_SCDMA); + case V1_0::PreferredNetworkType::TD_SCDMA_GSM: + return (RAF::E::TD_SCDMA | RAF::GSM); + case V1_0::PreferredNetworkType::TD_SCDMA_GSM_LTE: + return (RAF::LTE | RAF::E::TD_SCDMA | RAF::GSM); + case V1_0::PreferredNetworkType::TD_SCDMA_GSM_WCDMA: + return (RAF::E::TD_SCDMA | RAF::GSM | RAF::WCDMA); + case V1_0::PreferredNetworkType::TD_SCDMA_WCDMA_LTE: + return (RAF::LTE | RAF::E::TD_SCDMA | RAF::WCDMA); + case V1_0::PreferredNetworkType::TD_SCDMA_GSM_WCDMA_LTE: + return (RAF::LTE | RAF::E::TD_SCDMA | RAF::GSM | RAF::WCDMA); + case V1_0::PreferredNetworkType::TD_SCDMA_GSM_WCDMA_CDMA_EVDO_AUTO: + return (RAF::E::TD_SCDMA | RAF::CDMA | RAF::EVDO | RAF::GSM | RAF::WCDMA); + case V1_0::PreferredNetworkType::TD_SCDMA_LTE_CDMA_EVDO_GSM_WCDMA: + return (RAF::LTE | RAF::E::TD_SCDMA | RAF::CDMA | RAF::EVDO | RAF::GSM | RAF::WCDMA); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wswitch" + case V1_0::PreferredNetworkType(23): // NR_ONLY + return static_cast(RAF::NR); + case V1_0::PreferredNetworkType(24): // NR_LTE + return (RAF::NR | RAF::LTE); + case V1_0::PreferredNetworkType(25): // NR_LTE_CDMA_EVDO + return (RAF::NR | RAF::LTE | RAF::CDMA | RAF::EVDO); + case V1_0::PreferredNetworkType(26): // NR_LTE_GSM_WCDMA + return (RAF::NR | RAF::LTE | RAF::GSM | RAF::WCDMA); + case V1_0::PreferredNetworkType(27): // NR_LTE_CDMA_EVDO_GSM_WCDMA + return (RAF::NR | RAF::LTE | RAF::CDMA | RAF::EVDO | RAF::GSM | RAF::WCDMA); + case V1_0::PreferredNetworkType(28): // NR_LTE_WCDMA + return (RAF::NR | RAF::LTE | RAF::WCDMA); + case V1_0::PreferredNetworkType(29): // NR_LTE_TDSCDMA + return (RAF::NR | RAF::LTE | RAF::E::TD_SCDMA); + case V1_0::PreferredNetworkType(30): // NR_LTE_TDSCDMA_GSM + return (RAF::NR | RAF::LTE | RAF::E::TD_SCDMA | RAF::GSM); + case V1_0::PreferredNetworkType(31): // NR_LTE_TDSCDMA_WCDMA + return (RAF::NR | RAF::LTE | RAF::E::TD_SCDMA | RAF::WCDMA); + case V1_0::PreferredNetworkType(32): // NR_LTE_TDSCDMA_GSM_WCDMA + return (RAF::NR | RAF::LTE | RAF::E::TD_SCDMA | RAF::GSM | RAF::WCDMA); + case V1_0::PreferredNetworkType(33): // NR_LTE_TDSCDMA_CDMA_EVDO_GSM_WCDMA + return (RAF::NR | RAF::LTE | RAF::E::TD_SCDMA | RAF::CDMA | RAF::EVDO | RAF::GSM | + RAF::WCDMA); +#pragma GCC diagnostic pop + default: + return {}; // unknown + } +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/network/utils.h b/radio/aidl/compat/libradiocompat/network/utils.h new file mode 100644 index 0000000000..10714beaee --- /dev/null +++ b/radio/aidl/compat/libradiocompat/network/utils.h @@ -0,0 +1,25 @@ +/* + * 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 + +namespace android::hardware::radio::compat { + +V1_0::PreferredNetworkType getNetworkTypeFromRaf(hidl_bitfield raf); +hidl_bitfield getRafFromNetworkType(V1_0::PreferredNetworkType type); + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/service/Android.bp b/radio/aidl/compat/service/Android.bp index e97e2db73e..3c543f744d 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.network-V1-ndk", "android.hardware.radio.sim-V1-ndk", "android.hardware.radio@1.0", "android.hardware.radio@1.1", diff --git a/radio/aidl/compat/service/radio-compat.xml b/radio/aidl/compat/service/radio-compat.xml index ac812fb91f..e035cac793 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.network + IRadioNetwork/slot1 + android.hardware.radio.sim IRadioSim/slot1 diff --git a/radio/aidl/compat/service/service.cpp b/radio/aidl/compat/service/service.cpp index c97b47a097..82d234f8ba 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 @@ -60,6 +61,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); } From 6e084181d1f8e3f56e282cdf1155559314a7a947 Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Fri, 5 Nov 2021 10:53:55 -0700 Subject: [PATCH 6/7] Implement RadioVoice for AIDL-HIDL Telephony HAL translator Bug: 203699028 Test: Boot and grep logcat against radiocompat Change-Id: Ie2dce95ba1a468c10d92a74bfdca03d2a8d744b0 --- radio/aidl/compat/libradiocompat/Android.bp | 5 + .../compat/libradiocompat/RadioIndication.cpp | 64 ---- .../compat/libradiocompat/RadioResponse.cpp | 154 +-------- .../include/libradiocompat/RadioIndication.h | 4 + .../include/libradiocompat/RadioResponse.h | 4 + .../include/libradiocompat/RadioVoice.h | 84 +++++ .../voice/RadioIndication-voice.cpp | 142 +++++++++ .../voice/RadioResponse-voice.cpp | 294 ++++++++++++++++++ .../libradiocompat/voice/RadioVoice.cpp | 270 ++++++++++++++++ .../compat/libradiocompat/voice/structs.cpp | 223 +++++++++++++ .../compat/libradiocompat/voice/structs.h | 91 ++++++ 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, 1125 insertions(+), 217 deletions(-) create mode 100644 radio/aidl/compat/libradiocompat/include/libradiocompat/RadioVoice.h create mode 100644 radio/aidl/compat/libradiocompat/voice/RadioIndication-voice.cpp create mode 100644 radio/aidl/compat/libradiocompat/voice/RadioResponse-voice.cpp create mode 100644 radio/aidl/compat/libradiocompat/voice/RadioVoice.cpp create mode 100644 radio/aidl/compat/libradiocompat/voice/structs.cpp create mode 100644 radio/aidl/compat/libradiocompat/voice/structs.h diff --git a/radio/aidl/compat/libradiocompat/Android.bp b/radio/aidl/compat/libradiocompat/Android.bp index fdee336f4f..715a1c2d3b 100644 --- a/radio/aidl/compat/libradiocompat/Android.bp +++ b/radio/aidl/compat/libradiocompat/Android.bp @@ -41,6 +41,7 @@ cc_library { "android.hardware.radio.messaging-V1-ndk", "android.hardware.radio.network-V1-ndk", "android.hardware.radio.sim-V1-ndk", + "android.hardware.radio.voice-V1-ndk", "android.hardware.radio@1.0", "android.hardware.radio@1.1", "android.hardware.radio@1.2", @@ -79,6 +80,10 @@ cc_library { "sim/RadioResponse-sim.cpp", "sim/RadioSim.cpp", "sim/structs.cpp", + "voice/RadioIndication-voice.cpp", + "voice/RadioResponse-voice.cpp", + "voice/RadioVoice.cpp", + "voice/structs.cpp", ], export_include_dirs: ["include"], } diff --git a/radio/aidl/compat/libradiocompat/RadioIndication.cpp b/radio/aidl/compat/libradiocompat/RadioIndication.cpp index 90b9e752d8..df97841d16 100644 --- a/radio/aidl/compat/libradiocompat/RadioIndication.cpp +++ b/radio/aidl/compat/libradiocompat/RadioIndication.cpp @@ -26,59 +26,10 @@ Return RadioIndication::radioStateChanged(V1_0::RadioIndicationType type, return {}; } -Return RadioIndication::callStateChanged(V1_0::RadioIndicationType type) { - return {}; -} - -Return RadioIndication::stkCallSetup(V1_0::RadioIndicationType type, int64_t timeout) { - return {}; -} - -Return RadioIndication::callRing(V1_0::RadioIndicationType type, bool isGsm, - const V1_0::CdmaSignalInfoRecord& record) { - return {}; -} - -Return RadioIndication::enterEmergencyCallbackMode(V1_0::RadioIndicationType type) { - return {}; -} - -Return RadioIndication::cdmaCallWaiting(V1_0::RadioIndicationType type, - const V1_0::CdmaCallWaiting& callWaitingRecord) { - return {}; -} - -Return RadioIndication::cdmaOtaProvisionStatus(V1_0::RadioIndicationType type, - V1_0::CdmaOtaProvisionStatus status) { - return {}; -} - -Return RadioIndication::cdmaInfoRec(V1_0::RadioIndicationType type, - const V1_0::CdmaInformationRecords& records) { - return {}; -} - -Return RadioIndication::indicateRingbackTone(V1_0::RadioIndicationType type, bool start) { - return {}; -} - -Return RadioIndication::resendIncallMute(V1_0::RadioIndicationType type) { - return {}; -} - -Return RadioIndication::exitEmergencyCallbackMode(V1_0::RadioIndicationType type) { - return {}; -} - Return RadioIndication::rilConnected(V1_0::RadioIndicationType type) { return {}; } -Return RadioIndication::srvccStateNotify(V1_0::RadioIndicationType type, - V1_0::SrvccState state) { - return {}; -} - Return RadioIndication::hardwareConfigChanged(V1_0::RadioIndicationType type, const hidl_vec& configs) { return {}; @@ -89,24 +40,9 @@ Return RadioIndication::radioCapabilityIndication(V1_0::RadioIndicationTyp return {}; } -Return RadioIndication::onSupplementaryServiceIndication(V1_0::RadioIndicationType type, - const V1_0::StkCcUnsolSsResult& ss) { - return {}; -} - -Return RadioIndication::stkCallControlAlphaNotify(V1_0::RadioIndicationType type, - const hidl_string& alpha) { - return {}; -} - Return RadioIndication::modemReset(V1_0::RadioIndicationType type, const hidl_string& reason) { return {}; } -Return RadioIndication::currentEmergencyNumberList( - V1_0::RadioIndicationType type, const hidl_vec& emergencyNumbers) { - return {}; -} - } // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/RadioResponse.cpp b/radio/aidl/compat/libradiocompat/RadioResponse.cpp index 001330fbd9..a39f575695 100644 --- a/radio/aidl/compat/libradiocompat/RadioResponse.cpp +++ b/radio/aidl/compat/libradiocompat/RadioResponse.cpp @@ -32,46 +32,7 @@ Return RadioResponse::acknowledgeRequest(int32_t serial) { if (mMessagingCb) mMessagingCb->acknowledgeRequest(serial); if (mNetworkCb) mNetworkCb->acknowledgeRequest(serial); if (mSimCb) mSimCb->acknowledgeRequest(serial); - return {}; -} - -Return RadioResponse::getCurrentCallsResponse(const V1_0::RadioResponseInfo& info, - const hidl_vec& calls) { - return {}; -} - -Return RadioResponse::dialResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::hangupConnectionResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::hangupWaitingOrBackgroundResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::hangupForegroundResumeBackgroundResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::switchWaitingOrHoldingAndActiveResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::conferenceResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::rejectCallResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getLastCallFailCauseResponse( - const V1_0::RadioResponseInfo& info, const V1_0::LastCallFailCauseInfo& failCauseinfo) { + if (mVoiceCb) mVoiceCb->acknowledgeRequest(serial); return {}; } @@ -79,116 +40,17 @@ Return RadioResponse::setRadioPowerResponse(const V1_0::RadioResponseInfo& return {}; } -Return RadioResponse::sendDtmfResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getClirResponse(const V1_0::RadioResponseInfo& info, int32_t n, - int32_t m) { - return {}; -} - -Return RadioResponse::setClirResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getCallForwardStatusResponse( - const V1_0::RadioResponseInfo& info, const hidl_vec& callFwdInfos) { - return {}; -} - -Return RadioResponse::setCallForwardResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getCallWaitingResponse(const V1_0::RadioResponseInfo& info, bool enable, - int32_t serviceClass) { - return {}; -} - -Return RadioResponse::setCallWaitingResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::acceptCallResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::startDtmfResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::stopDtmfResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::getBasebandVersionResponse(const V1_0::RadioResponseInfo& info, const hidl_string& version) { return {}; } -Return RadioResponse::separateConnectionResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setMuteResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getMuteResponse(const V1_0::RadioResponseInfo& info, bool enable) { - return {}; -} - -Return RadioResponse::getClipResponse(const V1_0::RadioResponseInfo& info, - V1_0::ClipStatus status) { - return {}; -} - -Return RadioResponse::handleStkCallSetupRequestFromSimResponse( - const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::explicitCallTransferResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::setTTYModeResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getTTYModeResponse(const V1_0::RadioResponseInfo& info, - V1_0::TtyMode mode) { - return {}; -} - -Return RadioResponse::setPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::getPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo& info, - bool enable) { - return {}; -} - -Return RadioResponse::sendCDMAFeatureCodeResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - -Return RadioResponse::sendBurstDtmfResponse(const V1_0::RadioResponseInfo& info) { - 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::exitEmergencyCallbackModeResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::nvReadItemResponse(const V1_0::RadioResponseInfo& info, const hidl_string& result) { return {}; @@ -234,11 +96,6 @@ Return RadioResponse::sendDeviceStateResponse(const V1_0::RadioResponseInf return {}; } -Return RadioResponse::getCurrentCallsResponse_1_2(const V1_0::RadioResponseInfo& info, - const hidl_vec& calls) { - return {}; -} - Return RadioResponse::enableModemResponse(const V1_0::RadioResponseInfo& info) { return {}; } @@ -248,10 +105,6 @@ Return RadioResponse::getModemStackStatusResponse(const V1_0::RadioRespons return {}; } -Return RadioResponse::emergencyDialResponse(const V1_0::RadioResponseInfo& info) { - return {}; -} - Return RadioResponse::setRadioPowerResponse_1_5(const V1_0::RadioResponseInfo& info) { return {}; } @@ -260,9 +113,4 @@ Return RadioResponse::setRadioPowerResponse_1_6(const V1_6::RadioResponseI return {}; } -Return RadioResponse::getCurrentCallsResponse_1_6(const V1_6::RadioResponseInfo& info, - const hidl_vec& calls) { - return {}; -} - } // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h index c7a2629b7d..51cdccbc38 100644 --- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioIndication.h @@ -19,6 +19,7 @@ #include #include #include +#include #include namespace android::hardware::radio::compat { @@ -29,6 +30,7 @@ class RadioIndication : public V1_6::IRadioIndication { mMessagingCb; 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; // IRadioIndication @ 1.0 Return radioStateChanged(V1_0::RadioIndicationType type, @@ -186,6 +188,8 @@ class RadioIndication : public V1_6::IRadioIndication { std::shared_ptr<::aidl::android::hardware::radio::network::IRadioNetworkIndication> ni); void setResponseFunction( std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimIndication> simCb); + void setResponseFunction( + std::shared_ptr<::aidl::android::hardware::radio::voice::IRadioVoiceIndication> voicCb); }; } // 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 b87ca6e235..826d38566c 100644 --- a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioResponse.h @@ -19,6 +19,7 @@ #include #include #include +#include #include namespace android::hardware::radio::compat { @@ -29,6 +30,7 @@ class RadioResponse : public V1_6::IRadioResponse { mMessagingCb; 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; // IRadioResponse @ 1.0 Return getIccCardStatusResponse(const V1_0::RadioResponseInfo& info, @@ -414,6 +416,8 @@ class RadioResponse : public V1_6::IRadioResponse { std::shared_ptr<::aidl::android::hardware::radio::network::IRadioNetworkResponse> nwCb); void setResponseFunction( std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimResponse> simCb); + void setResponseFunction( + std::shared_ptr<::aidl::android::hardware::radio::voice::IRadioVoiceResponse> voiceCb); }; } // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioVoice.h b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioVoice.h new file mode 100644 index 0000000000..5bf93e0fb3 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/include/libradiocompat/RadioVoice.h @@ -0,0 +1,84 @@ +/* + * 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 RadioVoice : public RadioCompatBase, + public aidl::android::hardware::radio::voice::BnRadioVoice { + ::ndk::ScopedAStatus acceptCall(int32_t serial) override; + ::ndk::ScopedAStatus conference(int32_t serial) override; + ::ndk::ScopedAStatus dial( + int32_t serial, const ::aidl::android::hardware::radio::voice::Dial& dialInfo) override; + ::ndk::ScopedAStatus emergencyDial( + int32_t serial, const ::aidl::android::hardware::radio::voice::Dial& dialInfo, + ::aidl::android::hardware::radio::voice::EmergencyServiceCategory categories, + const std::vector& urns, + ::aidl::android::hardware::radio::voice::EmergencyCallRouting routing, + bool hasKnownUserIntentEmergency, bool isTesting) override; + ::ndk::ScopedAStatus exitEmergencyCallbackMode(int32_t serial) override; + ::ndk::ScopedAStatus explicitCallTransfer(int32_t serial) override; + ::ndk::ScopedAStatus getCallForwardStatus( + int32_t serial, + const ::aidl::android::hardware::radio::voice::CallForwardInfo& callInfo) override; + ::ndk::ScopedAStatus getCallWaiting(int32_t serial, int32_t serviceClass) override; + ::ndk::ScopedAStatus getClip(int32_t serial) override; + ::ndk::ScopedAStatus getClir(int32_t serial) override; + ::ndk::ScopedAStatus getCurrentCalls(int32_t serial) override; + ::ndk::ScopedAStatus getLastCallFailCause(int32_t serial) override; + ::ndk::ScopedAStatus getMute(int32_t serial) override; + ::ndk::ScopedAStatus getPreferredVoicePrivacy(int32_t serial) override; + ::ndk::ScopedAStatus getTtyMode(int32_t serial) override; + ::ndk::ScopedAStatus handleStkCallSetupRequestFromSim(int32_t serial, bool accept) override; + ::ndk::ScopedAStatus hangup(int32_t serial, int32_t gsmIndex) override; + ::ndk::ScopedAStatus hangupForegroundResumeBackground(int32_t serial) override; + ::ndk::ScopedAStatus hangupWaitingOrBackground(int32_t serial) override; + ::ndk::ScopedAStatus isVoNrEnabled(int32_t serial) override; + ::ndk::ScopedAStatus rejectCall(int32_t serial) override; + ::ndk::ScopedAStatus responseAcknowledgement() override; + ::ndk::ScopedAStatus sendBurstDtmf(int32_t serial, const std::string& dtmf, int32_t on, + int32_t off) override; + ::ndk::ScopedAStatus sendCdmaFeatureCode(int32_t serial, const std::string& fcode) override; + ::ndk::ScopedAStatus sendDtmf(int32_t serial, const std::string& s) override; + ::ndk::ScopedAStatus separateConnection(int32_t serial, int32_t gsmIndex) override; + ::ndk::ScopedAStatus setCallForward( + int32_t serial, + const ::aidl::android::hardware::radio::voice::CallForwardInfo& callInfo) override; + ::ndk::ScopedAStatus setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) override; + ::ndk::ScopedAStatus setClir(int32_t serial, int32_t status) override; + ::ndk::ScopedAStatus setMute(int32_t serial, bool enable) override; + ::ndk::ScopedAStatus setPreferredVoicePrivacy(int32_t serial, bool enable) override; + ::ndk::ScopedAStatus setResponseFunctions( + const std::shared_ptr<::aidl::android::hardware::radio::voice::IRadioVoiceResponse>& + radioVoiceResponse, + const std::shared_ptr<::aidl::android::hardware::radio::voice::IRadioVoiceIndication>& + radioVoiceIndication) override; + ::ndk::ScopedAStatus setTtyMode(int32_t serial, + ::aidl::android::hardware::radio::voice::TtyMode mode) override; + ::ndk::ScopedAStatus setVoNrEnabled(int32_t serial, bool enable) override; + ::ndk::ScopedAStatus startDtmf(int32_t serial, const std::string& s) override; + ::ndk::ScopedAStatus stopDtmf(int32_t serial) override; + ::ndk::ScopedAStatus switchWaitingOrHoldingAndActive(int32_t serial) override; + + public: + using RadioCompatBase::RadioCompatBase; +}; + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/voice/RadioIndication-voice.cpp b/radio/aidl/compat/libradiocompat/voice/RadioIndication-voice.cpp new file mode 100644 index 0000000000..6d9bda8dea --- /dev/null +++ b/radio/aidl/compat/libradiocompat/voice/RadioIndication-voice.cpp @@ -0,0 +1,142 @@ +/* + * 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 "VoiceIndication" + +namespace android::hardware::radio::compat { + +namespace aidl = ::aidl::android::hardware::radio::voice; + +void RadioIndication::setResponseFunction(std::shared_ptr voiceCb) { + CHECK(voiceCb); + mVoiceCb = voiceCb; +} + +Return RadioIndication::callRing(V1_0::RadioIndicationType type, bool isGsm, + const V1_0::CdmaSignalInfoRecord& record) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->callRing(toAidl(type), isGsm, toAidl(record)); + return {}; +} + +Return RadioIndication::callStateChanged(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->callStateChanged(toAidl(type)); + return {}; +} + +Return RadioIndication::cdmaCallWaiting(V1_0::RadioIndicationType type, + const V1_0::CdmaCallWaiting& callWaitingRecord) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->cdmaCallWaiting(toAidl(type), toAidl(callWaitingRecord)); + return {}; +} + +Return RadioIndication::cdmaInfoRec(V1_0::RadioIndicationType type, + const V1_0::CdmaInformationRecords& records) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->cdmaInfoRec(toAidl(type), toAidl(records.infoRec)); + return {}; +} + +Return RadioIndication::cdmaOtaProvisionStatus(V1_0::RadioIndicationType type, + V1_0::CdmaOtaProvisionStatus status) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->cdmaOtaProvisionStatus(toAidl(type), aidl::CdmaOtaProvisionStatus(status)); + return {}; +} + +Return RadioIndication::currentEmergencyNumberList( + V1_0::RadioIndicationType type, const hidl_vec& emergencyNumbers) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->currentEmergencyNumberList(toAidl(type), toAidl(emergencyNumbers)); + return {}; +} + +Return RadioIndication::enterEmergencyCallbackMode(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->enterEmergencyCallbackMode(toAidl(type)); + return {}; +} + +Return RadioIndication::exitEmergencyCallbackMode(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->exitEmergencyCallbackMode(toAidl(type)); + return {}; +} + +Return RadioIndication::indicateRingbackTone(V1_0::RadioIndicationType type, bool start) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->indicateRingbackTone(toAidl(type), start); + return {}; +} + +Return RadioIndication::onSupplementaryServiceIndication(V1_0::RadioIndicationType type, + const V1_0::StkCcUnsolSsResult& ss) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->onSupplementaryServiceIndication(toAidl(type), toAidl(ss)); + return {}; +} + +Return RadioIndication::resendIncallMute(V1_0::RadioIndicationType type) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->resendIncallMute(toAidl(type)); + return {}; +} + +Return RadioIndication::srvccStateNotify(V1_0::RadioIndicationType type, + V1_0::SrvccState state) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->srvccStateNotify(toAidl(type), aidl::SrvccState(state)); + return {}; +} + +Return RadioIndication::stkCallControlAlphaNotify(V1_0::RadioIndicationType type, + const hidl_string& alpha) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->stkCallControlAlphaNotify(toAidl(type), alpha); + return {}; +} + +Return RadioIndication::stkCallSetup(V1_0::RadioIndicationType type, int64_t timeout) { + LOG_CALL << type; + CHECK_CB(mVoiceCb); + mVoiceCb->stkCallSetup(toAidl(type), timeout); + return {}; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/voice/RadioResponse-voice.cpp b/radio/aidl/compat/libradiocompat/voice/RadioResponse-voice.cpp new file mode 100644 index 0000000000..0a64c56be2 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/voice/RadioResponse-voice.cpp @@ -0,0 +1,294 @@ +/* + * 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 "VoiceResponse" + +namespace android::hardware::radio::compat { + +namespace aidl = ::aidl::android::hardware::radio::voice; + +void RadioResponse::setResponseFunction(std::shared_ptr voiceCb) { + CHECK(voiceCb); + mVoiceCb = voiceCb; +} + +Return RadioResponse::acceptCallResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->acceptCallResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::conferenceResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->conferenceResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::dialResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->dialResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::emergencyDialResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->emergencyDialResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::exitEmergencyCallbackModeResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->exitEmergencyCallbackModeResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::explicitCallTransferResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->explicitCallTransferResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::getCallForwardStatusResponse( + const V1_0::RadioResponseInfo& info, const hidl_vec& callFwdInfos) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getCallForwardStatusResponse(toAidl(info), toAidl(callFwdInfos)); + return {}; +} + +Return RadioResponse::getCallWaitingResponse(const V1_0::RadioResponseInfo& info, bool enable, + int32_t serviceClass) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getCallWaitingResponse(toAidl(info), enable, serviceClass); + return {}; +} + +Return RadioResponse::getClipResponse(const V1_0::RadioResponseInfo& info, + V1_0::ClipStatus status) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getClipResponse(toAidl(info), aidl::ClipStatus(status)); + return {}; +} + +Return RadioResponse::getClirResponse(const V1_0::RadioResponseInfo& info, int32_t n, + int32_t m) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getClirResponse(toAidl(info), n, m); + return {}; +} + +Return RadioResponse::getCurrentCallsResponse(const V1_0::RadioResponseInfo& info, + const hidl_vec& calls) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getCurrentCallsResponse(toAidl(info), toAidl(calls)); + return {}; +} + +Return RadioResponse::getCurrentCallsResponse_1_2(const V1_0::RadioResponseInfo& info, + const hidl_vec& calls) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getCurrentCallsResponse(toAidl(info), toAidl(calls)); + return {}; +} + +Return RadioResponse::getCurrentCallsResponse_1_6(const V1_6::RadioResponseInfo& info, + const hidl_vec& calls) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getCurrentCallsResponse(toAidl(info), toAidl(calls)); + return {}; +} + +Return RadioResponse::getLastCallFailCauseResponse( + const V1_0::RadioResponseInfo& info, const V1_0::LastCallFailCauseInfo& failCauseinfo) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getLastCallFailCauseResponse(toAidl(info), toAidl(failCauseinfo)); + return {}; +} + +Return RadioResponse::getMuteResponse(const V1_0::RadioResponseInfo& info, bool enable) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getMuteResponse(toAidl(info), enable); + return {}; +} + +Return RadioResponse::getPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo& info, + bool enable) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getPreferredVoicePrivacyResponse(toAidl(info), enable); + return {}; +} + +Return RadioResponse::getTTYModeResponse(const V1_0::RadioResponseInfo& info, + V1_0::TtyMode mode) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->getTtyModeResponse(toAidl(info), aidl::TtyMode(mode)); + return {}; +} + +Return RadioResponse::handleStkCallSetupRequestFromSimResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->handleStkCallSetupRequestFromSimResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::hangupConnectionResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->hangupConnectionResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::hangupForegroundResumeBackgroundResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->hangupForegroundResumeBackgroundResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::hangupWaitingOrBackgroundResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->hangupWaitingOrBackgroundResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::rejectCallResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->rejectCallResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::sendBurstDtmfResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->sendBurstDtmfResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::sendCDMAFeatureCodeResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->sendCdmaFeatureCodeResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::sendDtmfResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->sendDtmfResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::separateConnectionResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->separateConnectionResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setCallForwardResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->setCallForwardResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setCallWaitingResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->setCallWaitingResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setClirResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->setClirResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setMuteResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->setMuteResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setPreferredVoicePrivacyResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->setPreferredVoicePrivacyResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::setTTYModeResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->setTtyModeResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::startDtmfResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->startDtmfResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::stopDtmfResponse(const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->stopDtmfResponse(toAidl(info)); + return {}; +} + +Return RadioResponse::switchWaitingOrHoldingAndActiveResponse( + const V1_0::RadioResponseInfo& info) { + LOG_CALL << info.serial; + CHECK_CB(mVoiceCb); + mVoiceCb->switchWaitingOrHoldingAndActiveResponse(toAidl(info)); + return {}; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/voice/RadioVoice.cpp b/radio/aidl/compat/libradiocompat/voice/RadioVoice.cpp new file mode 100644 index 0000000000..16c6b14632 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/voice/RadioVoice.cpp @@ -0,0 +1,270 @@ +/* + * 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 "Voice" + +namespace android::hardware::radio::compat { + +using ::ndk::ScopedAStatus; +namespace aidl = ::aidl::android::hardware::radio::voice; +constexpr auto ok = &ScopedAStatus::ok; + +ScopedAStatus RadioVoice::acceptCall(int32_t serial) { + LOG_CALL << serial; + mHal1_5->acceptCall(serial); + return ok(); +} + +ScopedAStatus RadioVoice::conference(int32_t serial) { + LOG_CALL << serial; + mHal1_5->conference(serial); + return ok(); +} + +ScopedAStatus RadioVoice::dial(int32_t serial, const aidl::Dial& dialInfo) { + LOG_CALL << serial; + mHal1_5->dial(serial, toHidl(dialInfo)); + return ok(); +} + +ScopedAStatus RadioVoice::emergencyDial( // + int32_t serial, const aidl::Dial& dialInfo, aidl::EmergencyServiceCategory categories, + const std::vector& urns, aidl::EmergencyCallRouting routing, + bool hasKnownUserIntentEmerg, bool isTesting) { + LOG_CALL << serial; + mHal1_5->emergencyDial(serial, toHidl(dialInfo), + toHidlBitfield(categories), toHidl(urns), + V1_4::EmergencyCallRouting(routing), hasKnownUserIntentEmerg, isTesting); + return ok(); +} + +ScopedAStatus RadioVoice::exitEmergencyCallbackMode(int32_t serial) { + LOG_CALL << serial; + mHal1_5->exitEmergencyCallbackMode(serial); + return ok(); +} + +ScopedAStatus RadioVoice::explicitCallTransfer(int32_t serial) { + LOG_CALL << serial; + mHal1_5->explicitCallTransfer(serial); + return ok(); +} + +ScopedAStatus RadioVoice::getCallForwardStatus(int32_t serial, + const aidl::CallForwardInfo& callInfo) { + LOG_CALL << serial; + mHal1_5->getCallForwardStatus(serial, toHidl(callInfo)); + return ok(); +} + +ScopedAStatus RadioVoice::getCallWaiting(int32_t serial, int32_t serviceClass) { + LOG_CALL << serial; + mHal1_5->getCallWaiting(serial, serviceClass); + return ok(); +} + +ScopedAStatus RadioVoice::getClip(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getClip(serial); + return ok(); +} + +ScopedAStatus RadioVoice::getClir(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getClir(serial); + return ok(); +} + +ScopedAStatus RadioVoice::getCurrentCalls(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getCurrentCalls(serial); + return ok(); +} + +ScopedAStatus RadioVoice::getLastCallFailCause(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getLastCallFailCause(serial); + return ok(); +} + +ScopedAStatus RadioVoice::getMute(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getMute(serial); + return ok(); +} + +ScopedAStatus RadioVoice::getPreferredVoicePrivacy(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getPreferredVoicePrivacy(serial); + return ok(); +} + +ScopedAStatus RadioVoice::getTtyMode(int32_t serial) { + LOG_CALL << serial; + mHal1_5->getTTYMode(serial); + return ok(); +} + +ScopedAStatus RadioVoice::handleStkCallSetupRequestFromSim(int32_t serial, bool accept) { + LOG_CALL << serial; + mHal1_5->handleStkCallSetupRequestFromSim(serial, accept); + return ok(); +} + +ScopedAStatus RadioVoice::hangup(int32_t serial, int32_t gsmIndex) { + LOG_CALL << serial; + mHal1_5->hangup(serial, gsmIndex); + return ok(); +} + +ScopedAStatus RadioVoice::hangupForegroundResumeBackground(int32_t serial) { + LOG_CALL << serial; + mHal1_5->hangupForegroundResumeBackground(serial); + return ok(); +} + +ScopedAStatus RadioVoice::hangupWaitingOrBackground(int32_t serial) { + LOG_CALL << serial; + mHal1_5->hangupWaitingOrBackground(serial); + return ok(); +} + +ScopedAStatus RadioVoice::isVoNrEnabled(int32_t serial) { + LOG_CALL << serial; + // TODO(b/203699028): can't call isVoNrEnabledResponse with 1.6 callback + return ok(); +} + +ScopedAStatus RadioVoice::rejectCall(int32_t serial) { + LOG_CALL << serial; + mHal1_5->rejectCall(serial); + return ok(); +} + +ScopedAStatus RadioVoice::responseAcknowledgement() { + LOG_CALL; + mHal1_5->responseAcknowledgement(); + return ok(); +} + +ScopedAStatus RadioVoice::sendBurstDtmf(int32_t serial, const std::string& dtmf, int32_t on, + int32_t off) { + LOG_CALL << serial; + mHal1_5->sendBurstDtmf(serial, dtmf, on, off); + return ok(); +} + +ScopedAStatus RadioVoice::sendCdmaFeatureCode(int32_t serial, const std::string& featureCode) { + LOG_CALL << serial; + mHal1_5->sendCDMAFeatureCode(serial, featureCode); + return ok(); +} + +ScopedAStatus RadioVoice::sendDtmf(int32_t serial, const std::string& s) { + LOG_CALL << serial; + mHal1_5->sendDtmf(serial, s); + return ok(); +} + +ScopedAStatus RadioVoice::separateConnection(int32_t serial, int32_t gsmIndex) { + LOG_CALL << serial; + mHal1_5->separateConnection(serial, gsmIndex); + return ok(); +} + +ScopedAStatus RadioVoice::setCallForward(int32_t serial, const aidl::CallForwardInfo& callInfo) { + LOG_CALL << serial; + mHal1_5->setCallForward(serial, toHidl(callInfo)); + return ok(); +} + +ScopedAStatus RadioVoice::setCallWaiting(int32_t serial, bool enable, int32_t serviceClass) { + LOG_CALL << serial; + mHal1_5->setCallWaiting(serial, enable, serviceClass); + return ok(); +} + +ScopedAStatus RadioVoice::setClir(int32_t serial, int32_t status) { + LOG_CALL << serial; + mHal1_5->setClir(serial, status); + return ok(); +} + +ScopedAStatus RadioVoice::setMute(int32_t serial, bool enable) { + LOG_CALL << serial; + mHal1_5->setMute(serial, enable); + return ok(); +} + +ScopedAStatus RadioVoice::setPreferredVoicePrivacy(int32_t serial, bool enable) { + LOG_CALL << serial; + mHal1_5->setPreferredVoicePrivacy(serial, enable); + return ok(); +} + +ScopedAStatus RadioVoice::setResponseFunctions( + const std::shared_ptr& voiceResponse, + const std::shared_ptr& voiceIndication) { + LOG_CALL << voiceResponse << ' ' << voiceIndication; + + CHECK(voiceResponse); + CHECK(voiceIndication); + + mRadioResponse->setResponseFunction(voiceResponse); + mRadioIndication->setResponseFunction(voiceIndication); + + return ok(); +} + +ScopedAStatus RadioVoice::setTtyMode(int32_t serial, aidl::TtyMode mode) { + LOG_CALL << serial; + mHal1_5->setTTYMode(serial, V1_0::TtyMode(mode)); + return ok(); +} + +ndk::ScopedAStatus RadioVoice::setVoNrEnabled(int32_t serial, [[maybe_unused]] bool enable) { + LOG_CALL << serial; + // TODO(b/203699028): should set `persist.radio.is_vonr_enabled_` property instead + return ok(); +} + +ScopedAStatus RadioVoice::startDtmf(int32_t serial, const std::string& s) { + LOG_CALL << serial; + mHal1_5->startDtmf(serial, s); + return ok(); +} + +ScopedAStatus RadioVoice::stopDtmf(int32_t serial) { + LOG_CALL << serial; + mHal1_5->stopDtmf(serial); + return ok(); +} + +ScopedAStatus RadioVoice::switchWaitingOrHoldingAndActive(int32_t serial) { + LOG_CALL << serial; + mHal1_5->switchWaitingOrHoldingAndActive(serial); + return ok(); +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/voice/structs.cpp b/radio/aidl/compat/libradiocompat/voice/structs.cpp new file mode 100644 index 0000000000..ae6342e5be --- /dev/null +++ b/radio/aidl/compat/libradiocompat/voice/structs.cpp @@ -0,0 +1,223 @@ +/* + * 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 { + +namespace aidl = ::aidl::android::hardware::radio::voice; + +V1_0::Dial toHidl(const aidl::Dial& info) { + return { + .address = info.address, + .clir = V1_0::Clir{info.clir}, + .uusInfo = toHidl(info.uusInfo), + }; +} + +V1_0::UusInfo toHidl(const aidl::UusInfo& info) { + return { + .uusType = V1_0::UusType{info.uusType}, + .uusDcs = V1_0::UusDcs{info.uusDcs}, + .uusData = info.uusData, + }; +} + +aidl::CallForwardInfo toAidl(const V1_0::CallForwardInfo& info) { + return { + .status = static_cast(info.status), + .reason = info.reason, + .serviceClass = info.serviceClass, + .toa = info.toa, + .number = info.number, + .timeSeconds = info.timeSeconds, + }; +} + +V1_0::CallForwardInfo toHidl(const aidl::CallForwardInfo& info) { + return { + .status = V1_0::CallForwardInfoStatus{info.status}, + .reason = info.reason, + .serviceClass = info.serviceClass, + .toa = info.toa, + .number = info.number, + .timeSeconds = info.timeSeconds, + }; +} + +aidl::CdmaSignalInfoRecord toAidl(const V1_0::CdmaSignalInfoRecord& record) { + return { + .isPresent = record.isPresent, + .signalType = record.signalType, + .alertPitch = record.alertPitch, + .signal = record.signal, + }; +} + +aidl::CdmaCallWaiting toAidl(const V1_0::CdmaCallWaiting& call) { + return { + .number = call.number, + .numberPresentation = static_cast(call.numberPresentation), + .name = call.name, + .signalInfoRecord = toAidl(call.signalInfoRecord), + .numberType = static_cast(call.numberType), + .numberPlan = static_cast(call.numberPlan), + }; +} + +aidl::CdmaInformationRecord toAidl(const V1_0::CdmaInformationRecord& record) { + return { + .name = static_cast(record.name), + .display = toAidl(record.display), + .number = toAidl(record.number), + .signal = toAidl(record.signal), + .redir = toAidl(record.redir), + .lineCtrl = toAidl(record.lineCtrl), + .clir = toAidl(record.clir), + .audioCtrl = toAidl(record.audioCtrl), + }; +} + +aidl::CdmaDisplayInfoRecord toAidl(const V1_0::CdmaDisplayInfoRecord& record) { + return { + .alphaBuf = record.alphaBuf, + }; +} + +aidl::CdmaNumberInfoRecord toAidl(const V1_0::CdmaNumberInfoRecord& record) { + return { + .number = record.number, + .numberType = static_cast(record.numberType), + .numberPlan = static_cast(record.numberPlan), + .pi = static_cast(record.pi), + .si = static_cast(record.si), + }; +} + +aidl::CdmaRedirectingNumberInfoRecord toAidl(const V1_0::CdmaRedirectingNumberInfoRecord& record) { + return { + .redirectingNumber = toAidl(record.redirectingNumber), + .redirectingReason = static_cast(record.redirectingReason), + }; +} + +aidl::CdmaLineControlInfoRecord toAidl(const V1_0::CdmaLineControlInfoRecord& record) { + return { + .lineCtrlPolarityIncluded = static_cast(record.lineCtrlPolarityIncluded), + .lineCtrlToggle = static_cast(record.lineCtrlToggle), + .lineCtrlReverse = static_cast(record.lineCtrlReverse), + .lineCtrlPowerDenial = static_cast(record.lineCtrlPowerDenial), + }; +} + +aidl::CdmaT53ClirInfoRecord toAidl(const V1_0::CdmaT53ClirInfoRecord& record) { + return { + .cause = static_cast(record.cause), + }; +} + +aidl::CdmaT53AudioControlInfoRecord toAidl(const V1_0::CdmaT53AudioControlInfoRecord& record) { + return { + .upLink = static_cast(record.upLink), + .downLink = static_cast(record.downLink), + }; +} + +aidl::EmergencyNumber toAidl(const V1_4::EmergencyNumber& num) { + return { + .number = num.number, + .mcc = num.mcc, + .mnc = num.mnc, + .categories = aidl::EmergencyServiceCategory(num.categories), + .urns = toAidl(num.urns), + .sources = num.sources, + }; +} + +aidl::StkCcUnsolSsResult toAidl(const V1_0::StkCcUnsolSsResult& res) { + return { + .serviceType = static_cast(res.serviceType), + .requestType = static_cast(res.requestType), + .teleserviceType = static_cast(res.teleserviceType), + .serviceClass = res.serviceClass, + .result = toAidl(res.result), + .ssInfo = toAidl(res.ssInfo), + .cfData = toAidl(res.cfData), + }; +} + +aidl::SsInfoData toAidl(const V1_0::SsInfoData& info) { + return { + .ssInfo = info.ssInfo, + }; +} + +aidl::CfData toAidl(const V1_0::CfData& data) { + return { + .cfInfo = toAidl(data.cfInfo), + }; +} + +aidl::Call toAidl(const V1_0::Call& call) { + return toAidl(V1_2::Call{call, {}}); +} + +aidl::Call toAidl(const V1_2::Call& call) { + return toAidl(V1_6::Call{call, {}}); +} + +aidl::Call toAidl(const V1_6::Call& call) { + return { + .state = static_cast(call.base.base.state), + .index = call.base.base.index, + .toa = call.base.base.toa, + .isMpty = call.base.base.isMpty, + .isMT = call.base.base.isMT, + .als = static_cast(call.base.base.als), + .isVoice = call.base.base.isVoice, + .isVoicePrivacy = call.base.base.isVoicePrivacy, + .number = call.base.base.number, + .numberPresentation = static_cast(call.base.base.numberPresentation), + .name = call.base.base.name, + .namePresentation = static_cast(call.base.base.namePresentation), + .uusInfo = toAidl(call.base.base.uusInfo), + .audioQuality = aidl::AudioQuality(call.base.audioQuality), + .forwardedNumber = call.forwardedNumber, + }; +} + +aidl::UusInfo toAidl(const V1_0::UusInfo& info) { + return { + .uusType = static_cast(info.uusType), + .uusDcs = static_cast(info.uusDcs), + .uusData = info.uusData, + }; +} + +aidl::LastCallFailCauseInfo toAidl(const V1_0::LastCallFailCauseInfo& info) { + return { + .causeCode = aidl::LastCallFailCause(info.causeCode), + .vendorCause = info.vendorCause, + }; +} + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/libradiocompat/voice/structs.h b/radio/aidl/compat/libradiocompat/voice/structs.h new file mode 100644 index 0000000000..b55a089062 --- /dev/null +++ b/radio/aidl/compat/libradiocompat/voice/structs.h @@ -0,0 +1,91 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace android::hardware::radio::compat { + +V1_0::Dial toHidl(const ::aidl::android::hardware::radio::voice::Dial& info); + +V1_0::UusInfo toHidl(const ::aidl::android::hardware::radio::voice::UusInfo& info); + +::aidl::android::hardware::radio::voice::CallForwardInfo toAidl(const V1_0::CallForwardInfo& info); +V1_0::CallForwardInfo toHidl(const ::aidl::android::hardware::radio::voice::CallForwardInfo& info); + +::aidl::android::hardware::radio::voice::CdmaSignalInfoRecord // +toAidl(const V1_0::CdmaSignalInfoRecord& record); + +::aidl::android::hardware::radio::voice::CdmaCallWaiting toAidl(const V1_0::CdmaCallWaiting& call); + +::aidl::android::hardware::radio::voice::CdmaInformationRecord // +toAidl(const V1_0::CdmaInformationRecord& record); + +::aidl::android::hardware::radio::voice::CdmaDisplayInfoRecord // +toAidl(const V1_0::CdmaDisplayInfoRecord& record); + +::aidl::android::hardware::radio::voice::CdmaNumberInfoRecord // +toAidl(const V1_0::CdmaNumberInfoRecord& record); + +::aidl::android::hardware::radio::voice::CdmaRedirectingNumberInfoRecord // +toAidl(const V1_0::CdmaRedirectingNumberInfoRecord& record); + +::aidl::android::hardware::radio::voice::CdmaLineControlInfoRecord // +toAidl(const V1_0::CdmaLineControlInfoRecord& record); + +::aidl::android::hardware::radio::voice::CdmaT53ClirInfoRecord // +toAidl(const V1_0::CdmaT53ClirInfoRecord& record); + +::aidl::android::hardware::radio::voice::CdmaT53AudioControlInfoRecord // +toAidl(const V1_0::CdmaT53AudioControlInfoRecord& record); + +::aidl::android::hardware::radio::voice::EmergencyNumber toAidl(const V1_4::EmergencyNumber& num); + +::aidl::android::hardware::radio::voice::StkCcUnsolSsResult // +toAidl(const V1_0::StkCcUnsolSsResult& res); + +::aidl::android::hardware::radio::voice::SsInfoData toAidl(const V1_0::SsInfoData& info); + +::aidl::android::hardware::radio::voice::CfData toAidl(const V1_0::CfData& data); + +::aidl::android::hardware::radio::voice::Call toAidl(const V1_0::Call& call); +::aidl::android::hardware::radio::voice::Call toAidl(const V1_2::Call& call); +::aidl::android::hardware::radio::voice::Call toAidl(const V1_6::Call& call); + +::aidl::android::hardware::radio::voice::UusInfo toAidl(const V1_0::UusInfo& info); + +::aidl::android::hardware::radio::voice::LastCallFailCauseInfo // +toAidl(const V1_0::LastCallFailCauseInfo& info); + +} // namespace android::hardware::radio::compat diff --git a/radio/aidl/compat/service/Android.bp b/radio/aidl/compat/service/Android.bp index 3c543f744d..0536c1c1b3 100644 --- a/radio/aidl/compat/service/Android.bp +++ b/radio/aidl/compat/service/Android.bp @@ -43,6 +43,7 @@ cc_binary { "android.hardware.radio.messaging-V1-ndk", "android.hardware.radio.network-V1-ndk", "android.hardware.radio.sim-V1-ndk", + "android.hardware.radio.voice-V1-ndk", "android.hardware.radio@1.0", "android.hardware.radio@1.1", "android.hardware.radio@1.2", diff --git a/radio/aidl/compat/service/radio-compat.xml b/radio/aidl/compat/service/radio-compat.xml index e035cac793..d3f4212fcf 100644 --- a/radio/aidl/compat/service/radio-compat.xml +++ b/radio/aidl/compat/service/radio-compat.xml @@ -25,5 +25,9 @@ android.hardware.radio.sim IRadioSim/slot1 + + android.hardware.radio.voice + IRadioVoice/slot1 + --> diff --git a/radio/aidl/compat/service/service.cpp b/radio/aidl/compat/service/service.cpp index 82d234f8ba..3d60ffe129 100644 --- a/radio/aidl/compat/service/service.cpp +++ b/radio/aidl/compat/service/service.cpp @@ -26,6 +26,7 @@ #include #include #include +#include namespace android::hardware::radio::service { @@ -63,6 +64,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); } static void publishRadioConfig() { From dcbae487dd54666acb6469645de873a2a17e021b Mon Sep 17 00:00:00 2001 From: Tomasz Wasilczyk Date: Mon, 8 Nov 2021 16:10:28 -0800 Subject: [PATCH 7/7] 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);