blob: 79e7c0144188b232807c75f0b16b49e5f56810ae [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;
107 mHal1_5->sendCdmaSms(serial, toHidl(sms));
108 return ok();
109}
110
111ScopedAStatus RadioMessaging::sendCdmaSmsExpectMore(int32_t serial, const aidl::CdmaSmsMessage& m) {
112 LOG_CALL << serial;
113 mHal1_5->sendCdmaSmsExpectMore(serial, toHidl(m));
114 return ok();
115}
116
117ScopedAStatus RadioMessaging::sendImsSms(int32_t serial, const aidl::ImsSmsMessage& message) {
118 LOG_CALL << serial;
119 mHal1_5->sendImsSms(serial, toHidl(message));
120 return ok();
121}
122
123ScopedAStatus RadioMessaging::sendSms(int32_t serial, const aidl::GsmSmsMessage& message) {
124 LOG_CALL << serial;
125 mHal1_5->sendSms(serial, toHidl(message));
126 return ok();
127}
128
129ScopedAStatus RadioMessaging::sendSmsExpectMore(int32_t serial, const aidl::GsmSmsMessage& msg) {
130 LOG_CALL << serial;
131 mHal1_5->sendSMSExpectMore(serial, toHidl(msg));
132 return ok();
133}
134
135ScopedAStatus RadioMessaging::sendUssd(int32_t serial, const std::string& ussd) {
136 LOG_CALL << serial << ' ' << ussd;
137 mHal1_5->sendUssd(serial, ussd);
138 return ok();
139}
140
141ScopedAStatus RadioMessaging::setCdmaBroadcastActivation(int32_t serial, bool activate) {
142 LOG_CALL << serial << ' ' << activate;
143 mHal1_5->setCdmaBroadcastActivation(serial, activate);
144 return ok();
145}
146
147ScopedAStatus RadioMessaging::setCdmaBroadcastConfig(
148 int32_t serial, const std::vector<aidl::CdmaBroadcastSmsConfigInfo>& cfgInfo) {
149 LOG_CALL << serial;
150 mHal1_5->setCdmaBroadcastConfig(serial, toHidl(cfgInfo));
151 return ok();
152}
153
154ScopedAStatus RadioMessaging::setGsmBroadcastActivation(int32_t serial, bool activate) {
155 LOG_CALL << serial << ' ' << activate;
156 mHal1_5->setGsmBroadcastActivation(serial, activate);
157 return ok();
158}
159
160ScopedAStatus RadioMessaging::setGsmBroadcastConfig(
161 int32_t serial, const std::vector<aidl::GsmBroadcastSmsConfigInfo>& configInfo) {
162 LOG_CALL << serial;
163 mHal1_5->setGsmBroadcastConfig(serial, toHidl(configInfo));
164 return ok();
165}
166
167ScopedAStatus RadioMessaging::setResponseFunctions(
168 const std::shared_ptr<aidl::IRadioMessagingResponse>& messagingResponse,
169 const std::shared_ptr<aidl::IRadioMessagingIndication>& messagingIndication) {
170 LOG_CALL << messagingResponse << ' ' << messagingIndication;
171
172 CHECK(messagingResponse);
173 CHECK(messagingIndication);
174
175 mRadioResponse->setResponseFunction(messagingResponse);
176 mRadioIndication->setResponseFunction(messagingIndication);
177
178 return ok();
179}
180
181ScopedAStatus RadioMessaging::setSmscAddress(int32_t serial, const std::string& smsc) {
182 LOG_CALL << serial << ' ' << smsc;
183 mHal1_5->setSmscAddress(serial, smsc);
184 return ok();
185}
186
187ScopedAStatus RadioMessaging::writeSmsToRuim(int32_t serial, const aidl::CdmaSmsWriteArgs& sms) {
188 LOG_CALL << serial;
189 mHal1_5->writeSmsToRuim(serial, toHidl(sms));
190 return ok();
191}
192
193ScopedAStatus RadioMessaging::writeSmsToSim(int32_t serial, const aidl::SmsWriteArgs& smsWrArgs) {
194 LOG_CALL << serial;
195 mHal1_5->writeSmsToSim(serial, toHidl(smsWrArgs));
196 return ok();
197}
198
199} // namespace android::hardware::radio::compat