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_2;
22 using namespace testing::ext;
23 namespace {
24 sptr<OHOS::HDI::Ril::V1_2::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_SendSimMatchedOperatorInfo_V1_0100
615  * @tc.name     Send sim matched operator info
616  * @tc.desc     Function test
617  */
618 HWTEST_F(RILSimTest, Telephony_DriverSystem_SendSimMatchedOperatorInfo_V1_0100, Function | MediumTest | Level3)
619 {
620     if (!RilTestUtil::IsReady(SLOTID_1)) {
621         return;
622     }
623     NcfgOperatorInfo ncfgOperatorInfo;
624     ncfgOperatorInfo.operName = "operName";
625     ncfgOperatorInfo.operKey = "operKey";
626     ncfgOperatorInfo.state = 0;
627     ncfgOperatorInfo.reserve = "reserve";
628     int32_t ret = g_rilInterface->SendSimMatchedOperatorInfo(SLOTID_1, RilTestUtil::GetSerialId(), ncfgOperatorInfo);
629     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
630     EXPECT_EQ(SUCCESS, ret);
631     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_SEND_NCFG_OPER_INFO));
632 }
633 
634 /**
635  * @tc.number   Telephony_DriverSystem_SendSimMatchedOperatorInfo_V1_0200
636  * @tc.name     Send sim matched operator info
637  * @tc.desc     Function test
638  */
639 HWTEST_F(RILSimTest, Telephony_DriverSystem_SendSimMatchedOperatorInfo_V1_0200, Function | MediumTest | Level3)
640 {
641     if (!RilTestUtil::IsReady(SLOTID_2)) {
642         return;
643     }
644     NcfgOperatorInfo ncfgOperatorInfo;
645     ncfgOperatorInfo.operName = "operName";
646     ncfgOperatorInfo.operKey = "operKey";
647     ncfgOperatorInfo.state = 0;
648     ncfgOperatorInfo.reserve = "reserve";
649     int32_t ret = g_rilInterface->SendSimMatchedOperatorInfo(SLOTID_2, RilTestUtil::GetSerialId(), ncfgOperatorInfo);
650     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
651     EXPECT_EQ(SUCCESS, ret);
652     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_SEND_NCFG_OPER_INFO));
653 }
654 
655 /**
656  * @tc.number   Telephony_DriverSystem_SetSimLock_V1_0100
657  * @tc.name     Set Sim lock
658  * @tc.desc     Function test
659  */
660 HWTEST_F(RILSimTest, Telephony_DriverSystem_SetSimLock_V1_0100, Function | MediumTest | Level3)
661 {
662 #ifdef TEL_TEST_PIN_PUK
663     if (!RilTestUtil::IsReady(SLOTID_1)) {
664         return;
665     }
666     SimLockInfo simLockInfo;
667     simLockInfo.fac = "SC"; // FAC_PIN_LOCK
668     simLockInfo.mode = 2; // MODE
669     simLockInfo.classx = 0;
670     simLockInfo.passwd = "1234";
671     char *FAC_PIN_LOCK = "SC";
672     int32_t ret = g_rilInterface->SetSimLock(SLOTID_1, RilTestUtil::GetSerialId(), simLockInfo);
673     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
674     EXPECT_EQ(SUCCESS, ret);
675     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_SET_SIM_LOCK));
676 #endif
677     ASSERT_TRUE(true);
678 }
679 
680 /**
681  * @tc.number   Telephony_DriverSystem_SetSimLock_V1_0200
682  * @tc.name     Set Sim lock
683  * @tc.desc     Function test
684  */
685 HWTEST_F(RILSimTest, Telephony_DriverSystem_SetSimLock_V1_0200, Function | MediumTest | Level3)
686 {
687 #ifdef TEL_TEST_PIN_PUK
688     if (!RilTestUtil::IsReady(SLOTID_2)) {
689         return;
690     }
691     SimLockInfo simLockInfo;
692     simLockInfo.fac = "SC"; // FAC_PIN_LOCK
693     simLockInfo.mode = 2; // MODE
694     simLockInfo.classx = 0;
695     simLockInfo.passwd = "1234";
696     char *FAC_PIN_LOCK = "SC";
697     int32_t ret = g_rilInterface->SetSimLock(SLOTID_2, RilTestUtil::GetSerialId(), simLockInfo);
698     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
699     EXPECT_EQ(SUCCESS, ret);
700     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_SET_SIM_LOCK));
701 #endif
702     ASSERT_TRUE(true);
703 }
704 
705 /**
706  * @tc.number   Telephony_DriverSystem_ChangeSimPassword_V1_0100
707  * @tc.name     Change sim password
708  * @tc.desc     Function test
709  */
710 HWTEST_F(RILSimTest, Telephony_DriverSystem_ChangeSimPassword_V1_0100, Function | MediumTest | Level3)
711 {
712 #ifdef TEL_TEST_PIN_PUK
713     if (!RilTestUtil::IsReady(SLOTID_1)) {
714         return;
715     }
716     ISimPasswordInfo simPassword;
717     simPassword.fac = "SC"; // FAC_PIN_LOCK
718     simPassword.oldPassword = "1234";
719     simPassword.newPassword = "1234";
720     simPassword.passwordLength = 4;
721     int32_t ret = g_rilInterface->ChangeSimPassword(SLOTID_1, RilTestUtil::GetSerialId(), simPassword);
722     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
723     EXPECT_EQ(SUCCESS, ret);
724     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_CHANGE_SIM_PASSWORD));
725 #endif
726     ASSERT_TRUE(true);
727 }
728 
729 /**
730  * @tc.number   Telephony_DriverSystem_ChangeSimPassword_V1_0200
731  * @tc.name     Change sim password
732  * @tc.desc     Function test
733  */
734 HWTEST_F(RILSimTest, Telephony_DriverSystem_ChangeSimPassword_V1_0200, Function | MediumTest | Level3)
735 {
736 #ifdef TEL_TEST_PIN_PUK
737     if (!RilTestUtil::IsReady(SLOTID_2)) {
738         return;
739     }
740     ISimPasswordInfo simPassword;
741     simPassword.fac = "SC"; // FAC_PIN_LOCK
742     simPassword.oldPassword = "1234";
743     simPassword.newPassword = "1234";
744     simPassword.passwordLength = 4;
745     int32_t ret = g_rilInterface->ChangeSimPassword(SLOTID_2, RilTestUtil::GetSerialId(), simPassword);
746     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
747     EXPECT_EQ(SUCCESS, ret);
748     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_CHANGE_SIM_PASSWORD));
749 #endif
750     ASSERT_TRUE(true);
751 }
752 
753 /**
754  * @tc.number   Telephony_DriverSystem_UnlockPin_V1_0100
755  * @tc.name     Unlock pin
756  * @tc.desc     Function test
757  */
758 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPin_V1_0100, Function | MediumTest | Level3)
759 {
760 #ifdef TEL_TEST_PIN_PUK
761     if (!RilTestUtil::IsReady(SLOTID_1)) {
762         return;
763     }
764     std::string pin = "1234";
765     int32_t ret = g_rilInterface->UnlockPin(SLOTID_1, RilTestUtil::GetSerialId(), pin);
766     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
767     EXPECT_EQ(SUCCESS, ret);
768     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PIN));
769 #endif
770     ASSERT_TRUE(true);
771 }
772 
773 /**
774  * @tc.number   Telephony_DriverSystem_UnlockPin_V1_0200
775  * @tc.name     Unlock pin
776  * @tc.desc     Function test
777  */
778 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPin_V1_0200, Function | MediumTest | Level3)
779 {
780 #ifdef TEL_TEST_PIN_PUK
781     if (!RilTestUtil::IsReady(SLOTID_2)) {
782         return;
783     }
784     std::string pin = "1234";
785     int32_t ret = g_rilInterface->UnlockPin(SLOTID_2, RilTestUtil::GetSerialId(), pin);
786     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
787     EXPECT_EQ(SUCCESS, ret);
788     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PIN));
789 #endif
790     ASSERT_TRUE(true);
791 }
792 
793 /**
794  * @tc.number   Telephony_DriverSystem_UnlockPuk_V1_0100
795  * @tc.name     Unlock puk
796  * @tc.desc     Function test
797  */
798 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPuk_V1_0100, Function | MediumTest | Level3)
799 {
800 #ifdef TEL_TEST_PIN_PUK
801     if (!RilTestUtil::IsReady(SLOTID_1)) {
802         return;
803     }
804     std::string puk = "42014264";
805     std::string pin = "1234";
806     int32_t ret = g_rilInterface->UnlockPuk(SLOTID_1, RilTestUtil::GetSerialId(), puk, pin);
807     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
808     EXPECT_EQ(SUCCESS, ret);
809     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PUK));
810 #endif
811     ASSERT_TRUE(true);
812 }
813 
814 /**
815  * @tc.number   Telephony_DriverSystem_UnlockPuk_V1_0200
816  * @tc.name     Unlock puk
817  * @tc.desc     Function test
818  */
819 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPuk_V1_0200, Function | MediumTest | Level3)
820 {
821 #ifdef TEL_TEST_PIN_PUK
822     if (!RilTestUtil::IsReady(SLOTID_2)) {
823         return;
824     }
825     std::string puk = "42014264";
826     std::string pin = "1234";
827     int32_t ret = g_rilInterface->UnlockPuk(SLOTID_2, RilTestUtil::GetSerialId(), puk, pin);
828     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
829     EXPECT_EQ(SUCCESS, ret);
830     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PUK));
831 #endif
832     ASSERT_TRUE(true);
833 }
834 
835 /**
836  * @tc.number   Telephony_DriverSystem_UnlockPin2_V1_0100
837  * @tc.name     Unlock pin2
838  * @tc.desc     Function test
839  */
840 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPin2_V1_0100, Function | MediumTest | Level3)
841 {
842 #ifdef TEL_TEST_PIN_PUK
843     if (!RilTestUtil::IsReady(SLOTID_1)) {
844         return;
845     }
846     std::string pin2 = "1234";
847     int32_t ret = g_rilInterface->UnlockPin2(SLOTID_1, RilTestUtil::GetSerialId(), pin2);
848     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
849     EXPECT_EQ(SUCCESS, ret);
850     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PIN2));
851 #endif
852     ASSERT_TRUE(true);
853 }
854 
855 /**
856  * @tc.number   Telephony_DriverSystem_UnlockPin2_V1_0200
857  * @tc.name     Unlock pin2
858  * @tc.desc     Function test
859  */
860 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPin2_V1_0200, Function | MediumTest | Level3)
861 {
862 #ifdef TEL_TEST_PIN_PUK
863     if (!RilTestUtil::IsReady(SLOTID_2)) {
864         return;
865     }
866     std::string pin2 = "1234";
867     int32_t ret = g_rilInterface->UnlockPin2(SLOTID_2, RilTestUtil::GetSerialId(), pin2);
868     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
869     EXPECT_EQ(SUCCESS, ret);
870     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PIN2));
871 #endif
872     ASSERT_TRUE(true);
873 }
874 
875 /**
876  * @tc.number   Telephony_DriverSystem_UnlockPuk2_V1_0100
877  * @tc.name     Unlock puk2
878  * @tc.desc     Function test
879  */
880 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPuk2_V1_0100, Function | MediumTest | Level3)
881 {
882 #ifdef TEL_TEST_PIN_PUK
883     if (!RilTestUtil::IsReady(SLOTID_1)) {
884         return;
885     }
886     std::string puk2 = "42014264";
887     std::string pin2 = "1234";
888     int32_t ret = g_rilInterface->UnlockPuk2(SLOTID_1, RilTestUtil::GetSerialId(), puk2, pin2);
889     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
890     EXPECT_EQ(SUCCESS, ret);
891     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PUK2));
892 #endif
893     ASSERT_TRUE(true);
894 }
895 
896 /**
897  * @tc.number   Telephony_DriverSystem_UnlockPuk2_V1_0200
898  * @tc.name     Unlock puk2
899  * @tc.desc     Function test
900  */
901 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockPuk2_V1_0200, Function | MediumTest | Level3)
902 {
903 #ifdef TEL_TEST_PIN_PUK
904     if (!RilTestUtil::IsReady(SLOTID_2)) {
905         return;
906     }
907     std::string puk2 = "42014264";
908     std::string pin2 = "1234";
909     int32_t ret = g_rilInterface->UnlockPuk2(SLOTID_2, RilTestUtil::GetSerialId(), puk2, pin2);
910     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
911     EXPECT_EQ(SUCCESS, ret);
912     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_PUK2));
913 #endif
914     ASSERT_TRUE(true);
915 }
916 
917 /**
918  * @tc.number   Telephony_DriverSystem_UnlockSimLock_V1_0100
919  * @tc.name     Unlock sim lock
920  * @tc.desc     Function test
921  */
922 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockSimLock_V1_0100, Function | MediumTest | Level3)
923 {
924 #ifdef TEL_TEST_PIN_PUK
925     if (!RilTestUtil::IsReady(SLOTID_1)) {
926         return;
927     }
928     int32_t lockType = 0;
929     std::string key = "1234"; // PN_PIN_LOCK
930     int32_t ret = g_rilInterface->UnlockSimLock(SLOTID_1, RilTestUtil::GetSerialId(), lockType, key);
931     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
932     EXPECT_EQ(SUCCESS, ret);
933     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_SIM_LOCK));
934 #endif
935     ASSERT_TRUE(true);
936 }
937 
938 /**
939  * @tc.number   Telephony_DriverSystem_UnlockSimLock_V1_0200
940  * @tc.name     Unlock sim lock
941  * @tc.desc     Function test
942  */
943 HWTEST_F(RILSimTest, Telephony_DriverSystem_UnlockSimLock_V1_0200, Function | MediumTest | Level3)
944 {
945 #ifdef TEL_TEST_PIN_PUK
946     if (!RilTestUtil::IsReady(SLOTID_2)) {
947         return;
948     }
949     int32_t lockType = 0;
950     std::string key = "1234"; // PN_PIN_LOCK
951     int32_t ret = g_rilInterface->UnlockSimLock(SLOTID_2, RilTestUtil::GetSerialId(), lockType, key);
952     RilTestUtil::WaitFor(WAIT_TIME_SECOND);
953     EXPECT_EQ(SUCCESS, ret);
954     ASSERT_TRUE(RilTestUtil::GetBoolResult(HdiId::HREQ_SIM_UNLOCK_SIM_LOCK));
955 #endif
956     ASSERT_TRUE(true);
957 }
958 
959 } // namespace Telephony
960 } // namespace OHOS
961