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/config/BnRadioConfigIndication.h>
20 #include <aidl/android/hardware/radio/config/BnRadioConfigResponse.h>
21 #include <aidl/android/hardware/radio/config/IRadioConfig.h>
22 
23 #include "radio_aidl_hal_utils.h"
24 
25 using namespace aidl::android::hardware::radio::config;
26 
27 class RadioConfigTest;
28 
29 /* Callback class for radio config response */
30 class RadioConfigResponse : public BnRadioConfigResponse {
31   protected:
32     RadioServiceTest& parent_config;
33 
34   public:
35     RadioConfigResponse(RadioServiceTest& parent_config);
36     virtual ~RadioConfigResponse() = default;
37 
38     RadioResponseInfo rspInfo;
39     PhoneCapability phoneCap;
40     bool modemReducedFeatureSet1;
41     std::vector<SimSlotStatus> simSlotStatus;
42     std::vector<int32_t> currentEnabledLogicalSlots;
43 
44     virtual ndk::ScopedAStatus getSimSlotsStatusResponse(
45             const RadioResponseInfo& info, const std::vector<SimSlotStatus>& slotStatus) override;
46 
47     virtual ndk::ScopedAStatus setSimSlotsMappingResponse(const RadioResponseInfo& info) override;
48 
49     virtual ndk::ScopedAStatus getPhoneCapabilityResponse(
50             const RadioResponseInfo& info, const PhoneCapability& phoneCapability) override;
51 
52     virtual ndk::ScopedAStatus getSimultaneousCallingSupportResponse(
53             const RadioResponseInfo& info, const std::vector<int32_t>& enabledLogicalSlots) override;
54 
55     virtual ndk::ScopedAStatus setPreferredDataModemResponse(
56             const RadioResponseInfo& info) override;
57 
58     virtual ndk::ScopedAStatus getNumOfLiveModemsResponse(const RadioResponseInfo& info,
59                                                           const int8_t numOfLiveModems) override;
60 
61     virtual ndk::ScopedAStatus setNumOfLiveModemsResponse(const RadioResponseInfo& info) override;
62 
63     virtual ndk::ScopedAStatus getHalDeviceCapabilitiesResponse(
64             const RadioResponseInfo& info, bool modemReducedFeatureSet1) override;
65 };
66 
67 /* Callback class for radio config indication */
68 class RadioConfigIndication : public BnRadioConfigIndication {
69   protected:
70     RadioServiceTest& parent_config;
71 
72   public:
73     RadioConfigIndication(RadioServiceTest& parent_config);
74     virtual ~RadioConfigIndication() = default;
75 
76     virtual ndk::ScopedAStatus simSlotsStatusChanged(
77             RadioIndicationType type, const std::vector<SimSlotStatus>& slotStatus) override;
78 
79     virtual ndk::ScopedAStatus onSimultaneousCallingSupportChanged(
80             const std::vector<int32_t>& /*enabledLogicalSlots*/) override;
81 };
82 
83 // The main test class for Radio AIDL Config.
84 class RadioConfigTest : public RadioServiceTest {
85   public:
86     void SetUp() override;
87 
88     ndk::ScopedAStatus updateSimCardStatus();
89     /* Override updateSimSlotStatus in RadioServiceTest to not call setResponseFunctions */
90     void updateSimSlotStatus();
91 
92     /* radio config service handle in RadioServiceTest */
93     /* radio config response handle */
94     std::shared_ptr<RadioConfigResponse> radioRsp_config;
95     /* radio config indication handle */
96     std::shared_ptr<RadioConfigIndication> radioInd_config;
97 };
98