Tomasz Wasilczyk | bff3b5b | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include <libradiocompat/RadioConfig.h> |
| 18 | |
Tomasz Wasilczyk | bff3b5b | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 19 | #include "commonStructs.h" |
| 20 | #include "debug.h" |
| 21 | #include "structs.h" |
| 22 | |
Tomasz Wasilczyk | e807d37 | 2022-01-05 13:15:39 -0800 | [diff] [blame] | 23 | #include "collections.h" |
| 24 | |
Tomasz Wasilczyk | bff3b5b | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 25 | #define RADIO_MODULE "Config" |
| 26 | |
| 27 | namespace android::hardware::radio::compat { |
| 28 | |
| 29 | using ::ndk::ScopedAStatus; |
| 30 | namespace aidl = ::aidl::android::hardware::radio::config; |
| 31 | constexpr auto ok = &ScopedAStatus::ok; |
| 32 | |
| 33 | RadioConfig::RadioConfig(sp<config::V1_1::IRadioConfig> hidlHal) |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 34 | : mHal1_1(hidlHal), |
| 35 | mHal1_3(config::V1_3::IRadioConfig::castFrom(hidlHal)), |
| 36 | mRadioConfigResponse(sp<RadioConfigResponse>::make()), |
| 37 | mRadioConfigIndication(sp<RadioConfigIndication>::make()) {} |
Tomasz Wasilczyk | bff3b5b | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 38 | |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 39 | std::shared_ptr<aidl::IRadioConfigResponse> RadioConfig::respond() { |
| 40 | return mRadioConfigResponse->respond(); |
Tomasz Wasilczyk | bff3b5b | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | ScopedAStatus RadioConfig::getHalDeviceCapabilities(int32_t serial) { |
| 44 | LOG_CALL << serial; |
| 45 | if (mHal1_3) { |
| 46 | mHal1_3->getHalDeviceCapabilities(serial); |
| 47 | } else { |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 48 | respond()->getHalDeviceCapabilitiesResponse(notSupported(serial), false); |
Tomasz Wasilczyk | bff3b5b | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 49 | } |
| 50 | return ok(); |
| 51 | } |
| 52 | |
| 53 | ScopedAStatus RadioConfig::getNumOfLiveModems(int32_t serial) { |
| 54 | LOG_CALL << serial; |
| 55 | mHal1_1->getModemsConfig(serial); |
| 56 | return ok(); |
| 57 | } |
| 58 | |
| 59 | ScopedAStatus RadioConfig::getPhoneCapability(int32_t serial) { |
| 60 | LOG_CALL << serial; |
| 61 | mHal1_1->getPhoneCapability(serial); |
| 62 | return ok(); |
| 63 | } |
| 64 | |
Grant Menke | 37cc14d | 2023-11-29 19:28:28 -0800 | [diff] [blame] | 65 | ScopedAStatus RadioConfig::getSimultaneousCallingSupport(int32_t serial) { |
| 66 | LOG_CALL << serial; |
| 67 | LOG(ERROR) << " getSimultaneousCallingSupport is unsupported by HIDL HALs"; |
| 68 | respond()->getSimultaneousCallingSupportResponse(notSupported(serial), {}); |
| 69 | return ok(); |
| 70 | } |
| 71 | |
Tomasz Wasilczyk | bff3b5b | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 72 | ScopedAStatus RadioConfig::getSimSlotsStatus(int32_t serial) { |
| 73 | LOG_CALL << serial; |
| 74 | mHal1_1->getSimSlotsStatus(serial); |
| 75 | return ok(); |
| 76 | } |
| 77 | |
| 78 | ScopedAStatus RadioConfig::setNumOfLiveModems(int32_t serial, int8_t numOfLiveModems) { |
| 79 | LOG_CALL << serial; |
| 80 | mHal1_1->setModemsConfig(serial, {static_cast<uint8_t>(numOfLiveModems)}); |
| 81 | return ok(); |
| 82 | } |
| 83 | |
| 84 | ScopedAStatus RadioConfig::setPreferredDataModem(int32_t serial, int8_t modemId) { |
| 85 | LOG_CALL << serial; |
| 86 | mHal1_1->setPreferredDataModem(serial, modemId); |
| 87 | return ok(); |
| 88 | } |
| 89 | |
| 90 | ScopedAStatus RadioConfig::setResponseFunctions( |
| 91 | const std::shared_ptr<aidl::IRadioConfigResponse>& radioConfigResponse, |
| 92 | const std::shared_ptr<aidl::IRadioConfigIndication>& radioConfigIndication) { |
| 93 | LOG_CALL << radioConfigResponse << ' ' << radioConfigIndication; |
| 94 | |
| 95 | CHECK(radioConfigResponse); |
| 96 | CHECK(radioConfigIndication); |
| 97 | |
Tomasz Wasilczyk | 6063857 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 98 | mRadioConfigResponse->setResponseFunction(radioConfigResponse); |
| 99 | mRadioConfigIndication->setResponseFunction(radioConfigIndication); |
Tomasz Wasilczyk | 963a56f | 2021-12-16 12:19:09 -0800 | [diff] [blame] | 100 | mHal1_1->setResponseFunctions(mRadioConfigResponse, mRadioConfigIndication).assertOk(); |
Tomasz Wasilczyk | bff3b5b | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 101 | |
| 102 | return ok(); |
| 103 | } |
| 104 | |
| 105 | ScopedAStatus RadioConfig::setSimSlotsMapping( // |
| 106 | int32_t serial, const std::vector<aidl::SlotPortMapping>& slotMap) { |
| 107 | LOG_CALL << serial; |
| 108 | mHal1_1->setSimSlotsMapping(serial, toHidl(slotMap)); |
| 109 | return ok(); |
| 110 | } |
| 111 | |
| 112 | } // namespace android::hardware::radio::compat |