• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 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 #pragma once
18 #include <memory>
19 
20 #include <aidl/android/hardware/radio/messaging/BnRadioMessaging.h>
21 #include "AtChannel.h"
22 
23 namespace aidl {
24 namespace android {
25 namespace hardware {
26 namespace radio {
27 namespace implementation {
28 using ::ndk::ScopedAStatus;
29 
30 struct RadioMessaging : public messaging::BnRadioMessaging {
31     RadioMessaging(std::shared_ptr<AtChannel> atChannel);
32 
33     ScopedAStatus acknowledgeIncomingGsmSmsWithPdu(int32_t serial, bool success,
34                                                    const std::string& ackPdu) override;
35     ScopedAStatus acknowledgeLastIncomingCdmaSms(
36             int32_t serial, const messaging::CdmaSmsAck& smsAck) override;
37     ScopedAStatus acknowledgeLastIncomingGsmSms(
38             int32_t serial, bool success,
39             messaging::SmsAcknowledgeFailCause cause) override;
40     ScopedAStatus deleteSmsOnRuim(int32_t serial, int32_t index) override;
41     ScopedAStatus deleteSmsOnSim(int32_t serial, int32_t index) override;
42     ScopedAStatus getCdmaBroadcastConfig(int32_t serial) override;
43     ScopedAStatus getGsmBroadcastConfig(int32_t serial) override;
44     ScopedAStatus getSmscAddress(int32_t serial) override;
45     ScopedAStatus reportSmsMemoryStatus(int32_t serial, bool available) override;
46     ScopedAStatus sendCdmaSms(
47             int32_t serial, const messaging::CdmaSmsMessage& sms) override;
48     ScopedAStatus sendCdmaSmsExpectMore(
49             int32_t serial, const messaging::CdmaSmsMessage& sms) override;
50     ScopedAStatus sendImsSms(
51             int32_t serial, const messaging::ImsSmsMessage& message) override;
52     ScopedAStatus sendSms(
53             int32_t serial, const messaging::GsmSmsMessage& message) override;
54     ScopedAStatus sendSmsExpectMore(
55             int32_t serial, const messaging::GsmSmsMessage& message) override;
56     ScopedAStatus setCdmaBroadcastConfig(
57             int32_t serial, const std::vector<messaging::CdmaBroadcastSmsConfigInfo>&
58                     configInfo) override;
59     ScopedAStatus setCdmaBroadcastActivation(int32_t serial, bool activate) override;
60     ScopedAStatus setGsmBroadcastConfig(
61             int32_t serial, const std::vector<messaging::GsmBroadcastSmsConfigInfo>&
62                     configInfo) override;
63     ScopedAStatus setGsmBroadcastActivation(int32_t serial, bool activate) override;
64     ScopedAStatus setSmscAddress(int32_t serial, const std::string& smsc) override;
65     ScopedAStatus writeSmsToRuim(
66             int32_t serial, const messaging::CdmaSmsWriteArgs& cdmaSms) override;
67     ScopedAStatus writeSmsToSim(
68             int32_t serial, const messaging::SmsWriteArgs& smsWriteArgs) override;
69 
70     void atResponseSink(const AtResponsePtr& response);
71     void handleUnsolicited(const AtResponse::CMT&);
72     void handleUnsolicited(const AtResponse::CDS&);
handleUnsolicitedRadioMessaging73     template <class IGNORE> void handleUnsolicited(const IGNORE&) {}
74 
75     ScopedAStatus responseAcknowledgement() override;
76     ScopedAStatus setResponseFunctions(
77             const std::shared_ptr<messaging::IRadioMessagingResponse>& radioMessagingResponse,
78             const std::shared_ptr<messaging::IRadioMessagingIndication>& radioMessagingIndication) override;
79 
80 private:
81     std::pair<RadioResponseInfo, messaging::SendSmsResult>
82         sendSmsImpl(AtChannel::RequestPipe, int serial,
83                     const messaging::GsmSmsMessage &);
84 
85     const std::shared_ptr<AtChannel> mAtChannel;
86     AtChannel::Conversation mAtConversation;
87     std::shared_ptr<messaging::IRadioMessagingResponse> mRadioMessagingResponse;
88     std::shared_ptr<messaging::IRadioMessagingIndication> mRadioMessagingIndication;
89 };
90 
91 }  // namespace implementation
92 }  // namespace radio
93 }  // namespace hardware
94 }  // namespace android
95 }  // namespace aidl
96