1 /*
2 * Copyright (C) 2017 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 #include <radio_hidl_hal_utils.h>
18
19 using namespace ::android::hardware::radio::V1_0;
20
21 /*
22 * Test IRadio.getDataRegistrationState() for the response returned.
23 */
TEST_F(RadioHidlTest,getDataRegistrationState)24 TEST_F(RadioHidlTest, getDataRegistrationState) {
25 int serial = GetRandomSerialNumber();
26
27 radio->getDataRegistrationState(serial);
28
29 EXPECT_EQ(std::cv_status::no_timeout, wait());
30 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
31 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
32
33 if (cardStatus.cardState == CardState::ABSENT) {
34 EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
35 }
36 }
37
38 /*
39 * Test IRadio.setupDataCall() for the response returned.
40 */
TEST_F(RadioHidlTest,setupDataCall)41 TEST_F(RadioHidlTest, setupDataCall) {
42 int serial = GetRandomSerialNumber();
43
44 RadioTechnology radioTechnology = RadioTechnology::LTE;
45
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();
65
66 bool modemCognitive = false;
67 bool roamingAllowed = false;
68 bool isRoaming = false;
69
70 radio->setupDataCall(serial, radioTechnology, dataProfileInfo, modemCognitive, roamingAllowed,
71 isRoaming);
72
73 EXPECT_EQ(std::cv_status::no_timeout, wait());
74 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
75 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
76
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 ||
82 CheckOEMError());
83 }
84 }
85
86 /*
87 * Test IRadio.deactivateDataCall() for the response returned.
88 */
TEST_F(RadioHidlTest,deactivateDataCall)89 TEST_F(RadioHidlTest, deactivateDataCall) {
90 int serial = GetRandomSerialNumber();
91 int cid = 1;
92 bool reasonRadioShutDown = false;
93
94 radio->deactivateDataCall(serial, cid, reasonRadioShutDown);
95
96 EXPECT_EQ(std::cv_status::no_timeout, wait());
97 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
98 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
99
100 if (cardStatus.cardState == CardState::ABSENT) {
101 EXPECT_EQ(RadioError::INVALID_CALL_ID, radioRsp->rspInfo.error);
102 }
103 }
104
105 /*
106 * Test IRadio.getDataCallList() for the response returned.
107 */
TEST_F(RadioHidlTest,getDataCallList)108 TEST_F(RadioHidlTest, getDataCallList) {
109 int serial = GetRandomSerialNumber();
110
111 radio->getDataCallList(serial);
112
113 EXPECT_EQ(std::cv_status::no_timeout, wait());
114 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
115 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
116
117 if (cardStatus.cardState == CardState::ABSENT) {
118 ASSERT_TRUE(radioRsp->rspInfo.error == RadioError::NONE ||
119 radioRsp->rspInfo.error == RadioError::RADIO_NOT_AVAILABLE);
120 }
121 }
122
123 /*
124 * Test IRadio.setInitialAttachApn() for the response returned.
125 */
TEST_F(RadioHidlTest,setInitialAttachApn)126 TEST_F(RadioHidlTest, setInitialAttachApn) {
127 int serial = GetRandomSerialNumber();
128
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();
148
149 bool modemCognitive = true;
150 bool isRoaming = false;
151
152 radio->setInitialAttachApn(serial, dataProfileInfo, modemCognitive, isRoaming);
153
154 EXPECT_EQ(std::cv_status::no_timeout, wait());
155 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
156 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
157
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 ||
162 CheckOEMError());
163 }
164 }
165
166 /*
167 * Test IRadio.setDataAllowed() for the response returned.
168 */
TEST_F(RadioHidlTest,setDataAllowed)169 TEST_F(RadioHidlTest, setDataAllowed) {
170 int serial = GetRandomSerialNumber();
171 bool allow = true;
172
173 radio->setDataAllowed(serial, allow);
174
175 EXPECT_EQ(std::cv_status::no_timeout, wait());
176 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
177 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
178
179 if (cardStatus.cardState == CardState::ABSENT) {
180 EXPECT_EQ(RadioError::NONE, radioRsp->rspInfo.error);
181 }
182 }
183
184 /*
185 * Test IRadio.setDataProfile() for the response returned.
186 */
TEST_F(RadioHidlTest,setDataProfile)187 TEST_F(RadioHidlTest, setDataProfile) {
188 int serial = GetRandomSerialNumber();
189
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();
210
211 // Create a dataProfileInfoList
212 android::hardware::hidl_vec<DataProfileInfo> dataProfileInfoList = {dataProfileInfo};
213
214 bool isRoadming = false;
215
216 radio->setDataProfile(serial, dataProfileInfoList, isRoadming);
217
218 EXPECT_EQ(std::cv_status::no_timeout, wait());
219 EXPECT_EQ(RadioResponseType::SOLICITED, radioRsp->rspInfo.type);
220 EXPECT_EQ(serial, radioRsp->rspInfo.serial);
221
222 if (cardStatus.cardState == CardState::ABSENT) {
223 // TODO(shuoq): Will add error check when we know the expected error from QC
224 }
225 }
226