blob: 56d49f1bb9e2ac213facdefaedc28e43e95aa18e [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() {
Tomasz Wasilczyk8579f1d2021-12-16 12:19:09 -080033 return mCallbackManager->response().messagingCb();
Tomasz Wasilczyk6902a752021-12-13 17:13:48 -080034}
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
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -070057ScopedAStatus RadioMessaging::deleteSmsOnRuim(int32_t serial, int32_t index) {
58 LOG_CALL << serial << ' ' << index;
59 mHal1_5->deleteSmsOnRuim(serial, index);
60 return ok();
61}
62
63ScopedAStatus RadioMessaging::deleteSmsOnSim(int32_t serial, int32_t index) {
64 LOG_CALL << serial << ' ' << index;
65 mHal1_5->deleteSmsOnSim(serial, index);
66 return ok();
67}
68
69ScopedAStatus RadioMessaging::getCdmaBroadcastConfig(int32_t serial) {
70 LOG_CALL << serial;
71 mHal1_5->getCdmaBroadcastConfig(serial);
72 return ok();
73}
74
75ScopedAStatus RadioMessaging::getGsmBroadcastConfig(int32_t serial) {
76 LOG_CALL << serial;
77 mHal1_5->getGsmBroadcastConfig(serial);
78 return ok();
79}
80
81ScopedAStatus RadioMessaging::getSmscAddress(int32_t serial) {
82 LOG_CALL << serial;
83 mHal1_5->getSmscAddress(serial);
84 return ok();
85}
86
87ScopedAStatus RadioMessaging::reportSmsMemoryStatus(int32_t serial, bool available) {
88 LOG_CALL << serial << ' ' << available;
89 mHal1_5->reportSmsMemoryStatus(serial, available);
90 return ok();
91}
92
93ScopedAStatus RadioMessaging::responseAcknowledgement() {
94 LOG_CALL;
95 mHal1_5->responseAcknowledgement();
96 return ok();
97}
98
99ScopedAStatus RadioMessaging::sendCdmaSms(int32_t serial, const aidl::CdmaSmsMessage& sms) {
100 LOG_CALL << serial;
Tomasz Wasilczyk31f6fab2021-12-15 16:15:45 -0800101 if (mHal1_6) {
102 mHal1_6->sendCdmaSms_1_6(serial, toHidl(sms));
103 } else {
104 mHal1_5->sendCdmaSms(serial, toHidl(sms));
105 }
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -0700106 return ok();
107}
108
109ScopedAStatus RadioMessaging::sendCdmaSmsExpectMore(int32_t serial, const aidl::CdmaSmsMessage& m) {
110 LOG_CALL << serial;
Tomasz Wasilczyk31f6fab2021-12-15 16:15:45 -0800111 if (mHal1_6) {
112 mHal1_6->sendCdmaSmsExpectMore_1_6(serial, toHidl(m));
113 } else {
114 mHal1_5->sendCdmaSmsExpectMore(serial, toHidl(m));
115 }
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -0700116 return ok();
117}
118
119ScopedAStatus RadioMessaging::sendImsSms(int32_t serial, const aidl::ImsSmsMessage& message) {
120 LOG_CALL << serial;
121 mHal1_5->sendImsSms(serial, toHidl(message));
122 return ok();
123}
124
125ScopedAStatus RadioMessaging::sendSms(int32_t serial, const aidl::GsmSmsMessage& message) {
126 LOG_CALL << serial;
Tomasz Wasilczyk31f6fab2021-12-15 16:15:45 -0800127 if (mHal1_6) {
128 mHal1_6->sendSms_1_6(serial, toHidl(message));
129 } else {
130 mHal1_5->sendSms(serial, toHidl(message));
131 }
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -0700132 return ok();
133}
134
135ScopedAStatus RadioMessaging::sendSmsExpectMore(int32_t serial, const aidl::GsmSmsMessage& msg) {
136 LOG_CALL << serial;
Tomasz Wasilczyk31f6fab2021-12-15 16:15:45 -0800137 if (mHal1_6) {
138 mHal1_6->sendSmsExpectMore_1_6(serial, toHidl(msg));
139 } else {
140 mHal1_5->sendSMSExpectMore(serial, toHidl(msg));
141 }
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -0700142 return ok();
143}
144
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -0700145ScopedAStatus RadioMessaging::setCdmaBroadcastActivation(int32_t serial, bool activate) {
146 LOG_CALL << serial << ' ' << activate;
147 mHal1_5->setCdmaBroadcastActivation(serial, activate);
148 return ok();
149}
150
151ScopedAStatus RadioMessaging::setCdmaBroadcastConfig(
152 int32_t serial, const std::vector<aidl::CdmaBroadcastSmsConfigInfo>& cfgInfo) {
153 LOG_CALL << serial;
154 mHal1_5->setCdmaBroadcastConfig(serial, toHidl(cfgInfo));
155 return ok();
156}
157
158ScopedAStatus RadioMessaging::setGsmBroadcastActivation(int32_t serial, bool activate) {
159 LOG_CALL << serial << ' ' << activate;
160 mHal1_5->setGsmBroadcastActivation(serial, activate);
161 return ok();
162}
163
164ScopedAStatus RadioMessaging::setGsmBroadcastConfig(
165 int32_t serial, const std::vector<aidl::GsmBroadcastSmsConfigInfo>& configInfo) {
166 LOG_CALL << serial;
167 mHal1_5->setGsmBroadcastConfig(serial, toHidl(configInfo));
168 return ok();
169}
170
171ScopedAStatus RadioMessaging::setResponseFunctions(
Tomasz Wasilczyk8579f1d2021-12-16 12:19:09 -0800172 const std::shared_ptr<aidl::IRadioMessagingResponse>& response,
173 const std::shared_ptr<aidl::IRadioMessagingIndication>& indication) {
174 LOG_CALL << response << ' ' << indication;
175 mCallbackManager->setResponseFunctions(response, indication);
Tomasz Wasilczyk1f16d3a2021-10-25 20:20:49 -0700176 return ok();
177}
178
179ScopedAStatus RadioMessaging::setSmscAddress(int32_t serial, const std::string& smsc) {
180 LOG_CALL << serial << ' ' << smsc;
181 mHal1_5->setSmscAddress(serial, smsc);
182 return ok();
183}
184
185ScopedAStatus RadioMessaging::writeSmsToRuim(int32_t serial, const aidl::CdmaSmsWriteArgs& sms) {
186 LOG_CALL << serial;
187 mHal1_5->writeSmsToRuim(serial, toHidl(sms));
188 return ok();
189}
190
191ScopedAStatus RadioMessaging::writeSmsToSim(int32_t serial, const aidl::SmsWriteArgs& smsWrArgs) {
192 LOG_CALL << serial;
193 mHal1_5->writeSmsToSim(serial, toHidl(smsWrArgs));
194 return ok();
195}
196
197} // namespace android::hardware::radio::compat