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 #pragma once
17 
18 #include "DriverContext.h"
19 #include "GuaranteedCallback.h"
20 
21 #include <aidl/android/hardware/radio/data/IRadioDataIndication.h>
22 #include <aidl/android/hardware/radio/ims/IRadioImsIndication.h>
23 #include <aidl/android/hardware/radio/messaging/IRadioMessagingIndication.h>
24 #include <aidl/android/hardware/radio/modem/IRadioModemIndication.h>
25 #include <aidl/android/hardware/radio/network/IRadioNetworkIndication.h>
26 #include <aidl/android/hardware/radio/sim/IRadioSimIndication.h>
27 #include <aidl/android/hardware/radio/voice/IRadioVoiceIndication.h>
28 #include <android/hardware/radio/1.6/IRadioIndication.h>
29 #include <aidl/android/hardware/radio/modem/ImeiInfo.h>
30 
31 namespace android::hardware::radio::compat {
32 
33 class RadioIndication : public V1_6::IRadioIndication {
34     std::shared_ptr<DriverContext> mContext;
35 
36     GuaranteedCallback<  //
37             ::aidl::android::hardware::radio::data::IRadioDataIndication,
38             ::aidl::android::hardware::radio::data::IRadioDataIndicationDefault, true>
39             mDataCb;
40     GuaranteedCallback<  //
41             ::aidl::android::hardware::radio::messaging::IRadioMessagingIndication,
42             ::aidl::android::hardware::radio::messaging::IRadioMessagingIndicationDefault, true>
43             mMessagingCb;
44     GuaranteedCallback<  //
45             ::aidl::android::hardware::radio::modem::IRadioModemIndication,
46             ::aidl::android::hardware::radio::modem::IRadioModemIndicationDefault, true>
47             mModemCb;
48     GuaranteedCallback<  //
49             ::aidl::android::hardware::radio::network::IRadioNetworkIndication,
50             ::aidl::android::hardware::radio::network::IRadioNetworkIndicationDefault, true>
51             mNetworkCb;
52     GuaranteedCallback<  //
53             ::aidl::android::hardware::radio::sim::IRadioSimIndication,
54             ::aidl::android::hardware::radio::sim::IRadioSimIndicationDefault, true>
55             mSimCb;
56     GuaranteedCallback<  //
57             ::aidl::android::hardware::radio::voice::IRadioVoiceIndication,
58             ::aidl::android::hardware::radio::voice::IRadioVoiceIndicationDefault, true>
59             mVoiceCb;
60     GuaranteedCallback<  //
61             ::aidl::android::hardware::radio::ims::IRadioImsIndication,
62             ::aidl::android::hardware::radio::ims::IRadioImsIndicationDefault, true>
63             mImsCb;
64 
65     // IRadioIndication @ 1.0
66     Return<void> radioStateChanged(V1_0::RadioIndicationType type,
67                                    V1_0::RadioState radioState) override;
68     Return<void> callStateChanged(V1_0::RadioIndicationType type) override;
69     Return<void> networkStateChanged(V1_0::RadioIndicationType type) override;
70     Return<void> newSms(V1_0::RadioIndicationType type, const hidl_vec<uint8_t>& pdu) override;
71     Return<void> newSmsStatusReport(V1_0::RadioIndicationType type,
72                                     const hidl_vec<uint8_t>& pdu) override;
73     Return<void> newSmsOnSim(V1_0::RadioIndicationType type, int32_t recordNumber) override;
74     Return<void> onUssd(V1_0::RadioIndicationType type, V1_0::UssdModeType modeType,
75                         const hidl_string& msg) override;
76     Return<void> nitzTimeReceived(V1_0::RadioIndicationType type, const hidl_string& nitzTime,
77                                   uint64_t receivedTime) override;
78     Return<void> currentSignalStrength(V1_0::RadioIndicationType type,
79                                        const V1_0::SignalStrength& signalStrength) override;
80     Return<void> dataCallListChanged(V1_0::RadioIndicationType type,
81                                      const hidl_vec<V1_0::SetupDataCallResult>& dcList) override;
82     Return<void> suppSvcNotify(V1_0::RadioIndicationType type,
83                                const V1_0::SuppSvcNotification& suppSvc) override;
84     Return<void> stkSessionEnd(V1_0::RadioIndicationType type) override;
85     Return<void> stkProactiveCommand(V1_0::RadioIndicationType type,
86                                      const hidl_string& cmd) override;
87     Return<void> stkEventNotify(V1_0::RadioIndicationType type, const hidl_string& cmd) override;
88     Return<void> stkCallSetup(V1_0::RadioIndicationType type, int64_t timeout) override;
89     Return<void> simSmsStorageFull(V1_0::RadioIndicationType type) override;
90     Return<void> simRefresh(V1_0::RadioIndicationType type,
91                             const V1_0::SimRefreshResult& refreshResult) override;
92     Return<void> callRing(V1_0::RadioIndicationType type, bool isGsm,
93                           const V1_0::CdmaSignalInfoRecord& record) override;
94     Return<void> simStatusChanged(V1_0::RadioIndicationType type) override;
95     Return<void> cdmaNewSms(V1_0::RadioIndicationType type,
96                             const V1_0::CdmaSmsMessage& msg) override;
97     Return<void> newBroadcastSms(V1_0::RadioIndicationType type,
98                                  const hidl_vec<uint8_t>& data) override;
99     Return<void> cdmaRuimSmsStorageFull(V1_0::RadioIndicationType type) override;
100     Return<void> restrictedStateChanged(V1_0::RadioIndicationType type,
101                                         V1_0::PhoneRestrictedState state) override;
102     Return<void> enterEmergencyCallbackMode(V1_0::RadioIndicationType type) override;
103     Return<void> cdmaCallWaiting(V1_0::RadioIndicationType type,
104                                  const V1_0::CdmaCallWaiting& callWaitingRecord) override;
105     Return<void> cdmaOtaProvisionStatus(V1_0::RadioIndicationType type,
106                                         V1_0::CdmaOtaProvisionStatus status) override;
107     Return<void> cdmaInfoRec(V1_0::RadioIndicationType type,
108                              const V1_0::CdmaInformationRecords& records) override;
109     Return<void> indicateRingbackTone(V1_0::RadioIndicationType type, bool start) override;
110     Return<void> resendIncallMute(V1_0::RadioIndicationType type) override;
111     Return<void> cdmaSubscriptionSourceChanged(V1_0::RadioIndicationType type,
112                                                V1_0::CdmaSubscriptionSource cdmaSource) override;
113     Return<void> cdmaPrlChanged(V1_0::RadioIndicationType type, int32_t version) override;
114     Return<void> exitEmergencyCallbackMode(V1_0::RadioIndicationType type) override;
115     Return<void> rilConnected(V1_0::RadioIndicationType type) override;
116     Return<void> voiceRadioTechChanged(V1_0::RadioIndicationType type,
117                                        V1_0::RadioTechnology rat) override;
118     Return<void> cellInfoList(V1_0::RadioIndicationType type,
119                               const hidl_vec<V1_0::CellInfo>& records) override;
120     Return<void> imsNetworkStateChanged(V1_0::RadioIndicationType type) override;
121     Return<void> subscriptionStatusChanged(V1_0::RadioIndicationType type, bool activate) override;
122     Return<void> srvccStateNotify(V1_0::RadioIndicationType type, V1_0::SrvccState state) override;
123     Return<void> hardwareConfigChanged(V1_0::RadioIndicationType type,
124                                        const hidl_vec<V1_0::HardwareConfig>& configs) override;
125     Return<void> radioCapabilityIndication(V1_0::RadioIndicationType type,
126                                            const V1_0::RadioCapability& rc) override;
127     Return<void> onSupplementaryServiceIndication(V1_0::RadioIndicationType type,
128                                                   const V1_0::StkCcUnsolSsResult& ss) override;
129     Return<void> stkCallControlAlphaNotify(V1_0::RadioIndicationType type,
130                                            const hidl_string& alpha) override;
131     Return<void> lceData(V1_0::RadioIndicationType type, const V1_0::LceDataInfo& lce) override;
132     Return<void> pcoData(V1_0::RadioIndicationType type, const V1_0::PcoDataInfo& pco) override;
133     Return<void> modemReset(V1_0::RadioIndicationType type, const hidl_string& reason) override;
134 
135     // IRadioIndication @ 1.1
136     Return<void> carrierInfoForImsiEncryption(V1_0::RadioIndicationType info) override;
137     Return<void> networkScanResult(V1_0::RadioIndicationType type,
138                                    const V1_1::NetworkScanResult& result) override;
139     Return<void> keepaliveStatus(V1_0::RadioIndicationType type,
140                                  const V1_1::KeepaliveStatus& status) override;
141 
142     // IRadioIndication @ 1.2
143     Return<void> networkScanResult_1_2(V1_0::RadioIndicationType type,
144                                        const V1_2::NetworkScanResult& result) override;
145     Return<void> cellInfoList_1_2(V1_0::RadioIndicationType type,
146                                   const hidl_vec<V1_2::CellInfo>& records) override;
147     Return<void> currentLinkCapacityEstimate(V1_0::RadioIndicationType type,
148                                              const V1_2::LinkCapacityEstimate& lce) override;
149     Return<void> currentPhysicalChannelConfigs(
150             V1_0::RadioIndicationType type,
151             const hidl_vec<V1_2::PhysicalChannelConfig>& configs) override;
152     Return<void> currentSignalStrength_1_2(V1_0::RadioIndicationType type,
153                                            const V1_2::SignalStrength& signalStrength) override;
154 
155     // IRadioIndication @ 1.4
156     Return<void> currentEmergencyNumberList(
157             V1_0::RadioIndicationType type,
158             const hidl_vec<V1_4::EmergencyNumber>& emergencyNumberList) override;
159     Return<void> cellInfoList_1_4(V1_0::RadioIndicationType type,
160                                   const hidl_vec<V1_4::CellInfo>& records) override;
161     Return<void> networkScanResult_1_4(V1_0::RadioIndicationType type,
162                                        const V1_4::NetworkScanResult& result) override;
163     Return<void> currentPhysicalChannelConfigs_1_4(
164             V1_0::RadioIndicationType type,
165             const hidl_vec<V1_4::PhysicalChannelConfig>& configs) override;
166     Return<void> dataCallListChanged_1_4(
167             V1_0::RadioIndicationType type,
168             const hidl_vec<V1_4::SetupDataCallResult>& dcList) override;
169     Return<void> currentSignalStrength_1_4(V1_0::RadioIndicationType type,
170                                            const V1_4::SignalStrength& signalStrength) override;
171 
172     // IRadioIndication @ 1.5
173     Return<void> uiccApplicationsEnablementChanged(V1_0::RadioIndicationType type,
174                                                    bool enabled) override;
175     Return<void> registrationFailed(  //
176             V1_0::RadioIndicationType type, const V1_5::CellIdentity& cellIdentity,
177             const hidl_string& chosenPlmn, hidl_bitfield<V1_5::Domain> domain, int32_t causeCode,
178             int32_t additionalCauseCode) override;
179     Return<void> barringInfoChanged(  //
180             V1_0::RadioIndicationType type, const V1_5::CellIdentity& cellIdentity,
181             const hidl_vec<V1_5::BarringInfo>& barringInfos) override;
182     Return<void> cellInfoList_1_5(V1_0::RadioIndicationType type,
183                                   const hidl_vec<V1_5::CellInfo>& records) override;
184     Return<void> networkScanResult_1_5(V1_0::RadioIndicationType type,
185                                        const V1_5::NetworkScanResult& result) override;
186     Return<void> dataCallListChanged_1_5(
187             V1_0::RadioIndicationType type,
188             const hidl_vec<V1_5::SetupDataCallResult>& dcList) override;
189 
190     // IRadioIndication @ 1.6
191     Return<void> dataCallListChanged_1_6(
192             V1_0::RadioIndicationType type,
193             const hidl_vec<V1_6::SetupDataCallResult>& dcList) override;
194     Return<void> unthrottleApn(V1_0::RadioIndicationType type, const hidl_string& apn) override;
195     Return<void> slicingConfigChanged(V1_0::RadioIndicationType type,
196                                       const V1_6::SlicingConfig& slicingConfig);
197     Return<void> currentLinkCapacityEstimate_1_6(V1_0::RadioIndicationType type,
198                                                  const V1_6::LinkCapacityEstimate& lce) override;
199     Return<void> currentSignalStrength_1_6(V1_0::RadioIndicationType type,
200                                            const V1_6::SignalStrength& signalStrength) override;
201     Return<void> cellInfoList_1_6(V1_0::RadioIndicationType type,
202                                   const hidl_vec<V1_6::CellInfo>& records) override;
203     Return<void> networkScanResult_1_6(V1_0::RadioIndicationType type,
204                                        const V1_6::NetworkScanResult& result) override;
205     Return<void> currentPhysicalChannelConfigs_1_6(
206             V1_0::RadioIndicationType type,
207             const hidl_vec<V1_6::PhysicalChannelConfig>& configs) override;
208     Return<void> simPhonebookChanged(V1_0::RadioIndicationType type) override;
209     Return<void> simPhonebookRecordsReceived(
210             V1_0::RadioIndicationType type, V1_6::PbReceivedStatus status,
211             const hidl_vec<V1_6::PhonebookRecordInfo>& records) override;
212     Return<void> onImeiMappingChanged(V1_0::RadioIndicationType type,
213                                       ::aidl::android::hardware::radio::modem::ImeiInfo config);
214   public:
215     RadioIndication(std::shared_ptr<DriverContext> context);
216 
217     void setResponseFunction(
218             std::shared_ptr<::aidl::android::hardware::radio::data::IRadioDataIndication> dataCb);
219     void setResponseFunction(
220             std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingIndication>
221                     radioMessagingIndication);
222     void setResponseFunction(
223             std::shared_ptr<::aidl::android::hardware::radio::modem::IRadioModemIndication> modmCb);
224     void setResponseFunction(
225             std::shared_ptr<::aidl::android::hardware::radio::network::IRadioNetworkIndication> ni);
226     void setResponseFunction(
227             std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimIndication> simCb);
228     void setResponseFunction(
229             std::shared_ptr<::aidl::android::hardware::radio::voice::IRadioVoiceIndication> voicCb);
230     void setResponseFunction(
231             std::shared_ptr<::aidl::android::hardware::radio::ims::IRadioImsIndication> imsCb);
232 
233     std::shared_ptr<::aidl::android::hardware::radio::data::IRadioDataIndication> dataCb();
234     std::shared_ptr<::aidl::android::hardware::radio::messaging::IRadioMessagingIndication>
235     messagingCb();
236     std::shared_ptr<::aidl::android::hardware::radio::modem::IRadioModemIndication> modemCb();
237     std::shared_ptr<::aidl::android::hardware::radio::network::IRadioNetworkIndication> networkCb();
238     std::shared_ptr<::aidl::android::hardware::radio::sim::IRadioSimIndication> simCb();
239     std::shared_ptr<::aidl::android::hardware::radio::voice::IRadioVoiceIndication> voiceCb();
240     std::shared_ptr<::aidl::android::hardware::radio::ims::IRadioImsIndication> imsCb();
241 };
242 
243 }  // namespace android::hardware::radio::compat
244