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