• 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 #pragma once
18 
19 #include <aidl/android/hardware/radio/network/BnRadioNetworkIndication.h>
20 #include <aidl/android/hardware/radio/network/BnRadioNetworkResponse.h>
21 #include <aidl/android/hardware/radio/network/IRadioNetwork.h>
22 
23 #include "radio_aidl_hal_utils.h"
24 
25 using namespace aidl::android::hardware::radio::network;
26 
27 class RadioNetworkTest;
28 
29 /* Callback class for radio network response */
30 class RadioNetworkResponse : public BnRadioNetworkResponse {
31   protected:
32     RadioServiceTest& parent_network;
33 
34   public:
35     RadioNetworkResponse(RadioServiceTest& parent_network);
36     virtual ~RadioNetworkResponse() = default;
37 
38     RadioResponseInfo rspInfo;
39     std::vector<RadioBandMode> radioBandModes;
40     std::vector<OperatorInfo> networkInfos;
41     bool isNrDualConnectivityEnabled = false;
42     int networkTypeBitmapResponse = 0;
43     RegStateResult voiceRegResp;
44     RegStateResult dataRegResp;
45     CellIdentity barringCellIdentity;
46     std::vector<BarringInfo> barringInfoList;
47     UsageSetting usageSetting;
48     std::vector<RadioAccessSpecifier> specifiers;
49     bool isCellularIdentifierTransparencyEnabled = false;
50     bool isSecurityAlgorithmsUpdatedEnabled = false;
51 
52     virtual ndk::ScopedAStatus acknowledgeRequest(int32_t serial) override;
53 
54     virtual ndk::ScopedAStatus getAllowedNetworkTypesBitmapResponse(
55             const RadioResponseInfo& info, const int32_t networkTypeBitmap) override;
56 
57     virtual ndk::ScopedAStatus getAvailableBandModesResponse(
58             const RadioResponseInfo& info, const std::vector<RadioBandMode>& bandModes) override;
59 
60     virtual ndk::ScopedAStatus getAvailableNetworksResponse(
61             const RadioResponseInfo& info, const std::vector<OperatorInfo>& networkInfos) override;
62 
63     virtual ndk::ScopedAStatus getBarringInfoResponse(
64             const RadioResponseInfo& info, const CellIdentity& cellIdentity,
65             const std::vector<BarringInfo>& barringInfos) override;
66 
67     virtual ndk::ScopedAStatus getCdmaRoamingPreferenceResponse(const RadioResponseInfo& info,
68                                                                 CdmaRoamingType type) override;
69 
70     virtual ndk::ScopedAStatus getCellInfoListResponse(
71             const RadioResponseInfo& info, const std::vector<CellInfo>& cellInfo) override;
72 
73     virtual ndk::ScopedAStatus getDataRegistrationStateResponse(
74             const RadioResponseInfo& info, const RegStateResult& dataRegResponse) override;
75 
76     virtual ndk::ScopedAStatus getImsRegistrationStateResponse(
77             const RadioResponseInfo& info, bool isRegistered,
78             RadioTechnologyFamily ratFamily) override;
79 
80     virtual ndk::ScopedAStatus getNetworkSelectionModeResponse(const RadioResponseInfo& info,
81                                                                bool manual) override;
82 
83     virtual ndk::ScopedAStatus getOperatorResponse(const RadioResponseInfo& info,
84                                                    const std::string& longName,
85                                                    const std::string& shortName,
86                                                    const std::string& numeric) override;
87 
88     virtual ndk::ScopedAStatus getSignalStrengthResponse(
89             const RadioResponseInfo& info, const SignalStrength& sigStrength) override;
90 
91     virtual ndk::ScopedAStatus getSystemSelectionChannelsResponse(
92             const RadioResponseInfo& info,
93             const std::vector<RadioAccessSpecifier>& specifier) override;
94 
95     virtual ndk::ScopedAStatus getUsageSettingResponse(const RadioResponseInfo& info,
96                                                        UsageSetting usageSetting) override;
97 
98     virtual ndk::ScopedAStatus getVoiceRadioTechnologyResponse(const RadioResponseInfo& info,
99                                                                RadioTechnology rat) override;
100 
101     virtual ndk::ScopedAStatus getVoiceRegistrationStateResponse(
102             const RadioResponseInfo& info, const RegStateResult& voiceRegResponse) override;
103 
104     virtual ndk::ScopedAStatus isNrDualConnectivityEnabledResponse(const RadioResponseInfo& info,
105                                                                    bool isEnabled) override;
106 
107     virtual ndk::ScopedAStatus setAllowedNetworkTypesBitmapResponse(
108             const RadioResponseInfo& info) override;
109 
110     virtual ndk::ScopedAStatus setBandModeResponse(const RadioResponseInfo& info) override;
111 
112     virtual ndk::ScopedAStatus setBarringPasswordResponse(const RadioResponseInfo& info) override;
113 
114     virtual ndk::ScopedAStatus setCdmaRoamingPreferenceResponse(
115             const RadioResponseInfo& info) override;
116 
117     virtual ndk::ScopedAStatus setCellInfoListRateResponse(const RadioResponseInfo& info) override;
118 
119     virtual ndk::ScopedAStatus setIndicationFilterResponse(const RadioResponseInfo& info) override;
120 
121     virtual ndk::ScopedAStatus setLinkCapacityReportingCriteriaResponse(
122             const RadioResponseInfo& info) override;
123 
124     virtual ndk::ScopedAStatus setLocationUpdatesResponse(const RadioResponseInfo& info) override;
125 
126     virtual ndk::ScopedAStatus setNetworkSelectionModeAutomaticResponse(
127             const RadioResponseInfo& info) override;
128 
129     virtual ndk::ScopedAStatus setNetworkSelectionModeManualResponse(
130             const RadioResponseInfo& info) override;
131 
132     virtual ndk::ScopedAStatus setNrDualConnectivityStateResponse(
133             const RadioResponseInfo& info) override;
134 
135     virtual ndk::ScopedAStatus setSignalStrengthReportingCriteriaResponse(
136             const RadioResponseInfo& info) override;
137 
138     virtual ndk::ScopedAStatus setSuppServiceNotificationsResponse(
139             const RadioResponseInfo& info) override;
140 
141     virtual ndk::ScopedAStatus setSystemSelectionChannelsResponse(
142             const RadioResponseInfo& info) override;
143 
144     virtual ndk::ScopedAStatus setUsageSettingResponse(const RadioResponseInfo& info) override;
145 
146     virtual ndk::ScopedAStatus startNetworkScanResponse(const RadioResponseInfo& info) override;
147 
148     virtual ndk::ScopedAStatus stopNetworkScanResponse(const RadioResponseInfo& info) override;
149 
150     virtual ndk::ScopedAStatus supplyNetworkDepersonalizationResponse(
151             const RadioResponseInfo& info, int32_t remainingRetries) override;
152 
153     virtual ndk::ScopedAStatus setEmergencyModeResponse(
154             const RadioResponseInfo& info, const EmergencyRegResult& regState) override;
155 
156     virtual ndk::ScopedAStatus triggerEmergencyNetworkScanResponse(
157             const RadioResponseInfo& info) override;
158 
159     virtual ndk::ScopedAStatus exitEmergencyModeResponse(const RadioResponseInfo& info) override;
160 
161     virtual ndk::ScopedAStatus cancelEmergencyNetworkScanResponse(
162             const RadioResponseInfo& info) override;
163 
164     virtual ndk::ScopedAStatus setNullCipherAndIntegrityEnabledResponse(
165             const RadioResponseInfo& info) override;
166 
167     virtual ndk::ScopedAStatus isNullCipherAndIntegrityEnabledResponse(
168             const RadioResponseInfo& info, const bool isEnabled) override;
169 
170     virtual ndk::ScopedAStatus isN1ModeEnabledResponse(
171             const RadioResponseInfo& info, bool isEnabled) override;
172 
173     virtual ndk::ScopedAStatus setN1ModeEnabledResponse(const RadioResponseInfo& info) override;
174 
175     virtual ndk::ScopedAStatus setCellularIdentifierTransparencyEnabledResponse(
176             const RadioResponseInfo& info) override;
177 
178     virtual ndk::ScopedAStatus isCellularIdentifierTransparencyEnabledResponse(
179             const RadioResponseInfo& info, bool /*enabled*/) override;
180 
181     virtual ndk::ScopedAStatus isSecurityAlgorithmsUpdatedEnabledResponse(
182             const RadioResponseInfo& info, bool isEnabled) override;
183 
184     virtual ndk::ScopedAStatus setSecurityAlgorithmsUpdatedEnabledResponse(
185             const RadioResponseInfo& info) override;
186 };
187 
188 /* Callback class for radio network indication */
189 class RadioNetworkIndication : public BnRadioNetworkIndication {
190   protected:
191     RadioServiceTest& parent_network;
192 
193   public:
194     RadioNetworkIndication(RadioServiceTest& parent_network);
195     virtual ~RadioNetworkIndication() = default;
196 
197     virtual ndk::ScopedAStatus barringInfoChanged(
198             RadioIndicationType type, const CellIdentity& cellIdentity,
199             const std::vector<BarringInfo>& barringInfos) override;
200 
201     virtual ndk::ScopedAStatus cdmaPrlChanged(RadioIndicationType type, int32_t version) override;
202 
203     virtual ndk::ScopedAStatus cellInfoList(RadioIndicationType type,
204                                             const std::vector<CellInfo>& records) override;
205 
206     virtual ndk::ScopedAStatus currentLinkCapacityEstimate(
207             RadioIndicationType type, const LinkCapacityEstimate& lce) override;
208 
209     virtual ndk::ScopedAStatus currentPhysicalChannelConfigs(
210             RadioIndicationType type, const std::vector<PhysicalChannelConfig>& configs) override;
211 
212     virtual ndk::ScopedAStatus currentSignalStrength(RadioIndicationType type,
213                                                      const SignalStrength& signalStrength) override;
214 
215     virtual ndk::ScopedAStatus imsNetworkStateChanged(RadioIndicationType type) override;
216 
217     virtual ndk::ScopedAStatus networkScanResult(RadioIndicationType type,
218                                                  const NetworkScanResult& result) override;
219 
220     virtual ndk::ScopedAStatus networkStateChanged(RadioIndicationType type) override;
221 
222     virtual ndk::ScopedAStatus nitzTimeReceived(RadioIndicationType type,
223                                                 const std::string& nitzTime, int64_t receivedTimeMs,
224                                                 int64_t ageMs) override;
225 
226     virtual ndk::ScopedAStatus registrationFailed(RadioIndicationType type,
227                                                   const CellIdentity& cellIdentity,
228                                                   const std::string& chosenPlmn, int32_t domain,
229                                                   int32_t causeCode,
230                                                   int32_t additionalCauseCode) override;
231 
232     virtual ndk::ScopedAStatus restrictedStateChanged(RadioIndicationType type,
233                                                       PhoneRestrictedState state) override;
234 
235     virtual ndk::ScopedAStatus suppSvcNotify(RadioIndicationType type,
236                                              const SuppSvcNotification& suppSvc) override;
237 
238     virtual ndk::ScopedAStatus voiceRadioTechChanged(RadioIndicationType type,
239                                                      RadioTechnology rat) override;
240 
241     virtual ndk::ScopedAStatus emergencyNetworkScanResult(
242             RadioIndicationType type, const EmergencyRegResult& result) override;
243 
244     virtual ndk::ScopedAStatus cellularIdentifierDisclosed(
245             RadioIndicationType type, const CellularIdentifierDisclosure& disclosures) override;
246 
247     virtual ndk::ScopedAStatus securityAlgorithmsUpdated(
248             RadioIndicationType type,
249             const SecurityAlgorithmUpdate& securityAlgorithmUpdate) override;
250 };
251 
252 // The main test class for Radio AIDL Network.
253 class RadioNetworkTest : public RadioServiceTest {
254   public:
255     void SetUp() override;
256 
257     /* radio network service handle */
258     std::shared_ptr<IRadioNetwork> radio_network;
259     /* radio network response handle */
260     std::shared_ptr<RadioNetworkResponse> radioRsp_network;
261     /* radio network indication handle */
262     std::shared_ptr<RadioNetworkIndication> radioInd_network;
263 
264     void invokeAndExpectResponse(std::function<ndk::ScopedAStatus(int32_t serial)> request,
265                                  std::vector<RadioError> errors_to_check);
266 
267     // Helper function to reduce copy+paste
268     void testSetUsageSetting_InvalidValues(std::vector<RadioError> errors);
269 
270     void stopNetworkScan();
271 };
272