Sarah Chin | fc5603b | 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/data/BnRadioDataIndication.h> |
| 20 | #include <aidl/android/hardware/radio/data/BnRadioDataResponse.h> |
| 21 | #include <aidl/android/hardware/radio/data/IRadioData.h> |
| 22 | |
| 23 | #include "radio_aidl_hal_utils.h" |
| 24 | |
| 25 | using namespace aidl::android::hardware::radio::data; |
| 26 | using aidl::android::hardware::radio::sim::CardStatus; |
| 27 | |
| 28 | class RadioDataTest; |
| 29 | |
| 30 | /* Callback class for radio data response */ |
| 31 | class RadioDataResponse : public BnRadioDataResponse { |
| 32 | protected: |
| 33 | RadioResponseWaiter& parent_data; |
| 34 | |
| 35 | public: |
| 36 | RadioDataResponse(RadioResponseWaiter& parent_data); |
| 37 | virtual ~RadioDataResponse() = default; |
| 38 | |
| 39 | RadioResponseInfo rspInfo; |
| 40 | int32_t allocatedPduSessionId; |
| 41 | SetupDataCallResult setupDataCallResult; |
| 42 | |
| 43 | virtual ndk::ScopedAStatus acknowledgeRequest(int32_t serial) override; |
| 44 | |
| 45 | virtual ndk::ScopedAStatus allocatePduSessionIdResponse(const RadioResponseInfo& info, |
| 46 | int32_t id) override; |
| 47 | |
| 48 | virtual ndk::ScopedAStatus cancelHandoverResponse(const RadioResponseInfo& info) override; |
| 49 | |
| 50 | virtual ndk::ScopedAStatus deactivateDataCallResponse(const RadioResponseInfo& info) override; |
| 51 | |
| 52 | virtual ndk::ScopedAStatus getDataCallListResponse( |
| 53 | const RadioResponseInfo& info, |
| 54 | const std::vector<SetupDataCallResult>& dcResponse) override; |
| 55 | |
| 56 | virtual ndk::ScopedAStatus getSlicingConfigResponse( |
| 57 | const RadioResponseInfo& info, const SlicingConfig& slicingConfig) override; |
| 58 | |
| 59 | virtual ndk::ScopedAStatus releasePduSessionIdResponse(const RadioResponseInfo& info) override; |
| 60 | |
| 61 | virtual ndk::ScopedAStatus setDataAllowedResponse(const RadioResponseInfo& info) override; |
| 62 | |
| 63 | virtual ndk::ScopedAStatus setDataProfileResponse(const RadioResponseInfo& info) override; |
| 64 | |
| 65 | virtual ndk::ScopedAStatus setDataThrottlingResponse(const RadioResponseInfo& info) override; |
| 66 | |
| 67 | virtual ndk::ScopedAStatus setInitialAttachApnResponse(const RadioResponseInfo& info) override; |
| 68 | |
| 69 | virtual ndk::ScopedAStatus setupDataCallResponse( |
| 70 | const RadioResponseInfo& info, const SetupDataCallResult& dcResponse) override; |
| 71 | |
| 72 | virtual ndk::ScopedAStatus startHandoverResponse(const RadioResponseInfo& info) override; |
| 73 | |
| 74 | virtual ndk::ScopedAStatus startKeepaliveResponse(const RadioResponseInfo& info, |
| 75 | const KeepaliveStatus& status) override; |
| 76 | |
| 77 | virtual ndk::ScopedAStatus stopKeepaliveResponse(const RadioResponseInfo& info) override; |
| 78 | }; |
| 79 | |
| 80 | /* Callback class for radio data indication */ |
| 81 | class RadioDataIndication : public BnRadioDataIndication { |
| 82 | protected: |
| 83 | RadioDataTest& parent_data; |
| 84 | |
| 85 | public: |
| 86 | RadioDataIndication(RadioDataTest& parent_data); |
| 87 | virtual ~RadioDataIndication() = default; |
| 88 | |
| 89 | virtual ndk::ScopedAStatus dataCallListChanged( |
| 90 | RadioIndicationType type, const std::vector<SetupDataCallResult>& dcList) override; |
| 91 | |
| 92 | virtual ndk::ScopedAStatus keepaliveStatus(RadioIndicationType type, |
| 93 | const KeepaliveStatus& status) override; |
| 94 | |
| 95 | virtual ndk::ScopedAStatus pcoData(RadioIndicationType type, const PcoDataInfo& pco) override; |
| 96 | |
| 97 | virtual ndk::ScopedAStatus unthrottleApn(RadioIndicationType type, |
| 98 | const DataProfileInfo& dataProfile) override; |
| 99 | }; |
| 100 | |
| 101 | // The main test class for Radio AIDL Data. |
| 102 | class RadioDataTest : public ::testing::TestWithParam<std::string>, public RadioResponseWaiter { |
| 103 | protected: |
| 104 | /* Get current data call list */ |
| 105 | ndk::ScopedAStatus getDataCallList(); |
| 106 | |
| 107 | public: |
| 108 | virtual void SetUp() override; |
| 109 | |
| 110 | /* radio data service handle */ |
| 111 | std::shared_ptr<IRadioData> radio_data; |
| 112 | /* radio data response handle */ |
| 113 | std::shared_ptr<RadioDataResponse> radioRsp_data; |
| 114 | /* radio data indication handle */ |
| 115 | std::shared_ptr<RadioDataIndication> radioInd_data; |
| 116 | }; |