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