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/modem/BnRadioModemIndication.h> |
| 20 | #include <aidl/android/hardware/radio/modem/BnRadioModemResponse.h> |
| 21 | #include <aidl/android/hardware/radio/modem/IRadioModem.h> |
| 22 | |
| 23 | #include "radio_aidl_hal_utils.h" |
| 24 | |
| 25 | using namespace aidl::android::hardware::radio::config; |
| 26 | using namespace aidl::android::hardware::radio::modem; |
| 27 | |
| 28 | class RadioModemTest; |
| 29 | |
| 30 | /* Callback class for radio modem response */ |
| 31 | class RadioModemResponse : public BnRadioModemResponse { |
| 32 | protected: |
| 33 | RadioResponseWaiter& parent_modem; |
| 34 | |
| 35 | public: |
| 36 | RadioModemResponse(RadioResponseWaiter& parent_modem); |
| 37 | virtual ~RadioModemResponse() = default; |
| 38 | |
| 39 | RadioResponseInfo rspInfo; |
| 40 | bool isModemEnabled; |
| 41 | bool enableModemResponseToggle; |
| 42 | |
| 43 | virtual ndk::ScopedAStatus acknowledgeRequest(int32_t serial) override; |
| 44 | |
| 45 | virtual ndk::ScopedAStatus enableModemResponse(const RadioResponseInfo& info) override; |
| 46 | |
| 47 | virtual ndk::ScopedAStatus getBasebandVersionResponse(const RadioResponseInfo& info, |
| 48 | const std::string& version) override; |
| 49 | |
| 50 | virtual ndk::ScopedAStatus getDeviceIdentityResponse(const RadioResponseInfo& info, |
| 51 | const std::string& imei, |
| 52 | const std::string& imeisv, |
| 53 | const std::string& esn, |
| 54 | const std::string& meid) override; |
| 55 | |
| 56 | virtual ndk::ScopedAStatus getHardwareConfigResponse( |
| 57 | const RadioResponseInfo& info, const std::vector<HardwareConfig>& config) override; |
| 58 | |
| 59 | virtual ndk::ScopedAStatus getModemActivityInfoResponse( |
| 60 | const RadioResponseInfo& info, const ActivityStatsInfo& activityInfo) override; |
| 61 | |
| 62 | virtual ndk::ScopedAStatus getModemStackStatusResponse(const RadioResponseInfo& info, |
| 63 | const bool enabled) override; |
| 64 | |
| 65 | virtual ndk::ScopedAStatus getRadioCapabilityResponse(const RadioResponseInfo& info, |
| 66 | const RadioCapability& rc) override; |
| 67 | |
| 68 | virtual ndk::ScopedAStatus nvReadItemResponse(const RadioResponseInfo& info, |
| 69 | const std::string& result) override; |
| 70 | |
| 71 | virtual ndk::ScopedAStatus nvResetConfigResponse(const RadioResponseInfo& info) override; |
| 72 | |
| 73 | virtual ndk::ScopedAStatus nvWriteCdmaPrlResponse(const RadioResponseInfo& info) override; |
| 74 | |
| 75 | virtual ndk::ScopedAStatus nvWriteItemResponse(const RadioResponseInfo& info) override; |
| 76 | |
| 77 | virtual ndk::ScopedAStatus requestShutdownResponse(const RadioResponseInfo& info) override; |
| 78 | |
| 79 | virtual ndk::ScopedAStatus sendDeviceStateResponse(const RadioResponseInfo& info) override; |
| 80 | |
| 81 | virtual ndk::ScopedAStatus setRadioCapabilityResponse(const RadioResponseInfo& info, |
| 82 | const RadioCapability& rc) override; |
| 83 | |
| 84 | virtual ndk::ScopedAStatus setRadioPowerResponse(const RadioResponseInfo& info) override; |
| 85 | }; |
| 86 | |
| 87 | /* Callback class for radio modem indication */ |
| 88 | class RadioModemIndication : public BnRadioModemIndication { |
| 89 | protected: |
| 90 | RadioModemTest& parent_modem; |
| 91 | |
| 92 | public: |
| 93 | RadioModemIndication(RadioModemTest& parent_modem); |
| 94 | virtual ~RadioModemIndication() = default; |
| 95 | |
| 96 | virtual ndk::ScopedAStatus hardwareConfigChanged( |
| 97 | RadioIndicationType type, const std::vector<HardwareConfig>& configs) override; |
| 98 | |
| 99 | virtual ndk::ScopedAStatus modemReset(RadioIndicationType type, |
| 100 | const std::string& reason) override; |
| 101 | |
| 102 | virtual ndk::ScopedAStatus radioCapabilityIndication(RadioIndicationType type, |
| 103 | const RadioCapability& rc) override; |
| 104 | |
| 105 | virtual ndk::ScopedAStatus radioStateChanged(RadioIndicationType type, |
| 106 | RadioState radioState) override; |
| 107 | |
| 108 | virtual ndk::ScopedAStatus rilConnected(RadioIndicationType type) override; |
| 109 | }; |
| 110 | |
| 111 | // The main test class for Radio AIDL Modem. |
| 112 | class RadioModemTest : public ::testing::TestWithParam<std::string>, public RadioResponseWaiter { |
| 113 | public: |
| 114 | virtual void SetUp() override; |
| 115 | |
| 116 | /* radio modem service handle */ |
| 117 | std::shared_ptr<IRadioModem> radio_modem; |
| 118 | /* radio modem response handle */ |
| 119 | std::shared_ptr<RadioModemResponse> radioRsp_modem; |
| 120 | /* radio modem indication handle */ |
| 121 | std::shared_ptr<RadioModemIndication> radioInd_modem; |
| 122 | }; |