2 * Copyright (C) 2017 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include <radio_hidl_hal_utils_v1_0.h>
19 using namespace ::android::hardware::radio::V1_0;
22 * Test IRadio.getDataRegistrationState() for the response returned.
24 TEST_F(RadioHidlTest, getDataRegistrationState) {
25 int serial = GetRandomSerialNumber();
27 radio->getDataRegistrationState(serial);
29 EXPECT_EQ(std::cv_status::no_timeout, wait());
30 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
31 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
33 if (cardStatus.cardState == CardState::ABSENT) {
34 EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
39 * Test IRadio.setupDataCall() for the response returned.
41 TEST_F(RadioHidlTest, setupDataCall) {
42 int serial = GetRandomSerialNumber();
44 RadioTechnology radioTechnology = RadioTechnology::LTE;
46 DataProfileInfo dataProfileInfo;
47 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
48 dataProfileInfo.profileId = DataProfileId::IMS;
49 dataProfileInfo.apn = hidl_string("VZWIMS");
50 dataProfileInfo.protocol = hidl_string("IPV4V6");
51 dataProfileInfo.roamingProtocol = hidl_string("IPV6");
52 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
53 dataProfileInfo.user = "";
54 dataProfileInfo.password = "";
55 dataProfileInfo.type = DataProfileInfoType::THREE_GPP2;
56 dataProfileInfo.maxConnsTime = 300;
57 dataProfileInfo.maxConns = 20;
58 dataProfileInfo.waitTime = 0;
59 dataProfileInfo.enabled = true;
60 dataProfileInfo.supportedApnTypesBitmap = 320;
61 dataProfileInfo.bearerBitmap = 161543;
62 dataProfileInfo.mtu = 0;
63 dataProfileInfo.mvnoType = MvnoType::NONE;
64 dataProfileInfo.mvnoMatchData = hidl_string();
66 bool modemCognitive = false;
67 bool roamingAllowed = false;
68 bool isRoaming = false;
70 radio->setupDataCall(serial, radioTechnology, dataProfileInfo, modemCognitive, roamingAllowed,
73 EXPECT_EQ(std::cv_status::no_timeout, wait());
74 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
75 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
77 if (cardStatus.cardState == CardState::ABSENT) {
78 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE ||
79 radioRsp->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE ||
80 radioRsp->rspInfo.error == RadioError::OP_NOT_ALLOWED_BEFORE_REG_TO_NW ||
81 radioRsp->rspInfo.error == RadioError::OP_NOT_ALLOWED_DURING_VOICE_CALL ||
87 * Test IRadio.deactivateDataCall() for the response returned.
89 TEST_F(RadioHidlTest, deactivateDataCall) {
90 int serial = GetRandomSerialNumber();
92 bool reasonRadioShutDown = false;
94 radio->deactivateDataCall(serial, cid, reasonRadioShutDown);
96 EXPECT_EQ(std::cv_status::no_timeout, wait());
97 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
98 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
100 if (cardStatus.cardState == CardState::ABSENT) {
101 EXPECT_EQ(RadioError::INVALID_CALL_ID, radioRsp->rspInfo.error);
106 * Test IRadio.getDataCallList() for the response returned.
108 TEST_F(RadioHidlTest, getDataCallList) {
109 int serial = GetRandomSerialNumber();
111 radio->getDataCallList(serial);
113 EXPECT_EQ(std::cv_status::no_timeout, wait());
114 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
115 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
117 if (cardStatus.cardState == CardState::ABSENT) {
118 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE ||
119 radioRsp->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE);
124 * Test IRadio.setInitialAttachApn() for the response returned.
126 TEST_F(RadioHidlTest, setInitialAttachApn) {
127 int serial = GetRandomSerialNumber();
129 DataProfileInfo dataProfileInfo;
130 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
131 dataProfileInfo.profileId = DataProfileId::IMS;
132 dataProfileInfo.apn = hidl_string("VZWIMS");
133 dataProfileInfo.protocol = hidl_string("IPV4V6");
134 dataProfileInfo.roamingProtocol = hidl_string("IPV6");
135 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
136 dataProfileInfo.user = "";
137 dataProfileInfo.password = "";
138 dataProfileInfo.type = DataProfileInfoType::THREE_GPP2;
139 dataProfileInfo.maxConnsTime = 300;
140 dataProfileInfo.maxConns = 20;
141 dataProfileInfo.waitTime = 0;
142 dataProfileInfo.enabled = true;
143 dataProfileInfo.supportedApnTypesBitmap = 320;
144 dataProfileInfo.bearerBitmap = 161543;
145 dataProfileInfo.mtu = 0;
146 dataProfileInfo.mvnoType = MvnoType::NONE;
147 dataProfileInfo.mvnoMatchData = hidl_string();
149 bool modemCognitive = true;
150 bool isRoaming = false;
152 radio->setInitialAttachApn(serial, dataProfileInfo, modemCognitive, isRoaming);
154 EXPECT_EQ(std::cv_status::no_timeout, wait());
155 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
156 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
158 if (cardStatus.cardState == CardState::ABSENT) {
159 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE ||
160 radioRsp->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE ||
161 radioRsp->rspInfo.error == RadioError::SUBSCRIPTION_NOT_AVAILABLE ||
167 * Test IRadio.setDataAllowed() for the response returned.
169 TEST_F(RadioHidlTest, setDataAllowed) {
170 int serial = GetRandomSerialNumber();
173 radio->setDataAllowed(serial, allow);
175 EXPECT_EQ(std::cv_status::no_timeout, wait());
176 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
177 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
179 if (cardStatus.cardState == CardState::ABSENT) {
180 EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
185 * Test IRadio.setDataProfile() for the response returned.
187 TEST_F(RadioHidlTest, setDataProfile) {
188 int serial = GetRandomSerialNumber();
190 // Create a dataProfileInfo
191 DataProfileInfo dataProfileInfo;
192 memset(&dataProfileInfo, 0, sizeof(dataProfileInfo));
193 dataProfileInfo.profileId = DataProfileId::IMS;
194 dataProfileInfo.apn = hidl_string("VZWIMS");
195 dataProfileInfo.protocol = hidl_string("IPV4V6");
196 dataProfileInfo.roamingProtocol = hidl_string("IPV6");
197 dataProfileInfo.authType = ApnAuthType::NO_PAP_NO_CHAP;
198 dataProfileInfo.user = "";
199 dataProfileInfo.password = "";
200 dataProfileInfo.type = DataProfileInfoType::THREE_GPP2;
201 dataProfileInfo.maxConnsTime = 300;
202 dataProfileInfo.maxConns = 20;
203 dataProfileInfo.waitTime = 0;
204 dataProfileInfo.enabled = true;
205 dataProfileInfo.supportedApnTypesBitmap = 320;
206 dataProfileInfo.bearerBitmap = 161543;
207 dataProfileInfo.mtu = 0;
208 dataProfileInfo.mvnoType = MvnoType::NONE;
209 dataProfileInfo.mvnoMatchData = hidl_string();
211 // Create a dataProfileInfoList
212 android::hardware::hidl_vec<DataProfileInfo> dataProfileInfoList = {dataProfileInfo};
214 bool isRoadming = false;
216 radio->setDataProfile(serial, dataProfileInfoList, isRoadming);
218 EXPECT_EQ(std::cv_status::no_timeout, wait());
219 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
220 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
222 if (cardStatus.cardState == CardState::ABSENT) {
223 // TODO(shuoq): Will add error check when we know the expected error from QC