Tomasz Wasilczyk | 6301e8f | 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 | 6301e8f | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 19 | #include "commonStructs.h" |
| 20 | #include "debug.h" |
| 21 | #include "structs.h" |
| 22 | |
| 23 | #define RADIO_MODULE "Config" |
| 24 | |
| 25 | namespace android::hardware::radio::compat { |
| 26 | |
| 27 | using ::ndk::ScopedAStatus; |
| 28 | namespace aidl = ::aidl::android::hardware::radio::config; |
| 29 | constexpr auto ok = &ScopedAStatus::ok; |
| 30 | |
| 31 | RadioConfig::RadioConfig(sp<config::V1_1::IRadioConfig> hidlHal) |
Tomasz Wasilczyk | 6902a75 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 32 | : mHal1_1(hidlHal), |
| 33 | mHal1_3(config::V1_3::IRadioConfig::castFrom(hidlHal)), |
| 34 | mRadioConfigResponse(sp<RadioConfigResponse>::make()), |
| 35 | mRadioConfigIndication(sp<RadioConfigIndication>::make()) {} |
Tomasz Wasilczyk | 6301e8f | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 36 | |
Tomasz Wasilczyk | 6902a75 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 37 | std::shared_ptr<aidl::IRadioConfigResponse> RadioConfig::respond() { |
| 38 | return mRadioConfigResponse->respond(); |
Tomasz Wasilczyk | 6301e8f | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | ScopedAStatus RadioConfig::getHalDeviceCapabilities(int32_t serial) { |
| 42 | LOG_CALL << serial; |
| 43 | if (mHal1_3) { |
| 44 | mHal1_3->getHalDeviceCapabilities(serial); |
| 45 | } else { |
Tomasz Wasilczyk | 6902a75 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 46 | respond()->getHalDeviceCapabilitiesResponse(notSupported(serial), false); |
Tomasz Wasilczyk | 6301e8f | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 47 | } |
| 48 | return ok(); |
| 49 | } |
| 50 | |
| 51 | ScopedAStatus RadioConfig::getNumOfLiveModems(int32_t serial) { |
| 52 | LOG_CALL << serial; |
| 53 | mHal1_1->getModemsConfig(serial); |
| 54 | return ok(); |
| 55 | } |
| 56 | |
| 57 | ScopedAStatus RadioConfig::getPhoneCapability(int32_t serial) { |
| 58 | LOG_CALL << serial; |
| 59 | mHal1_1->getPhoneCapability(serial); |
| 60 | return ok(); |
| 61 | } |
| 62 | |
| 63 | ScopedAStatus RadioConfig::getSimSlotsStatus(int32_t serial) { |
| 64 | LOG_CALL << serial; |
| 65 | mHal1_1->getSimSlotsStatus(serial); |
| 66 | return ok(); |
| 67 | } |
| 68 | |
| 69 | ScopedAStatus RadioConfig::setNumOfLiveModems(int32_t serial, int8_t numOfLiveModems) { |
| 70 | LOG_CALL << serial; |
| 71 | mHal1_1->setModemsConfig(serial, {static_cast<uint8_t>(numOfLiveModems)}); |
| 72 | return ok(); |
| 73 | } |
| 74 | |
| 75 | ScopedAStatus RadioConfig::setPreferredDataModem(int32_t serial, int8_t modemId) { |
| 76 | LOG_CALL << serial; |
| 77 | mHal1_1->setPreferredDataModem(serial, modemId); |
| 78 | return ok(); |
| 79 | } |
| 80 | |
| 81 | ScopedAStatus RadioConfig::setResponseFunctions( |
| 82 | const std::shared_ptr<aidl::IRadioConfigResponse>& radioConfigResponse, |
| 83 | const std::shared_ptr<aidl::IRadioConfigIndication>& radioConfigIndication) { |
| 84 | LOG_CALL << radioConfigResponse << ' ' << radioConfigIndication; |
| 85 | |
| 86 | CHECK(radioConfigResponse); |
| 87 | CHECK(radioConfigIndication); |
| 88 | |
Tomasz Wasilczyk | 6902a75 | 2021-12-13 17:13:48 -0800 | [diff] [blame] | 89 | mRadioConfigResponse->setResponseFunction(radioConfigResponse); |
| 90 | mRadioConfigIndication->setResponseFunction(radioConfigIndication); |
Tomasz Wasilczyk | 8579f1d | 2021-12-16 12:19:09 -0800 | [diff] [blame] | 91 | mHal1_1->setResponseFunctions(mRadioConfigResponse, mRadioConfigIndication).assertOk(); |
Tomasz Wasilczyk | 6301e8f | 2021-10-18 16:53:40 -0700 | [diff] [blame] | 92 | |
| 93 | return ok(); |
| 94 | } |
| 95 | |
| 96 | ScopedAStatus RadioConfig::setSimSlotsMapping( // |
| 97 | int32_t serial, const std::vector<aidl::SlotPortMapping>& slotMap) { |
| 98 | LOG_CALL << serial; |
| 99 | mHal1_1->setSimSlotsMapping(serial, toHidl(slotMap)); |
| 100 | return ok(); |
| 101 | } |
| 102 | |
| 103 | } // namespace android::hardware::radio::compat |