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/sim/BnRadioSimIndication.h> 20 #include <aidl/android/hardware/radio/sim/BnRadioSimResponse.h> 21 #include <aidl/android/hardware/radio/sim/IRadioSim.h> 22 23 #include "radio_aidl_hal_utils.h" 24 25 using namespace aidl::android::hardware::radio::sim; 26 27 class RadioSimTest; 28 29 /* Callback class for radio SIM response */ 30 class RadioSimResponse : public BnRadioSimResponse { 31 protected: 32 RadioServiceTest& parent_sim; 33 34 public: 35 RadioSimResponse(RadioServiceTest& parent_sim); 36 virtual ~RadioSimResponse() = default; 37 38 RadioResponseInfo rspInfo; 39 CarrierRestrictions carrierRestrictionsResp; 40 SimLockMultiSimPolicy multiSimPolicyResp; 41 bool canToggleUiccApplicationsEnablement; 42 bool areUiccApplicationsEnabled; 43 PhonebookCapacity capacity; 44 int32_t updatedRecordIndex; 45 std::string imsi; 46 47 virtual ndk::ScopedAStatus acknowledgeRequest(int32_t serial) override; 48 49 virtual ndk::ScopedAStatus areUiccApplicationsEnabledResponse(const RadioResponseInfo& info, 50 bool enabled) override; 51 52 virtual ndk::ScopedAStatus changeIccPin2ForAppResponse(const RadioResponseInfo& info, 53 int32_t remainingRetries) override; 54 55 virtual ndk::ScopedAStatus changeIccPinForAppResponse(const RadioResponseInfo& info, 56 int32_t remainingRetries) override; 57 58 virtual ndk::ScopedAStatus enableUiccApplicationsResponse( 59 const RadioResponseInfo& info) override; 60 61 virtual ndk::ScopedAStatus getAllowedCarriersResponse( 62 const RadioResponseInfo& info, const CarrierRestrictions& carriers, 63 const SimLockMultiSimPolicy multiSimPolicy) override; 64 65 virtual ndk::ScopedAStatus getCdmaSubscriptionResponse( 66 const RadioResponseInfo& info, const std::string& mdn, const std::string& hSid, 67 const std::string& hNid, const std::string& min, const std::string& prl) override; 68 69 virtual ndk::ScopedAStatus getCdmaSubscriptionSourceResponse( 70 const RadioResponseInfo& info, CdmaSubscriptionSource source) override; 71 72 virtual ndk::ScopedAStatus getFacilityLockForAppResponse(const RadioResponseInfo& info, 73 int32_t response) override; 74 75 virtual ndk::ScopedAStatus getIccCardStatusResponse(const RadioResponseInfo& info, 76 const CardStatus& cardStatus) override; 77 78 virtual ndk::ScopedAStatus getImsiForAppResponse(const RadioResponseInfo& info, 79 const std::string& imsi) override; 80 81 virtual ndk::ScopedAStatus getSimPhonebookCapacityResponse( 82 const RadioResponseInfo& info, const PhonebookCapacity& capacity) override; 83 84 virtual ndk::ScopedAStatus getSimPhonebookRecordsResponse( 85 const RadioResponseInfo& info) override; 86 87 virtual ndk::ScopedAStatus iccCloseLogicalChannelResponse( 88 const RadioResponseInfo& info) override; 89 90 virtual ndk::ScopedAStatus iccCloseLogicalChannelWithSessionInfoResponse( 91 const RadioResponseInfo& info) override; 92 93 virtual ndk::ScopedAStatus iccIoForAppResponse(const RadioResponseInfo& info, 94 const IccIoResult& iccIo) override; 95 96 virtual ndk::ScopedAStatus iccOpenLogicalChannelResponse( 97 const RadioResponseInfo& info, int32_t channelId, 98 const std::vector<uint8_t>& selectResponse) override; 99 100 virtual ndk::ScopedAStatus iccTransmitApduBasicChannelResponse( 101 const RadioResponseInfo& info, const IccIoResult& result) override; 102 103 virtual ndk::ScopedAStatus iccTransmitApduLogicalChannelResponse( 104 const RadioResponseInfo& info, const IccIoResult& result) override; 105 106 virtual ndk::ScopedAStatus reportStkServiceIsRunningResponse( 107 const RadioResponseInfo& info) override; 108 109 virtual ndk::ScopedAStatus requestIccSimAuthenticationResponse( 110 const RadioResponseInfo& info, const IccIoResult& result) override; 111 112 virtual ndk::ScopedAStatus sendEnvelopeResponse(const RadioResponseInfo& info, 113 const std::string& commandResponse) override; 114 115 virtual ndk::ScopedAStatus sendEnvelopeWithStatusResponse(const RadioResponseInfo& info, 116 const IccIoResult& iccIo) override; 117 118 virtual ndk::ScopedAStatus sendTerminalResponseToSimResponse( 119 const RadioResponseInfo& info) override; 120 121 virtual ndk::ScopedAStatus setAllowedCarriersResponse(const RadioResponseInfo& info) override; 122 123 virtual ndk::ScopedAStatus setCarrierInfoForImsiEncryptionResponse( 124 const RadioResponseInfo& info) override; 125 126 virtual ndk::ScopedAStatus setCdmaSubscriptionSourceResponse( 127 const RadioResponseInfo& info) override; 128 129 virtual ndk::ScopedAStatus setFacilityLockForAppResponse(const RadioResponseInfo& info, 130 int32_t retry) override; 131 132 virtual ndk::ScopedAStatus setSimCardPowerResponse(const RadioResponseInfo& info) override; 133 134 virtual ndk::ScopedAStatus setUiccSubscriptionResponse(const RadioResponseInfo& info) override; 135 136 virtual ndk::ScopedAStatus supplyIccPin2ForAppResponse(const RadioResponseInfo& info, 137 int32_t remainingRetries) override; 138 139 virtual ndk::ScopedAStatus supplyIccPinForAppResponse(const RadioResponseInfo& info, 140 int32_t remainingRetries) override; 141 142 virtual ndk::ScopedAStatus supplyIccPuk2ForAppResponse(const RadioResponseInfo& info, 143 int32_t remainingRetries) override; 144 145 virtual ndk::ScopedAStatus supplyIccPukForAppResponse(const RadioResponseInfo& info, 146 int32_t remainingRetries) override; 147 148 virtual ndk::ScopedAStatus supplySimDepersonalizationResponse( 149 const RadioResponseInfo& info, PersoSubstate persoType, 150 int32_t remainingRetries) override; 151 152 virtual ndk::ScopedAStatus updateSimPhonebookRecordsResponse( 153 const RadioResponseInfo& info, int32_t updatedRecordIndex) override; 154 }; 155 156 /* Callback class for radio SIM indication */ 157 class RadioSimIndication : public BnRadioSimIndication { 158 protected: 159 RadioServiceTest& parent_sim; 160 161 public: 162 RadioSimIndication(RadioServiceTest& parent_sim); 163 virtual ~RadioSimIndication() = default; 164 165 virtual ndk::ScopedAStatus carrierInfoForImsiEncryption(RadioIndicationType info) override; 166 167 virtual ndk::ScopedAStatus cdmaSubscriptionSourceChanged( 168 RadioIndicationType type, CdmaSubscriptionSource cdmaSource) override; 169 170 virtual ndk::ScopedAStatus simPhonebookChanged(RadioIndicationType type) override; 171 172 virtual ndk::ScopedAStatus simPhonebookRecordsReceived( 173 RadioIndicationType type, PbReceivedStatus status, 174 const std::vector<PhonebookRecordInfo>& records) override; 175 176 virtual ndk::ScopedAStatus simRefresh(RadioIndicationType type, 177 const SimRefreshResult& refreshResult) override; 178 179 virtual ndk::ScopedAStatus simStatusChanged(RadioIndicationType type) override; 180 181 virtual ndk::ScopedAStatus stkEventNotify(RadioIndicationType type, 182 const std::string& cmd) override; 183 184 virtual ndk::ScopedAStatus stkProactiveCommand(RadioIndicationType type, 185 const std::string& cmd) override; 186 187 virtual ndk::ScopedAStatus stkSessionEnd(RadioIndicationType type) override; 188 189 virtual ndk::ScopedAStatus subscriptionStatusChanged(RadioIndicationType type, 190 bool activate) override; 191 192 virtual ndk::ScopedAStatus uiccApplicationsEnablementChanged(RadioIndicationType type, 193 bool enabled) override; 194 }; 195 196 // The main test class for Radio AIDL SIM. 197 class RadioSimTest : public RadioServiceTest { 198 public: 199 void SetUp() override; 200 201 /* Override updateSimCardStatus in RadioServiceTest to not call setResponseFunctions */ 202 void updateSimCardStatus(); 203 204 /* radio SIM service handle in RadioServiceTest */ 205 /* radio SIM response handle */ 206 std::shared_ptr<RadioSimResponse> radioRsp_sim; 207 /* radio SIM indication handle */ 208 std::shared_ptr<RadioSimIndication> radioInd_sim; 209 }; 210