1 /*
2 * Copyright (C) 2021-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 #define private public
17 #define protected public
18 #include "cellular_call_config.h"
19 #include "cellular_call_handler.h"
20 #include "cellular_call_proxy.h"
21 #include "cellular_call_register.h"
22 #include "cellular_call_service.h"
23 #include "tel_ril_call_parcel.h"
24 #include "ims_call_callback_proxy.h"
25 #include "ims_call_callback_stub.h"
26 #include "ims_call_client.h"
27 #include "ims_control.h"
28 #include "ims_error.h"
29 #include "securec.h"
30 #include "call_manager_errors.h"
31 #include "cellular_call_interface.h"
32 #include "core_service_client.h"
33 #include "gtest/gtest.h"
34 #include "ims_core_service_client.h"
35 #include "iservice_registry.h"
36 #include "system_ability_definition.h"
37 #include "token.h"
38
39 namespace OHOS {
40 namespace Telephony {
41 using namespace testing::ext;
42 const int32_t SIM1_SLOTID = 0;
43 const int32_t SIM2_SLOTID = 1;
44 const std::string PHONE_NUMBER = "0000000";
45 const std::string PHONE_NUMBER_SECOND = "1111111";
46 const std::string PHONE_NUMBER_THIRD = "2222222";
47 const std::string PHONE_NUMBER_FOUR = "3333333";
48
49 class Ims1Test : public testing::Test {
50 public:
51 static void SetUpTestCase();
52 static void TearDownTestCase();
53 void SetUp();
54 void TearDown();
55
HasSimCard(int32_t slotId)56 bool HasSimCard(int32_t slotId)
57 {
58 bool hasSimCard = false;
59 DelayedRefSingleton<CoreServiceClient>::GetInstance().HasSimCard(slotId, hasSimCard);
60 return hasSimCard;
61 }
CanUseImsService(int32_t slotId,ImsServiceType type)62 bool CanUseImsService(int32_t slotId, ImsServiceType type)
63 {
64 ImsRegInfo info;
65 CoreServiceClient::GetInstance().GetImsRegStatus(slotId, type, info);
66 bool imsReg = info.imsRegState == ImsRegState::IMS_REGISTERED;
67 return imsReg;
68 }
69
InitCellularCallInfo(int32_t accountId,std::string phonenumber,CellularCallInfo & callInfo)70 int32_t InitCellularCallInfo(int32_t accountId, std::string phonenumber, CellularCallInfo &callInfo)
71 {
72 callInfo.accountId = accountId;
73 callInfo.slotId = accountId;
74 callInfo.index = accountId;
75 callInfo.callType = CallType::TYPE_IMS;
76 callInfo.videoState = 0; // 0 means audio
77 if (memset_s(callInfo.phoneNum, kMaxNumberLen, 0, kMaxNumberLen) != EOK) {
78 return TELEPHONY_ERR_MEMSET_FAIL;
79 }
80 if (phonenumber.length() > static_cast<size_t>(kMaxNumberLen)) {
81 return CALL_ERR_NUMBER_OUT_OF_RANGE;
82 }
83 if (memcpy_s(callInfo.phoneNum, kMaxNumberLen, phonenumber.c_str(), phonenumber.length()) != EOK) {
84 return TELEPHONY_ERR_MEMCPY_FAIL;
85 }
86 return TELEPHONY_SUCCESS;
87 };
88
TestDialCallByIms(int32_t slotId,std::string code)89 int32_t TestDialCallByIms(int32_t slotId, std::string code)
90 {
91 AccessToken token;
92 auto saMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
93 if (saMgr == nullptr) {
94 return TELEPHONY_ERR_FAIL;
95 }
96 auto remote = saMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
97 if (remote == nullptr) {
98 return TELEPHONY_ERR_FAIL;
99 }
100 auto telephonyService = iface_cast<CellularCallInterface>(remote);
101 if (telephonyService == nullptr) {
102 return TELEPHONY_ERR_FAIL;
103 }
104 CellularCallInfo imsCellularCallInfo;
105 int32_t ret = TELEPHONY_SUCCESS;
106 ret = InitCellularCallInfo(slotId, code, imsCellularCallInfo);
107 if (ret != TELEPHONY_SUCCESS) {
108 return ret;
109 }
110 // open ims, make this time use ims to test
111 ret = telephonyService->SetImsSwitchStatus(slotId, true);
112 if (ret != TELEPHONY_SUCCESS) {
113 return ret;
114 }
115 ret = telephonyService->Dial(imsCellularCallInfo);
116 return ret;
117 };
118 };
119
SetUpTestCase(void)120 void Ims1Test::SetUpTestCase(void)
121 {
122 // step 3: Set Up Test Case
123 std::cout << "---------- ImsCoreServiceClient start ------------" << std::endl;
124 DelayedSingleton<ImsCoreServiceClient>::GetInstance()->Init();
125 }
126
TearDownTestCase(void)127 void Ims1Test::TearDownTestCase(void)
128 {
129 // step 3: Tear Down Test Case
130 }
131
SetUp(void)132 void Ims1Test::SetUp(void) {}
133
TearDown(void)134 void Ims1Test::TearDown(void)
135 {
136 // step 3: input testcase teardown step
137 }
138 /**
139 * @tc.number cellular_call_ims_test_001
140 * @tc.name Test the corresponding functions by entering commands, such as 300 -- SetCallPreferenceMode, 301 --
141 * GetCallPreferenceMode, etc
142 * @tc.desc Function test
143 */
144 HWTEST_F(Ims1Test, cellular_call_ims_test_001, Function | MediumTest | Level0)
145 {
146 AccessToken token;
147 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
148 ASSERT_TRUE(systemAbilityMgr != nullptr);
149 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
150 ASSERT_TRUE(remote != nullptr);
151 auto telephonyService = iface_cast<CellularCallInterface>(remote);
152 ASSERT_TRUE(telephonyService != nullptr);
153 std::cout << "HWTEST_F cellular_call_ims_test_001";
154 }
155
156 /**
157 * @tc.number cellular_call_DialCall_0001
158 * @tc.name Test for SetClip function by ims
159 * @tc.desc Function test
160 */
161 HWTEST_F(Ims1Test, cellular_call_DialCall_0001, Function | MediumTest | Level2)
162 {
163 AccessToken token;
164 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
165 return;
166 }
167 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
168 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*30#");
169 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
170 }
171 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
172 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*30#");
173 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
174 }
175 }
176
177 /**
178 * @tc.number cellular_call_DialCall_0002
179 * @tc.name Test for SetClip function by ims
180 * @tc.desc Function test
181 */
182 HWTEST_F(Ims1Test, cellular_call_DialCall_0002, Function | MediumTest | Level2)
183 {
184 AccessToken token;
185 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
186 return;
187 }
188 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
189 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#30#");
190 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
191 }
192 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
193 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#30#");
194 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
195 }
196 }
197
198 /**
199 * @tc.number cellular_call_DialCall_0003
200 * @tc.name Test for getClip function by ims
201 * @tc.desc Function test
202 */
203 HWTEST_F(Ims1Test, cellular_call_DialCall_0003, Function | MediumTest | Level2)
204 {
205 AccessToken token;
206 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
207 return;
208 }
209 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
210 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#30#");
211 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
212 }
213 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
214 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#30#");
215 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
216 }
217 }
218
219 /**
220 * @tc.number cellular_call_DialCall_0004
221 * @tc.name Test for SetClir function by ims
222 * @tc.desc Function test
223 */
224 HWTEST_F(Ims1Test, cellular_call_DialCall_0004, Function | MediumTest | Level2)
225 {
226 AccessToken token;
227 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
228 return;
229 }
230 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
231 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*31#");
232 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
233 }
234 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
235 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*31#");
236 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
237 }
238 }
239
240 /**
241 * @tc.number cellular_call_DialCall_0005
242 * @tc.name Test for SetClir function by ims
243 * @tc.desc Function test
244 */
245 HWTEST_F(Ims1Test, cellular_call_DialCall_0005, Function | MediumTest | Level2)
246 {
247 AccessToken token;
248 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
249 return;
250 }
251 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
252 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#31#");
253 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
254 }
255 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
256 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#31#");
257 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
258 }
259 }
260
261 /**
262 * @tc.number cellular_call_DialCall_0006
263 * @tc.name Test for GetClir function by ims
264 * @tc.desc Function test
265 */
266 HWTEST_F(Ims1Test, cellular_call_DialCall_0006, Function | MediumTest | Level2)
267 {
268 AccessToken token;
269 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
270 return;
271 }
272 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
273 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#31#");
274 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
275 }
276 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
277 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#31#");
278 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
279 }
280 }
281
282 /**
283 * @tc.number cellular_call_DialCall_0007
284 * @tc.name Test for SetCallTransfer function by ims
285 * @tc.desc Function test
286 */
287 HWTEST_F(Ims1Test, cellular_call_DialCall_0007, Function | MediumTest | Level2)
288 {
289 AccessToken token;
290 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
291 return;
292 }
293 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
294 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*21#");
295 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
296 }
297 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
298 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*21#");
299 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
300 }
301 }
302
303 /**
304 * @tc.number cellular_call_DialCall_0008
305 * @tc.name Test for SetCallTransfer function by ims
306 * @tc.desc Function test
307 */
308 HWTEST_F(Ims1Test, cellular_call_DialCall_0008, Function | MediumTest | Level2)
309 {
310 AccessToken token;
311 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
312 return;
313 }
314 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
315 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#21#");
316 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
317 }
318 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
319 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#21#");
320 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
321 }
322 }
323
324 /**
325 * @tc.number cellular_call_DialCall_0009
326 * @tc.name Test for GetCallTransfer function by ims
327 * @tc.desc Function test
328 */
329 HWTEST_F(Ims1Test, cellular_call_DialCall_0009, Function | MediumTest | Level2)
330 {
331 AccessToken token;
332 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
333 return;
334 }
335 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
336 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#21#");
337 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
338 }
339 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
340 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#21#");
341 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
342 }
343 }
344
345 /**
346 * @tc.number cellular_call_DialCall_0010
347 * @tc.name Test for SetCallRestriction function by ims
348 * @tc.desc Function test
349 */
350 HWTEST_F(Ims1Test, cellular_call_DialCall_0010, Function | MediumTest | Level2)
351 {
352 AccessToken token;
353 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
354 return;
355 }
356 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
357 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*33#");
358 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
359 }
360 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
361 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*33#");
362 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
363 }
364 }
365
366 /**
367 * @tc.number cellular_call_DialCall_0011
368 * @tc.name Test for SetCallRestriction function by ims
369 * @tc.desc Function test
370 */
371 HWTEST_F(Ims1Test, cellular_call_DialCall_0011, Function | MediumTest | Level2)
372 {
373 AccessToken token;
374 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
375 return;
376 }
377 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
378 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#33#");
379 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
380 }
381 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
382 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#33#");
383 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
384 }
385 }
386
387 /**
388 * @tc.number cellular_call_DialCall_0012
389 * @tc.name Test for GetCallRestriction function by ims
390 * @tc.desc Function test
391 */
392 HWTEST_F(Ims1Test, cellular_call_DialCall_0012, Function | MediumTest | Level2)
393 {
394 AccessToken token;
395 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
396 return;
397 }
398 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
399 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#33#");
400 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
401 }
402 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
403 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#33#");
404 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
405 }
406 }
407
408 /**
409 * @tc.number cellular_call_DialCall_0013
410 * @tc.name Test for SetCallWaiting function by ims
411 * @tc.desc Function test
412 */
413 HWTEST_F(Ims1Test, cellular_call_DialCall_0013, Function | MediumTest | Level2)
414 {
415 AccessToken token;
416 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
417 return;
418 }
419 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
420 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*43#");
421 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
422 }
423 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
424 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*43#");
425 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
426 }
427 }
428
429 /**
430 * @tc.number cellular_call_DialCall_0014
431 * @tc.name Test for SetCallWaiting function by ims
432 * @tc.desc Function test
433 */
434 HWTEST_F(Ims1Test, cellular_call_DialCall_0014, Function | MediumTest | Level2)
435 {
436 AccessToken token;
437 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
438 return;
439 }
440 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
441 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "#43#");
442 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
443 }
444 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
445 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "#43#");
446 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
447 }
448 }
449
450 /**
451 * @tc.number cellular_call_DialCall_0015
452 * @tc.name Test for GetCallWaiting function by ims
453 * @tc.desc Function test
454 */
455 HWTEST_F(Ims1Test, cellular_call_DialCall_0015, Function | MediumTest | Level2)
456 {
457 AccessToken token;
458 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
459 return;
460 }
461 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
462 int32_t ret = TestDialCallByIms(SIM1_SLOTID, "*#43#");
463 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
464 ret = TestDialCallByIms(SIM1_SLOTID, "*#4@3#");
465 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
466 }
467 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_UT)) {
468 int32_t ret = TestDialCallByIms(SIM2_SLOTID, "*#43#");
469 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
470 ret = TestDialCallByIms(SIM2_SLOTID, "*#4@3#");
471 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
472 }
473 }
474
475 /**
476 * @tc.number cellular_call_HangUpCall_0001
477 * @tc.name Test for HangUp function by ims
478 * @tc.desc Function test
479 */
480 HWTEST_F(Ims1Test, cellular_call_HangUpCall_0001, Function | MediumTest | Level2)
481 {
482 AccessToken token;
483 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
484 ASSERT_TRUE(systemAbilityMgr != nullptr);
485 auto hangUpCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
486 ASSERT_TRUE(hangUpCallRemote != nullptr);
487 auto telephonyService = iface_cast<CellularCallInterface>(hangUpCallRemote);
488 ASSERT_TRUE(telephonyService != nullptr);
489 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
490 return;
491 }
492 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
493 CellularCallInfo callInfo;
494 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
495 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
496 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
497 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
498 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
499 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
500 }
501 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
502 CellularCallInfo callInfo;
503 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
504 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
505 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_DEFAULT);
506 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
507 ret = telephonyService->HangUp(callInfo, CallSupplementType::TYPE_HANG_UP_ACTIVE);
508 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
509 }
510 }
511
512 /**
513 * @tc.number cellular_call_AnswerCall_0001
514 * @tc.name Test for answer function by ims
515 * @tc.desc Function test
516 */
517 HWTEST_F(Ims1Test, cellular_call_AnswerCall_0001, Function | MediumTest | Level2)
518 {
519 AccessToken token;
520 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
521 ASSERT_TRUE(systemAbilityMgr != nullptr);
522 auto answerCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
523 ASSERT_TRUE(answerCallRemote != nullptr);
524 auto telephonyService = iface_cast<CellularCallInterface>(answerCallRemote);
525 ASSERT_TRUE(telephonyService != nullptr);
526 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
527 return;
528 }
529 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
530 CellularCallInfo callInfo;
531 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
532 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
533 ret = telephonyService->Answer(callInfo);
534 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
535 }
536 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
537 CellularCallInfo callInfo;
538 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
539 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
540 ret = telephonyService->Answer(callInfo);
541 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
542 }
543 }
544
545 /**
546 * @tc.number cellular_call_RejectCall_0001
547 * @tc.name Test for reject function by ims
548 * @tc.desc Function test
549 */
550 HWTEST_F(Ims1Test, cellular_call_RejectCall_0001, Function | MediumTest | Level2)
551 {
552 AccessToken token;
553 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
554 ASSERT_TRUE(systemAbilityMgr != nullptr);
555 auto rejectCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
556 ASSERT_TRUE(rejectCallRemote != nullptr);
557 auto telephonyService = iface_cast<CellularCallInterface>(rejectCallRemote);
558 ASSERT_TRUE(telephonyService != nullptr);
559 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
560 return;
561 }
562 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
563 CellularCallInfo callInfo;
564 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
565 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
566 ret = telephonyService->Reject(callInfo);
567 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
568 }
569 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
570 CellularCallInfo callInfo;
571 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
572 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
573 ret = telephonyService->Reject(callInfo);
574 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
575 }
576 }
577
578 /**
579 * @tc.number cellular_call_HoldCall_0001
580 * @tc.name Test for hold call function by ims
581 * @tc.desc Function test
582 */
583 HWTEST_F(Ims1Test, cellular_call_HoldCall_0001, Function | MediumTest | Level2)
584 {
585 AccessToken token;
586 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
587 ASSERT_TRUE(systemAbilityMgr != nullptr);
588 auto holdCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
589 ASSERT_TRUE(holdCallRemote != nullptr);
590 auto telephonyService = iface_cast<CellularCallInterface>(holdCallRemote);
591 ASSERT_TRUE(telephonyService != nullptr);
592 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
593 return;
594 }
595 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
596 CellularCallInfo callInfo;
597 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
598 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
599 ret = telephonyService->HoldCall(callInfo);
600 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
601 }
602 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
603 CellularCallInfo callInfo;
604 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
605 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
606 ret = telephonyService->HoldCall(callInfo);
607 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
608 }
609 }
610
611 /**
612 * @tc.number cellular_call_UnHoldCall_0001
613 * @tc.name Test for unhold call function by ims
614 * @tc.desc Function test
615 */
616 HWTEST_F(Ims1Test, cellular_call_UnHoldCall_0001, Function | MediumTest | Level2)
617 {
618 AccessToken token;
619 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
620 ASSERT_TRUE(systemAbilityMgr != nullptr);
621 auto unHoldCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
622 ASSERT_TRUE(unHoldCallRemote != nullptr);
623 auto telephonyService = iface_cast<CellularCallInterface>(unHoldCallRemote);
624 ASSERT_TRUE(telephonyService != nullptr);
625 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
626 return;
627 }
628 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
629 CellularCallInfo callInfo;
630 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
631 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
632 ret = telephonyService->UnHoldCall(callInfo);
633 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
634 }
635 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
636 CellularCallInfo callInfo;
637 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
638 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
639 ret = telephonyService->UnHoldCall(callInfo);
640 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
641 }
642 }
643
644 /**
645 * @tc.number cellular_call_SwitchCall_0001
646 * @tc.name Test for switch call function by ims
647 * @tc.desc Function test
648 */
649 HWTEST_F(Ims1Test, cellular_call_SwitchCall_0001, Function | MediumTest | Level2)
650 {
651 AccessToken token;
652 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
653 ASSERT_TRUE(systemAbilityMgr != nullptr);
654 auto switchCallRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
655 ASSERT_TRUE(switchCallRemote != nullptr);
656 auto telephonyService = iface_cast<CellularCallInterface>(switchCallRemote);
657 ASSERT_TRUE(telephonyService != nullptr);
658 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
659 return;
660 }
661 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
662 CellularCallInfo callInfo;
663 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
664 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
665 ret = telephonyService->SwitchCall(callInfo);
666 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
667 }
668 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
669 CellularCallInfo callInfo;
670 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
671 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
672 ret = telephonyService->SwitchCall(callInfo);
673 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
674 }
675 }
676
677 /**
678 * @tc.number cellular_call_CombineConference_0001
679 * @tc.name Test for combineConference function by ims
680 * @tc.desc Function test
681 */
682 HWTEST_F(Ims1Test, cellular_call_CombineConference_0001, Function | MediumTest | Level2)
683 {
684 AccessToken token;
685 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
686 ASSERT_TRUE(systemAbilityMgr != nullptr);
687 auto combineRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
688 ASSERT_TRUE(combineRemote != nullptr);
689 auto telephonyService = iface_cast<CellularCallInterface>(combineRemote);
690 ASSERT_TRUE(telephonyService != nullptr);
691 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
692 return;
693 }
694 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
695 CellularCallInfo callInfo;
696 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
697 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
698 ret = telephonyService->CombineConference(callInfo);
699 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
700 }
701 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
702 CellularCallInfo callInfo;
703 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
704 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
705 ret = telephonyService->CombineConference(callInfo);
706 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
707 }
708 }
709
710 /**
711 * @tc.number cellular_call_SeparateConference_0001
712 * @tc.name Test for separateConference function by ims
713 * @tc.desc Function test
714 */
715 HWTEST_F(Ims1Test, cellular_call_SeparateConference_0001, Function | MediumTest | Level2)
716 {
717 AccessToken token;
718 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
719 ASSERT_TRUE(systemAbilityMgr != nullptr);
720 auto separateRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
721 ASSERT_TRUE(separateRemote != nullptr);
722 auto telephonyService = iface_cast<CellularCallInterface>(separateRemote);
723 ASSERT_TRUE(telephonyService != nullptr);
724 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
725 return;
726 }
727 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
728 CellularCallInfo callInfo;
729 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
730 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
731 ret = telephonyService->SeparateConference(callInfo);
732 EXPECT_EQ(ret, TELEPHONY_ERR_ARGUMENT_INVALID);
733 }
734 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
735 CellularCallInfo callInfo;
736 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
737 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
738 ret = telephonyService->SeparateConference(callInfo);
739 EXPECT_EQ(ret, TELEPHONY_ERR_ARGUMENT_INVALID);
740 }
741 }
742
743 /**
744 * @tc.number cellular_call_KickOutFromConference_0001
745 * @tc.name Test for KickOutFromConference function by ims
746 * @tc.desc Function test
747 */
748 HWTEST_F(Ims1Test, cellular_call_KickOutFromConference_0001, Function | MediumTest | Level2)
749 {
750 AccessToken token;
751 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
752 ASSERT_TRUE(systemAbilityMgr != nullptr);
753 auto kickOutRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
754 ASSERT_TRUE(kickOutRemote != nullptr);
755 auto telephonyService = iface_cast<CellularCallInterface>(kickOutRemote);
756 ASSERT_TRUE(telephonyService != nullptr);
757 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
758 return;
759 }
760 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
761 CellularCallInfo callInfo;
762 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
763 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
764 ret = telephonyService->KickOutFromConference(callInfo);
765 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
766 }
767 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
768 CellularCallInfo callInfo;
769 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
770 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
771 ret = telephonyService->KickOutFromConference(callInfo);
772 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
773 }
774 }
775
776 /**
777 * @tc.number cellular_call_StartDtmf_0001
778 * @tc.name Test for startDtmf function by ims
779 * @tc.desc Function test
780 */
781 HWTEST_F(Ims1Test, cellular_call_StartDtmf_0001, Function | MediumTest | Level2)
782 {
783 AccessToken token;
784 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
785 ASSERT_TRUE(systemAbilityMgr != nullptr);
786 auto startDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
787 ASSERT_TRUE(startDtmfRemote != nullptr);
788 auto telephonyService = iface_cast<CellularCallInterface>(startDtmfRemote);
789 ASSERT_TRUE(telephonyService != nullptr);
790 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
791 return;
792 }
793 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
794 CellularCallInfo callInfo;
795 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
796 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
797 char code = '1';
798 ret = telephonyService->StartDtmf(code, callInfo);
799 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
800 }
801 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
802 CellularCallInfo callInfo;
803 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
804 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
805 char code = '1';
806 ret = telephonyService->StartDtmf(code, callInfo);
807 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
808 }
809 }
810
811 /**
812 * @tc.number cellular_call_StopDtmf_0001
813 * @tc.name Test for stopDtmf function by ims
814 * @tc.desc Function test
815 */
816 HWTEST_F(Ims1Test, cellular_call_StopDtmf_0001, Function | MediumTest | Level2)
817 {
818 AccessToken token;
819 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
820 ASSERT_TRUE(systemAbilityMgr != nullptr);
821 auto stopDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
822 ASSERT_TRUE(stopDtmfRemote != nullptr);
823 auto telephonyService = iface_cast<CellularCallInterface>(stopDtmfRemote);
824 ASSERT_TRUE(telephonyService != nullptr);
825 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
826 return;
827 }
828 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
829 CellularCallInfo callInfo;
830 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
831 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
832 ret = telephonyService->StopDtmf(callInfo);
833 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
834 }
835 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
836 CellularCallInfo callInfo;
837 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
838 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
839 ret = telephonyService->StopDtmf(callInfo);
840 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
841 }
842 }
843
844 /**
845 * @tc.number cellular_call_SendDtmf_0001
846 * @tc.name Test for sendDtmf function by ims
847 * @tc.desc Function test
848 */
849 HWTEST_F(Ims1Test, cellular_call_SendDtmf_0001, Function | MediumTest | Level2)
850 {
851 AccessToken token;
852 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
853 ASSERT_TRUE(systemAbilityMgr != nullptr);
854 auto sendDtmfRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
855 ASSERT_TRUE(sendDtmfRemote != nullptr);
856 auto telephonyService = iface_cast<CellularCallInterface>(sendDtmfRemote);
857 ASSERT_TRUE(telephonyService != nullptr);
858 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
859 return;
860 }
861 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_VOICE)) {
862 CellularCallInfo callInfo;
863 int32_t ret = InitCellularCallInfo(SIM1_SLOTID, PHONE_NUMBER, callInfo);
864 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
865 char code = '1';
866 ret = telephonyService->SendDtmf(code, callInfo);
867 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
868 }
869 if (HasSimCard(SIM2_SLOTID) && CanUseImsService(SIM2_SLOTID, ImsServiceType::TYPE_VOICE)) {
870 CellularCallInfo callInfo;
871 int32_t ret = InitCellularCallInfo(SIM2_SLOTID, PHONE_NUMBER, callInfo);
872 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
873 char code = '1';
874 ret = telephonyService->SendDtmf(code, callInfo);
875 EXPECT_EQ(ret, CALL_ERR_CALL_CONNECTION_NOT_EXIST);
876 }
877 }
878
879 /**
880 * @tc.number cellular_call_CanSetCallTransferTime_0001
881 * @tc.name Test for CanSetCallTransferTime function by ims
882 * @tc.desc Function test
883 */
884 HWTEST_F(Ims1Test, cellular_call_CanSetCallTransferTime_0001, Function | MediumTest | Level2)
885 {
886 AccessToken token;
887 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
888 ASSERT_TRUE(systemAbilityMgr != nullptr);
889 auto transferRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
890 ASSERT_TRUE(transferRemote != nullptr);
891 auto telephonyService = iface_cast<CellularCallInterface>(transferRemote);
892 ASSERT_TRUE(telephonyService != nullptr);
893 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
894 return;
895 }
896 if (HasSimCard(SIM1_SLOTID) && CanUseImsService(SIM1_SLOTID, ImsServiceType::TYPE_UT)) {
897 bool result;
898 int32_t ret = telephonyService->CanSetCallTransferTime(SIM1_SLOTID, result);
899 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
900 }
901 if (HasSimCard(SIM2_SLOTID)) {
902 bool result;
903 int32_t ret = telephonyService->CanSetCallTransferTime(SIM2_SLOTID, result);
904 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
905 }
906 }
907
908
909 /**
910 * @tc.number cellular_call_SetVoNRState_0001
911 * @tc.name Test for SetVoNRState function
912 * @tc.desc Function test
913 */
914 HWTEST_F(Ims1Test, cellular_call_SetVoNRState_0001, Function | MediumTest | Level2)
915 {
916 AccessToken token;
917 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
918 ASSERT_TRUE(systemAbilityMgr != nullptr);
919 auto setVoNRRemote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
920 ASSERT_TRUE(setVoNRRemote != nullptr);
921 auto telephonyService = iface_cast<CellularCallInterface>(setVoNRRemote);
922 ASSERT_TRUE(telephonyService != nullptr);
923 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
924 return;
925 }
926 if (HasSimCard(SIM2_SLOTID)) {
927 int32_t ret = telephonyService->SetVoNRState(SIM2_SLOTID, 1);
928 EXPECT_EQ(ret, TELEPHONY_SUCCESS);
929 }
930 }
931 } // namespace Telephony
932 } // namespace OHOS
933