• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
respond()32 std::shared_ptr<aidl::IRadioMessagingResponse> RadioMessaging::respond() {
33     return mCallbackManager->response().messagingCb();
34 }
35 
acknowledgeIncomingGsmSmsWithPdu(int32_t serial,bool success,const std::string & ackPdu)36 ScopedAStatus 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 
acknowledgeLastIncomingCdmaSms(int32_t serial,const aidl::CdmaSmsAck & smsAck)43 ScopedAStatus 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 
acknowledgeLastIncomingGsmSms(int32_t serial,bool success,aidl::SmsAcknowledgeFailCause cause)50 ScopedAStatus 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 
deleteSmsOnRuim(int32_t serial,int32_t index)57 ScopedAStatus RadioMessaging::deleteSmsOnRuim(int32_t serial, int32_t index) {
58     LOG_CALL << serial << ' ' << index;
59     mHal1_5->deleteSmsOnRuim(serial, index);
60     return ok();
61 }
62 
deleteSmsOnSim(int32_t serial,int32_t index)63 ScopedAStatus RadioMessaging::deleteSmsOnSim(int32_t serial, int32_t index) {
64     LOG_CALL << serial << ' ' << index;
65     mHal1_5->deleteSmsOnSim(serial, index);
66     return ok();
67 }
68 
getCdmaBroadcastConfig(int32_t serial)69 ScopedAStatus RadioMessaging::getCdmaBroadcastConfig(int32_t serial) {
70     LOG_CALL << serial;
71     mHal1_5->getCdmaBroadcastConfig(serial);
72     return ok();
73 }
74 
getGsmBroadcastConfig(int32_t serial)75 ScopedAStatus RadioMessaging::getGsmBroadcastConfig(int32_t serial) {
76     LOG_CALL << serial;
77     mHal1_5->getGsmBroadcastConfig(serial);
78     return ok();
79 }
80 
getSmscAddress(int32_t serial)81 ScopedAStatus RadioMessaging::getSmscAddress(int32_t serial) {
82     LOG_CALL << serial;
83     mHal1_5->getSmscAddress(serial);
84     return ok();
85 }
86 
reportSmsMemoryStatus(int32_t serial,bool available)87 ScopedAStatus RadioMessaging::reportSmsMemoryStatus(int32_t serial, bool available) {
88     LOG_CALL << serial << ' ' << available;
89     mHal1_5->reportSmsMemoryStatus(serial, available);
90     return ok();
91 }
92 
responseAcknowledgement()93 ScopedAStatus RadioMessaging::responseAcknowledgement() {
94     LOG_CALL;
95     mHal1_5->responseAcknowledgement();
96     return ok();
97 }
98 
sendCdmaSms(int32_t serial,const aidl::CdmaSmsMessage & sms)99 ScopedAStatus RadioMessaging::sendCdmaSms(int32_t serial, const aidl::CdmaSmsMessage& sms) {
100     LOG_CALL << serial;
101     if (mHal1_6) {
102         mHal1_6->sendCdmaSms_1_6(serial, toHidl(sms));
103     } else {
104         mHal1_5->sendCdmaSms(serial, toHidl(sms));
105     }
106     return ok();
107 }
108 
sendCdmaSmsExpectMore(int32_t serial,const aidl::CdmaSmsMessage & m)109 ScopedAStatus RadioMessaging::sendCdmaSmsExpectMore(int32_t serial, const aidl::CdmaSmsMessage& m) {
110     LOG_CALL << serial;
111     if (mHal1_6) {
112         mHal1_6->sendCdmaSmsExpectMore_1_6(serial, toHidl(m));
113     } else {
114         mHal1_5->sendCdmaSmsExpectMore(serial, toHidl(m));
115     }
116     return ok();
117 }
118 
sendImsSms(int32_t serial,const aidl::ImsSmsMessage & message)119 ScopedAStatus 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 
sendSms(int32_t serial,const aidl::GsmSmsMessage & message)125 ScopedAStatus RadioMessaging::sendSms(int32_t serial, const aidl::GsmSmsMessage& message) {
126     LOG_CALL << serial;
127     if (mHal1_6) {
128         mHal1_6->sendSms_1_6(serial, toHidl(message));
129     } else {
130         mHal1_5->sendSms(serial, toHidl(message));
131     }
132     return ok();
133 }
134 
sendSmsExpectMore(int32_t serial,const aidl::GsmSmsMessage & msg)135 ScopedAStatus RadioMessaging::sendSmsExpectMore(int32_t serial, const aidl::GsmSmsMessage& msg) {
136     LOG_CALL << serial;
137     if (mHal1_6) {
138         mHal1_6->sendSmsExpectMore_1_6(serial, toHidl(msg));
139     } else {
140         mHal1_5->sendSMSExpectMore(serial, toHidl(msg));
141     }
142     return ok();
143 }
144 
setCdmaBroadcastActivation(int32_t serial,bool activate)145 ScopedAStatus RadioMessaging::setCdmaBroadcastActivation(int32_t serial, bool activate) {
146     LOG_CALL << serial << ' ' << activate;
147     mHal1_5->setCdmaBroadcastActivation(serial, activate);
148     return ok();
149 }
150 
setCdmaBroadcastConfig(int32_t serial,const std::vector<aidl::CdmaBroadcastSmsConfigInfo> & cfgInfo)151 ScopedAStatus 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 
setGsmBroadcastActivation(int32_t serial,bool activate)158 ScopedAStatus RadioMessaging::setGsmBroadcastActivation(int32_t serial, bool activate) {
159     LOG_CALL << serial << ' ' << activate;
160     mHal1_5->setGsmBroadcastActivation(serial, activate);
161     return ok();
162 }
163 
setGsmBroadcastConfig(int32_t serial,const std::vector<aidl::GsmBroadcastSmsConfigInfo> & configInfo)164 ScopedAStatus 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 
setResponseFunctions(const std::shared_ptr<aidl::IRadioMessagingResponse> & response,const std::shared_ptr<aidl::IRadioMessagingIndication> & indication)171 ScopedAStatus RadioMessaging::setResponseFunctions(
172         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);
176     return ok();
177 }
178 
setSmscAddress(int32_t serial,const std::string & smsc)179 ScopedAStatus 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 
writeSmsToRuim(int32_t serial,const aidl::CdmaSmsWriteArgs & sms)185 ScopedAStatus 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 
writeSmsToSim(int32_t serial,const aidl::SmsWriteArgs & smsWrArgs)191 ScopedAStatus 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
198