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 #include "cs_test.h"
17
18 #define private public
19 #define protected public
20 #include "cellular_call_callback.h"
21 #include "cellular_call_handler.h"
22 #include "cellular_call_proxy.h"
23 #include "cellular_call_register.h"
24 #include "cellular_call_service.h"
25 #include "cellular_call_supplement.h"
26 #include "config_request.h"
27 #include "core_service_client.h"
28 #include "cs_control.h"
29 #include "tel_ril_call_parcel.h"
30 #include "operator_config_types.h"
31 #include "radio_event.h"
32 #include "securec.h"
33 #include "sim_state_type.h"
34
35 namespace OHOS {
36 namespace Telephony {
37 using namespace testing::ext;
38 const int32_t SIM1_SLOTID = 0;
39 const int32_t SIM2_SLOTID = 1;
40 const std::string PHONE_NUMBER = "0000000";
41 const std::string PHONE_NUMBER_SECOND = "1111111";
42 const std::string PHONE_NUMBER_THIRD = "2222222";
43 const int32_t CELLULAR_CALL_SUCCESS = 0;
44 const int32_t CELLULAR_CALL_ERROR = -1;
45
HasSimCard(int32_t slotId)46 bool CsTest::HasSimCard(int32_t slotId)
47 {
48 bool hasSimCard = false;
49 DelayedRefSingleton<CoreServiceClient>::GetInstance().HasSimCard(slotId, hasSimCard);
50 return hasSimCard;
51 }
52
SetUpTestCase(void)53 void CsTest::SetUpTestCase(void)
54 {
55 // step 3: Set Up Test Case
56 }
57
TearDownTestCase(void)58 void CsTest::TearDownTestCase(void)
59 {
60 // step 3: Tear Down Test Case
61 }
62
SetUp(void)63 void CsTest::SetUp(void)
64 {
65 // step 3: input testcase setup step
66 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::DIAL)] = &CsTest::Dial;
67 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::HANG_UP)] = &CsTest::HangUp;
68 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::REJECT)] = &CsTest::Reject;
69 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::ANSWER)] = &CsTest::Answer;
70 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::HOLD_CALL)] = &CsTest::HoldCall;
71 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::UN_HOLD_CALL)] = &CsTest::UnHoldCall;
72 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SWITCH_CALL)] = &CsTest::SwitchCall;
73 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::EMERGENCY_CALL)] = &CsTest::IsEmergencyPhoneNumber;
74 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::COMBINE_CONFERENCE)] = &CsTest::CombineConference;
75 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SEPARATE_CONFERENCE)] = &CsTest::SeparateConference;
76 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::INVITE_TO_CONFERENCE)] =
77 &CsTest::InviteToConference;
78 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::KICK_OUT_CONFERENCE)] =
79 &CsTest::KickOutFromConference;
80 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::HANG_UP_ALL_CONNECTION)] =
81 &CsTest::HangUpAllConnection;
82 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::REGISTER_CALLBACK)] =
83 &CsTest::RegisterCallBack;
84 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::UNREGISTER_CALLBACK)] =
85 &CsTest::UnRegisterCallBack;
86 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::START_DTMF)] = &CsTest::StartDtmf;
87 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::STOP_DTMF)] = &CsTest::StopDtmf;
88 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SEND_DTMF)] = &CsTest::SendDtmf;
89 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::START_RTT)] = &CsTest::StartRtt;
90 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::STOP_RTT)] = &CsTest::StopRtt;
91 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_CALL_TRANSFER)] =
92 &CsTest::SetCallTransferInfo;
93 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_CALL_TRANSFER)] =
94 &CsTest::GetCallTransferInfo;
95 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_CALL_WAITING)] =
96 &CsTest::SetCallWaiting;
97 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_CALL_WAITING)] =
98 &CsTest::GetCallWaiting;
99 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_CALL_RESTRICTION)] =
100 &CsTest::SetCallRestriction;
101 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_CALL_RESTRICTION)] =
102 &CsTest::GetCallRestriction;
103 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_CALL_RESTRICTION_PWD)] =
104 &CsTest::SetCallRestrictionPassword;
105 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::SET_MUTE)] = &CsTest::SetMute;
106 requestFuncMap_[static_cast<int32_t>(CellularCallInterfaceCode::GET_MUTE)] = &CsTest::GetMute;
107 }
108
TearDown(void)109 void CsTest::TearDown(void)
110 {
111 // step 3: input testcase teardown step
112 }
113
Dial(const sptr<CellularCallInterface> & telephonyService) const114 int32_t CsTest::Dial(const sptr<CellularCallInterface> &telephonyService) const
115 {
116 std::cout << "test Dial entry.\n";
117 CellularCallInfo callInfo;
118 if (memset_s(&callInfo, sizeof(callInfo), 0, sizeof(callInfo)) != EOK) {
119 std::cout << "CellularCallService return, memset_s failed. \n";
120 return TELEPHONY_ERR_ARGUMENT_INVALID;
121 }
122 std::cout << "please enter the phone number:";
123 std::cin >> callInfo.phoneNum;
124 callInfo.videoState = 1;
125 int32_t slotId = 0;
126 std::cout << "please enter the slotId:(0 1)";
127 std::cin >> slotId;
128 callInfo.slotId = slotId;
129 return telephonyService->Dial(callInfo);
130 }
131
HangUp(const sptr<CellularCallInterface> & telephonyService) const132 int32_t CsTest::HangUp(const sptr<CellularCallInterface> &telephonyService) const
133 {
134 std::cout << "test HangUp entry.\n";
135 CellularCallInfo callInfo;
136 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
137 return TELEPHONY_ERR_ARGUMENT_INVALID;
138 }
139 std::cout << "please enter the connect index:";
140 std::cin >> callInfo.index;
141 std::cout << "please enter the type:";
142 int32_t type;
143 std::cin >> type;
144 return telephonyService->HangUp(callInfo, static_cast<CallSupplementType>(type));
145 }
146
Answer(const sptr<CellularCallInterface> & telephonyService) const147 int32_t CsTest::Answer(const sptr<CellularCallInterface> &telephonyService) const
148 {
149 std::cout << "test Answer entry.\n";
150 CellularCallInfo callInfo;
151 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
152 return TELEPHONY_ERR_ARGUMENT_INVALID;
153 }
154 return telephonyService->Answer(callInfo);
155 }
156
Reject(const sptr<CellularCallInterface> & telephonyService) const157 int32_t CsTest::Reject(const sptr<CellularCallInterface> &telephonyService) const
158 {
159 std::cout << "test Reject entry.\n";
160 CellularCallInfo callInfo;
161 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
162 return TELEPHONY_ERR_ARGUMENT_INVALID;
163 }
164 std::cout << "please enter the connect index:";
165 std::cin >> callInfo.index;
166 return telephonyService->Reject(callInfo);
167 }
168
HoldCall(const sptr<CellularCallInterface> & telephonyService) const169 int32_t CsTest::HoldCall(const sptr<CellularCallInterface> &telephonyService) const
170 {
171 std::cout << "test HoldCall entry.\n";
172 CellularCallInfo callInfo;
173 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
174 return TELEPHONY_ERR_ARGUMENT_INVALID;
175 }
176 return telephonyService->HoldCall(callInfo);
177 }
178
UnHoldCall(const sptr<CellularCallInterface> & telephonyService) const179 int32_t CsTest::UnHoldCall(const sptr<CellularCallInterface> &telephonyService) const
180 {
181 std::cout << "test UnHoldCall entry.\n";
182 CellularCallInfo callInfo;
183 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
184 return TELEPHONY_ERR_ARGUMENT_INVALID;
185 }
186 return telephonyService->UnHoldCall(callInfo);
187 }
188
SwitchCall(const sptr<CellularCallInterface> & telephonyService) const189 int32_t CsTest::SwitchCall(const sptr<CellularCallInterface> &telephonyService) const
190 {
191 std::cout << "test SwitchCall entry.\n";
192 CellularCallInfo callInfo;
193 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
194 return TELEPHONY_ERR_ARGUMENT_INVALID;
195 }
196 return telephonyService->SwitchCall(callInfo);
197 }
198
IsEmergencyPhoneNumber(const sptr<CellularCallInterface> & telephonyService) const199 int32_t CsTest::IsEmergencyPhoneNumber(const sptr<CellularCallInterface> &telephonyService) const
200 {
201 std::cout << "test IsEmergencyPhoneNumber entry.\n";
202 std::string phoneNum;
203 std::cout << "input phoneNum: ";
204 std::cin >> phoneNum;
205 std::cout << "input slotId: ";
206 int32_t slotId = 0;
207 std::cin >> slotId;
208 bool enabled = false;
209 telephonyService->IsEmergencyPhoneNumber(slotId, phoneNum, enabled);
210 return enabled;
211 }
212
CombineConference(const sptr<CellularCallInterface> & telephonyService) const213 int32_t CsTest::CombineConference(const sptr<CellularCallInterface> &telephonyService) const
214 {
215 std::cout << "test CombineConference entry." << std::endl;
216 CellularCallInfo callInfo;
217 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
218 return TELEPHONY_ERR_ARGUMENT_INVALID;
219 }
220 return telephonyService->CombineConference(callInfo);
221 }
222
SeparateConference(const sptr<CellularCallInterface> & telephonyService) const223 int32_t CsTest::SeparateConference(const sptr<CellularCallInterface> &telephonyService) const
224 {
225 std::cout << "test SeparateConference entry." << std::endl;
226 CellularCallInfo callInfo;
227 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
228 return TELEPHONY_ERR_ARGUMENT_INVALID;
229 }
230 std::cout << "please enter the need split index:";
231 std::cin >> callInfo.index;
232 return telephonyService->SeparateConference(callInfo);
233 }
234
InviteToConference(const sptr<CellularCallInterface> & telephonyService) const235 int32_t CsTest::InviteToConference(const sptr<CellularCallInterface> &telephonyService) const
236 {
237 std::cout << "test InviteToConference entry." << std::endl;
238 std::vector<std::string> numberList;
239 std::cout << "please enter the invite phone number:";
240 std::string phoneNum;
241 std::cin >> phoneNum;
242 numberList.push_back(phoneNum);
243 std::cout << "please enter the slotId:";
244 int32_t slotId = 0;
245 return telephonyService->InviteToConference(slotId, numberList);
246 }
247
KickOutFromConference(const sptr<CellularCallInterface> & telephonyService) const248 int32_t CsTest::KickOutFromConference(const sptr<CellularCallInterface> &telephonyService) const
249 {
250 std::cout << "test KickOutFromConference entry." << std::endl;
251 CellularCallInfo callInfo;
252 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
253 return TELEPHONY_ERR_ARGUMENT_INVALID;
254 }
255 std::cout << "please enter the need kick out index:";
256 std::cin >> callInfo.index;
257 return telephonyService->KickOutFromConference(callInfo);
258 }
259
HangUpAllConnection(const sptr<CellularCallInterface> & telephonyService) const260 int32_t CsTest::HangUpAllConnection(const sptr<CellularCallInterface> &telephonyService) const
261 {
262 std::cout << "test HangUpAllConnection entry." << std::endl;
263 return telephonyService->HangUpAllConnection();
264 }
265
RegisterCallBack(const sptr<CellularCallInterface> & telephonyService) const266 int32_t CsTest::RegisterCallBack(const sptr<CellularCallInterface> &telephonyService) const
267 {
268 std::cout << "test RegisterCallBack entry.\n";
269 return CELLULAR_CALL_SUCCESS;
270 }
271
UnRegisterCallBack(const sptr<CellularCallInterface> & telephonyService) const272 int32_t CsTest::UnRegisterCallBack(const sptr<CellularCallInterface> &telephonyService) const
273 {
274 std::cout << "test UnRegisterCallBack entry.\n";
275 return telephonyService->UnRegisterCallManagerCallBack();
276 }
277
StartDtmf(const sptr<CellularCallInterface> & telephonyService) const278 int32_t CsTest::StartDtmf(const sptr<CellularCallInterface> &telephonyService) const
279 {
280 std::cout << "test StartDtmf entry." << std::endl;
281 CellularCallInfo callInfo;
282 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
283 return TELEPHONY_ERR_ARGUMENT_INVALID;
284 }
285 std::cout << "please enter the index:";
286 std::cin >> callInfo.index;
287 char cDtmfCode;
288 std::cout << "please enter the Dtmf code:";
289 std::cin >> cDtmfCode;
290 return telephonyService->StartDtmf(cDtmfCode, callInfo);
291 }
292
StopDtmf(const sptr<CellularCallInterface> & telephonyService) const293 int32_t CsTest::StopDtmf(const sptr<CellularCallInterface> &telephonyService) const
294 {
295 std::cout << "test StopDtmf entry." << std::endl;
296 CellularCallInfo callInfo;
297 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
298 return TELEPHONY_ERR_ARGUMENT_INVALID;
299 }
300 std::cout << "please enter the index:";
301 std::cin >> callInfo.index;
302 return telephonyService->StopDtmf(callInfo);
303 }
304
SendDtmf(const sptr<CellularCallInterface> & telephonyService) const305 int32_t CsTest::SendDtmf(const sptr<CellularCallInterface> &telephonyService) const
306 {
307 std::cout << "test SendDtmf entry." << std::endl;
308 CellularCallInfo callInfo;
309 if (InitCallInfo(callInfo) != CELLULAR_CALL_SUCCESS) {
310 return TELEPHONY_ERR_ARGUMENT_INVALID;
311 }
312 std::cout << "please enter the index:";
313 std::cin >> callInfo.index;
314 char cDtmfCode;
315 std::cout << "please enter the Dtmf code:";
316 std::cin >> cDtmfCode;
317 return telephonyService->SendDtmf(cDtmfCode, callInfo);
318 }
319
StartRtt(const sptr<CellularCallInterface> & telephonyService) const320 int32_t CsTest::StartRtt(const sptr<CellularCallInterface> &telephonyService) const
321 {
322 std::cout << "test StartRtt entry." << std::endl;
323 std::string msg;
324 std::cout << "please enter the send msg:";
325 std::cin >> msg;
326 int32_t slotId;
327 std::cout << "please enter the slotId:";
328 std::cin >> slotId;
329 return telephonyService->StartRtt(slotId, msg);
330 }
331
StopRtt(const sptr<CellularCallInterface> & telephonyService) const332 int32_t CsTest::StopRtt(const sptr<CellularCallInterface> &telephonyService) const
333 {
334 std::cout << "test StopRtt entry." << std::endl;
335 int32_t slotId;
336 std::cout << "please enter the slotId:";
337 std::cin >> slotId;
338 return telephonyService->StopRtt(slotId);
339 }
340
SetCallTransferInfo(const sptr<CellularCallInterface> & telephonyService) const341 int32_t CsTest::SetCallTransferInfo(const sptr<CellularCallInterface> &telephonyService) const
342 {
343 std::cout << "test SetCallTransferInfoInfo entry.\n";
344 int32_t slotId = 0;
345 std::cout << "please enter the slotId:(0 1)";
346 std::cin >> slotId;
347 CallTransferInfo callTransferInfo;
348 std::cout << "please enter the transfer type(0 - 5):";
349 int32_t type = 0;
350 std::cin >> type;
351 callTransferInfo.type = static_cast<CallTransferType>(type);
352 std::cout << "please enter the transfer setting type(0 - 4):";
353 int32_t settingType = 0;
354 std::cin >> settingType;
355 callTransferInfo.settingType = static_cast<CallTransferSettingType>(settingType);
356 std::cout << "please enter the phone number:";
357 std::cin >> callTransferInfo.transferNum;
358 return telephonyService->SetCallTransferInfo(slotId, callTransferInfo);
359 }
360
GetCallTransferInfo(const sptr<CellularCallInterface> & telephonyService) const361 int32_t CsTest::GetCallTransferInfo(const sptr<CellularCallInterface> &telephonyService) const
362 {
363 std::cout << "test GetCallTransferInfo entry.\n";
364 int32_t slotId = 0;
365 std::cout << "please enter the slotId:(0 1)";
366 std::cin >> slotId;
367 std::cout << "please enter the transfer type(0 - 5):";
368 int32_t type = 0;
369 std::cin >> type;
370 return telephonyService->GetCallTransferInfo(slotId, static_cast<CallTransferType>(type));
371 }
372
SetCallWaiting(const sptr<CellularCallInterface> & telephonyService) const373 int32_t CsTest::SetCallWaiting(const sptr<CellularCallInterface> &telephonyService) const
374 {
375 std::cout << "test SetCallWaiting entry.\n";
376 bool activate = true;
377 int32_t slotId = 0;
378 std::cout << "please enter the slotId:(0 1)";
379 std::cin >> slotId;
380 return telephonyService->SetCallWaiting(slotId, activate);
381 }
382
GetCallWaiting(const sptr<CellularCallInterface> & telephonyService) const383 int32_t CsTest::GetCallWaiting(const sptr<CellularCallInterface> &telephonyService) const
384 {
385 std::cout << "test GetCallWaiting entry.\n";
386 int32_t slotId = 0;
387 std::cout << "please enter the slotId:(0 1)";
388 std::cin >> slotId;
389 return telephonyService->GetCallWaiting(slotId);
390 }
391
SetCallRestriction(const sptr<CellularCallInterface> & telephonyService) const392 int32_t CsTest::SetCallRestriction(const sptr<CellularCallInterface> &telephonyService) const
393 {
394 std::cout << "test SetCallRestriction entry.\n";
395 int32_t slotId = 0;
396 std::cout << "please enter the slotId:(0 1)";
397 std::cin >> slotId;
398 CallRestrictionInfo info;
399 std::cout << "please enter the fac(0 - 4):";
400 int32_t fac = 0;
401 std::cin >> fac;
402 info.fac = static_cast<CallRestrictionType>(fac);
403 std::cout << "please enter the phone password:";
404 std::cin >> info.password;
405 std::cout << "please enter the mode:";
406 int32_t mode = 0;
407 std::cin >> mode;
408 info.mode = static_cast<CallRestrictionMode>(mode);
409 return telephonyService->SetCallRestriction(slotId, info);
410 }
411
GetCallRestriction(const sptr<CellularCallInterface> & telephonyService) const412 int32_t CsTest::GetCallRestriction(const sptr<CellularCallInterface> &telephonyService) const
413 {
414 std::cout << "test GetCallRestriction entry.\n";
415 int32_t slotId = 0;
416 std::cout << "please enter the slotId:(0 1)";
417 std::cin >> slotId;
418 std::cout << "please enter the fac(0 - 4):";
419 int32_t facType = 0;
420 std::cin >> facType;
421 return telephonyService->GetCallRestriction(slotId, static_cast<CallRestrictionType>(facType));
422 }
423
SetCallRestrictionPassword(const sptr<CellularCallInterface> & telephonyService) const424 int32_t CsTest::SetCallRestrictionPassword(const sptr<CellularCallInterface> &telephonyService) const
425 {
426 std::cout << "test SetCallRestrictionPassword entry.\n";
427 int32_t slotId = 0;
428 std::cout << "please enter the slotId:(0 1)";
429 std::cin >> slotId;
430 std::cout << "please enter the fac(0 - 4):";
431 int32_t fac = 0;
432 std::cin >> fac;
433 CallRestrictionType facType = static_cast<CallRestrictionType>(fac);
434 std::cout << "please enter the old password:";
435 char oldPassword[kMaxNumberLen + 1] = { 0 };
436 std::cin >> oldPassword;
437 std::cout << "please enter the new password:";
438 char newPassword[kMaxNumberLen + 1] = { 0 };
439 std::cin >> newPassword;
440 int32_t ret = telephonyService->SetCallRestrictionPassword(slotId, facType, oldPassword, newPassword);
441 (void)memset_s(oldPassword, sizeof(oldPassword), 0, sizeof(oldPassword));
442 (void)memset_s(newPassword, sizeof(newPassword), 0, sizeof(newPassword));
443 return ret;
444 }
445
SetMute(const sptr<CellularCallInterface> & telephonyService) const446 int32_t CsTest::SetMute(const sptr<CellularCallInterface> &telephonyService) const
447 {
448 std::cout << "test SetMute entry.\n";
449 int32_t slotId = 0;
450 std::cout << "please enter the slotId:(0 1)";
451 std::cin >> slotId;
452 std::cout << "please enter the mute(0 - 1):";
453 int32_t mute = -1;
454 std::cin >> mute;
455 return telephonyService->SetMute(slotId, mute);
456 }
457
GetMute(const sptr<CellularCallInterface> & telephonyService) const458 int32_t CsTest::GetMute(const sptr<CellularCallInterface> &telephonyService) const
459 {
460 std::cout << "test GetMute entry.\n";
461 int32_t slotId = 0;
462 std::cout << "please enter the slotId:(0 1)";
463 std::cin >> slotId;
464 return telephonyService->GetMute(slotId);
465 }
466
JudgeIsEmergencyPhoneNumber()467 void CsTest::JudgeIsEmergencyPhoneNumber()
468 {
469 auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
470 ASSERT_TRUE(systemAbilityMgr != nullptr);
471 auto remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_CELLULAR_CALL_SYS_ABILITY_ID);
472 ASSERT_TRUE(remote != nullptr);
473 auto telephonyService = iface_cast<CellularCallInterface>(remote);
474 ASSERT_TRUE(telephonyService != nullptr);
475
476 if (!HasSimCard(SIM1_SLOTID) && !HasSimCard(SIM2_SLOTID)) {
477 return;
478 }
479 bool enabled = false;
480 int32_t successCode = 1;
481 if (HasSimCard(SIM1_SLOTID)) {
482 telephonyService->IsEmergencyPhoneNumber(SIM1_SLOTID, "499", enabled);
483 EXPECT_NE(enabled, successCode);
484 telephonyService->IsEmergencyPhoneNumber(SIM1_SLOTID, "443", enabled);
485 EXPECT_NE(enabled, successCode);
486 telephonyService->IsEmergencyPhoneNumber(SIM1_SLOTID, "356", enabled);
487 EXPECT_NE(enabled, successCode);
488 telephonyService->IsEmergencyPhoneNumber(SIM1_SLOTID, "975", enabled);
489 EXPECT_NE(enabled, successCode);
490 telephonyService->IsEmergencyPhoneNumber(SIM1_SLOTID, "783", enabled);
491 EXPECT_NE(enabled, successCode);
492 telephonyService->IsEmergencyPhoneNumber(SIM1_SLOTID, "350", enabled);
493 EXPECT_NE(enabled, successCode);
494 }
495 if (HasSimCard(SIM2_SLOTID)) {
496 telephonyService->IsEmergencyPhoneNumber(SIM2_SLOTID, "499", enabled);
497 EXPECT_NE(enabled, successCode);
498 telephonyService->IsEmergencyPhoneNumber(SIM2_SLOTID, "443", enabled);
499 EXPECT_NE(enabled, successCode);
500 telephonyService->IsEmergencyPhoneNumber(SIM2_SLOTID, "356", enabled);
501 EXPECT_NE(enabled, successCode);
502 telephonyService->IsEmergencyPhoneNumber(SIM2_SLOTID, "975", enabled);
503 EXPECT_NE(enabled, successCode);
504 telephonyService->IsEmergencyPhoneNumber(SIM2_SLOTID, "783", enabled);
505 EXPECT_NE(enabled, successCode);
506 telephonyService->IsEmergencyPhoneNumber(SIM2_SLOTID, "350", enabled);
507 EXPECT_NE(enabled, successCode);
508 }
509 }
510
InputNumForInterface(const sptr<CellularCallInterface> & telephonyService) const511 int32_t CsTest::InputNumForInterface(const sptr<CellularCallInterface> &telephonyService) const
512 {
513 int32_t ret = -1;
514 bool loopFlag = true;
515 int32_t InputNumber = 0;
516 int32_t returnNum = 1000; // end loop variable value
517 while (loopFlag) {
518 std::cout << "\n**********Unit Test Start**********\n"
519 "Usage: please input a cmd num:\n"
520 "1:Dial\n2:HangUp\n3:Reject\n4:Answer\n5:HoldCall\n6:UnHoldCall\n7:SwitchCall\n"
521 "8:IsEmergencyPhoneNumber\n10:CombineConference\n11:SeparateConference\n12:InviteToConference\n"
522 "13:KickOutFromConference\n14:HangUpAllConnection\n"
523 "17:RegisterCallBack\n18:UnRegisterCallBack\n100:StartDtmf\n101:StopDtmf\n102:SendDtmf\n"
524 "104:StartRtt\n105:StopRtt\n200:SetCallTransferInfo\n201:GetCallTransferInfo\n"
525 "203:SetCallWaiting\n204:GetCallWaiting\n205:SetCallRestriction\n"
526 "206:GetCallRestriction\n208:SetCallRestrictionPassword\n309:SetMute\n310:GetMute\n"
527 "1000:Exit\n"
528 "***********************************\n"
529 "Your choice: ";
530 std::cin >> InputNumber;
531 if (InputNumber == returnNum) {
532 std::cout << "exiting...\n";
533 break;
534 }
535 auto itFunc = requestFuncMap_.find(InputNumber);
536 if (itFunc != requestFuncMap_.end()) {
537 auto requestFunc = itFunc->second;
538 if (requestFunc != nullptr) {
539 ret = (this->*requestFunc)(telephonyService);
540 }
541 }
542 if (ret != CELLULAR_CALL_SUCCESS) {
543 std::cout << "this execution did not return a successful value, please check.\n";
544 return ret;
545 }
546 }
547 return CELLULAR_CALL_SUCCESS;
548 }
549
InitCallInfo(CellularCallInfo & callInfo) const550 int32_t CsTest::InitCallInfo(CellularCallInfo &callInfo) const
551 {
552 if (memset_s(&callInfo, sizeof(callInfo), 0, sizeof(callInfo)) != EOK) {
553 std::cout << "CellularCallService return, memset_s failed. \n";
554 return CELLULAR_CALL_ERROR;
555 }
556
557 std::cout << "please enter the phone number:";
558 std::cin >> callInfo.phoneNum;
559 callInfo.videoState = 1;
560 std::cout << "please enter the call type(0:CS 1:IMS):";
561 int32_t callType = 0;
562 std::cin >> callType;
563 callInfo.callType = static_cast<CallType>(callType);
564 int32_t slotId = 0;
565 std::cout << "please enter the slotId:(0 1)";
566 std::cin >> slotId;
567 callInfo.slotId = slotId;
568 return CELLULAR_CALL_SUCCESS;
569 }
570 } // namespace Telephony
571 } // namespace OHOS
572