1 /* 2 * Copyright (C) 2020 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 <android-base/logging.h> 20 21 #include <chrono> 22 #include <condition_variable> 23 #include <mutex> 24 25 #include <android/hardware/radio/config/1.1/IRadioConfig.h> 26 #include <android/hardware/radio/config/1.1/types.h> 27 #include <android/hardware/radio/config/1.2/IRadioConfigIndication.h> 28 #include <android/hardware/radio/config/1.2/IRadioConfigResponse.h> 29 #include <android/hardware/radio/config/1.2/types.h> 30 #include <android/hardware/radio/config/1.3/IRadioConfig.h> 31 #include <android/hardware/radio/config/1.3/IRadioConfigResponse.h> 32 #include <gtest/gtest.h> 33 #include <hidl/GtestPrinter.h> 34 #include <hidl/ServiceManagement.h> 35 #include <log/log.h> 36 37 #include "vts_test_util.h" 38 39 using namespace ::android::hardware::radio::config::V1_3; 40 41 using ::android::sp; 42 using ::android::hardware::hidl_string; 43 using ::android::hardware::hidl_vec; 44 using ::android::hardware::Return; 45 using ::android::hardware::Void; 46 using ::android::hardware::radio::config::V1_1::ModemsConfig; 47 using ::android::hardware::radio::config::V1_1::PhoneCapability; 48 using ::android::hardware::radio::config::V1_2::IRadioConfigIndication; 49 using ::android::hardware::radio::config::V1_2::SimSlotStatus; 50 using ::android::hardware::radio::config::V1_3::IRadioConfig; 51 using ::android::hardware::radio::config::V1_3::IRadioConfigResponse; 52 using ::android::hardware::radio::V1_0::RadioResponseInfo; 53 54 #define RADIO_SERVICE_NAME "slot1" 55 56 class RadioConfigHidlTest; 57 58 /* Callback class for radio config response */ 59 class RadioConfigResponse : public IRadioConfigResponse { 60 protected: 61 RadioResponseWaiter& parent; 62 63 public: 64 RadioResponseInfo rspInfo; 65 PhoneCapability phoneCap; 66 bool modemReducedFeatureSet1; 67 68 RadioConfigResponse(RadioResponseWaiter& parent); 69 virtual ~RadioConfigResponse() = default; 70 71 Return<void> getSimSlotsStatusResponse( 72 const RadioResponseInfo& info, 73 const ::android::hardware::hidl_vec< 74 ::android::hardware::radio::config::V1_0::SimSlotStatus>& slotStatus); 75 76 Return<void> getSimSlotsStatusResponse_1_2( 77 const RadioResponseInfo& info, 78 const ::android::hardware::hidl_vec<SimSlotStatus>& slotStatus); 79 80 Return<void> setSimSlotsMappingResponse(const RadioResponseInfo& info); 81 82 Return<void> getPhoneCapabilityResponse(const RadioResponseInfo& info, 83 const PhoneCapability& phoneCapability); 84 85 Return<void> setPreferredDataModemResponse(const RadioResponseInfo& info); 86 87 Return<void> getModemsConfigResponse(const RadioResponseInfo& info, 88 const ModemsConfig& mConfig); 89 90 Return<void> setModemsConfigResponse(const RadioResponseInfo& info); 91 92 Return<void> getHalDeviceCapabilitiesResponse( 93 const ::android::hardware::radio::V1_6::RadioResponseInfo& info, 94 bool modemReducedFeatureSet1); 95 }; 96 97 /* Callback class for radio config indication */ 98 class RadioConfigIndication : public IRadioConfigIndication { 99 protected: 100 RadioConfigHidlTest& parent; 101 102 public: 103 RadioConfigIndication(RadioConfigHidlTest& parent); 104 virtual ~RadioConfigIndication() = default; 105 106 Return<void> simSlotsStatusChanged_1_2( 107 ::android::hardware::radio::V1_0::RadioIndicationType type, 108 const ::android::hardware::hidl_vec<SimSlotStatus>& slotStatus); 109 }; 110 111 // The main test class for Radio config HIDL. 112 class RadioConfigHidlTest : public ::testing::TestWithParam<std::string>, 113 public RadioResponseWaiter { 114 public: 115 virtual void SetUp() override; 116 117 void updateSimCardStatus(); 118 119 /* radio config service handle */ 120 sp<IRadioConfig> radioConfig; 121 122 /* radio config response handle */ 123 sp<RadioConfigResponse> radioConfigRsp; 124 }; 125