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/RadioIndication.h>
18 
19 #include "commonStructs.h"
20 #include "debug.h"
21 #include "structs.h"
22 
23 #include "collections.h"
24 
25 #define RADIO_MODULE "NetworkIndication"
26 
27 namespace android::hardware::radio::compat {
28 
29 using ::aidl::android::hardware::radio::RadioTechnology;
30 namespace aidl = ::aidl::android::hardware::radio::network;
31 
setResponseFunction(std::shared_ptr<aidl::IRadioNetworkIndication> netCb)32 void RadioIndication::setResponseFunction(std::shared_ptr<aidl::IRadioNetworkIndication> netCb) {
33     mNetworkCb = netCb;
34 }
35 
networkCb()36 std::shared_ptr<aidl::IRadioNetworkIndication> RadioIndication::networkCb() {
37     return mNetworkCb.get();
38 }
39 
barringInfoChanged(V1_0::RadioIndicationType type,const V1_5::CellIdentity & cellIdentity,const hidl_vec<V1_5::BarringInfo> & barringInfos)40 Return<void> RadioIndication::barringInfoChanged(V1_0::RadioIndicationType type,
41                                                  const V1_5::CellIdentity& cellIdentity,
42                                                  const hidl_vec<V1_5::BarringInfo>& barringInfos) {
43     LOG_CALL << type;
44     networkCb()->barringInfoChanged(toAidl(type), toAidl(cellIdentity), toAidl(barringInfos));
45     return {};
46 }
47 
cdmaPrlChanged(V1_0::RadioIndicationType type,int32_t version)48 Return<void> RadioIndication::cdmaPrlChanged(V1_0::RadioIndicationType type, int32_t version) {
49     LOG_CALL << type;
50     networkCb()->cdmaPrlChanged(toAidl(type), version);
51     return {};
52 }
53 
cellInfoList(V1_0::RadioIndicationType type,const hidl_vec<V1_0::CellInfo> &)54 Return<void> RadioIndication::cellInfoList(V1_0::RadioIndicationType type,
55                                            const hidl_vec<V1_0::CellInfo>&) {
56     LOG_CALL << type;
57     LOG(ERROR) << "IRadio HAL 1.0 not supported";
58     return {};
59 }
60 
cellInfoList_1_2(V1_0::RadioIndicationType type,const hidl_vec<V1_2::CellInfo> &)61 Return<void> RadioIndication::cellInfoList_1_2(V1_0::RadioIndicationType type,
62                                                const hidl_vec<V1_2::CellInfo>&) {
63     LOG_CALL << type;
64     LOG(ERROR) << "IRadio HAL 1.2 not supported";
65     return {};
66 }
67 
cellInfoList_1_4(V1_0::RadioIndicationType type,const hidl_vec<V1_4::CellInfo> &)68 Return<void> RadioIndication::cellInfoList_1_4(V1_0::RadioIndicationType type,
69                                                const hidl_vec<V1_4::CellInfo>&) {
70     LOG_CALL << type;
71     LOG(ERROR) << "IRadio HAL 1.4 not supported";
72     return {};
73 }
74 
cellInfoList_1_5(V1_0::RadioIndicationType type,const hidl_vec<V1_5::CellInfo> & records)75 Return<void> RadioIndication::cellInfoList_1_5(V1_0::RadioIndicationType type,
76                                                const hidl_vec<V1_5::CellInfo>& records) {
77     LOG_CALL << type;
78     networkCb()->cellInfoList(toAidl(type), toAidl(records));
79     return {};
80 }
81 
cellInfoList_1_6(V1_0::RadioIndicationType type,const hidl_vec<V1_6::CellInfo> & records)82 Return<void> RadioIndication::cellInfoList_1_6(V1_0::RadioIndicationType type,
83                                                const hidl_vec<V1_6::CellInfo>& records) {
84     LOG_CALL << type;
85     networkCb()->cellInfoList(toAidl(type), toAidl(records));
86     return {};
87 }
88 
currentLinkCapacityEstimate(V1_0::RadioIndicationType type,const V1_2::LinkCapacityEstimate & lce)89 Return<void> RadioIndication::currentLinkCapacityEstimate(V1_0::RadioIndicationType type,
90                                                           const V1_2::LinkCapacityEstimate& lce) {
91     LOG_CALL << type;
92     networkCb()->currentLinkCapacityEstimate(toAidl(type), toAidl(lce));
93     return {};
94 }
95 
currentLinkCapacityEstimate_1_6(V1_0::RadioIndicationType type,const V1_6::LinkCapacityEstimate & lce)96 Return<void> RadioIndication::currentLinkCapacityEstimate_1_6(
97         V1_0::RadioIndicationType type, const V1_6::LinkCapacityEstimate& lce) {
98     LOG_CALL << type;
99     networkCb()->currentLinkCapacityEstimate(toAidl(type), toAidl(lce));
100     return {};
101 }
102 
currentPhysicalChannelConfigs(V1_0::RadioIndicationType type,const hidl_vec<V1_2::PhysicalChannelConfig> &)103 Return<void> RadioIndication::currentPhysicalChannelConfigs(
104         V1_0::RadioIndicationType type, const hidl_vec<V1_2::PhysicalChannelConfig>&) {
105     LOG_CALL << type;
106     LOG(ERROR) << "IRadio HAL 1.0 not supported";
107     return {};
108 }
109 
currentPhysicalChannelConfigs_1_4(V1_0::RadioIndicationType type,const hidl_vec<V1_4::PhysicalChannelConfig> & configs)110 Return<void> RadioIndication::currentPhysicalChannelConfigs_1_4(
111         V1_0::RadioIndicationType type, const hidl_vec<V1_4::PhysicalChannelConfig>& configs) {
112     LOG_CALL << type;
113     networkCb()->currentPhysicalChannelConfigs(toAidl(type), toAidl(configs));
114     return {};
115 }
116 
currentPhysicalChannelConfigs_1_6(V1_0::RadioIndicationType type,const hidl_vec<V1_6::PhysicalChannelConfig> & configs)117 Return<void> RadioIndication::currentPhysicalChannelConfigs_1_6(
118         V1_0::RadioIndicationType type, const hidl_vec<V1_6::PhysicalChannelConfig>& configs) {
119     LOG_CALL << type;
120     networkCb()->currentPhysicalChannelConfigs(toAidl(type), toAidl(configs));
121     return {};
122 }
123 
currentSignalStrength(V1_0::RadioIndicationType type,const V1_0::SignalStrength &)124 Return<void> RadioIndication::currentSignalStrength(V1_0::RadioIndicationType type,
125                                                     const V1_0::SignalStrength&) {
126     LOG_CALL << type;
127     LOG(ERROR) << "IRadio HAL 1.0 not supported";
128     return {};
129 }
130 
currentSignalStrength_1_2(V1_0::RadioIndicationType type,const V1_2::SignalStrength &)131 Return<void> RadioIndication::currentSignalStrength_1_2(V1_0::RadioIndicationType type,
132                                                         const V1_2::SignalStrength&) {
133     LOG_CALL << type;
134     LOG(ERROR) << "IRadio HAL 1.2 not supported";
135     return {};
136 }
137 
currentSignalStrength_1_4(V1_0::RadioIndicationType type,const V1_4::SignalStrength & signalStrength)138 Return<void> RadioIndication::currentSignalStrength_1_4(
139         V1_0::RadioIndicationType type, const V1_4::SignalStrength& signalStrength) {
140     LOG_CALL << type;
141     networkCb()->currentSignalStrength(toAidl(type), toAidl(signalStrength));
142     return {};
143 }
144 
currentSignalStrength_1_6(V1_0::RadioIndicationType type,const V1_6::SignalStrength & signalStrength)145 Return<void> RadioIndication::currentSignalStrength_1_6(
146         V1_0::RadioIndicationType type, const V1_6::SignalStrength& signalStrength) {
147     LOG_CALL << type;
148     networkCb()->currentSignalStrength(toAidl(type), toAidl(signalStrength));
149     return {};
150 }
151 
imsNetworkStateChanged(V1_0::RadioIndicationType type)152 Return<void> RadioIndication::imsNetworkStateChanged(V1_0::RadioIndicationType type) {
153     LOG_CALL << type;
154     networkCb()->imsNetworkStateChanged(toAidl(type));
155     return {};
156 }
157 
networkScanResult(V1_0::RadioIndicationType type,const V1_1::NetworkScanResult &)158 Return<void> RadioIndication::networkScanResult(V1_0::RadioIndicationType type,
159                                                 const V1_1::NetworkScanResult&) {
160     LOG_CALL << type;
161     LOG(ERROR) << "IRadio HAL 1.0 not supported";
162     return {};
163 }
164 
networkScanResult_1_2(V1_0::RadioIndicationType type,const V1_2::NetworkScanResult &)165 Return<void> RadioIndication::networkScanResult_1_2(V1_0::RadioIndicationType type,
166                                                     const V1_2::NetworkScanResult&) {
167     LOG_CALL << type;
168     LOG(ERROR) << "IRadio HAL 1.2 not supported";
169     return {};
170 }
171 
networkScanResult_1_4(V1_0::RadioIndicationType type,const V1_4::NetworkScanResult &)172 Return<void> RadioIndication::networkScanResult_1_4(V1_0::RadioIndicationType type,
173                                                     const V1_4::NetworkScanResult&) {
174     LOG_CALL << type;
175     LOG(ERROR) << "IRadio HAL 1.4 not supported";
176     return {};
177 }
178 
networkScanResult_1_5(V1_0::RadioIndicationType type,const V1_5::NetworkScanResult & result)179 Return<void> RadioIndication::networkScanResult_1_5(V1_0::RadioIndicationType type,
180                                                     const V1_5::NetworkScanResult& result) {
181     LOG_CALL << type;
182     networkCb()->networkScanResult(toAidl(type), toAidl(result));
183     return {};
184 }
185 
networkScanResult_1_6(V1_0::RadioIndicationType type,const V1_6::NetworkScanResult & result)186 Return<void> RadioIndication::networkScanResult_1_6(V1_0::RadioIndicationType type,
187                                                     const V1_6::NetworkScanResult& result) {
188     LOG_CALL << type;
189     networkCb()->networkScanResult(toAidl(type), toAidl(result));
190     return {};
191 }
192 
networkStateChanged(V1_0::RadioIndicationType type)193 Return<void> RadioIndication::networkStateChanged(V1_0::RadioIndicationType type) {
194     LOG_CALL << type;
195     networkCb()->networkStateChanged(toAidl(type));
196     return {};
197 }
198 
nitzTimeReceived(V1_0::RadioIndicationType type,const hidl_string & nitzTime,uint64_t receivedTime)199 Return<void> RadioIndication::nitzTimeReceived(V1_0::RadioIndicationType type,
200                                                const hidl_string& nitzTime, uint64_t receivedTime) {
201     LOG_CALL << type;
202     networkCb()->nitzTimeReceived(toAidl(type), nitzTime, receivedTime, 0);
203     return {};
204 }
205 
registrationFailed(V1_0::RadioIndicationType type,const V1_5::CellIdentity & cellIdentity,const hidl_string & chosenPlmn,hidl_bitfield<V1_5::Domain> domain,int32_t causeCode,int32_t additionalCauseCode)206 Return<void> RadioIndication::registrationFailed(  //
207         V1_0::RadioIndicationType type, const V1_5::CellIdentity& cellIdentity,
208         const hidl_string& chosenPlmn, hidl_bitfield<V1_5::Domain> domain, int32_t causeCode,
209         int32_t additionalCauseCode) {
210     LOG_CALL << type;
211     networkCb()->registrationFailed(toAidl(type), toAidl(cellIdentity), chosenPlmn, domain,
212                                     causeCode, additionalCauseCode);
213     return {};
214 }
215 
restrictedStateChanged(V1_0::RadioIndicationType type,V1_0::PhoneRestrictedState state)216 Return<void> RadioIndication::restrictedStateChanged(V1_0::RadioIndicationType type,
217                                                      V1_0::PhoneRestrictedState state) {
218     LOG_CALL << type;
219     networkCb()->restrictedStateChanged(toAidl(type), aidl::PhoneRestrictedState(state));
220     return {};
221 }
222 
suppSvcNotify(V1_0::RadioIndicationType type,const V1_0::SuppSvcNotification & suppSvc)223 Return<void> RadioIndication::suppSvcNotify(V1_0::RadioIndicationType type,
224                                             const V1_0::SuppSvcNotification& suppSvc) {
225     LOG_CALL << type;
226     networkCb()->suppSvcNotify(toAidl(type), toAidl(suppSvc));
227     return {};
228 }
229 
voiceRadioTechChanged(V1_0::RadioIndicationType type,V1_0::RadioTechnology rat)230 Return<void> RadioIndication::voiceRadioTechChanged(V1_0::RadioIndicationType type,
231                                                     V1_0::RadioTechnology rat) {
232     LOG_CALL << type;
233     networkCb()->voiceRadioTechChanged(toAidl(type), RadioTechnology(rat));
234     return {};
235 }
236 
lceData(V1_0::RadioIndicationType type,const V1_0::LceDataInfo &)237 Return<void> RadioIndication::lceData(V1_0::RadioIndicationType type, const V1_0::LceDataInfo&) {
238     LOG_CALL << type;
239     LOG(WARNING) << "lceData indication is deprecated";
240     return {};
241 }
242 
243 }  // namespace android::hardware::radio::compat
244