1 /*
2 * Copyright (C) 2022-2024 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 #define private public
16 #define protected public
17 #include "bluetooth_call_client.h"
18 #include "bluetooth_call_manager.h"
19 #include "bluetooth_call_service.h"
20 #include "bluetooth_connection.h"
21 #include "iremote_broker.h"
22 #include "call_ability_callback.h"
23 #include "call_ability_connect_callback.h"
24 #include "call_ability_report_proxy.h"
25 #include "call_connect_ability.h"
26 #include "call_control_manager.h"
27 #include "call_manager_client.h"
28 #include "call_manager_hisysevent.h"
29 #include "call_number_utils.h"
30 #include "call_policy.h"
31 #include "call_records_manager.h"
32 #include "call_request_event_handler_helper.h"
33 #include "call_request_handler.h"
34 #include "call_request_process.h"
35 #include "call_setting_manager.h"
36 #include "call_state_report_proxy.h"
37 #include "call_status_manager.h"
38 #include "cellular_call_connection.h"
39 #include "common_event_manager.h"
40 #include "common_event_support.h"
41 #include "cs_call.h"
42 #include "cs_conference.h"
43 #include "distributed_call_manager.h"
44 #include "gtest/gtest.h"
45 #include "i_voip_call_manager_service.h"
46 #include "ims_call.h"
47 #include "ims_conference.h"
48 #include "incoming_call_notification.h"
49 #include "missed_call_notification.h"
50 #include "ott_call.h"
51 #include "ott_conference.h"
52 #include "reject_call_sms.h"
53 #include "report_call_info_handler.h"
54 #include "satellite_call.h"
55 #include "surface_utils.h"
56 #include "telephony_errors.h"
57 #include "telephony_hisysevent.h"
58 #include "telephony_log_wrapper.h"
59 #include "video_call_state.h"
60 #include "video_control_manager.h"
61 #include "voip_call_manager_proxy.h"
62 #include "voip_call.h"
63 #include "accesstoken_kit.h"
64 #include "token_setproc.h"
65 #include "nativetoken_kit.h"
66 #include "number_identity_data_base_helper.h"
67 #include "call_ability_callback_death_recipient.h"
68 #include "app_state_observer.h"
69 #include "call_ability_callback_proxy.h"
70 #include "super_privacy_manager_client.h"
71 #include "call_status_callback.h"
72 #include "satellite_call_control.h"
73 #include "proximity_sensor.h"
74 #include "status_bar.h"
75 #include "wired_headset.h"
76 #include "call_status_policy.h"
77
78 namespace OHOS {
79 namespace Telephony {
80 using namespace testing::ext;
81
82 namespace {
83 const int32_t INVALID_SLOTID = 2;
84 const int32_t SIM1_SLOTID = 0;
85 const int32_t DEFAULT_INDEX = 1;
86 const int16_t CAMERA_ROTATION_0 = 0;
87 const int16_t CAMERA_ROTATION_90 = 90;
88 const int16_t CAMERA_ROTATION_180 = 180;
89 const int16_t CAMERA_ROTATION_270 = 270;
90 const int32_t INVALID_MODE = 0;
91 const int32_t VALID_CALLID = 1;
92 const int32_t ERROR_CALLID = -1;
93 const int32_t ONE_TIME = 1;
94 const int32_t STEP_1 = 1;
95 const int32_t SOURCE_CALL = 2;
96 constexpr int16_t DEFAULT_TIME = 0;
97 constexpr const char *TEST_STR = "123";
98 constexpr const char *LONG_STR =
99 "11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111"
100 "111111111";
101 } // namespace
102
103 class DemoHandler : public AppExecFwk::EventHandler {
104 public:
DemoHandler(std::shared_ptr<AppExecFwk::EventRunner> & eventRunner)105 explicit DemoHandler(std::shared_ptr<AppExecFwk::EventRunner> &eventRunner) : AppExecFwk::EventHandler(eventRunner)
106 {}
~DemoHandler()107 virtual ~DemoHandler() {}
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)108 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) {}
109 };
110
111 class ZeroBranch5Test : public testing::Test {
112 public:
113 void SetUp();
114 void TearDown();
115 static void SetUpTestCase();
116 static void TearDownTestCase();
117 };
118
SetUp()119 void ZeroBranch5Test::SetUp() {}
120
TearDown()121 void ZeroBranch5Test::TearDown() {}
122
SetUpTestCase()123 void ZeroBranch5Test::SetUpTestCase()
124 {
125 constexpr int permissionNum = 1;
126 const char *perms[permissionNum] = {
127 "ohos.permission.GET_TELEPHONY_STATE"
128 };
129 NativeTokenInfoParams infoInstance = {
130 .dcapsNum = 0, // Indicates the capsbility list of the sa.
131 .permsNum = permissionNum,
132 .aclsNum = 0, // acls is the list of rights thar can be escalated.
133 .dcaps = nullptr,
134 .perms = perms,
135 .acls = nullptr,
136 .processName = "ZeroBranch5Test",
137 .aplStr = "system_basic",
138 };
139 uint64_t tokenId = GetAccessTokenId(&infoInstance);
140 SetSelfTokenID(tokenId);
141 auto result = Security::AccessToken::AccessTokenKit::ReloadNativeTokenInfo();
142 EXPECT_EQ(result, Security::AccessToken::RET_SUCCESS);
143 }
144
TearDownTestCase()145 void ZeroBranch5Test::TearDownTestCase() {}
146
CreateDataShareHelper(std::string uri)147 std::shared_ptr<DataShare::DataShareHelper> CreateDataShareHelper(std::string uri)
148 {
149 auto saManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
150 if (saManager == nullptr) {
151 printf("Get system ability mgr failed.");
152 return nullptr;
153 }
154 auto remoteObj = saManager->GetSystemAbility(TELEPHONY_CALL_MANAGER_SYS_ABILITY_ID);
155 if (remoteObj == nullptr) {
156 printf("GetSystemAbility Service Failed.");
157 return nullptr;
158 }
159 return DataShare::DataShareHelper::Creator(remoteObj, uri);
160 }
161
162 /**
163 * @tc.number Telephony_CallStatusManager_003
164 * @tc.name test error branch
165 * @tc.desc Function test
166 */
167 HWTEST_F(ZeroBranch5Test, Telephony_CallStatusManager_003, Function | MediumTest | Level3)
168 {
169 std::shared_ptr<CallStatusManager> callStatusManager = std::make_shared<CallStatusManager>();
170 callStatusManager->Init();
171 CellularCallEventInfo cellularCallEventInfo;
172 ASSERT_EQ(callStatusManager->HandleEventResultReportInfo(cellularCallEventInfo), TELEPHONY_SUCCESS);
173 cellularCallEventInfo.eventType = CellularCallEventType::EVENT_REQUEST_RESULT_TYPE;
174 cellularCallEventInfo.eventId = RequestResultEventId::RESULT_DIAL_NO_CARRIER;
175 ASSERT_EQ(callStatusManager->HandleEventResultReportInfo(cellularCallEventInfo), TELEPHONY_SUCCESS);
176 OttCallEventInfo ottCallEventInfo;
177 (void)memset_s(&ottCallEventInfo, sizeof(OttCallEventInfo), 0, sizeof(OttCallEventInfo));
178 ottCallEventInfo.ottCallEventId = OttCallEventId::OTT_CALL_EVENT_FUNCTION_UNSUPPORTED;
179 (void)memcpy_s(ottCallEventInfo.bundleName, kMaxBundleNameLen + 1, LONG_STR, strlen(LONG_STR));
180 ASSERT_EQ(callStatusManager->HandleOttEventReportInfo(ottCallEventInfo), TELEPHONY_SUCCESS);
181 (void)memset_s(&ottCallEventInfo, sizeof(OttCallEventInfo), 0, sizeof(OttCallEventInfo));
182 ottCallEventInfo.ottCallEventId = OttCallEventId::OTT_CALL_EVENT_FUNCTION_UNSUPPORTED;
183 (void)memcpy_s(ottCallEventInfo.bundleName, kMaxBundleNameLen + 1, TEST_STR, strlen(TEST_STR));
184 ASSERT_EQ(callStatusManager->HandleOttEventReportInfo(ottCallEventInfo), TELEPHONY_SUCCESS);
185 CallDetailInfo callDetailInfo;
186 std::string number = "";
187 memcpy_s(&callDetailInfo.phoneNum, kMaxNumberLen, number.c_str(), number.length());
188 callDetailInfo.state = TelCallState::CALL_STATUS_INCOMING;
189 callDetailInfo.callType = CallType::TYPE_CS;
190 ASSERT_EQ(callStatusManager->IncomingFilterPolicy(callDetailInfo), TELEPHONY_SUCCESS);
191 callStatusManager->CallFilterCompleteResult(callDetailInfo);
192 CallDirection dir = CallDirection::CALL_DIRECTION_OUT;
193 ASSERT_FALSE(callStatusManager->CreateNewCall(callDetailInfo, dir) == nullptr);
194 dir = CallDirection::CALL_DIRECTION_IN;
195 ASSERT_FALSE(callStatusManager->CreateNewCall(callDetailInfo, dir) == nullptr);
196 callDetailInfo.callType = CallType::TYPE_IMS;
197 dir = CallDirection::CALL_DIRECTION_OUT;
198 ASSERT_FALSE(callStatusManager->CreateNewCall(callDetailInfo, dir) == nullptr);
199 dir = CallDirection::CALL_DIRECTION_IN;
200 ASSERT_FALSE(callStatusManager->CreateNewCall(callDetailInfo, dir) == nullptr);
201 callDetailInfo.callType = CallType::TYPE_OTT;
202 dir = CallDirection::CALL_DIRECTION_OUT;
203 ASSERT_FALSE(callStatusManager->CreateNewCall(callDetailInfo, dir) == nullptr);
204 dir = CallDirection::CALL_DIRECTION_IN;
205 ASSERT_FALSE(callStatusManager->CreateNewCall(callDetailInfo, dir) == nullptr);
206 callDetailInfo.callType = CallType::TYPE_ERR_CALL;
207 ASSERT_TRUE(callStatusManager->CreateNewCall(callDetailInfo, dir) == nullptr);
208 }
209
210 /**
211 * @tc.number Telephony_CallStatusManager_004
212 * @tc.name test error branch
213 * @tc.desc Function test
214 */
215 HWTEST_F(ZeroBranch5Test, Telephony_CallStatusManager_004, Function | MediumTest | Level3)
216 {
217 std::shared_ptr<CallStatusManager> callStatusManager = std::make_shared<CallStatusManager>();
218 callStatusManager->Init();
219 sptr<CallBase> callObjectPtr = nullptr;
220 callStatusManager->HandleRejectCall(callObjectPtr, true);
221 DialParaInfo dialParaInfo;
222 dialParaInfo.callType = CallType::TYPE_CS;
223 dialParaInfo.callState = TelCallState::CALL_STATUS_INCOMING;
224 callObjectPtr = new CSCall(dialParaInfo);
225 callStatusManager->HandleRejectCall(callObjectPtr, true);
226 CallDetailInfo callDetailInfo;
227 std::string number = "";
228 memcpy_s(&callDetailInfo.phoneNum, kMaxNumberLen, number.c_str(), number.length());
229 callDetailInfo.state = TelCallState::CALL_STATUS_INCOMING;
230 callDetailInfo.callType = CallType::TYPE_CS;
231 callDetailInfo.voipCallInfo.voipCallId = "123456789";
232 callStatusManager->OutgoingVoipCallHandle(callDetailInfo);
233 std::vector<std::u16string> callIdList;
234 CallRunningState previousState = CallRunningState::CALL_RUNNING_STATE_CREATE;
235 TelCallState priorState = TelCallState::CALL_STATUS_INCOMING;
236 callStatusManager->HandleHoldCallOrAutoAnswerCall(callObjectPtr, callIdList, previousState, priorState);
237 callStatusManager->AutoAnswerForVoiceCall(callObjectPtr, SIM1_SLOTID, true);
238 callStatusManager->SetVideoCallState(callObjectPtr, TelCallState::CALL_STATUS_ACTIVE);
239 callStatusManager->ShouldRejectIncomingCall();
240 callStatusManager->IsRingOnceCall(callObjectPtr, callDetailInfo);
241 sptr<CallBase> callObjectPtr1 = nullptr;
242 int32_t res = callStatusManager->HandleRingOnceCall(callObjectPtr1);
243 callStatusManager->HandleRingOnceCall(callObjectPtr);
244 ASSERT_NE(res, TELEPHONY_SUCCESS);
245 }
246
247 /**
248 * @tc.number Telephony_IncomingCallWakeup_001
249 * @tc.name test error branch
250 * @tc.desc Function test
251 */
252 HWTEST_F(ZeroBranch5Test, Telephony_IncomingCallWakeup_001, Function | MediumTest | Level3)
253 {
254 IncomingCallWakeup incomingCallWakeup;
255 sptr<CallBase> callObjectPtr = nullptr;
256 ASSERT_NO_THROW(incomingCallWakeup.NewCallCreated(callObjectPtr));
257 }
258
259 /**
260 * @tc.number Telephony_CallStateReportProxy_001
261 * @tc.name test error branch
262 * @tc.desc Function test
263 */
264 HWTEST_F(ZeroBranch5Test, Telephony_CallStateReportProxy_001, Function | MediumTest | Level3)
265 {
266 CallStateReportProxy callStateReportPtr;
267 sptr<CallBase> callObjectPtr = nullptr;
268 callStateReportPtr.CallStateUpdated(
269 callObjectPtr, TelCallState::CALL_STATUS_INCOMING, TelCallState::CALL_STATUS_INCOMING);
270 DialParaInfo dialParaInfo;
271 dialParaInfo.callType = CallType::TYPE_CS;
272 dialParaInfo.callState = TelCallState::CALL_STATUS_INCOMING;
273 callObjectPtr = new CSCall(dialParaInfo);
274 ASSERT_TRUE(callObjectPtr != nullptr);
275 callStateReportPtr.CallStateUpdated(
276 callObjectPtr, TelCallState::CALL_STATUS_INCOMING, TelCallState::CALL_STATUS_INCOMING);
277 callObjectPtr->SetTelCallState(TelCallState::CALL_STATUS_ACTIVE);
278 callStateReportPtr.CallStateUpdated(
279 callObjectPtr, TelCallState::CALL_STATUS_INCOMING, TelCallState::CALL_STATUS_INCOMING);
280 callStateReportPtr.UpdateCallState(callObjectPtr, TelCallState::CALL_STATUS_INCOMING);
281 callStateReportPtr.UpdateCallStateForSlotId(callObjectPtr, TelCallState::CALL_STATUS_INCOMING);
282 std::string number = "123456789012";
283 std::u16string phoneNumber = Str8ToStr16(number);
284 callStateReportPtr.ReportCallState(0, phoneNumber);
285 callStateReportPtr.ReportCallStateForCallId(0, 0, phoneNumber);
286 ASSERT_TRUE(!number.empty());
287 }
288
289 /**
290 * @tc.number Telephony_CallStateListener_001
291 * @tc.name test error branch
292 * @tc.desc Function test
293 */
294 HWTEST_F(ZeroBranch5Test, Telephony_CallStateListener_001, Function | MediumTest | Level3)
295 {
296 CallStateListener callStateListener;
297 sptr<CallBase> callObjectPtr = nullptr;
298 callStateListener.NewCallCreated(callObjectPtr);
299 callStateListener.CallStateUpdated(
300 callObjectPtr, TelCallState::CALL_STATUS_INCOMING, TelCallState::CALL_STATUS_INCOMING);
301 callStateListener.IncomingCallHungUp(callObjectPtr, true, "");
302 callStateListener.IncomingCallActivated(callObjectPtr);
303 DialParaInfo dialParaInfo;
304 callObjectPtr = new CSCall(dialParaInfo);
305 callStateListener.NewCallCreated(callObjectPtr);
306 callStateListener.CallStateUpdated(
307 callObjectPtr, TelCallState::CALL_STATUS_INCOMING, TelCallState::CALL_STATUS_INCOMING);
308 callStateListener.IncomingCallHungUp(callObjectPtr, true, "");
309 callStateListener.IncomingCallActivated(callObjectPtr);
310 std::shared_ptr<CallStateReportProxy> callStateReportPtr = nullptr;
311 ASSERT_FALSE(callStateListener.AddOneObserver(callStateReportPtr));
312 ASSERT_FALSE(callStateListener.RemoveOneObserver(callStateReportPtr));
313 callStateReportPtr = std::make_shared<CallStateReportProxy>();
314 ASSERT_TRUE(callStateListener.AddOneObserver(callStateReportPtr));
315 ASSERT_TRUE(callStateListener.AddOneObserver(callStateReportPtr));
316 }
317
318 /**
319 * @tc.number Telephony_ConferenceBase_001
320 * @tc.name test error branch
321 * @tc.desc Function test
322 */
323 HWTEST_F(ZeroBranch5Test, Telephony_ConferenceBase_001, Function | MediumTest | Level3)
324 {
325 std::shared_ptr<ConferenceBase> conference = std::make_shared<CsConference>();
326 std::vector<std::u16string> callIdList;
327 ASSERT_NE(conference->GetSubCallIdList(VALID_CALLID, callIdList), TELEPHONY_SUCCESS);
328 ASSERT_NE(conference->GetCallIdListForConference(VALID_CALLID, callIdList), TELEPHONY_SUCCESS);
329 ASSERT_NE(conference->JoinToConference(VALID_CALLID), TELEPHONY_SUCCESS);
330 ASSERT_NE(conference->LeaveFromConference(VALID_CALLID), TELEPHONY_SUCCESS);
331 ASSERT_NE(conference->HoldConference(VALID_CALLID), TELEPHONY_SUCCESS);
332 ASSERT_NE(conference->CanSeparateConference(), TELEPHONY_SUCCESS);
333 ASSERT_NE(conference->CanKickOutFromConference(), TELEPHONY_SUCCESS);
334 ASSERT_EQ(conference->SetMainCall(ERROR_CALLID), TELEPHONY_SUCCESS);
335 ASSERT_EQ(conference->SetMainCall(VALID_CALLID), TELEPHONY_SUCCESS);
336 ASSERT_NE(conference->CanSeparateConference(), TELEPHONY_SUCCESS);
337 ASSERT_NE(conference->CanKickOutFromConference(), TELEPHONY_SUCCESS);
338 conference->SetConferenceState(ConferenceState::CONFERENCE_STATE_CREATING);
339 ASSERT_EQ(conference->JoinToConference(VALID_CALLID), TELEPHONY_SUCCESS);
340 ASSERT_EQ(conference->GetSubCallIdList(VALID_CALLID, callIdList), TELEPHONY_SUCCESS);
341 ASSERT_EQ(conference->GetCallIdListForConference(VALID_CALLID, callIdList), TELEPHONY_SUCCESS);
342 ASSERT_EQ(conference->CanSeparateConference(), TELEPHONY_SUCCESS);
343 ASSERT_EQ(conference->CanKickOutFromConference(), TELEPHONY_SUCCESS);
344 ASSERT_EQ(conference->HoldConference(VALID_CALLID), TELEPHONY_SUCCESS);
345 ASSERT_EQ(conference->SetMainCall(VALID_CALLID), TELEPHONY_SUCCESS);
346 ASSERT_EQ(conference->JoinToConference(VALID_CALLID), TELEPHONY_SUCCESS);
347 ASSERT_EQ(conference->LeaveFromConference(VALID_CALLID), TELEPHONY_SUCCESS);
348 }
349
350 /**
351 * @tc.number Telephony_CallAbilityReportProxy_001
352 * @tc.name test error branch
353 * @tc.desc Function test
354 */
355 HWTEST_F(ZeroBranch5Test, Telephony_CallAbilityReportProxy_001, Function | MediumTest | Level3)
356 {
357 CallAbilityConnectCallback callAbilityConnectCallback;
358 callAbilityConnectCallback.ReConnectAbility();
359 if (CallObjectManager::HasCallExist()) {
360 callAbilityConnectCallback.ReConnectAbility();
361 }
362 CallConnectAbility callConnectCalluiAbility;
363 ASSERT_FALSE(callConnectCalluiAbility.WaitForConnectResult());
364 std::shared_ptr<CallAbilityReportProxy> callAbilityReportProxy = std::make_shared<CallAbilityReportProxy>();
365 sptr<ICallAbilityCallback> callAbilityCallbackPtr = nullptr;
366 std::string pidName = "123";
367 ASSERT_NE(callAbilityReportProxy->RegisterCallBack(callAbilityCallbackPtr, pidName), TELEPHONY_SUCCESS);
368 ASSERT_NE(callAbilityReportProxy->UnRegisterCallBack(pidName), TELEPHONY_SUCCESS);
369 sptr<IRemoteObject> object = nullptr;
370 ASSERT_NE(callAbilityReportProxy->UnRegisterCallBack(object), TELEPHONY_SUCCESS);
371 sptr<CallBase> callObjectPtr = nullptr;
372 callAbilityReportProxy->CallStateUpdated(
373 callObjectPtr, TelCallState::CALL_STATUS_INCOMING, TelCallState::CALL_STATUS_INCOMING);
374 callAbilityCallbackPtr = new CallAbilityCallback();
375 ASSERT_EQ(callAbilityReportProxy->RegisterCallBack(callAbilityCallbackPtr, pidName), TELEPHONY_SUCCESS);
376 DisconnectedDetails disconnectedDetails;
377 callAbilityReportProxy->CallDestroyed(disconnectedDetails);
378 CallAttributeInfo callAttributeInfo;
379 callAbilityReportProxy->ReportCallStateInfo(callAttributeInfo);
380 callAbilityReportProxy->ReportCallStateInfo(callAttributeInfo, pidName);
381 CallEventInfo callEventInfo;
382 callAbilityReportProxy->CallEventUpdated(callEventInfo);
383 callAbilityReportProxy->ReportCallEvent(callEventInfo);
384 CallResultReportId reportId = CallResultReportId::GET_CALL_CLIP_ID;
385 AppExecFwk::PacMap resultInfo;
386 callAbilityReportProxy->ReportAsyncResults(reportId, resultInfo);
387 MmiCodeInfo mmiCodeInfo;
388 callAbilityReportProxy->ReportMmiCodeResult(mmiCodeInfo);
389 OttCallRequestId ottReportId = OttCallRequestId::OTT_REQUEST_ANSWER;
390 callAbilityReportProxy->OttCallRequest(ottReportId, resultInfo);
391 callAbilityReportProxy->ReportPostDialDelay(TEST_STR);
392 std::string ottBundleName = "com.ohos.callservice";
393 sptr<CallAbilityCallback> ottCallAbilityCallbackPtr = new CallAbilityCallback();
394 ASSERT_EQ(callAbilityReportProxy->RegisterCallBack(ottCallAbilityCallbackPtr, ottBundleName), TELEPHONY_SUCCESS);
395 callAbilityReportProxy->OttCallRequest(ottReportId, resultInfo);
396 ASSERT_EQ(callAbilityReportProxy->UnRegisterCallBack(ottBundleName), TELEPHONY_SUCCESS);
397 CallMediaModeInfo imsCallModeInfo;
398 callAbilityReportProxy->ReportImsCallModeChange(imsCallModeInfo);
399 CallSessionEvent callSessionEventOptions;
400 callAbilityReportProxy->ReportCallSessionEventChange(callSessionEventOptions);
401 PeerDimensionsDetail peerDimensionsDetail;
402 callAbilityReportProxy->ReportPeerDimensionsChange(peerDimensionsDetail);
403 }
404
405 /**
406 * @tc.number Telephony_CallAbilityReportProxy_002
407 * @tc.name test error branch
408 * @tc.desc Function test
409 */
410 HWTEST_F(ZeroBranch5Test, Telephony_CallAbilityReportProxy_002, Function | MediumTest | Level3)
411 {
412 CallAbilityConnectCallback callAbilityConnectCallback;
413 callAbilityConnectCallback.ReConnectAbility();
414 if (CallObjectManager::HasCallExist()) {
415 callAbilityConnectCallback.ReConnectAbility();
416 }
417 CallConnectAbility callConnectCalluiAbility;
418 callConnectCalluiAbility.WaitForConnectResult();
419 std::shared_ptr<CallAbilityReportProxy> callAbilityReportProxy = std::make_shared<CallAbilityReportProxy>();
420 ASSERT_NE(callAbilityReportProxy, nullptr);
421 int64_t dataUsage = 0;
422 std::string pidName = "123";
423 ASSERT_NE(callAbilityReportProxy->ReportCallDataUsageChange(dataUsage), TELEPHONY_SUCCESS);
424 CameraCapabilities cameraCapabilities;
425 ASSERT_NE(callAbilityReportProxy->ReportCameraCapabilities(cameraCapabilities), TELEPHONY_SUCCESS);
426 ASSERT_NE(callAbilityReportProxy->UnRegisterCallBack(pidName), TELEPHONY_SUCCESS);
427 }
428
429 /**
430 * @tc.number Telephony_CallAbilityConnectCallback_001
431 * @tc.name test error branch
432 * @tc.desc Function test
433 */
434 HWTEST_F(ZeroBranch5Test, Telephony_CallAbilityConnectCallback_001, Function | MediumTest | Level3)
435 {
436 CallAbilityConnectCallback callAbilityConnectCallback;
437 callAbilityConnectCallback.ReConnectAbility();
438 if (CallObjectManager::HasCallExist()) {
439 callAbilityConnectCallback.ReConnectAbility();
440 }
441 std::string bundle = "111";
442 std::string ability = "222";
443 AppExecFwk::ElementName element("", bundle, ability);
444 int resultCode = 0;
445 callAbilityConnectCallback.OnAbilityConnectDone(element, nullptr, resultCode);
446 ASSERT_EQ(resultCode, 0);
447 callAbilityConnectCallback.OnAbilityDisconnectDone(element, resultCode);
448 ASSERT_EQ(resultCode, 0);
449 }
450
451 /**
452 * @tc.number Telephony_AutoAnswerState_001
453 * @tc.name test error branch
454 * @tc.desc Function test
455 */
456 HWTEST_F(ZeroBranch5Test, Telephony_AutoAnswerState_001, Function | MediumTest | Level3)
457 {
458 bool flag = true;
459 sptr<CallBase> callObjectPtr = nullptr;
460 DialParaInfo dialParaInfo;
461 dialParaInfo.callType = CallType::TYPE_IMS;
462 dialParaInfo.callState = TelCallState::CALL_STATUS_INCOMING;
463 callObjectPtr = new IMSCall(dialParaInfo);
464 ASSERT_TRUE(callObjectPtr != nullptr);
465 callObjectPtr->SetAutoAnswerState(flag);
466 ASSERT_EQ(callObjectPtr->GetAutoAnswerState(), true);
467 }
468
469 /**
470 * @tc.number Telephony_CanUnHoldState_001
471 * @tc.name test error branch
472 * @tc.desc Function test
473 */
474 HWTEST_F(ZeroBranch5Test, Telephony_CanUnHoldState_001, Function | MediumTest | Level3)
475 {
476 bool flag = true;
477 sptr<CallBase> callObjectPtr = nullptr;
478 DialParaInfo dialParaInfo;
479 dialParaInfo.callType = CallType::TYPE_IMS;
480 dialParaInfo.callState = TelCallState::CALL_STATUS_INCOMING;
481 callObjectPtr = new IMSCall(dialParaInfo);
482 ASSERT_TRUE(callObjectPtr != nullptr);
483 callObjectPtr->SetCanUnHoldState(flag);
484 ASSERT_EQ(callObjectPtr->GetCanUnHoldState(), true);
485 }
486
487 /**
488 * @tc.number Telephony_SatelliteCall_001
489 * @tc.name test error branch
490 * @tc.desc Function test
491 */
492 HWTEST_F(ZeroBranch5Test, Telephony_SatelliteCall_001, Function | MediumTest | Level3)
493 {
494 DialParaInfo dialParaInfo;
495 SatelliteCall call { dialParaInfo };
496 int32_t ret1 = call.DialingProcess();
497 int32_t ret2 = call.AnswerCall(0);
498 int32_t ret3 = call.RejectCall();
499 int32_t ret4 = call.HangUpCall();
500 CallAttributeInfo callAttributeInfo;
501 call.GetCallAttributeInfo(callAttributeInfo);
502 EXPECT_EQ(ret1, TELEPHONY_SUCCESS);
503 EXPECT_NE(ret2, TELEPHONY_SUCCESS);
504 EXPECT_NE(ret3, TELEPHONY_SUCCESS);
505 EXPECT_NE(ret4, TELEPHONY_SUCCESS);
506 }
507
508 /**
509 * @tc.number Telephony_VoipCallManagerProxy_001
510 * @tc.name test error branch
511 * @tc.desc Function test
512 */
513 HWTEST_F(ZeroBranch5Test, Telephony_VoipCallManagerProxy_001, Function | MediumTest | Level3)
514 {
515 sptr<ISystemAbilityManager> managerPtr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
516 sptr<IVoipCallManagerService> voipCallManagerInterfacePtr = nullptr;
517 if (managerPtr != nullptr) {
518 sptr<IRemoteObject> iRemoteObjectPtr = managerPtr->GetSystemAbility(TELEPHONY_CALL_MANAGER_SYS_ABILITY_ID);
519 if (iRemoteObjectPtr != nullptr) {
520 voipCallManagerInterfacePtr = iface_cast<IVoipCallManagerService>(iRemoteObjectPtr);
521 }
522 }
523 AppExecFwk::PacMap mPacMap;
524 ErrorReason error = ErrorReason::VOIP_CALL_EXISTS;
525 if (voipCallManagerInterfacePtr != nullptr) {
526 std::vector<uint8_t> userProfile = { 0 };
527 int32_t ret1 = voipCallManagerInterfacePtr->ReportIncomingCall(mPacMap, userProfile, error);
528 int32_t ret2 = voipCallManagerInterfacePtr->ReportIncomingCallError(mPacMap);
529 VoipCallState voipCallState = VoipCallState::VOIP_CALL_STATE_ACTIVE;
530 VoipCallType voipCallType = VoipCallType::VOIP_CALL_VOICE;
531 std::string callId = "123";
532 int32_t ret3 = voipCallManagerInterfacePtr->ReportCallStateChange(callId, voipCallState, voipCallType);
533 int32_t ret4 = voipCallManagerInterfacePtr->UnRegisterCallBack();
534 std::string bundleName = " ";
535 std::string processMode = "0";
536 int32_t uid = 0;
537 int32_t ret5 = voipCallManagerInterfacePtr->ReportVoipIncomingCall(callId, bundleName, processMode, uid);
538 std::string extensionId = " ";
539 int32_t ret6 = voipCallManagerInterfacePtr->ReportVoipCallExtensionId(callId, bundleName, extensionId, uid);
540 VoipCallEventInfo voipCallEventInfo;
541 voipCallEventInfo.voipCallId = "123";
542 int32_t ret7 = voipCallManagerInterfacePtr->Answer(voipCallEventInfo,
543 static_cast<int32_t>(VideoStateType::TYPE_VOICE));
544 int32_t ret8 = voipCallManagerInterfacePtr->HangUp(voipCallEventInfo);
545 int32_t ret9 = voipCallManagerInterfacePtr->Reject(voipCallEventInfo);
546 int32_t ret10 = voipCallManagerInterfacePtr->UnloadVoipSa();
547 sptr<ICallStatusCallback> statusCallback = (std::make_unique<CallStatusCallback>()).release();
548 int32_t ret11 = voipCallManagerInterfacePtr->RegisterCallManagerCallBack(statusCallback);
549 int32_t ret12 = voipCallManagerInterfacePtr->UnRegisterCallManagerCallBack();
550 EXPECT_NE(ret1, TELEPHONY_SUCCESS);
551 EXPECT_NE(ret2, TELEPHONY_SUCCESS);
552 EXPECT_NE(ret3, TELEPHONY_SUCCESS);
553 EXPECT_NE(ret4, TELEPHONY_SUCCESS);
554 EXPECT_NE(ret5, TELEPHONY_SUCCESS);
555 EXPECT_NE(ret6, TELEPHONY_SUCCESS);
556 EXPECT_NE(ret7, TELEPHONY_SUCCESS);
557 EXPECT_NE(ret8, TELEPHONY_SUCCESS);
558 EXPECT_NE(ret9, TELEPHONY_SUCCESS);
559 EXPECT_NE(ret10, TELEPHONY_SUCCESS);
560 EXPECT_NE(ret11, TELEPHONY_SUCCESS);
561 EXPECT_NE(ret12, TELEPHONY_SUCCESS);
562 }
563 }
564
565 /**
566 * @tc.number Telephony_CallRequestEventHandlerHelper_001
567 * @tc.name test error branch
568 * @tc.desc Function test
569 */
570 HWTEST_F(ZeroBranch5Test, Telephony_CallRequestEventHandlerHelper_001, Function | MediumTest | Level3)
571 {
572 bool flag = false;
573 DelayedSingleton<CallRequestEventHandlerHelper>::GetInstance()->RestoreDialingFlag(flag);
574 EXPECT_FALSE(DelayedSingleton<CallRequestEventHandlerHelper>::GetInstance()->IsDialingCallProcessing());
575 }
576
577 /**
578 * @tc.number Telephony_DistributedCallManager_001
579 * @tc.name test error branch
580 * @tc.desc Function test
581 */
582 HWTEST_F(ZeroBranch5Test, Telephony_DistributedCallManager_001, Function | MediumTest | Level3)
583 {
584 DistributedCallManager manager;
585 AudioDevice device;
586 device.deviceType = AudioDeviceType::DEVICE_EARPIECE;
587 std::string restr = manager.GetDevIdFromAudioDevice(device);
588 bool res1 = manager.SwitchOnDCallDeviceSync(device);
589 device.deviceType = AudioDeviceType::DEVICE_DISTRIBUTED_PHONE;
590 std::string devId = "";
591 manager.CreateDAudioDevice(devId, device);
592 manager.CreateDAudioDevice(TEST_STR, device);
593 manager.dcallProxy_ = std::make_shared<DistributedCallProxy>();
594 manager.CreateDAudioDevice(TEST_STR, device);
595 manager.AddDCallDevice(TEST_STR);
596 manager.RemoveDCallDevice(TEST_STR);
597 manager.onlineDCallDevices_.insert(std::make_pair(TEST_STR, device));
598 manager.AddDCallDevice(TEST_STR);
599 manager.RemoveDCallDevice(TEST_STR);
600 manager.GetConnectedDCallDeviceId();
601 manager.SwitchOffDCallDeviceSync();
602 manager.dCallDeviceSwitchedOn_.store(true);
603 manager.SwitchOffDCallDeviceSync();
604 manager.GetConnectedDCallDeviceId();
605 manager.GetConnectedDCallDevice(device);
606 manager.SetConnectedDCallDevice(device);
607 manager.ClearConnectedDCallDevice();
608 manager.SwitchOnDCallDeviceSync(device);
609 manager.OnDCallSystemAbilityAdded(TEST_STR);
610 EXPECT_TRUE(restr.empty());
611 EXPECT_FALSE(res1);
612 }
613
614 /**
615 * @tc.number Telephony_DistributedCallProxy_001
616 * @tc.name test error branch
617 * @tc.desc Function test
618 */
619 HWTEST_F(ZeroBranch5Test, Telephony_DistributedCallProxy_001, Function | MediumTest | Level3)
620 {
621 std::unique_ptr<DistributedCallProxy> proxy = std::make_unique<DistributedCallProxy>();
622 proxy->GetDCallClient();
623 int32_t res = proxy->Init();
624 proxy->GetDCallClient();
625 proxy->dcallClient_ = nullptr;
626 int32_t res1 = proxy->UnInit();
627 int32_t res3 = proxy->SwitchDevice(TEST_STR, 1);
628 std::vector<std::string> devList;
629 int32_t res4 = proxy->GetOnlineDeviceList(devList);
630 OHOS::DistributedHardware::DCallDeviceInfo devInfo;
631 int32_t res5 = proxy->GetDCallDeviceInfo(TEST_STR, devInfo);
632 proxy->GetDCallClient();
633 int32_t res6 = proxy->SwitchDevice(TEST_STR, 1);
634 int32_t res7 = proxy->GetOnlineDeviceList(devList);
635 proxy->GetDCallDeviceInfo(TEST_STR, devInfo);
636 int32_t res8 = proxy->UnInit();
637 EXPECT_NE(res, TELEPHONY_SUCCESS);
638 EXPECT_NE(res1, TELEPHONY_SUCCESS);
639 EXPECT_NE(res3, TELEPHONY_SUCCESS);
640 EXPECT_NE(res4, TELEPHONY_SUCCESS);
641 EXPECT_NE(res5, TELEPHONY_SUCCESS);
642 EXPECT_NE(res6, TELEPHONY_SUCCESS);
643 EXPECT_NE(res7, TELEPHONY_SUCCESS);
644 EXPECT_NE(res8, TELEPHONY_SUCCESS);
645 }
646
647 /**
648 * @tc.number Telephony_BluetoothCallManager_001
649 * @tc.name test error branch
650 * @tc.desc Function test
651 */
652 HWTEST_F(ZeroBranch5Test, Telephony_BluetoothCallManager_001, Function | MediumTest | Level3)
653 {
654 int32_t state = 0;
655 int32_t numActive = CallObjectManager::GetCallNum(TelCallState::CALL_STATUS_ACTIVE);
656 int32_t numHeld = CallObjectManager::GetCallNum(TelCallState::CALL_STATUS_HOLDING);
657 int32_t numDial = CallObjectManager::GetCallNum(TelCallState::CALL_STATUS_DIALING);
658 int32_t callState = static_cast<int32_t>(TelCallState::CALL_STATUS_IDLE);
659 std::string number = CallObjectManager::GetCallNumber(TelCallState::CALL_STATUS_HOLDING);
660 BluetoothCallManager bluetoothCallManager;
661 ASSERT_EQ(bluetoothCallManager.SendBtCallState(numActive, numHeld, callState, number), TELEPHONY_SUCCESS);
662 ASSERT_EQ(bluetoothCallManager.SendCallDetailsChange(1, 1), TELEPHONY_SUCCESS);
663 ASSERT_NE(bluetoothCallManager.IsBtAvailble(), true);
664 }
665
666 /**
667 * @tc.number Telephony_CallAbilityCallbackDeathRecipient_001
668 * @tc.name test error branch
669 * @tc.desc Function test
670 */
671 HWTEST_F(ZeroBranch5Test, Telephony_CallAbilityCallbackDeathRecipient_001, Function | MediumTest | Level3)
672 {
673 CallAbilityCallbackDeathRecipient recipient;
674 OHOS::wptr<OHOS::IRemoteObject> object;
675 recipient.OnRemoteDied(object);
676 ASSERT_EQ(object, nullptr);
677 }
678
679 /**
680 * @tc.number Telephony_ApplicationStateObserver_001
681 * @tc.name test error branch
682 * @tc.desc Function test
683 */
684 HWTEST_F(ZeroBranch5Test, Telephony_ApplicationStateObserver_001, Function | MediumTest | Level3)
685 {
686 ApplicationStateObserver applicationStateObserver;
687 AppExecFwk::ProcessData processData;
688 applicationStateObserver.OnProcessDied(processData);
689 ASSERT_NE(sizeof(processData), 0);
690 }
691
692 /**
693 * @tc.number Telephony_CallAbilityCallbackProxy_001
694 * @tc.name test error branch
695 * @tc.desc Function test
696 */
697 HWTEST_F(ZeroBranch5Test, Telephony_CallAbilityCallbackProxy_001, Function | MediumTest | Level3)
698 {
699 sptr<IRemoteObject> impl;
700 CallAbilityCallbackProxy callAbilityCallbackProxy(impl);
701 CallAttributeInfo callAttributeInfo;
702 callAbilityCallbackProxy.OnCallDetailsChange(callAttributeInfo);
703 CallEventInfo info;
704 callAbilityCallbackProxy.OnCallEventChange(info);
705 DisconnectedDetails details;
706 callAbilityCallbackProxy.OnCallDisconnectedCause(details);
707 AppExecFwk::PacMap resultInfo;
708
709 callAbilityCallbackProxy.OnReportAsyncResults(CallResultReportId::GET_CALL_CLIP_ID, resultInfo);
710 MmiCodeInfo mmiCodeInfo;
711 callAbilityCallbackProxy.OnReportMmiCodeResult(mmiCodeInfo);
712 callAbilityCallbackProxy.OnOttCallRequest(OttCallRequestId::OTT_REQUEST_ANSWER, resultInfo);
713 CallMediaModeInfo imsCallModeInfo;
714 callAbilityCallbackProxy.OnReportImsCallModeChange(imsCallModeInfo);
715 CallSessionEvent callSessionEventOptions;
716 callAbilityCallbackProxy.OnReportCallSessionEventChange(callSessionEventOptions);
717 PeerDimensionsDetail peerDimensionsDetail;
718 callAbilityCallbackProxy.OnReportPeerDimensionsChange(peerDimensionsDetail);
719 int64_t dataUsage = 0;
720 callAbilityCallbackProxy.OnReportCallDataUsageChange(dataUsage);
721 CameraCapabilities cameraCapabilities;
722 callAbilityCallbackProxy.OnReportCameraCapabilities(cameraCapabilities);
723
724 AudioDeviceInfo audioDeviceInfo;
725 callAbilityCallbackProxy.OnReportAudioDeviceChange(audioDeviceInfo);
726 const std::string str {"123"};
727 callAbilityCallbackProxy.OnReportPostDialDelay(str);
728 ASSERT_TRUE(!str.empty());
729 }
730
731 /**
732 * @tc.number Telephony_OTTCallConnection_001
733 * @tc.name test error branch
734 * @tc.desc Function test
735 */
736 HWTEST_F(ZeroBranch5Test, Telephony_OTTCallConnection_001, Function | MediumTest | Level3)
737 {
738 OTTCallConnection ott;
739 OttCallRequestInfo requestInfo;
740 ott.Answer(requestInfo);
741 ott.HoldCall(requestInfo);
742 ott.HangUp(requestInfo);
743 ott.Reject(requestInfo);
744 ott.UnHoldCall(requestInfo);
745 ott.SwitchCall(requestInfo);
746 ott.CombineConference(requestInfo);
747 ott.SeparateConference(requestInfo);
748 ott.KickOutFromConference(requestInfo);
749 std::vector<std::string> numberList;
750 int32_t result = ott.InviteToConference(requestInfo, numberList);
751 ott.UpdateImsCallMode(requestInfo, ImsCallMode::CALL_MODE_AUDIO_ONLY);
752 AppExecFwk::PacMap info;
753 ott.PackCellularCallInfo(requestInfo, info);
754 ASSERT_NE(result, TELEPHONY_SUCCESS);
755 }
756
757 /**
758 * @tc.number Telephony_SuperPrivacyManagerClient_001
759 * @tc.name test error branch
760 * @tc.desc Function test
761 */
762 HWTEST_F(ZeroBranch5Test, Telephony_SuperPrivacyManagerClient_001, Function | MediumTest | Level3)
763 {
764 int32_t privacy = SuperPrivacyManagerClient::GetInstance().
765 SetSuperPrivacyMode(static_cast<int32_t>(CallSuperPrivacyModeType::OFF), SOURCE_CALL);
766 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE
767 ASSERT_EQ(privacy, 22);
768 #else
769 ASSERT_EQ(privacy, 0);
770 #endif
771 }
772
773 /**
774 * @tc.number Telephony_CallStatusCallback_001
775 * @tc.name test error branch
776 * @tc.desc Function test
777 */
778 HWTEST_F(ZeroBranch5Test, Telephony_CallStatusCallback_001, Function | MediumTest | Level3)
779 {
780 auto callStatusCallback = std::make_shared<CallStatusCallback>();
781 CallReportInfo callReportInfo;
782 callStatusCallback->UpdateCallReportInfo(callReportInfo);
783 CallsReportInfo callsReportInfo;
784 callStatusCallback->UpdateCallsReportInfo(callsReportInfo);
785 DisconnectedDetails disconnectedDetails;
786 callStatusCallback->UpdateDisconnectedCause(disconnectedDetails);
787 CellularCallEventInfo cellularCallEventIndo;
788 callStatusCallback->UpdateEventResultInfo(cellularCallEventIndo);
789 RBTPlayInfo rbtpPlyaInfo = RBTPlayInfo::LOCAL_ALERTING;
790 callStatusCallback->UpdateRBTPlayInfo(rbtpPlyaInfo);
791 int32_t result = 0;
792 callStatusCallback->StartDtmfResult(result);
793 callStatusCallback->StopDtmfResult(result);
794 callStatusCallback->SendUssdResult(result);
795 callStatusCallback->GetImsCallDataResult(result);
796 CallWaitResponse callWaitResponse;
797 callStatusCallback->UpdateGetWaitingResult(callWaitResponse);
798 callStatusCallback->UpdateSetWaitingResult(result);
799 CallRestrictionResponse callRestrictionResponse;
800 callStatusCallback->UpdateGetRestrictionResult(callRestrictionResponse);
801 callStatusCallback->UpdateSetRestrictionResult(result);
802 callStatusCallback->UpdateSetRestrictionPasswordResult(result);
803 CallTransferResponse callTransferResponse;
804 callStatusCallback->UpdateGetTransferResult(callTransferResponse);
805 callStatusCallback->UpdateSetTransferResult(result);
806 ClipResponse clipResponse;
807 callStatusCallback->UpdateGetCallClipResult(clipResponse);
808 ClirResponse clirResponse;
809 callStatusCallback->UpdateGetCallClirResult(clirResponse);
810 callStatusCallback->UpdateSetCallClirResult(result);
811 callStatusCallback->StartRttResult(result);
812 callStatusCallback->StopRttResult(result);
813 GetImsConfigResponse getImsConfigResponse;
814 callStatusCallback->GetImsConfigResult(getImsConfigResponse);
815 callStatusCallback->SetImsConfigResult(result);
816 GetImsFeatureValueResponse getImsFeatureValueResopnse;
817 callStatusCallback->GetImsFeatureValueResult(getImsFeatureValueResopnse);
818 callStatusCallback->SetImsFeatureValueResult(result);
819 CallModeReportInfo callModeReportInfo;
820 callStatusCallback->ReceiveUpdateCallMediaModeRequest(callModeReportInfo);
821 callStatusCallback->ReceiveUpdateCallMediaModeResponse(callModeReportInfo);
822 callStatusCallback->InviteToConferenceResult(result);
823 MmiCodeInfo mmiCodeInfo;
824 callStatusCallback->SendMmiCodeResult(mmiCodeInfo);
825 int32_t res = callStatusCallback->CloseUnFinishedUssdResult(result);
826 ASSERT_NE(res, TELEPHONY_SUCCESS);
827 }
828
829 /**
830 * @tc.number Telephony_CallStatusCallback_002
831 * @tc.name test error branch
832 * @tc.desc Function test
833 */
834 HWTEST_F(ZeroBranch5Test, Telephony_CallStatusCallback_002, Function | MediumTest | Level3)
835 {
836 auto callStatusCallback = std::make_shared<CallStatusCallback>();
837 std::string c("a");
838 callStatusCallback->ReportPostDialChar(c);
839 std::string str("abc");
840 callStatusCallback->ReportPostDialDelay(str);
841 CallSessionReportInfo callSessionReportInfo;
842 callStatusCallback->HandleCallSessionEventChanged(callSessionReportInfo);
843 PeerDimensionsReportInfo peerDimensionReportInfo;
844 callStatusCallback->HandlePeerDimensionsChanged(peerDimensionReportInfo);
845 int64_t res = 0;
846 callStatusCallback->HandleCallDataUsageChanged(res);
847 CameraCapabilitiesReportInfo cameraCapabilities;
848 callStatusCallback->HandleCameraCapabilitiesChanged(cameraCapabilities);
849 VoipCallEventInfo voipCallEventInfo;
850 res = callStatusCallback->UpdateVoipEventInfo(voipCallEventInfo);
851 ASSERT_NE(res, TELEPHONY_SUCCESS);
852 }
853
854 /**
855 * @tc.number Telephony_CallStatusCallbackStub_001
856 * @tc.name test error branch
857 * @tc.desc Function test
858 */
859 HWTEST_F(ZeroBranch5Test, Telephony_CallStatusCallbackStub_001, Function | MediumTest | Level3)
860 {
861 auto callStatusCallback = std::make_shared<CallStatusCallback>();
862 MessageParcel data;
863 MessageParcel reply;
864 MessageOption option;
865 data.WriteInterfaceToken(CallStatusCallbackStub::GetDescriptor());
866 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_CALL_INFO),
867 data, reply, option);
868 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_CALLS_INFO),
869 data, reply, option);
870 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_DISCONNECTED_CAUSE),
871 data, reply, option);
872 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_EVENT_RESULT_INFO),
873 data, reply, option);
874 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_RBT_PLAY_INFO),
875 data, reply, option);
876 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_GET_WAITING),
877 data, reply, option);
878 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_SET_WAITING),
879 data, reply, option);
880 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_GET_RESTRICTION),
881 data, reply, option);
882 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_SET_RESTRICTION),
883 data, reply, option);
884 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_GET_TRANSFER),
885 data, reply, option);
886 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_SET_TRANSFER),
887 data, reply, option);
888 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_GET_CALL_CLIP),
889 data, reply, option);
890 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_GET_CALL_CLIR),
891 data, reply, option);
892 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_SET_CALL_CLIR),
893 data, reply, option);
894 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::GET_IMS_SWITCH_STATUS),
895 data, reply, option);
896 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::SET_IMS_SWITCH_STATUS),
897 data, reply, option);
898 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_STARTRTT_STATUS),
899 data, reply, option);
900 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_STOPRTT_STATUS),
901 data, reply, option);
902 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::GET_IMS_CONFIG),
903 data, reply, option);
904 int32_t res = callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::SET_IMS_CONFIG),
905 data, reply, option);
906 ASSERT_NE(res, TELEPHONY_SUCCESS);
907 }
908
909 /**
910 * @tc.number Telephony_CallStatusCallbackStub_002
911 * @tc.name test error branch
912 * @tc.desc Function test
913 */
914 HWTEST_F(ZeroBranch5Test, Telephony_CallStatusCallbackStub_002, Function | MediumTest | Level3)
915 {
916 auto callStatusCallback = std::make_shared<CallStatusCallback>();
917 MessageParcel data;
918 MessageParcel reply;
919 MessageOption option;
920 data.WriteInterfaceToken(CallStatusCallbackStub::GetDescriptor());
921 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::GET_IMS_FEATURE_VALUE),
922 data, reply, option);
923 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::SET_IMS_FEATURE_VALUE),
924 data, reply, option);
925 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::GET_LTE_ENHANCE_MODE),
926 data, reply, option);
927 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::SET_LTE_ENHANCE_MODE),
928 data, reply, option);
929 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(
930 CallStatusInterfaceCode::RECEIVE_UPDATE_MEDIA_MODE_RESPONSE), data, reply, option);
931 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::INVITE_TO_CONFERENCE),
932 data, reply, option);
933 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::START_DTMF),
934 data, reply, option);
935 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::STOP_DTMF),
936 data, reply, option);
937 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::SEND_USSD),
938 data, reply, option);
939 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::GET_IMS_CALL_DATA),
940 data, reply, option);
941 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::MMI_CODE_INFO_RESPONSE),
942 data, reply, option);
943 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::CLOSE_UNFINISHED_USSD),
944 data, reply, option);
945 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_SET_RESTRICTION_PWD),
946 data, reply, option);
947 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::POST_DIAL_CHAR),
948 data, reply, option);
949 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::POST_DIAL_DELAY),
950 data, reply, option);
951 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::CALL_SESSION_EVENT),
952 data, reply, option);
953 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::PEER_DIMENSION_CHANGE),
954 data, reply, option);
955 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::CALL_DATA_USAGE),
956 data, reply, option);
957 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(CallStatusInterfaceCode::CAMERA_CAPBILITIES_CHANGE),
958 data, reply, option);
959 callStatusCallback->OnRemoteRequest(static_cast<uint32_t>(
960 CallStatusInterfaceCode::RECEIVE_UPDATE_MEDIA_MODE_REQUEST), data, reply, option);
961 int32_t res = callStatusCallback->OnRemoteRequest(
962 static_cast<uint32_t>(CallStatusInterfaceCode::UPDATE_VOIP_EVENT_INFO), data, reply, option);
963 ASSERT_NE(res, TELEPHONY_SUCCESS);
964 }
965
966 /**
967 * @tc.number Telephony_CallStatusCallbackStub_003
968 * @tc.name test error branch
969 * @tc.desc Function test
970 */
971 HWTEST_F(ZeroBranch5Test, Telephony_CallStatusCallbackStub_003, Function | MediumTest | Level3)
972 {
973 auto callStatusCallback = std::make_shared<CallStatusCallback>();
974 MessageParcel data;
975 MessageParcel reply;
976 int32_t accountId = 0;
977 int32_t defaultNumber = 0;
978 std::string defaultString = "";
979 std::vector<uint8_t> userProfile = {};
980 char accountNum[kMaxNumberLen + 1] = { 0 };
981 data.WriteInterfaceToken(CallStatusCallbackStub::GetDescriptor());
982 data.WriteInt32(0);
983 data.WriteCString(accountNum);
984 data.WriteInt32(accountId);
985 data.WriteInt32(static_cast<int32_t>(CallType::TYPE_VOIP));
986 data.WriteInt32(static_cast<int32_t>(VideoStateType::TYPE_VOICE));
987 data.WriteInt32(static_cast<int32_t>(TelCallState::CALL_STATUS_ACTIVE));
988 data.WriteInt32(defaultNumber);
989 data.WriteInt32(defaultNumber);
990 data.WriteInt32(defaultNumber);
991 data.WriteInt32(defaultNumber);
992 data.WriteString(defaultString);
993 data.WriteString(defaultString);
994 data.WriteString(defaultString);
995 data.WriteString(defaultString);
996 data.WriteString(defaultString);
997 data.WriteUInt8Vector(userProfile);
998 data.RewindRead(0);
999 ASSERT_EQ(callStatusCallback->OnUpdateCallReportInfo(data, reply), TELEPHONY_SUCCESS);
1000 }
1001 } // namespace Telephony
1002 } // namespace OHOS
1003