Tomasz Wasilczyk | 535f30c | 2021-11-08 16:10:28 -0800 | [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/RadioModem.h> |
| 18 | |
| 19 | #include "debug.h" |
| 20 | #include "structs.h" |
| 21 | |
| 22 | #define RADIO_MODULE "Modem" |
| 23 | |
| 24 | namespace android::hardware::radio::compat { |
| 25 | |
| 26 | using ::ndk::ScopedAStatus; |
| 27 | namespace aidl = ::aidl::android::hardware::radio::modem; |
| 28 | constexpr auto ok = &ScopedAStatus::ok; |
| 29 | |
| 30 | ScopedAStatus RadioModem::enableModem(int32_t serial, bool on) { |
| 31 | LOG_CALL << serial; |
| 32 | mHal1_5->enableModem(serial, on); |
| 33 | return ok(); |
| 34 | } |
| 35 | |
| 36 | ScopedAStatus RadioModem::getBasebandVersion(int32_t serial) { |
| 37 | LOG_CALL << serial; |
| 38 | mHal1_5->getBasebandVersion(serial); |
| 39 | return ok(); |
| 40 | } |
| 41 | |
| 42 | ScopedAStatus RadioModem::getDeviceIdentity(int32_t serial) { |
| 43 | LOG_CALL << serial; |
| 44 | mHal1_5->getDeviceIdentity(serial); |
| 45 | return ok(); |
| 46 | } |
| 47 | |
| 48 | ScopedAStatus RadioModem::getHardwareConfig(int32_t serial) { |
| 49 | LOG_CALL << serial; |
| 50 | mHal1_5->getHardwareConfig(serial); |
| 51 | return ok(); |
| 52 | } |
| 53 | |
| 54 | ScopedAStatus RadioModem::getModemActivityInfo(int32_t serial) { |
| 55 | LOG_CALL << serial; |
| 56 | mHal1_5->getModemActivityInfo(serial); |
| 57 | return ok(); |
| 58 | } |
| 59 | |
| 60 | ScopedAStatus RadioModem::getModemStackStatus(int32_t serial) { |
| 61 | LOG_CALL << serial; |
| 62 | mHal1_5->getModemStackStatus(serial); |
| 63 | return ok(); |
| 64 | } |
| 65 | |
| 66 | ScopedAStatus RadioModem::getRadioCapability(int32_t serial) { |
| 67 | LOG_CALL << serial; |
| 68 | mHal1_5->getRadioCapability(serial); |
| 69 | return ok(); |
| 70 | } |
| 71 | |
| 72 | ScopedAStatus RadioModem::nvReadItem(int32_t serial, aidl::NvItem itemId) { |
| 73 | LOG_CALL << serial; |
| 74 | mHal1_5->nvReadItem(serial, V1_0::NvItem(itemId)); |
| 75 | return ok(); |
| 76 | } |
| 77 | |
| 78 | ScopedAStatus RadioModem::nvResetConfig(int32_t serial, aidl::ResetNvType resetType) { |
| 79 | LOG_CALL << serial; |
| 80 | mHal1_5->nvResetConfig(serial, V1_0::ResetNvType(resetType)); |
| 81 | return ok(); |
| 82 | } |
| 83 | |
| 84 | ScopedAStatus RadioModem::nvWriteCdmaPrl(int32_t serial, const std::vector<uint8_t>& prl) { |
| 85 | LOG_CALL << serial; |
| 86 | mHal1_5->nvWriteCdmaPrl(serial, prl); |
| 87 | return ok(); |
| 88 | } |
| 89 | |
| 90 | ScopedAStatus RadioModem::nvWriteItem(int32_t serial, const aidl::NvWriteItem& item) { |
| 91 | LOG_CALL << serial; |
| 92 | mHal1_5->nvWriteItem(serial, toHidl(item)); |
| 93 | return ok(); |
| 94 | } |
| 95 | |
| 96 | ScopedAStatus RadioModem::requestShutdown(int32_t serial) { |
| 97 | LOG_CALL << serial; |
| 98 | mHal1_5->requestShutdown(serial); |
| 99 | return ok(); |
| 100 | } |
| 101 | |
| 102 | ScopedAStatus RadioModem::responseAcknowledgement() { |
| 103 | LOG_CALL; |
| 104 | mHal1_5->responseAcknowledgement(); |
| 105 | return ok(); |
| 106 | } |
| 107 | |
| 108 | ScopedAStatus RadioModem::sendDeviceState(int32_t serial, aidl::DeviceStateType type, bool state) { |
| 109 | LOG_CALL << serial; |
| 110 | mHal1_5->sendDeviceState(serial, V1_0::DeviceStateType(type), state); |
| 111 | return ok(); |
| 112 | } |
| 113 | |
| 114 | ScopedAStatus RadioModem::setRadioCapability(int32_t serial, const aidl::RadioCapability& rc) { |
| 115 | LOG_CALL << serial; |
| 116 | mHal1_5->setRadioCapability(serial, toHidl(rc)); |
| 117 | return ok(); |
| 118 | } |
| 119 | |
| 120 | ScopedAStatus RadioModem::setRadioPower(int32_t serial, bool powerOn, bool forEmergencyCall, |
| 121 | bool preferredForEmergencyCall) { |
| 122 | LOG_CALL << serial; |
| 123 | if (mHal1_6) { |
| 124 | mHal1_6->setRadioPower_1_6(serial, powerOn, forEmergencyCall, preferredForEmergencyCall); |
| 125 | } else { |
| 126 | mHal1_5->setRadioPower_1_5(serial, powerOn, forEmergencyCall, preferredForEmergencyCall); |
| 127 | } |
| 128 | return ok(); |
| 129 | } |
| 130 | |
| 131 | ScopedAStatus RadioModem::setResponseFunctions( |
| 132 | const std::shared_ptr<aidl::IRadioModemResponse>& modemResponse, |
| 133 | const std::shared_ptr<aidl::IRadioModemIndication>& modemIndication) { |
| 134 | LOG_CALL << modemResponse << ' ' << modemIndication; |
| 135 | |
| 136 | CHECK(modemResponse); |
| 137 | CHECK(modemIndication); |
| 138 | |
| 139 | mRadioResponse->setResponseFunction(modemResponse); |
| 140 | mRadioIndication->setResponseFunction(modemIndication); |
| 141 | |
| 142 | return ok(); |
| 143 | } |
| 144 | |
| 145 | } // namespace android::hardware::radio::compat |