Tomasz Wasilczyk | 1f16d3a | 2021-10-25 20:20:49 -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/RadioMessaging.h> |
| 18 | |
| 19 | #include "debug.h" |
| 20 | #include "structs.h" |
| 21 | |
| 22 | #include "collections.h" |
| 23 | |
| 24 | #define RADIO_MODULE "Messaging" |
| 25 | |
| 26 | namespace android::hardware::radio::compat { |
| 27 | |
| 28 | using ::ndk::ScopedAStatus; |
| 29 | namespace aidl = ::aidl::android::hardware::radio::messaging; |
| 30 | constexpr auto ok = &ScopedAStatus::ok; |
| 31 | |
| 32 | ScopedAStatus RadioMessaging::acknowledgeIncomingGsmSmsWithPdu( // |
| 33 | int32_t serial, bool success, const std::string& ackPdu) { |
| 34 | LOG_CALL << serial << ' ' << success << ' ' << ackPdu; |
| 35 | mHal1_5->acknowledgeIncomingGsmSmsWithPdu(serial, success, ackPdu); |
| 36 | return ok(); |
| 37 | } |
| 38 | |
| 39 | ScopedAStatus RadioMessaging::acknowledgeLastIncomingCdmaSms( // |
| 40 | int32_t serial, const aidl::CdmaSmsAck& smsAck) { |
| 41 | LOG_CALL << serial; |
| 42 | mHal1_5->acknowledgeLastIncomingCdmaSms(serial, toHidl(smsAck)); |
| 43 | return ok(); |
| 44 | } |
| 45 | |
| 46 | ScopedAStatus RadioMessaging::acknowledgeLastIncomingGsmSms( // |
| 47 | int32_t serial, bool success, aidl::SmsAcknowledgeFailCause cause) { |
| 48 | LOG_CALL << serial << ' ' << success; |
| 49 | mHal1_5->acknowledgeLastIncomingGsmSms(serial, success, V1_0::SmsAcknowledgeFailCause(cause)); |
| 50 | return ok(); |
| 51 | } |
| 52 | |
| 53 | ScopedAStatus RadioMessaging::cancelPendingUssd(int32_t serial) { |
| 54 | LOG_CALL << serial; |
| 55 | mHal1_5->cancelPendingUssd(serial); |
| 56 | return ok(); |
| 57 | } |
| 58 | |
| 59 | ScopedAStatus RadioMessaging::deleteSmsOnRuim(int32_t serial, int32_t index) { |
| 60 | LOG_CALL << serial << ' ' << index; |
| 61 | mHal1_5->deleteSmsOnRuim(serial, index); |
| 62 | return ok(); |
| 63 | } |
| 64 | |
| 65 | ScopedAStatus RadioMessaging::deleteSmsOnSim(int32_t serial, int32_t index) { |
| 66 | LOG_CALL << serial << ' ' << index; |
| 67 | mHal1_5->deleteSmsOnSim(serial, index); |
| 68 | return ok(); |
| 69 | } |
| 70 | |
| 71 | ScopedAStatus RadioMessaging::getCdmaBroadcastConfig(int32_t serial) { |
| 72 | LOG_CALL << serial; |
| 73 | mHal1_5->getCdmaBroadcastConfig(serial); |
| 74 | return ok(); |
| 75 | } |
| 76 | |
| 77 | ScopedAStatus RadioMessaging::getGsmBroadcastConfig(int32_t serial) { |
| 78 | LOG_CALL << serial; |
| 79 | mHal1_5->getGsmBroadcastConfig(serial); |
| 80 | return ok(); |
| 81 | } |
| 82 | |
| 83 | ScopedAStatus RadioMessaging::getSmscAddress(int32_t serial) { |
| 84 | LOG_CALL << serial; |
| 85 | mHal1_5->getSmscAddress(serial); |
| 86 | return ok(); |
| 87 | } |
| 88 | |
| 89 | ScopedAStatus RadioMessaging::reportSmsMemoryStatus(int32_t serial, bool available) { |
| 90 | LOG_CALL << serial << ' ' << available; |
| 91 | mHal1_5->reportSmsMemoryStatus(serial, available); |
| 92 | return ok(); |
| 93 | } |
| 94 | |
| 95 | ScopedAStatus RadioMessaging::responseAcknowledgement() { |
| 96 | LOG_CALL; |
| 97 | mHal1_5->responseAcknowledgement(); |
| 98 | return ok(); |
| 99 | } |
| 100 | |
| 101 | ScopedAStatus RadioMessaging::sendCdmaSms(int32_t serial, const aidl::CdmaSmsMessage& sms) { |
| 102 | LOG_CALL << serial; |
| 103 | mHal1_5->sendCdmaSms(serial, toHidl(sms)); |
| 104 | return ok(); |
| 105 | } |
| 106 | |
| 107 | ScopedAStatus RadioMessaging::sendCdmaSmsExpectMore(int32_t serial, const aidl::CdmaSmsMessage& m) { |
| 108 | LOG_CALL << serial; |
| 109 | mHal1_5->sendCdmaSmsExpectMore(serial, toHidl(m)); |
| 110 | return ok(); |
| 111 | } |
| 112 | |
| 113 | ScopedAStatus RadioMessaging::sendImsSms(int32_t serial, const aidl::ImsSmsMessage& message) { |
| 114 | LOG_CALL << serial; |
| 115 | mHal1_5->sendImsSms(serial, toHidl(message)); |
| 116 | return ok(); |
| 117 | } |
| 118 | |
| 119 | ScopedAStatus RadioMessaging::sendSms(int32_t serial, const aidl::GsmSmsMessage& message) { |
| 120 | LOG_CALL << serial; |
| 121 | mHal1_5->sendSms(serial, toHidl(message)); |
| 122 | return ok(); |
| 123 | } |
| 124 | |
| 125 | ScopedAStatus RadioMessaging::sendSmsExpectMore(int32_t serial, const aidl::GsmSmsMessage& msg) { |
| 126 | LOG_CALL << serial; |
| 127 | mHal1_5->sendSMSExpectMore(serial, toHidl(msg)); |
| 128 | return ok(); |
| 129 | } |
| 130 | |
| 131 | ScopedAStatus RadioMessaging::sendUssd(int32_t serial, const std::string& ussd) { |
| 132 | LOG_CALL << serial << ' ' << ussd; |
| 133 | mHal1_5->sendUssd(serial, ussd); |
| 134 | return ok(); |
| 135 | } |
| 136 | |
| 137 | ScopedAStatus RadioMessaging::setCdmaBroadcastActivation(int32_t serial, bool activate) { |
| 138 | LOG_CALL << serial << ' ' << activate; |
| 139 | mHal1_5->setCdmaBroadcastActivation(serial, activate); |
| 140 | return ok(); |
| 141 | } |
| 142 | |
| 143 | ScopedAStatus RadioMessaging::setCdmaBroadcastConfig( |
| 144 | int32_t serial, const std::vector<aidl::CdmaBroadcastSmsConfigInfo>& cfgInfo) { |
| 145 | LOG_CALL << serial; |
| 146 | mHal1_5->setCdmaBroadcastConfig(serial, toHidl(cfgInfo)); |
| 147 | return ok(); |
| 148 | } |
| 149 | |
| 150 | ScopedAStatus RadioMessaging::setGsmBroadcastActivation(int32_t serial, bool activate) { |
| 151 | LOG_CALL << serial << ' ' << activate; |
| 152 | mHal1_5->setGsmBroadcastActivation(serial, activate); |
| 153 | return ok(); |
| 154 | } |
| 155 | |
| 156 | ScopedAStatus RadioMessaging::setGsmBroadcastConfig( |
| 157 | int32_t serial, const std::vector<aidl::GsmBroadcastSmsConfigInfo>& configInfo) { |
| 158 | LOG_CALL << serial; |
| 159 | mHal1_5->setGsmBroadcastConfig(serial, toHidl(configInfo)); |
| 160 | return ok(); |
| 161 | } |
| 162 | |
| 163 | ScopedAStatus RadioMessaging::setResponseFunctions( |
| 164 | const std::shared_ptr<aidl::IRadioMessagingResponse>& messagingResponse, |
| 165 | const std::shared_ptr<aidl::IRadioMessagingIndication>& messagingIndication) { |
| 166 | LOG_CALL << messagingResponse << ' ' << messagingIndication; |
| 167 | |
| 168 | CHECK(messagingResponse); |
| 169 | CHECK(messagingIndication); |
| 170 | |
| 171 | mRadioResponse->setResponseFunction(messagingResponse); |
| 172 | mRadioIndication->setResponseFunction(messagingIndication); |
| 173 | |
| 174 | return ok(); |
| 175 | } |
| 176 | |
| 177 | ScopedAStatus RadioMessaging::setSmscAddress(int32_t serial, const std::string& smsc) { |
| 178 | LOG_CALL << serial << ' ' << smsc; |
| 179 | mHal1_5->setSmscAddress(serial, smsc); |
| 180 | return ok(); |
| 181 | } |
| 182 | |
| 183 | ScopedAStatus RadioMessaging::writeSmsToRuim(int32_t serial, const aidl::CdmaSmsWriteArgs& sms) { |
| 184 | LOG_CALL << serial; |
| 185 | mHal1_5->writeSmsToRuim(serial, toHidl(sms)); |
| 186 | return ok(); |
| 187 | } |
| 188 | |
| 189 | ScopedAStatus RadioMessaging::writeSmsToSim(int32_t serial, const aidl::SmsWriteArgs& smsWrArgs) { |
| 190 | LOG_CALL << serial; |
| 191 | mHal1_5->writeSmsToSim(serial, toHidl(smsWrArgs)); |
| 192 | return ok(); |
| 193 | } |
| 194 | |
| 195 | } // namespace android::hardware::radio::compat |