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