1 /*
2 * Copyright (C) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "ril_sim_test.h"
17 #include "ril_test_util.h"
18
19 namespace OHOS {
20 namespace Telephony {
21 using namespace OHOS::HDI::Ril::V1_1;
22 using namespace testing::ext;
23 namespace {
24 sptr<IRil> g_rilInterface = nullptr;
25 }
26
SetUpTestCase()27 void RILSimTest::SetUpTestCase()
28 {
29 TELEPHONY_LOGI("----------RilCallTest gtest start ------------");
30 RilTestUtil::GetInstance().Init();
31 g_rilInterface = RilTestUtil::GetRilInterface();
32 }
33
TearDownTestCase()34 void RILSimTest::TearDownTestCase() {}
35
SetUp()36 void RILSimTest::SetUp() {}
37
TearDown()38 void RILSimTest::TearDown() {}
39
40 /**
41 * @tc.number Telephony_DriverSystem_GetSimStatus_V1_0100
42 * @tc.name Get sim status
43 * @tc.desc Function test
44 */
45 HWTEST_F(RILSimTest, Telephony_DriverSystem_GetSimStatus_V1_0100, Function | MediumTest | Level2)
46 {
47 if (g_rilInterface == nullptr || !RilTestUtil::HasVoiceCapability() || !RilTestUtil::IsValidSlotId(SLOTID_1)) {
48 return;
49 }
50 int32_t ret = g_rilInterface->GetSimStatus(SLOTID_1, RilTestUtil::GetSerialId());
51 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
52 EXPECT_EQ(SUCCESS, ret);
53 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_GET_SIM_STATUS));
54 }
55
56 /**
57 * @tc.number Telephony_DriverSystem_GetSimStatus_V1_0200
58 * @tc.name Get sim status
59 * @tc.desc Function test
60 */
61 HWTEST_F(RILSimTest, Telephony_DriverSystem_GetSimStatus_V1_0200, Function | MediumTest | Level2)
62 {
63 if (g_rilInterface == nullptr || !RilTestUtil::HasVoiceCapability() || !RilTestUtil::IsValidSlotId(SLOTID_2)) {
64 return;
65 }
66 int32_t ret = g_rilInterface->GetSimStatus(SLOTID_2, RilTestUtil::GetSerialId());
67 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
68 EXPECT_EQ(SUCCESS, ret);
69 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_GET_SIM_STATUS));
70 }
71
72 /**
73 * @tc.number Telephony_DriverSystem_GetSimIO_V1_0100
74 * @tc.name Get sim IO
75 * @tc.desc Function test
76 */
77 HWTEST_F(RILSimTest, Telephony_DriverSystem_GetSimIO_V1_0100, Function | MediumTest | Level3)
78 {
79 if (!RilTestUtil::IsReady(SLOTID_1)) {
80 return;
81 }
82 SimIoRequestInfo msg;
83 msg.command = 0xc0;
84 msg.fileId = 0x2FE2;
85 msg.p1 = 0;
86 msg.p2 = 0;
87 msg.p3 = 15;
88 msg.data = "";
89 msg.path = "3F00";
90 msg.pin2 = "";
91 int32_t ret = g_rilInterface->GetSimIO(SLOTID_1, RilTestUtil::GetSerialId(), msg);
92 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
93 EXPECT_EQ(SUCCESS, ret);
94 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_GET_SIM_IO));
95 }
96
97 /**
98 * @tc.number Telephony_DriverSystem_GetSimIO_V1_0200
99 * @tc.name Get sim IO
100 * @tc.desc Function test
101 */
102 HWTEST_F(RILSimTest, Telephony_DriverSystem_GetSimIO_V1_0200, Function | MediumTest | Level3)
103 {
104 if (!RilTestUtil::IsReady(SLOTID_2)) {
105 return;
106 }
107 SimIoRequestInfo msg;
108 msg.command = 0xC0;
109 // ICCID
110 msg.fileId = 0x2FE2;
111 msg.p1 = 0;
112 msg.p2 = 0;
113 msg.p3 = 15;
114 msg.data = "";
115 msg.path = "3F00";
116 msg.pin2 = "";
117 int32_t ret = g_rilInterface->GetSimIO(SLOTID_2, RilTestUtil::GetSerialId(), msg);
118 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
119 EXPECT_EQ(SUCCESS, ret);
120 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_GET_SIM_IO));
121 }
122
123 /**
124 * @tc.number Telephony_DriverSystem_GetImsi_V1_0100
125 * @tc.name Get imsi
126 * @tc.desc Function test
127 */
128 HWTEST_F(RILSimTest, Telephony_DriverSystem_GetImsi_V1_0100, Function | MediumTest | Level3)
129 {
130 if (!RilTestUtil::IsReady(SLOTID_1)) {
131 return;
132 }
133 int32_t ret = g_rilInterface->GetImsi(SLOTID_1, RilTestUtil::GetSerialId());
134 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
135 EXPECT_EQ(SUCCESS, ret);
136 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_GET_IMSI));
137 }
138
139 /**
140 * @tc.number Telephony_DriverSystem_GetImsi_V1_0200
141 * @tc.name Get imsi
142 * @tc.desc Function test
143 */
144 HWTEST_F(RILSimTest, Telephony_DriverSystem_GetImsi_V1_0200, Function | MediumTest | Level3)
145 {
146 if (!RilTestUtil::IsReady(SLOTID_2)) {
147 return;
148 }
149 int32_t ret = g_rilInterface->GetImsi(SLOTID_2, RilTestUtil::GetSerialId());
150 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
151 EXPECT_EQ(SUCCESS, ret);
152 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_GET_IMSI));
153 }
154
155 /**
156 * @tc.number Telephony_DriverSystem_SetActiveSim_V1_0100
157 * @tc.name Set active sim
158 * @tc.desc Function test
159 */
160 HWTEST_F(RILSimTest, Telephony_DriverSystem_SetActiveSim_V1_0100, Function | MediumTest | Level3)
161 {
162 if (!RilTestUtil::IsReady(SLOTID_1)) {
163 return;
164 }
165 int32_t enable = 1;
166 int32_t index = 1; // ENTITY_CARD
167 int32_t ret = g_rilInterface->SetActiveSim(SLOTID_1, RilTestUtil::GetSerialId(), index, enable);
168 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
169 EXPECT_EQ(SUCCESS, ret);
170 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_SET_ACTIVE_SIM));
171 }
172
173 /**
174 * @tc.number Telephony_DriverSystem_SetActiveSim_V1_0200
175 * @tc.name Set active sim
176 * @tc.desc Function test
177 */
178 HWTEST_F(RILSimTest, Telephony_DriverSystem_SetActiveSim_V1_0200, Function | MediumTest | Level3)
179 {
180 if (!RilTestUtil::IsReady(SLOTID_2)) {
181 return;
182 }
183 int32_t enable = 1;
184 int32_t index = 1; // ENTITY_CARD
185 int32_t ret = g_rilInterface->SetActiveSim(SLOTID_2, RilTestUtil::GetSerialId(), index, enable);
186 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
187 EXPECT_EQ(SUCCESS, ret);
188 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_SET_ACTIVE_SIM));
189 }
190
191 /**
192 * @tc.number Telephony_DriverSystem_SimStkSendTerminalResponse_V1_0100
193 * @tc.name Sim stk send terminal response
194 * @tc.desc Function test
195 */
196 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimStkSendTerminalResponse_V1_0100, Function | MediumTest | Level3)
197 {
198 if (!RilTestUtil::IsReady(SLOTID_1)) {
199 return;
200 }
201 std::string cmd = "send terminal response";
202 int32_t ret = g_rilInterface->SimStkSendTerminalResponse(SLOTID_1, RilTestUtil::GetSerialId(), cmd);
203 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
204 EXPECT_EQ(SUCCESS, ret);
205 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_STK_SEND_TERMINAL_RESPONSE));
206 }
207
208 /**
209 * @tc.number Telephony_DriverSystem_SimStkSendTerminalResponse_V1_0200
210 * @tc.name Sim stk send terminal response
211 * @tc.desc Function test
212 */
213 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimStkSendTerminalResponse_V1_0200, Function | MediumTest | Level3)
214 {
215 if (!RilTestUtil::IsReady(SLOTID_2)) {
216 return;
217 }
218 std::string cmd = "send terminal response";
219 int32_t ret = g_rilInterface->SimStkSendTerminalResponse(SLOTID_2, RilTestUtil::GetSerialId(), cmd);
220 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
221 EXPECT_EQ(SUCCESS, ret);
222 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_STK_SEND_TERMINAL_RESPONSE));
223 }
224
225 /**
226 * @tc.number Telephony_DriverSystem_SimStkSendEnvelope_V1_0100
227 * @tc.name Sim stk send envelope
228 * @tc.desc Function test
229 */
230 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimStkSendEnvelope_V1_0100, Function | MediumTest | Level3)
231 {
232 if (!RilTestUtil::IsReady(SLOTID_1)) {
233 return;
234 }
235 std::string cmd = "send envelope";
236 int32_t ret = g_rilInterface->SimStkSendEnvelope(SLOTID_1, RilTestUtil::GetSerialId(), cmd);
237 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
238 EXPECT_EQ(SUCCESS, ret);
239 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_STK_SEND_ENVELOPE));
240 }
241
242 /**
243 * @tc.number Telephony_DriverSystem_SimStkSendEnvelope_V1_0200
244 * @tc.name Sim stk send envelope
245 * @tc.desc Function test
246 */
247 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimStkSendEnvelope_V1_0200, Function | MediumTest | Level3)
248 {
249 if (!RilTestUtil::IsReady(SLOTID_2)) {
250 return;
251 }
252 std::string cmd = "send envelope";
253 int32_t ret = g_rilInterface->SimStkSendEnvelope(SLOTID_2, RilTestUtil::GetSerialId(), cmd);
254 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
255 EXPECT_EQ(SUCCESS, ret);
256 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_STK_SEND_ENVELOPE));
257 }
258
259 /**
260 * @tc.number Telephony_DriverSystem_SimStkSendCallSetupRequestResult_V1_0100
261 * @tc.name Sim stk send call setup requestResult
262 * @tc.desc Function test
263 */
264 HWTEST_F(
265 RILSimTest, Telephony_DriverSystem_SimStkSendCallSetupRequestResult_V1_0100, Function | MediumTest | Level3)
266 {
267 if (!RilTestUtil::IsReady(SLOTID_1)) {
268 return;
269 }
270 int32_t ret = g_rilInterface->SimStkSendCallSetupRequestResult(SLOTID_1, RilTestUtil::GetSerialId(), true);
271 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
272 EXPECT_EQ(SUCCESS, ret);
273 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_STK_SEND_CALL_SETUP_REQUEST_RESULT));
274 }
275
276 /**
277 * @tc.number Telephony_DriverSystem_SimStkSendCallSetupRequestResult_V1_0200
278 * @tc.name Sim stk send call setup requestResult
279 * @tc.desc Function test
280 */
281 HWTEST_F(
282 RILSimTest, Telephony_DriverSystem_SimStkSendCallSetupRequestResult_V1_0200, Function | MediumTest | Level3)
283 {
284 if (!RilTestUtil::IsReady(SLOTID_2)) {
285 return;
286 }
287 int32_t ret = g_rilInterface->SimStkSendCallSetupRequestResult(SLOTID_2, RilTestUtil::GetSerialId(), true);
288 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
289 EXPECT_EQ(SUCCESS, ret);
290 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_STK_SEND_CALL_SETUP_REQUEST_RESULT));
291 }
292
293 /**
294 * @tc.number Telephony_DriverSystem_SimStkIsReady_V1_0100
295 * @tc.name Sim stk is ready
296 * @tc.desc Function test
297 */
298 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimStkIsReady_V1_0100, Function | MediumTest | Level3)
299 {
300 if (!RilTestUtil::IsReady(SLOTID_1)) {
301 return;
302 }
303 int32_t ret = g_rilInterface->SimStkIsReady(SLOTID_1, RilTestUtil::GetSerialId());
304 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
305 EXPECT_EQ(SUCCESS, ret);
306 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_STK_IS_READY));
307 }
308
309 /**
310 * @tc.number Telephony_DriverSystem_SimStkIsReady_V1_0200
311 * @tc.name Sim stk is ready
312 * @tc.desc Function test
313 */
314 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimStkIsReady_V1_0200, Function | MediumTest | Level3)
315 {
316 if (!RilTestUtil::IsReady(SLOTID_2)) {
317 return;
318 }
319 int32_t ret = g_rilInterface->SimStkIsReady(SLOTID_2, RilTestUtil::GetSerialId());
320 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
321 EXPECT_EQ(SUCCESS, ret);
322 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_STK_IS_READY));
323 }
324
325 /**
326 * @tc.number Telephony_DriverSystem_SetRadioProtocol_V1_0100
327 * @tc.name Set radio protocol
328 * @tc.desc Function test
329 */
330 HWTEST_F(RILSimTest, Telephony_DriverSystem_SetRadioProtocol_V1_0100, Function | MediumTest | Level3)
331 {
332 if (!RilTestUtil::IsReady(SLOTID_1)) {
333 return;
334 }
335 RadioProtocol protocol;
336 protocol.slotId = SLOTID_1;
337 int32_t ret = g_rilInterface->SetRadioProtocol(SLOTID_1, RilTestUtil::GetSerialId(), protocol);
338 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
339 EXPECT_EQ(SUCCESS, ret);
340 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_RADIO_PROTOCOL));
341 }
342
343 /**
344 * @tc.number Telephony_DriverSystem_SetRadioProtocol_V1_0200
345 * @tc.name Set radio protocol
346 * @tc.desc Function test
347 */
348 HWTEST_F(RILSimTest, Telephony_DriverSystem_SetRadioProtocol_V1_0200, Function | MediumTest | Level3)
349 {
350 if (!RilTestUtil::IsReady(SLOTID_2)) {
351 return;
352 }
353 RadioProtocol protocol;
354 protocol.slotId = SLOTID_2;
355 int32_t ret = g_rilInterface->SetRadioProtocol(SLOTID_2, RilTestUtil::GetSerialId(), protocol);
356 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
357 EXPECT_EQ(SUCCESS, ret);
358 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_RADIO_PROTOCOL));
359 }
360
361 /**
362 * @tc.number Telephony_DriverSystem_SimOpenLogicalChannel_V1_0100
363 * @tc.name Sim open logical channel
364 * @tc.desc Function test
365 */
366 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimOpenLogicalChannel_V1_0100, Function | MediumTest | Level3)
367 {
368 if (!RilTestUtil::IsReady(SLOTID_1)) {
369 return;
370 }
371 std::string appID = "A00000015141434C00"; // ARAM_AID
372 int32_t p2 = 0;
373 int32_t ret = g_rilInterface->SimOpenLogicalChannel(SLOTID_1, RilTestUtil::GetSerialId(), appID, p2);
374 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
375 EXPECT_EQ(SUCCESS, ret);
376 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_OPEN_LOGICAL_CHANNEL));
377 }
378
379 /**
380 * @tc.number Telephony_DriverSystem_SimTransmitApduLogicalChannel_V1_0100
381 * @tc.name Sim transmit apdu logical channel
382 * @tc.desc Function test
383 */
384 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimTransmitApduLogicalChannel_V1_0100, Function | MediumTest | Level3)
385 {
386 if (!RilTestUtil::IsReady(SLOTID_1)) {
387 return;
388 }
389 ApduSimIORequestInfo reqInfo;
390 reqInfo.channelId = RilTestUtil::GetCallback()->GetCurrentChannelId();
391 reqInfo.type = 0x80; // CLA
392 reqInfo.instruction = 0xCA; // COMMAND;
393 reqInfo.p1 = 0xFF;
394 reqInfo.p2 = 0x40;
395 reqInfo.p3 = 0x00;
396 reqInfo.data = "";
397 int32_t ret = g_rilInterface->SimTransmitApduLogicalChannel(SLOTID_1, RilTestUtil::GetSerialId(), reqInfo);
398 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
399 EXPECT_EQ(SUCCESS, ret);
400 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_TRANSMIT_APDU_LOGICAL_CHANNEL));
401 }
402
403 /**
404 * @tc.number Telephony_DriverSystem_SimCloseLogicalChannel_V1_0100
405 * @tc.name Sim close logical channel
406 * @tc.desc Function test
407 */
408 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimCloseLogicalChannel_V1_0100, Function | MediumTest | Level3)
409 {
410 if (!RilTestUtil::IsReady(SLOTID_1)) {
411 return;
412 }
413 int32_t ret = g_rilInterface->SimCloseLogicalChannel(
414 SLOTID_1, RilTestUtil::GetSerialId(), RilTestUtil::GetCallback()->GetCurrentChannelId());
415 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
416 EXPECT_EQ(SUCCESS, ret);
417 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_CLOSE_LOGICAL_CHANNEL));
418 }
419
420 /**
421 * @tc.number Telephony_DriverSystem_SimCloseLogicalChannel_V1_0100
422 * @tc.name Sim open logical channel
423 * @tc.desc Function test
424 */
425 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimOpenLogicalChannel_V1_0200, Function | MediumTest | Level3)
426 {
427 if (!RilTestUtil::IsReady(SLOTID_2)) {
428 return;
429 }
430 std::string appID = "A00000015141434C00"; // ARAM_AID
431 int32_t p2 = 0;
432 int32_t ret = g_rilInterface->SimOpenLogicalChannel(SLOTID_2, RilTestUtil::GetSerialId(), appID, p2);
433 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
434 EXPECT_EQ(SUCCESS, ret);
435 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_OPEN_LOGICAL_CHANNEL));
436 }
437
438 /**
439 * @tc.number Telephony_DriverSystem_SimTransmitApduLogicalChannel_V1_0200
440 * @tc.name Sim transmit apdu logical channel
441 * @tc.desc Function test
442 */
443 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimTransmitApduLogicalChannel_V1_0200, Function | MediumTest | Level3)
444 {
445 if (!RilTestUtil::IsReady(SLOTID_2)) {
446 return;
447 }
448 ApduSimIORequestInfo reqInfo;
449 reqInfo.channelId = RilTestUtil::GetCallback()->GetCurrentChannelId();
450 reqInfo.type = 0x80; // CLA
451 reqInfo.instruction = 0xCA; // COMMAND;
452 reqInfo.p1 = 0xFF;
453 reqInfo.p2 = 0x40;
454 reqInfo.p3 = 0x00;
455 reqInfo.data = "";
456 int32_t ret = g_rilInterface->SimTransmitApduLogicalChannel(SLOTID_2, RilTestUtil::GetSerialId(), reqInfo);
457 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
458 EXPECT_EQ(SUCCESS, ret);
459 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_TRANSMIT_APDU_LOGICAL_CHANNEL));
460 }
461
462 /**
463 * @tc.number Telephony_DriverSystem_SimCloseLogicalChannel_V1_0100
464 * @tc.name Sim close logical channel
465 * @tc.desc Function test
466 */
467 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimCloseLogicalChannel_V1_0200, Function | MediumTest | Level3)
468 {
469 if (!RilTestUtil::IsReady(SLOTID_2)) {
470 return;
471 }
472 int32_t ret = g_rilInterface->SimCloseLogicalChannel(
473 SLOTID_2, RilTestUtil::GetSerialId(), RilTestUtil::GetCallback()->GetCurrentChannelId());
474 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
475 EXPECT_EQ(SUCCESS, ret);
476 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_CLOSE_LOGICAL_CHANNEL));
477 }
478
479 /**
480 * @tc.number Telephony_DriverSystem_SimTransmitApduBasicChannel_V1_0100
481 * @tc.name Sim transmit apdu basic channel
482 * @tc.desc Function test
483 */
484 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimTransmitApduBasicChannel_V1_0100, Function | MediumTest | Level3)
485 {
486 if (!RilTestUtil::IsReady(SLOTID_1)) {
487 return;
488 }
489 ApduSimIORequestInfo reqInfo;
490 reqInfo.type = 0x80; // CLA
491 reqInfo.instruction = 0xCA; // COMMAND;
492 reqInfo.p1 = 0xFF;
493 reqInfo.p2 = 0x40;
494 reqInfo.p3 = 0x00;
495 reqInfo.data = "";
496 int32_t ret = g_rilInterface->SimTransmitApduBasicChannel(SLOTID_1, RilTestUtil::GetSerialId(), reqInfo);
497 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
498 EXPECT_EQ(SUCCESS, ret);
499 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_TRANSMIT_APDU_BASIC_CHANNEL));
500 }
501
502 /**
503 * @tc.number Telephony_DriverSystem_SimTransmitApduBasicChannel_V1_0200
504 * @tc.name Sim transmit apdu basic channel
505 * @tc.desc Function test
506 */
507 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimTransmitApduBasicChannel_V1_0200, Function | MediumTest | Level3)
508 {
509 if (!RilTestUtil::IsReady(SLOTID_2)) {
510 return;
511 }
512 ApduSimIORequestInfo reqInfo;
513 reqInfo.type = 0x80; // CLA
514 reqInfo.instruction = 0xCA; // COMMAND;
515 reqInfo.p1 = 0xFF;
516 reqInfo.p2 = 0x40;
517 reqInfo.p3 = 0x00;
518 reqInfo.data = "";
519 int32_t ret = g_rilInterface->SimTransmitApduBasicChannel(SLOTID_2, RilTestUtil::GetSerialId(), reqInfo);
520 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
521 EXPECT_EQ(SUCCESS, ret);
522 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_TRANSMIT_APDU_BASIC_CHANNEL));
523 }
524
525 /**
526 * @tc.number Telephony_DriverSystem_SimAuthentication_V1_0100
527 * @tc.name Sim authentication
528 * @tc.desc Function test
529 */
530 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimAuthentication_V1_0100, Function | MediumTest | Level3)
531 {
532 if (!RilTestUtil::IsReady(SLOTID_1)) {
533 return;
534 }
535 SimAuthenticationRequestInfo simAuthInfo;
536 simAuthInfo.serial = SIM_AUTH_EAP_AKA_TYPE;
537 simAuthInfo.aid = "USIM_AID";
538 simAuthInfo.authData = "authData";
539 int32_t ret = g_rilInterface->SimAuthentication(SLOTID_1, RilTestUtil::GetSerialId(), simAuthInfo);
540 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
541 EXPECT_EQ(SUCCESS, ret);
542 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_AUTHENTICATION));
543 }
544
545 /**
546 * @tc.number Telephony_DriverSystem_SimAuthentication_V1_0200
547 * @tc.name Sim authentication
548 * @tc.desc Function test
549 */
550 HWTEST_F(RILSimTest, Telephony_DriverSystem_SimAuthentication_V1_0200, Function | MediumTest | Level3)
551 {
552 if (!RilTestUtil::IsReady(SLOTID_2)) {
553 return;
554 }
555 SimAuthenticationRequestInfo simAuthInfo;
556 simAuthInfo.serial = SIM_AUTH_EAP_AKA_TYPE;
557 simAuthInfo.aid = "USIM_AID";
558 simAuthInfo.authData = "authData";
559 int32_t ret = g_rilInterface->SimAuthentication(SLOTID_2, RilTestUtil::GetSerialId(), simAuthInfo);
560 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
561 EXPECT_EQ(SUCCESS, ret);
562 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_AUTHENTICATION));
563 }
564
565 /**
566 * @tc.number Telephony_DriverSystem_GetSimLockStatus_V1_0100
567 * @tc.name Get Sim lock status
568 * @tc.desc Function test
569 */
570 HWTEST_F(RILSimTest, Telephony_DriverSystem_GetSimLockStatus_V1_0100, Function | MediumTest | Level3)
571 {
572 #ifdef TEL_TEST_PIN_PUK
573 if (!RilTestUtil::IsReady(SLOTID_1)) {
574 return;
575 }
576 SimLockInfo simLockInfo;
577 simLockInfo.fac = "SC"; // FAC_PIN_LOCK
578 simLockInfo.mode = 2; // MODE
579 simLockInfo.classx = 0;
580 char *FAC_PIN_LOCK = "SC";
581 int32_t ret = g_rilInterface->GetSimLockStatus(SLOTID_1, RilTestUtil::GetSerialId(), simLockInfo);
582 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
583 EXPECT_EQ(SUCCESS, ret);
584 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_GET_SIM_LOCK_STATUS));
585 #endif
586 ASSERT_TRUE(true);
587 }
588
589 /**
590 * @tc.number Telephony_DriverSystem_GetSimLockStatus_V1_0200
591 * @tc.name Get Sim lock status
592 * @tc.desc Function test
593 */
594 HWTEST_F(RILSimTest, Telephony_DriverSystem_GetSimLockStatus_V1_0200, Function | MediumTest | Level3)
595 {
596 #ifdef TEL_TEST_PIN_PUK
597 if (!RilTestUtil::IsReady(SLOTID_2)) {
598 return;
599 }
600 SimLockInfo simLockInfo;
601 simLockInfo.fac = "SC"; // FAC_PIN_LOCK
602 simLockInfo.mode = 2; // MODE
603 simLockInfo.classx = 0;
604 char *FAC_PIN_LOCK = "SC";
605 int32_t ret = g_rilInterface->GetSimLockStatus(SLOTID_2, RilTestUtil::GetSerialId(), simLockInfo);
606 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
607 EXPECT_EQ(SUCCESS, ret);
608 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_GET_SIM_LOCK_STATUS));
609 #endif
610 ASSERT_TRUE(true);
611 }
612
613 /**
614 * @tc.number Telephony_DriverSystem_SetSimLock_V1_0100
615 * @tc.name Set Sim lock
616 * @tc.desc Function test
617 */
618 HWTEST_F(RILSimTest, Telephony_DriverSystem_SetSimLock_V1_0100, Function | MediumTest | Level3)
619 {
620 #ifdef TEL_TEST_PIN_PUK
621 if (!RilTestUtil::IsReady(SLOTID_1)) {
622 return;
623 }
624 SimLockInfo simLockInfo;
625 simLockInfo.fac = "SC"; // FAC_PIN_LOCK
626 simLockInfo.mode = 2; // MODE
627 simLockInfo.classx = 0;
628 simLockInfo.passwd = "1234";
629 char *FAC_PIN_LOCK = "SC";
630 int32_t ret = g_rilInterface->SetSimLock(SLOTID_1, RilTestUtil::GetSerialId(), simLockInfo);
631 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
632 EXPECT_EQ(SUCCESS, ret);
633 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_SET_SIM_LOCK));
634 #endif
635 ASSERT_TRUE(true);
636 }
637
638 /**
639 * @tc.number Telephony_DriverSystem_SetSimLock_V1_0200
640 * @tc.name Set Sim lock
641 * @tc.desc Function test
642 */
643 HWTEST_F(RILSimTest, Telephony_DriverSystem_SetSimLock_V1_0200, Function | MediumTest | Level3)
644 {
645 #ifdef TEL_TEST_PIN_PUK
646 if (!RilTestUtil::IsReady(SLOTID_2)) {
647 return;
648 }
649 SimLockInfo simLockInfo;
650 simLockInfo.fac = "SC"; // FAC_PIN_LOCK
651 simLockInfo.mode = 2; // MODE
652 simLockInfo.classx = 0;
653 simLockInfo.passwd = "1234";
654 char *FAC_PIN_LOCK = "SC";
655 int32_t ret = g_rilInterface->SetSimLock(SLOTID_2, RilTestUtil::GetSerialId(), simLockInfo);
656 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
657 EXPECT_EQ(SUCCESS, ret);
658 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_SET_SIM_LOCK));
659 #endif
660 ASSERT_TRUE(true);
661 }
662
663 /**
664 * @tc.number Telephony_DriverSystem_ChangeSimPassword_V1_0100
665 * @tc.name Change sim password
666 * @tc.desc Function test
667 */
668 HWTEST_F(RILSimTest, Telephony_DriverSystem_ChangeSimPassword_V1_0100, Function | MediumTest | Level3)
669 {
670 #ifdef TEL_TEST_PIN_PUK
671 if (!RilTestUtil::IsReady(SLOTID_1)) {
672 return;
673 }
674 ISimPasswordInfo simPassword;
675 simPassword.fac = "SC"; // FAC_PIN_LOCK
676 simPassword.oldPassword = "1234";
677 simPassword.newPassword = "1234";
678 simPassword.passwordLength = 4;
679 int32_t ret = g_rilInterface->ChangeSimPassword(SLOTID_1, RilTestUtil::GetSerialId(), simPassword);
680 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
681 EXPECT_EQ(SUCCESS, ret);
682 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_CHANGE_SIM_PASSWORD));
683 #endif
684 ASSERT_TRUE(true);
685 }
686
687 /**
688 * @tc.number Telephony_DriverSystem_ChangeSimPassword_V1_0200
689 * @tc.name Change sim password
690 * @tc.desc Function test
691 */
692 HWTEST_F(RILSimTest, Telephony_DriverSystem_ChangeSimPassword_V1_0200, Function | MediumTest | Level3)
693 {
694 #ifdef TEL_TEST_PIN_PUK
695 if (!RilTestUtil::IsReady(SLOTID_2)) {
696 return;
697 }
698 ISimPasswordInfo simPassword;
699 simPassword.fac = "SC"; // FAC_PIN_LOCK
700 simPassword.oldPassword = "1234";
701 simPassword.newPassword = "1234";
702 simPassword.passwordLength = 4;
703 int32_t ret = g_rilInterface->ChangeSimPassword(SLOTID_2, RilTestUtil::GetSerialId(), simPassword);
704 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
705 EXPECT_EQ(SUCCESS, ret);
706 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_CHANGE_SIM_PASSWORD));
707 #endif
708 ASSERT_TRUE(true);
709 }
710
711 /**
712 * @tc.number Telephony_DriverSystem_UnlockPin_V1_0100
713 * @tc.name Unlock pin
714 * @tc.desc Function test
715 */
716 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPin_V1_0100, Function | MediumTest | Level3)
717 {
718 #ifdef TEL_TEST_PIN_PUK
719 if (!RilTestUtil::IsReady(SLOTID_1)) {
720 return;
721 }
722 std::string pin = "1234";
723 int32_t ret = g_rilInterface->UnlockPin(SLOTID_1, RilTestUtil::GetSerialId(), pin);
724 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
725 EXPECT_EQ(SUCCESS, ret);
726 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PIN));
727 #endif
728 ASSERT_TRUE(true);
729 }
730
731 /**
732 * @tc.number Telephony_DriverSystem_UnlockPin_V1_0200
733 * @tc.name Unlock pin
734 * @tc.desc Function test
735 */
736 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPin_V1_0200, Function | MediumTest | Level3)
737 {
738 #ifdef TEL_TEST_PIN_PUK
739 if (!RilTestUtil::IsReady(SLOTID_2)) {
740 return;
741 }
742 std::string pin = "1234";
743 int32_t ret = g_rilInterface->UnlockPin(SLOTID_2, RilTestUtil::GetSerialId(), pin);
744 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
745 EXPECT_EQ(SUCCESS, ret);
746 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PIN));
747 #endif
748 ASSERT_TRUE(true);
749 }
750
751 /**
752 * @tc.number Telephony_DriverSystem_UnlockPuk_V1_0100
753 * @tc.name Unlock puk
754 * @tc.desc Function test
755 */
756 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPuk_V1_0100, Function | MediumTest | Level3)
757 {
758 #ifdef TEL_TEST_PIN_PUK
759 if (!RilTestUtil::IsReady(SLOTID_1)) {
760 return;
761 }
762 std::string puk = "42014264";
763 std::string pin = "1234";
764 int32_t ret = g_rilInterface->UnlockPuk(SLOTID_1, RilTestUtil::GetSerialId(), puk, pin);
765 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
766 EXPECT_EQ(SUCCESS, ret);
767 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PUK));
768 #endif
769 ASSERT_TRUE(true);
770 }
771
772 /**
773 * @tc.number Telephony_DriverSystem_UnlockPuk_V1_0200
774 * @tc.name Unlock puk
775 * @tc.desc Function test
776 */
777 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPuk_V1_0200, Function | MediumTest | Level3)
778 {
779 #ifdef TEL_TEST_PIN_PUK
780 if (!RilTestUtil::IsReady(SLOTID_2)) {
781 return;
782 }
783 std::string puk = "42014264";
784 std::string pin = "1234";
785 int32_t ret = g_rilInterface->UnlockPuk(SLOTID_2, RilTestUtil::GetSerialId(), puk, pin);
786 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
787 EXPECT_EQ(SUCCESS, ret);
788 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PUK));
789 #endif
790 ASSERT_TRUE(true);
791 }
792
793 /**
794 * @tc.number Telephony_DriverSystem_UnlockPin2_V1_0100
795 * @tc.name Unlock pin2
796 * @tc.desc Function test
797 */
798 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPin2_V1_0100, Function | MediumTest | Level3)
799 {
800 #ifdef TEL_TEST_PIN_PUK
801 if (!RilTestUtil::IsReady(SLOTID_1)) {
802 return;
803 }
804 std::string pin2 = "1234";
805 int32_t ret = g_rilInterface->UnlockPin2(SLOTID_1, RilTestUtil::GetSerialId(), pin2);
806 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
807 EXPECT_EQ(SUCCESS, ret);
808 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PIN2));
809 #endif
810 ASSERT_TRUE(true);
811 }
812
813 /**
814 * @tc.number Telephony_DriverSystem_UnlockPin2_V1_0200
815 * @tc.name Unlock pin2
816 * @tc.desc Function test
817 */
818 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPin2_V1_0200, Function | MediumTest | Level3)
819 {
820 #ifdef TEL_TEST_PIN_PUK
821 if (!RilTestUtil::IsReady(SLOTID_2)) {
822 return;
823 }
824 std::string pin2 = "1234";
825 int32_t ret = g_rilInterface->UnlockPin2(SLOTID_2, RilTestUtil::GetSerialId(), pin2);
826 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
827 EXPECT_EQ(SUCCESS, ret);
828 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PIN2));
829 #endif
830 ASSERT_TRUE(true);
831 }
832
833 /**
834 * @tc.number Telephony_DriverSystem_UnlockPuk2_V1_0100
835 * @tc.name Unlock puk2
836 * @tc.desc Function test
837 */
838 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPuk2_V1_0100, Function | MediumTest | Level3)
839 {
840 #ifdef TEL_TEST_PIN_PUK
841 if (!RilTestUtil::IsReady(SLOTID_1)) {
842 return;
843 }
844 std::string puk2 = "42014264";
845 std::string pin2 = "1234";
846 int32_t ret = g_rilInterface->UnlockPuk2(SLOTID_1, RilTestUtil::GetSerialId(), puk2, pin2);
847 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
848 EXPECT_EQ(SUCCESS, ret);
849 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PUK2));
850 #endif
851 ASSERT_TRUE(true);
852 }
853
854 /**
855 * @tc.number Telephony_DriverSystem_UnlockPuk2_V1_0200
856 * @tc.name Unlock puk2
857 * @tc.desc Function test
858 */
859 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPuk2_V1_0200, Function | MediumTest | Level3)
860 {
861 #ifdef TEL_TEST_PIN_PUK
862 if (!RilTestUtil::IsReady(SLOTID_2)) {
863 return;
864 }
865 std::string puk2 = "42014264";
866 std::string pin2 = "1234";
867 int32_t ret = g_rilInterface->UnlockPuk2(SLOTID_2, RilTestUtil::GetSerialId(), puk2, pin2);
868 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
869 EXPECT_EQ(SUCCESS, ret);
870 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PUK2));
871 #endif
872 ASSERT_TRUE(true);
873 }
874
875 /**
876 * @tc.number Telephony_DriverSystem_UnlockSimLock_V1_0100
877 * @tc.name Unlock sim lock
878 * @tc.desc Function test
879 */
880 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockSimLock_V1_0100, Function | MediumTest | Level3)
881 {
882 #ifdef TEL_TEST_PIN_PUK
883 if (!RilTestUtil::IsReady(SLOTID_1)) {
884 return;
885 }
886 int32_t lockType = 0;
887 std::string key = "1234"; // PN_PIN_LOCK
888 int32_t ret = g_rilInterface->UnlockSimLock(SLOTID_1, RilTestUtil::GetSerialId(), lockType, key);
889 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
890 EXPECT_EQ(SUCCESS, ret);
891 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_SIM_LOCK));
892 #endif
893 ASSERT_TRUE(true);
894 }
895
896 /**
897 * @tc.number Telephony_DriverSystem_UnlockSimLock_V1_0200
898 * @tc.name Unlock sim lock
899 * @tc.desc Function test
900 */
901 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockSimLock_V1_0200, Function | MediumTest | Level3)
902 {
903 #ifdef TEL_TEST_PIN_PUK
904 if (!RilTestUtil::IsReady(SLOTID_2)) {
905 return;
906 }
907 int32_t lockType = 0;
908 std::string key = "1234"; // PN_PIN_LOCK
909 int32_t ret = g_rilInterface->UnlockSimLock(SLOTID_2, RilTestUtil::GetSerialId(), lockType, key);
910 RilTestUtil::WaitFor(WAIT_TIME_SECOND);
911 EXPECT_EQ(SUCCESS, ret);
912 ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_SIM_LOCK));
913 #endif
914 ASSERT_TRUE(true);
915 }
916
917 } // namespace Telephony
918 } // namespace OHOS