Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 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: |
Sarah Chin | 91997ac | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 32 | RadioServiceTest& parent_sim; |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 33 | |
| 34 | public: |
Sarah Chin | 91997ac | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 35 | RadioSimResponse(RadioServiceTest& parent_sim); |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 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; |
Sarah Chin | 52de0ad | 2022-01-28 01:02:16 -0800 | [diff] [blame^] | 45 | std::string imsi; |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 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 iccIoForAppResponse(const RadioResponseInfo& info, |
| 91 | const IccIoResult& iccIo) override; |
| 92 | |
| 93 | virtual ndk::ScopedAStatus iccOpenLogicalChannelResponse( |
| 94 | const RadioResponseInfo& info, int32_t channelId, |
| 95 | const std::vector<uint8_t>& selectResponse) override; |
| 96 | |
| 97 | virtual ndk::ScopedAStatus iccTransmitApduBasicChannelResponse( |
| 98 | const RadioResponseInfo& info, const IccIoResult& result) override; |
| 99 | |
| 100 | virtual ndk::ScopedAStatus iccTransmitApduLogicalChannelResponse( |
| 101 | const RadioResponseInfo& info, const IccIoResult& result) override; |
| 102 | |
| 103 | virtual ndk::ScopedAStatus reportStkServiceIsRunningResponse( |
| 104 | const RadioResponseInfo& info) override; |
| 105 | |
| 106 | virtual ndk::ScopedAStatus requestIccSimAuthenticationResponse( |
| 107 | const RadioResponseInfo& info, const IccIoResult& result) override; |
| 108 | |
| 109 | virtual ndk::ScopedAStatus sendEnvelopeResponse(const RadioResponseInfo& info, |
| 110 | const std::string& commandResponse) override; |
| 111 | |
| 112 | virtual ndk::ScopedAStatus sendEnvelopeWithStatusResponse(const RadioResponseInfo& info, |
| 113 | const IccIoResult& iccIo) override; |
| 114 | |
| 115 | virtual ndk::ScopedAStatus sendTerminalResponseToSimResponse( |
| 116 | const RadioResponseInfo& info) override; |
| 117 | |
| 118 | virtual ndk::ScopedAStatus setAllowedCarriersResponse(const RadioResponseInfo& info) override; |
| 119 | |
| 120 | virtual ndk::ScopedAStatus setCarrierInfoForImsiEncryptionResponse( |
| 121 | const RadioResponseInfo& info) override; |
| 122 | |
| 123 | virtual ndk::ScopedAStatus setCdmaSubscriptionSourceResponse( |
| 124 | const RadioResponseInfo& info) override; |
| 125 | |
| 126 | virtual ndk::ScopedAStatus setFacilityLockForAppResponse(const RadioResponseInfo& info, |
| 127 | int32_t retry) override; |
| 128 | |
| 129 | virtual ndk::ScopedAStatus setSimCardPowerResponse(const RadioResponseInfo& info) override; |
| 130 | |
| 131 | virtual ndk::ScopedAStatus setUiccSubscriptionResponse(const RadioResponseInfo& info) override; |
| 132 | |
| 133 | virtual ndk::ScopedAStatus supplyIccPin2ForAppResponse(const RadioResponseInfo& info, |
| 134 | int32_t remainingRetries) override; |
| 135 | |
| 136 | virtual ndk::ScopedAStatus supplyIccPinForAppResponse(const RadioResponseInfo& info, |
| 137 | int32_t remainingRetries) override; |
| 138 | |
| 139 | virtual ndk::ScopedAStatus supplyIccPuk2ForAppResponse(const RadioResponseInfo& info, |
| 140 | int32_t remainingRetries) override; |
| 141 | |
| 142 | virtual ndk::ScopedAStatus supplyIccPukForAppResponse(const RadioResponseInfo& info, |
| 143 | int32_t remainingRetries) override; |
| 144 | |
| 145 | virtual ndk::ScopedAStatus supplySimDepersonalizationResponse( |
| 146 | const RadioResponseInfo& info, PersoSubstate persoType, |
| 147 | int32_t remainingRetries) override; |
| 148 | |
| 149 | virtual ndk::ScopedAStatus updateSimPhonebookRecordsResponse( |
| 150 | const RadioResponseInfo& info, int32_t updatedRecordIndex) override; |
| 151 | }; |
| 152 | |
| 153 | /* Callback class for radio SIM indication */ |
| 154 | class RadioSimIndication : public BnRadioSimIndication { |
| 155 | protected: |
Sarah Chin | 91997ac | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 156 | RadioServiceTest& parent_sim; |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 157 | |
| 158 | public: |
Sarah Chin | 91997ac | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 159 | RadioSimIndication(RadioServiceTest& parent_sim); |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 160 | virtual ~RadioSimIndication() = default; |
| 161 | |
| 162 | virtual ndk::ScopedAStatus carrierInfoForImsiEncryption(RadioIndicationType info) override; |
| 163 | |
| 164 | virtual ndk::ScopedAStatus cdmaSubscriptionSourceChanged( |
| 165 | RadioIndicationType type, CdmaSubscriptionSource cdmaSource) override; |
| 166 | |
| 167 | virtual ndk::ScopedAStatus simPhonebookChanged(RadioIndicationType type) override; |
| 168 | |
| 169 | virtual ndk::ScopedAStatus simPhonebookRecordsReceived( |
| 170 | RadioIndicationType type, PbReceivedStatus status, |
| 171 | const std::vector<PhonebookRecordInfo>& records) override; |
| 172 | |
| 173 | virtual ndk::ScopedAStatus simRefresh(RadioIndicationType type, |
| 174 | const SimRefreshResult& refreshResult) override; |
| 175 | |
| 176 | virtual ndk::ScopedAStatus simStatusChanged(RadioIndicationType type) override; |
| 177 | |
| 178 | virtual ndk::ScopedAStatus stkEventNotify(RadioIndicationType type, |
| 179 | const std::string& cmd) override; |
| 180 | |
| 181 | virtual ndk::ScopedAStatus stkProactiveCommand(RadioIndicationType type, |
| 182 | const std::string& cmd) override; |
| 183 | |
| 184 | virtual ndk::ScopedAStatus stkSessionEnd(RadioIndicationType type) override; |
| 185 | |
| 186 | virtual ndk::ScopedAStatus subscriptionStatusChanged(RadioIndicationType type, |
| 187 | bool activate) override; |
| 188 | |
| 189 | virtual ndk::ScopedAStatus uiccApplicationsEnablementChanged(RadioIndicationType type, |
| 190 | bool enabled) override; |
| 191 | }; |
| 192 | |
| 193 | // The main test class for Radio AIDL SIM. |
Sarah Chin | 91997ac | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 194 | class RadioSimTest : public ::testing::TestWithParam<std::string>, public RadioServiceTest { |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 195 | public: |
| 196 | virtual void SetUp() override; |
| 197 | |
Sarah Chin | 91997ac | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 198 | /* Override updateSimCardStatus in RadioServiceTest to not call setResponseFunctions */ |
| 199 | void updateSimCardStatus(); |
| 200 | |
| 201 | /* radio SIM service handle in RadioServiceTest */ |
Sarah Chin | d2a4119 | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 202 | /* radio SIM response handle */ |
| 203 | std::shared_ptr<RadioSimResponse> radioRsp_sim; |
| 204 | /* radio SIM indication handle */ |
| 205 | std::shared_ptr<RadioSimIndication> radioInd_sim; |
| 206 | }; |