blob: 650d1910ffd81952e589750865651b6080dde610 [file] [log] [blame]
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -07001/*
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
26namespace android::hardware::radio::compat {
27
28using ::ndk::ScopedAStatus;
29namespace aidl = ::aidl::android::hardware::radio::messaging;
30constexpr auto ok = &ScopedAStatus::ok;
31
Tomasz Wasilczyk6902a752021-12-13 17:13:48 -080032std::shared_ptr<aidl::IRadioMessagingResponse> RadioMessaging::respond() {
33 return mRadioResponse->messagingCb();
34}
35
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -070036ScopedAStatus RadioMessaging::acknowledgeIncomingGsmSmsWithPdu( //
37 int32_t serial, bool success, const std::string& ackPdu) {
38 LOG_CALL << serial << ' ' << success << ' ' << ackPdu;
39 mHal1_5->acknowledgeIncomingGsmSmsWithPdu(serial, success, ackPdu);
40 return ok();
41}
42
43ScopedAStatus RadioMessaging::acknowledgeLastIncomingCdmaSms( //
44 int32_t serial, const aidl::CdmaSmsAck& smsAck) {
45 LOG_CALL << serial;
46 mHal1_5->acknowledgeLastIncomingCdmaSms(serial, toHidl(smsAck));
47 return ok();
48}
49
50ScopedAStatus RadioMessaging::acknowledgeLastIncomingGsmSms( //
51 int32_t serial, bool success, aidl::SmsAcknowledgeFailCause cause) {
52 LOG_CALL << serial << ' ' << success;
53 mHal1_5->acknowledgeLastIncomingGsmSms(serial, success, V1_0::SmsAcknowledgeFailCause(cause));
54 return ok();
55}
56
57ScopedAStatus RadioMessaging::cancelPendingUssd(int32_t serial) {
58 LOG_CALL << serial;
59 mHal1_5->cancelPendingUssd(serial);
60 return ok();
61}
62
63ScopedAStatus RadioMessaging::deleteSmsOnRuim(int32_t serial, int32_t index) {
64 LOG_CALL << serial << ' ' << index;
65 mHal1_5->deleteSmsOnRuim(serial, index);
66 return ok();
67}
68
69ScopedAStatus RadioMessaging::deleteSmsOnSim(int32_t serial, int32_t index) {
70 LOG_CALL << serial << ' ' << index;
71 mHal1_5->deleteSmsOnSim(serial, index);
72 return ok();
73}
74
75ScopedAStatus RadioMessaging::getCdmaBroadcastConfig(int32_t serial) {
76 LOG_CALL << serial;
77 mHal1_5->getCdmaBroadcastConfig(serial);
78 return ok();
79}
80
81ScopedAStatus RadioMessaging::getGsmBroadcastConfig(int32_t serial) {
82 LOG_CALL << serial;
83 mHal1_5->getGsmBroadcastConfig(serial);
84 return ok();
85}
86
87ScopedAStatus RadioMessaging::getSmscAddress(int32_t serial) {
88 LOG_CALL << serial;
89 mHal1_5->getSmscAddress(serial);
90 return ok();
91}
92
93ScopedAStatus RadioMessaging::reportSmsMemoryStatus(int32_t serial, bool available) {
94 LOG_CALL << serial << ' ' << available;
95 mHal1_5->reportSmsMemoryStatus(serial, available);
96 return ok();
97}
98
99ScopedAStatus RadioMessaging::responseAcknowledgement() {
100 LOG_CALL;
101 mHal1_5->responseAcknowledgement();
102 return ok();
103}
104
105ScopedAStatus RadioMessaging::sendCdmaSms(int32_t serial, const aidl::CdmaSmsMessage& sms) {
106 LOG_CALL << serial;
Tomasz Wasilczyk31f6fab2021-12-15 16:15:45 -0800107 if (mHal1_6) {
108 mHal1_6->sendCdmaSms_1_6(serial, toHidl(sms));
109 } else {
110 mHal1_5->sendCdmaSms(serial, toHidl(sms));
111 }
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -0700112 return ok();
113}
114
115ScopedAStatus RadioMessaging::sendCdmaSmsExpectMore(int32_t serial, const aidl::CdmaSmsMessage& m) {
116 LOG_CALL << serial;
Tomasz Wasilczyk31f6fab2021-12-15 16:15:45 -0800117 if (mHal1_6) {
118 mHal1_6->sendCdmaSmsExpectMore_1_6(serial, toHidl(m));
119 } else {
120 mHal1_5->sendCdmaSmsExpectMore(serial, toHidl(m));
121 }
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -0700122 return ok();
123}
124
125ScopedAStatus RadioMessaging::sendImsSms(int32_t serial, const aidl::ImsSmsMessage& message) {
126 LOG_CALL << serial;
127 mHal1_5->sendImsSms(serial, toHidl(message));
128 return ok();
129}
130
131ScopedAStatus RadioMessaging::sendSms(int32_t serial, const aidl::GsmSmsMessage& message) {
132 LOG_CALL << serial;
Tomasz Wasilczyk31f6fab2021-12-15 16:15:45 -0800133 if (mHal1_6) {
134 mHal1_6->sendSms_1_6(serial, toHidl(message));
135 } else {
136 mHal1_5->sendSms(serial, toHidl(message));
137 }
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -0700138 return ok();
139}
140
141ScopedAStatus RadioMessaging::sendSmsExpectMore(int32_t serial, const aidl::GsmSmsMessage& msg) {
142 LOG_CALL << serial;
Tomasz Wasilczyk31f6fab2021-12-15 16:15:45 -0800143 if (mHal1_6) {
144 mHal1_6->sendSmsExpectMore_1_6(serial, toHidl(msg));
145 } else {
146 mHal1_5->sendSMSExpectMore(serial, toHidl(msg));
147 }
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -0700148 return ok();
149}
150
151ScopedAStatus RadioMessaging::sendUssd(int32_t serial, const std::string& ussd) {
152 LOG_CALL << serial << ' ' << ussd;
153 mHal1_5->sendUssd(serial, ussd);
154 return ok();
155}
156
157ScopedAStatus RadioMessaging::setCdmaBroadcastActivation(int32_t serial, bool activate) {
158 LOG_CALL << serial << ' ' << activate;
159 mHal1_5->setCdmaBroadcastActivation(serial, activate);
160 return ok();
161}
162
163ScopedAStatus RadioMessaging::setCdmaBroadcastConfig(
164 int32_t serial, const std::vector<aidl::CdmaBroadcastSmsConfigInfo>& cfgInfo) {
165 LOG_CALL << serial;
166 mHal1_5->setCdmaBroadcastConfig(serial, toHidl(cfgInfo));
167 return ok();
168}
169
170ScopedAStatus RadioMessaging::setGsmBroadcastActivation(int32_t serial, bool activate) {
171 LOG_CALL << serial << ' ' << activate;
172 mHal1_5->setGsmBroadcastActivation(serial, activate);
173 return ok();
174}
175
176ScopedAStatus RadioMessaging::setGsmBroadcastConfig(
177 int32_t serial, const std::vector<aidl::GsmBroadcastSmsConfigInfo>& configInfo) {
178 LOG_CALL << serial;
179 mHal1_5->setGsmBroadcastConfig(serial, toHidl(configInfo));
180 return ok();
181}
182
183ScopedAStatus RadioMessaging::setResponseFunctions(
184 const std::shared_ptr<aidl::IRadioMessagingResponse>& messagingResponse,
185 const std::shared_ptr<aidl::IRadioMessagingIndication>& messagingIndication) {
186 LOG_CALL << messagingResponse << ' ' << messagingIndication;
187
188 CHECK(messagingResponse);
189 CHECK(messagingIndication);
190
191 mRadioResponse->setResponseFunction(messagingResponse);
192 mRadioIndication->setResponseFunction(messagingIndication);
193
194 return ok();
195}
196
197ScopedAStatus RadioMessaging::setSmscAddress(int32_t serial, const std::string& smsc) {
198 LOG_CALL << serial << ' ' << smsc;
199 mHal1_5->setSmscAddress(serial, smsc);
200 return ok();
201}
202
203ScopedAStatus RadioMessaging::writeSmsToRuim(int32_t serial, const aidl::CdmaSmsWriteArgs& sms) {
204 LOG_CALL << serial;
205 mHal1_5->writeSmsToRuim(serial, toHidl(sms));
206 return ok();
207}
208
209ScopedAStatus RadioMessaging::writeSmsToSim(int32_t serial, const aidl::SmsWriteArgs& smsWrArgs) {
210 LOG_CALL << serial;
211 mHal1_5->writeSmsToSim(serial, toHidl(smsWrArgs));
212 return ok();
213}
214
215} // namespace android::hardware::radio::compat