blob: d47bdeb921b16ac8a0a814fcbbbedbb5ae965f92 [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>
arunvoddud9bbd442022-11-15 08:39:26 +000022#include <aidl/android/hardware/radio/modem/ImeiInfo.h>
Sarah Chinfc5603b2021-12-21 11:34:00 -080023
24#include "radio_aidl_hal_utils.h"
25
Sarah Chinfc5603b2021-12-21 11:34:00 -080026using namespace aidl::android::hardware::radio::modem;
27
28class RadioModemTest;
29
30/* Callback class for radio modem response */
31class RadioModemResponse : public BnRadioModemResponse {
32 protected:
Sarah Chinc83bce42021-12-29 00:35:12 -080033 RadioServiceTest& parent_modem;
Sarah Chinfc5603b2021-12-21 11:34:00 -080034
35 public:
Sarah Chinc83bce42021-12-29 00:35:12 -080036 RadioModemResponse(RadioServiceTest& parent_modem);
Sarah Chinfc5603b2021-12-21 11:34:00 -080037 virtual ~RadioModemResponse() = default;
38
39 RadioResponseInfo rspInfo;
40 bool isModemEnabled;
Tim Lin62cf4542022-04-07 09:33:45 +080041 bool enableModemResponseToggle = false;
Sarah Chinfc5603b2021-12-21 11:34:00 -080042
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
arunvoddud9bbd442022-11-15 08:39:26 +000056 virtual ndk::ScopedAStatus getImeiResponse(const RadioResponseInfo& info,
57 const std::optional<ImeiInfo>& config) override;
58
Sarah Chinfc5603b2021-12-21 11:34:00 -080059 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 */
91class RadioModemIndication : public BnRadioModemIndication {
92 protected:
Sarah Chinc83bce42021-12-29 00:35:12 -080093 RadioServiceTest& parent_modem;
Sarah Chinfc5603b2021-12-21 11:34:00 -080094
95 public:
Sarah Chinc83bce42021-12-29 00:35:12 -080096 RadioModemIndication(RadioServiceTest& parent_modem);
Sarah Chinfc5603b2021-12-21 11:34:00 -080097 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 Chinbb35a432023-05-02 21:11:41 -0700115class RadioModemTest : public RadioServiceTest {
Sarah Chinfc5603b2021-12-21 11:34:00 -0800116 public:
Sarah Chinbb35a432023-05-02 21:11:41 -0700117 void SetUp() override;
Sarah Chinfc5603b2021-12-21 11:34:00 -0800118
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};