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> |
arunvoddu | d9bbd44 | 2022-11-15 08:39:26 +0000 | [diff] [blame] | 22 | #include <aidl/android/hardware/radio/modem/ImeiInfo.h> |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 23 | |
| 24 | #include "radio_aidl_hal_utils.h" |
| 25 | |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 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: |
Sarah Chin | c83bce4 | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 33 | RadioServiceTest& parent_modem; |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 34 | |
| 35 | public: |
Sarah Chin | c83bce4 | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 36 | RadioModemResponse(RadioServiceTest& parent_modem); |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 37 | virtual ~RadioModemResponse() = default; |
| 38 | |
| 39 | RadioResponseInfo rspInfo; |
| 40 | bool isModemEnabled; |
Tim Lin | 62cf454 | 2022-04-07 09:33:45 +0800 | [diff] [blame] | 41 | bool enableModemResponseToggle = false; |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 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 | |
arunvoddu | d9bbd44 | 2022-11-15 08:39:26 +0000 | [diff] [blame] | 56 | virtual ndk::ScopedAStatus getImeiResponse(const RadioResponseInfo& info, |
| 57 | const std::optional<ImeiInfo>& config) override; |
| 58 | |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 59 | virtual ndk::ScopedAStatus getHardwareConfigResponse( |
| 60 | const RadioResponseInfo& info, const std::vector<HardwareConfig>& config) override; |
| 61 | |
| 62 | virtual ndk::ScopedAStatus getModemActivityInfoResponse( |
| 63 | const RadioResponseInfo& info, const ActivityStatsInfo& activityInfo) override; |
| 64 | |
| 65 | virtual ndk::ScopedAStatus getModemStackStatusResponse(const RadioResponseInfo& info, |
| 66 | const bool enabled) override; |
| 67 | |
| 68 | virtual ndk::ScopedAStatus getRadioCapabilityResponse(const RadioResponseInfo& info, |
| 69 | const RadioCapability& rc) override; |
| 70 | |
| 71 | virtual ndk::ScopedAStatus nvReadItemResponse(const RadioResponseInfo& info, |
| 72 | const std::string& result) override; |
| 73 | |
| 74 | virtual ndk::ScopedAStatus nvResetConfigResponse(const RadioResponseInfo& info) override; |
| 75 | |
| 76 | virtual ndk::ScopedAStatus nvWriteCdmaPrlResponse(const RadioResponseInfo& info) override; |
| 77 | |
| 78 | virtual ndk::ScopedAStatus nvWriteItemResponse(const RadioResponseInfo& info) override; |
| 79 | |
| 80 | virtual ndk::ScopedAStatus requestShutdownResponse(const RadioResponseInfo& info) override; |
| 81 | |
| 82 | virtual ndk::ScopedAStatus sendDeviceStateResponse(const RadioResponseInfo& info) override; |
| 83 | |
| 84 | virtual ndk::ScopedAStatus setRadioCapabilityResponse(const RadioResponseInfo& info, |
| 85 | const RadioCapability& rc) override; |
| 86 | |
| 87 | virtual ndk::ScopedAStatus setRadioPowerResponse(const RadioResponseInfo& info) override; |
| 88 | }; |
| 89 | |
| 90 | /* Callback class for radio modem indication */ |
| 91 | class RadioModemIndication : public BnRadioModemIndication { |
| 92 | protected: |
Sarah Chin | c83bce4 | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 93 | RadioServiceTest& parent_modem; |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 94 | |
| 95 | public: |
Sarah Chin | c83bce4 | 2021-12-29 00:35:12 -0800 | [diff] [blame] | 96 | RadioModemIndication(RadioServiceTest& parent_modem); |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 97 | virtual ~RadioModemIndication() = default; |
| 98 | |
| 99 | virtual ndk::ScopedAStatus hardwareConfigChanged( |
| 100 | RadioIndicationType type, const std::vector<HardwareConfig>& configs) override; |
| 101 | |
| 102 | virtual ndk::ScopedAStatus modemReset(RadioIndicationType type, |
| 103 | const std::string& reason) override; |
| 104 | |
| 105 | virtual ndk::ScopedAStatus radioCapabilityIndication(RadioIndicationType type, |
| 106 | const RadioCapability& rc) override; |
| 107 | |
| 108 | virtual ndk::ScopedAStatus radioStateChanged(RadioIndicationType type, |
| 109 | RadioState radioState) override; |
| 110 | |
| 111 | virtual ndk::ScopedAStatus rilConnected(RadioIndicationType type) override; |
| 112 | }; |
| 113 | |
| 114 | // The main test class for Radio AIDL Modem. |
Sarah Chin | a1efe7a | 2023-05-02 21:11:41 -0700 | [diff] [blame^] | 115 | class RadioModemTest : public RadioServiceTest { |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 116 | public: |
Sarah Chin | a1efe7a | 2023-05-02 21:11:41 -0700 | [diff] [blame^] | 117 | void SetUp() override; |
Sarah Chin | fc5603b | 2021-12-21 11:34:00 -0800 | [diff] [blame] | 118 | |
| 119 | /* radio modem service handle */ |
| 120 | std::shared_ptr<IRadioModem> radio_modem; |
| 121 | /* radio modem response handle */ |
| 122 | std::shared_ptr<RadioModemResponse> radioRsp_modem; |
| 123 | /* radio modem indication handle */ |
| 124 | std::shared_ptr<RadioModemIndication> radioInd_modem; |
| 125 | }; |