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