1 /*
2 * Copyright (C) 2021 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 "call_request_handler.h"
17
18 #include <securec.h>
19 #include <string_ex.h>
20
21 #include "call_manager_errors.h"
22 #include "call_manager_hisysevent.h"
23 #include "telephony_log_wrapper.h"
24
25 namespace OHOS {
26 namespace Telephony {
CallRequestHandler(const std::shared_ptr<AppExecFwk::EventRunner> & runner)27 CallRequestHandler::CallRequestHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner)
28 : AppExecFwk::EventHandler(runner), callRequestProcessPtr_(nullptr)
29 {
30 memberFuncMap_[CallRequestHandlerService::HANDLER_DIAL_CALL_REQUEST] = &CallRequestHandler::DialCallEvent;
31 memberFuncMap_[CallRequestHandlerService::HANDLER_ANSWER_CALL_REQUEST] = &CallRequestHandler::AcceptCallEvent;
32 memberFuncMap_[CallRequestHandlerService::HANDLER_REJECT_CALL_REQUEST] = &CallRequestHandler::RejectCallEvent;
33 memberFuncMap_[CallRequestHandlerService::HANDLER_HANGUP_CALL_REQUEST] = &CallRequestHandler::HangUpCallEvent;
34 memberFuncMap_[CallRequestHandlerService::HANDLER_HOLD_CALL_REQUEST] = &CallRequestHandler::HoldCallEvent;
35 memberFuncMap_[CallRequestHandlerService::HANDLER_UNHOLD_CALL_REQUEST] = &CallRequestHandler::UnHoldCallEvent;
36 memberFuncMap_[CallRequestHandlerService::HANDLER_SWAP_CALL_REQUEST] = &CallRequestHandler::SwitchCallEvent;
37 memberFuncMap_[CallRequestHandlerService::HANDLER_COMBINE_CONFERENCE_REQUEST] =
38 &CallRequestHandler::CombineConferenceEvent;
39 memberFuncMap_[CallRequestHandlerService::HANDLER_SEPARATE_CONFERENCE_REQUEST] =
40 &CallRequestHandler::SeparateConferenceEvent;
41 memberFuncMap_[CallRequestHandlerService::HANDLER_UPDATE_CALL_MEDIA_MODE_REQUEST] =
42 &CallRequestHandler::UpdateCallMediaModeEvent;
43 memberFuncMap_[CallRequestHandlerService::HANDLER_STARTRTT_REQUEST] = &CallRequestHandler::StartRttEvent;
44 memberFuncMap_[CallRequestHandlerService::HANDLER_STOPRTT_REQUEST] = &CallRequestHandler::StopRttEvent;
45 memberFuncMap_[CallRequestHandlerService::HANDLER_INVITE_TO_CONFERENCE] =
46 &CallRequestHandler::JoinConferenceEvent;
47 }
48
~CallRequestHandler()49 CallRequestHandler::~CallRequestHandler()
50 {
51 callRequestProcessPtr_ = nullptr;
52 }
53
Init()54 void CallRequestHandler::Init()
55 {
56 callRequestProcessPtr_ = std::make_unique<CallRequestProcess>();
57 if (callRequestProcessPtr_ == nullptr) {
58 TELEPHONY_LOGE("callRequestProcessPtr_ is null");
59 return;
60 }
61 }
62
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)63 void CallRequestHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event)
64 {
65 if (event == nullptr) {
66 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
67 return;
68 }
69 TELEPHONY_LOGI("CallRequestHandler inner event id obtained: %{public}u.", event->GetInnerEventId());
70 auto itFunc = memberFuncMap_.find(event->GetInnerEventId());
71 if (itFunc != memberFuncMap_.end()) {
72 auto memberFunc = itFunc->second;
73 if (memberFunc != nullptr) {
74 return (this->*memberFunc)(event);
75 }
76 }
77 }
78
DialCallEvent(const AppExecFwk::InnerEvent::Pointer & event)79 void CallRequestHandler::DialCallEvent(const AppExecFwk::InnerEvent::Pointer &event)
80 {
81 if (event == nullptr) {
82 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
83 return;
84 }
85 if (callRequestProcessPtr_ == nullptr) {
86 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
87 return;
88 }
89 callRequestProcessPtr_->DialRequest();
90 }
91
AcceptCallEvent(const AppExecFwk::InnerEvent::Pointer & event)92 void CallRequestHandler::AcceptCallEvent(const AppExecFwk::InnerEvent::Pointer &event)
93 {
94 if (event == nullptr) {
95 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
96 return;
97 }
98 auto object = event->GetUniqueObject<AnswerCallPara>();
99 if (object == nullptr) {
100 TELEPHONY_LOGE("object is nullptr!");
101 return;
102 }
103 AnswerCallPara acceptPara = *object;
104 if (callRequestProcessPtr_ == nullptr) {
105 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
106 return;
107 }
108 callRequestProcessPtr_->AnswerRequest(acceptPara.callId, acceptPara.videoState);
109 }
110
RejectCallEvent(const AppExecFwk::InnerEvent::Pointer & event)111 void CallRequestHandler::RejectCallEvent(const AppExecFwk::InnerEvent::Pointer &event)
112 {
113 if (event == nullptr) {
114 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
115 return;
116 }
117 auto object = event->GetUniqueObject<RejectCallPara>();
118 if (object == nullptr) {
119 TELEPHONY_LOGE("object is nullptr!");
120 return;
121 }
122 RejectCallPara rejectPara = *object;
123 if (callRequestProcessPtr_ == nullptr) {
124 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
125 return;
126 }
127 std::string content(rejectPara.content);
128 callRequestProcessPtr_->RejectRequest(rejectPara.callId, rejectPara.isSendSms, content);
129 }
130
HangUpCallEvent(const AppExecFwk::InnerEvent::Pointer & event)131 void CallRequestHandler::HangUpCallEvent(const AppExecFwk::InnerEvent::Pointer &event)
132 {
133 if (event == nullptr) {
134 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
135 return;
136 }
137 auto object = event->GetUniqueObject<int32_t>();
138 if (object == nullptr) {
139 TELEPHONY_LOGE("object is nullptr!");
140 return;
141 }
142 int32_t callId = *object;
143 if (callRequestProcessPtr_ == nullptr) {
144 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
145 return;
146 }
147 callRequestProcessPtr_->HangUpRequest(callId);
148 }
149
HoldCallEvent(const AppExecFwk::InnerEvent::Pointer & event)150 void CallRequestHandler::HoldCallEvent(const AppExecFwk::InnerEvent::Pointer &event)
151 {
152 if (event == nullptr) {
153 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
154 return;
155 }
156 auto object = event->GetUniqueObject<int32_t>();
157 if (object == nullptr) {
158 TELEPHONY_LOGE("object is nullptr!");
159 return;
160 }
161 int32_t callId = *object;
162 if (callRequestProcessPtr_ == nullptr) {
163 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
164 return;
165 }
166 callRequestProcessPtr_->HoldRequest(callId);
167 }
168
UnHoldCallEvent(const AppExecFwk::InnerEvent::Pointer & event)169 void CallRequestHandler::UnHoldCallEvent(const AppExecFwk::InnerEvent::Pointer &event)
170 {
171 if (event == nullptr) {
172 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
173 return;
174 }
175 auto object = event->GetUniqueObject<int32_t>();
176 if (object == nullptr) {
177 TELEPHONY_LOGE("object is nullptr!");
178 return;
179 }
180 int32_t callId = *object;
181 if (callRequestProcessPtr_ == nullptr) {
182 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
183 return;
184 }
185 callRequestProcessPtr_->UnHoldRequest(callId);
186 }
187
SwitchCallEvent(const AppExecFwk::InnerEvent::Pointer & event)188 void CallRequestHandler::SwitchCallEvent(const AppExecFwk::InnerEvent::Pointer &event)
189 {
190 if (event == nullptr) {
191 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
192 return;
193 }
194 auto object = event->GetUniqueObject<int32_t>();
195 if (object == nullptr) {
196 TELEPHONY_LOGE("object is nullptr!");
197 return;
198 }
199 int32_t callId = *object;
200 if (callRequestProcessPtr_ == nullptr) {
201 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
202 return;
203 }
204 callRequestProcessPtr_->SwitchRequest(callId);
205 }
206
CombineConferenceEvent(const AppExecFwk::InnerEvent::Pointer & event)207 void CallRequestHandler::CombineConferenceEvent(const AppExecFwk::InnerEvent::Pointer &event)
208 {
209 if (event == nullptr) {
210 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
211 return;
212 }
213 auto object = event->GetUniqueObject<int32_t>();
214 if (object == nullptr) {
215 TELEPHONY_LOGE("object is nullptr!");
216 return;
217 }
218 int32_t mainCallId = *object;
219 if (callRequestProcessPtr_ == nullptr) {
220 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
221 return;
222 }
223 callRequestProcessPtr_->CombineConferenceRequest(mainCallId);
224 }
225
SeparateConferenceEvent(const AppExecFwk::InnerEvent::Pointer & event)226 void CallRequestHandler::SeparateConferenceEvent(const AppExecFwk::InnerEvent::Pointer &event)
227 {
228 if (event == nullptr) {
229 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
230 return;
231 }
232 auto object = event->GetUniqueObject<int32_t>();
233 if (object == nullptr) {
234 TELEPHONY_LOGE("object is nullptr!");
235 return;
236 }
237 int32_t callId = *object;
238 if (callRequestProcessPtr_ == nullptr) {
239 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
240 return;
241 }
242 callRequestProcessPtr_->SeparateConferenceRequest(callId);
243 }
244
UpdateCallMediaModeEvent(const AppExecFwk::InnerEvent::Pointer & event)245 void CallRequestHandler::UpdateCallMediaModeEvent(const AppExecFwk::InnerEvent::Pointer &event)
246 {
247 if (event == nullptr) {
248 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
249 return;
250 }
251 auto object = event->GetUniqueObject<CallMediaUpdatePara>();
252 if (object == nullptr) {
253 TELEPHONY_LOGE("object is nullptr!");
254 return;
255 }
256 if (callRequestProcessPtr_ == nullptr) {
257 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
258 return;
259 }
260 callRequestProcessPtr_->UpdateCallMediaModeRequest(object->callId, object->mode);
261 }
262
StartRttEvent(const AppExecFwk::InnerEvent::Pointer & event)263 void CallRequestHandler::StartRttEvent(const AppExecFwk::InnerEvent::Pointer &event)
264 {
265 if (event == nullptr) {
266 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
267 return;
268 }
269 auto object = event->GetUniqueObject<StartRttPara>();
270 if (object == nullptr) {
271 TELEPHONY_LOGE("object is nullptr!");
272 return;
273 }
274 StartRttPara rttPara = *object;
275 if (callRequestProcessPtr_ == nullptr) {
276 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
277 return;
278 }
279 callRequestProcessPtr_->StartRttRequest(rttPara.callId, rttPara.msg);
280 }
281
StopRttEvent(const AppExecFwk::InnerEvent::Pointer & event)282 void CallRequestHandler::StopRttEvent(const AppExecFwk::InnerEvent::Pointer &event)
283 {
284 if (event == nullptr) {
285 TELEPHONY_LOGE("CallRequestHandler::ProcessEvent parameter error");
286 return;
287 }
288 auto object = event->GetUniqueObject<int32_t>();
289 if (object == nullptr) {
290 TELEPHONY_LOGE("object is nullptr!");
291 return;
292 }
293 int32_t callId = *object;
294 if (callRequestProcessPtr_ == nullptr) {
295 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
296 return;
297 }
298 callRequestProcessPtr_->StopRttRequest(callId);
299 }
300
JoinConferenceEvent(const AppExecFwk::InnerEvent::Pointer & event)301 void CallRequestHandler::JoinConferenceEvent(const AppExecFwk::InnerEvent::Pointer &event)
302 {
303 if (event == nullptr) {
304 TELEPHONY_LOGE("CallRequestHandler::JoinConferenceEvent parameter error");
305 return;
306 }
307 auto object = event->GetUniqueObject<JoinConferencePara>();
308 if (object == nullptr) {
309 TELEPHONY_LOGE("object is nullptr!");
310 return;
311 }
312 if (callRequestProcessPtr_ == nullptr) {
313 TELEPHONY_LOGE("callRequestProcessPtr_ is nullptr");
314 return;
315 }
316 callRequestProcessPtr_->JoinConference(object->callId, object->numberList);
317 }
318
CallRequestHandlerService()319 CallRequestHandlerService::CallRequestHandlerService() : eventLoop_(nullptr), handler_(nullptr) {}
320
~CallRequestHandlerService()321 CallRequestHandlerService::~CallRequestHandlerService()
322 {
323 if (eventLoop_ != nullptr) {
324 eventLoop_->Stop();
325 eventLoop_ = nullptr;
326 }
327 handler_ = nullptr;
328 }
329
Start()330 void CallRequestHandlerService::Start()
331 {
332 eventLoop_ = AppExecFwk::EventRunner::Create("CallRequestHandler");
333 if (eventLoop_.get() == nullptr) {
334 TELEPHONY_LOGE("failed to create EventRunner");
335 return;
336 }
337 handler_ = std::make_shared<CallRequestHandler>(eventLoop_);
338 if (handler_.get() == nullptr) {
339 TELEPHONY_LOGE("failed to create CallRequestHandler");
340 return;
341 }
342 handler_->Init();
343 eventLoop_->Run();
344 return;
345 }
346
DialCall()347 int32_t CallRequestHandlerService::DialCall()
348 {
349 if (handler_.get() == nullptr) {
350 TELEPHONY_LOGE("handler_ is nullptr");
351 return TELEPHONY_ERR_LOCAL_PTR_NULL;
352 }
353 if (!handler_->SendEvent(HANDLER_DIAL_CALL_REQUEST)) {
354 TELEPHONY_LOGE("send dial event failed!");
355 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
356 }
357 return TELEPHONY_SUCCESS;
358 }
359
AnswerCall(int32_t callId,int32_t videoState)360 int32_t CallRequestHandlerService::AnswerCall(int32_t callId, int32_t videoState)
361 {
362 if (handler_.get() == nullptr) {
363 TELEPHONY_LOGE("handler_ is nullptr");
364 return TELEPHONY_ERR_LOCAL_PTR_NULL;
365 }
366 std::unique_ptr<AnswerCallPara> para = std::make_unique<AnswerCallPara>();
367 if (para.get() == nullptr) {
368 TELEPHONY_LOGE("make_unique AnswerCallPara failed!");
369 return TELEPHONY_ERR_LOCAL_PTR_NULL;
370 }
371 para->callId = callId;
372 para->videoState = videoState;
373 if (!handler_->SendEvent(HANDLER_ANSWER_CALL_REQUEST, std::move(para))) {
374 TELEPHONY_LOGE("send accept event failed!");
375 CallManagerHisysevent::WriteAnswerCallFaultEvent(INVALID_PARAMETER, callId, videoState,
376 CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE, "send HANDLER_ANSWER_CALL_REQUEST event failed");
377 return TELEPHONY_ERR_LOCAL_PTR_NULL;
378 }
379 return TELEPHONY_SUCCESS;
380 }
381
RejectCall(int32_t callId,bool isSendSms,std::string & content)382 int32_t CallRequestHandlerService::RejectCall(int32_t callId, bool isSendSms, std::string &content)
383 {
384 if (handler_.get() == nullptr) {
385 TELEPHONY_LOGE("handler_ is nullptr");
386 return TELEPHONY_ERR_LOCAL_PTR_NULL;
387 }
388 std::unique_ptr<RejectCallPara> para = std::make_unique<RejectCallPara>();
389 if (para.get() == nullptr) {
390 TELEPHONY_LOGE("make_unique RejectCallPara failed!");
391 return TELEPHONY_ERR_LOCAL_PTR_NULL;
392 }
393 para->callId = callId;
394 para->isSendSms = isSendSms;
395 (void)memset_s(para->content, REJECT_CALL_MSG_MAX_LEN + 1, 0, REJECT_CALL_MSG_MAX_LEN + 1);
396 errno_t result = memcpy_s(para->content, REJECT_CALL_MSG_MAX_LEN, content.c_str(), content.length());
397 if (para->isSendSms && result != EOK) {
398 TELEPHONY_LOGE("memcpy_s rejectCall content failed!");
399 CallManagerHisysevent::WriteHangUpFaultEvent(
400 INVALID_PARAMETER, callId, TELEPHONY_ERR_MEMCPY_FAIL, "Reject memcpy_s rejectCall content failed");
401 return TELEPHONY_ERR_MEMCPY_FAIL;
402 }
403 if (!handler_->SendEvent(HANDLER_REJECT_CALL_REQUEST, std::move(para))) {
404 TELEPHONY_LOGE("send reject event failed!");
405 CallManagerHisysevent::WriteHangUpFaultEvent(INVALID_PARAMETER, callId, CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE,
406 "Reject send HANDLER_REJECT_CALL_REQUEST event failed");
407 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
408 }
409 return TELEPHONY_SUCCESS;
410 }
411
HangUpCall(int32_t callId)412 int32_t CallRequestHandlerService::HangUpCall(int32_t callId)
413 {
414 if (handler_.get() == nullptr) {
415 TELEPHONY_LOGE("handler_ is nullptr");
416 return TELEPHONY_ERR_LOCAL_PTR_NULL;
417 }
418 std::unique_ptr<int32_t> para = std::make_unique<int32_t>(callId);
419 if (para.get() == nullptr) {
420 TELEPHONY_LOGE("make_unique callId failed!");
421 return TELEPHONY_ERR_LOCAL_PTR_NULL;
422 }
423 if (!handler_->SendEvent(HANDLER_HANGUP_CALL_REQUEST, std::move(para))) {
424 TELEPHONY_LOGE("send hung up event failed!");
425 CallManagerHisysevent::WriteHangUpFaultEvent(INVALID_PARAMETER, callId,
426 CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE, "HangUp send HANDLER_HANGUP_CALL_REQUEST event failed");
427 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
428 }
429 return TELEPHONY_SUCCESS;
430 }
431
HoldCall(int32_t callId)432 int32_t CallRequestHandlerService::HoldCall(int32_t callId)
433 {
434 if (handler_.get() == nullptr) {
435 TELEPHONY_LOGE("handler_ is nullptr");
436 return TELEPHONY_ERR_LOCAL_PTR_NULL;
437 }
438 std::unique_ptr<int32_t> para = std::make_unique<int32_t>(callId);
439 if (para.get() == nullptr) {
440 TELEPHONY_LOGE("make_unique callId failed!");
441 return TELEPHONY_ERR_LOCAL_PTR_NULL;
442 }
443 if (!handler_->SendEvent(HANDLER_HOLD_CALL_REQUEST, std::move(para))) {
444 TELEPHONY_LOGE("send hold event failed!");
445 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
446 }
447 return TELEPHONY_SUCCESS;
448 }
449
UnHoldCall(int32_t callId)450 int32_t CallRequestHandlerService::UnHoldCall(int32_t callId)
451 {
452 if (handler_.get() == nullptr) {
453 TELEPHONY_LOGE("handler_ is nullptr");
454 return TELEPHONY_ERR_LOCAL_PTR_NULL;
455 }
456 std::unique_ptr<int32_t> para = std::make_unique<int32_t>(callId);
457 if (para.get() == nullptr) {
458 TELEPHONY_LOGE("make_unique callId failed!");
459 return TELEPHONY_ERR_LOCAL_PTR_NULL;
460 }
461 if (!handler_->SendEvent(HANDLER_UNHOLD_CALL_REQUEST, std::move(para))) {
462 TELEPHONY_LOGE("send unHold event failed!");
463 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
464 }
465 return TELEPHONY_SUCCESS;
466 }
467
SwitchCall(int32_t callId)468 int32_t CallRequestHandlerService::SwitchCall(int32_t callId)
469 {
470 if (handler_.get() == nullptr) {
471 TELEPHONY_LOGE("handler_ is nullptr");
472 return TELEPHONY_ERR_LOCAL_PTR_NULL;
473 }
474 std::unique_ptr<int32_t> para = std::make_unique<int32_t>(callId);
475 if (para.get() == nullptr) {
476 TELEPHONY_LOGE("make_unique callId failed!");
477 return TELEPHONY_ERR_LOCAL_PTR_NULL;
478 }
479 if (!handler_->SendEvent(HANDLER_SWAP_CALL_REQUEST, std::move(para))) {
480 TELEPHONY_LOGE("send swap event failed!");
481 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
482 }
483 return TELEPHONY_SUCCESS;
484 }
485
StartRtt(int32_t callId,std::u16string & msg)486 int32_t CallRequestHandlerService::StartRtt(int32_t callId, std::u16string &msg)
487 {
488 if (handler_.get() == nullptr) {
489 TELEPHONY_LOGE("handler_ is nullptr");
490 return TELEPHONY_ERR_LOCAL_PTR_NULL;
491 }
492 std::unique_ptr<StartRttPara> para = std::make_unique<StartRttPara>();
493 if (para.get() == nullptr) {
494 TELEPHONY_LOGE("make_unique StartRttPara failed!");
495 return TELEPHONY_ERR_LOCAL_PTR_NULL;
496 }
497 para->callId = callId;
498 para->msg = msg;
499 if (!handler_->SendEvent(HANDLER_STARTRTT_REQUEST, std::move(para))) {
500 TELEPHONY_LOGE("send StartRtt event failed!");
501 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
502 }
503 return TELEPHONY_SUCCESS;
504 }
505
StopRtt(int32_t callId)506 int32_t CallRequestHandlerService::StopRtt(int32_t callId)
507 {
508 if (handler_.get() == nullptr) {
509 TELEPHONY_LOGE("handler_ is nullptr");
510 return TELEPHONY_ERR_LOCAL_PTR_NULL;
511 }
512 std::unique_ptr<int32_t> para = std::make_unique<int32_t>(callId);
513 if (para.get() == nullptr) {
514 TELEPHONY_LOGE("make_unique callId failed!");
515 return TELEPHONY_ERR_LOCAL_PTR_NULL;
516 }
517 if (!handler_->SendEvent(HANDLER_STOPRTT_REQUEST, std::move(para))) {
518 TELEPHONY_LOGE("send StopRtt event failed!");
519 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
520 }
521 return TELEPHONY_SUCCESS;
522 }
523
JoinConference(int32_t callId,std::vector<std::string> & numberList)524 int32_t CallRequestHandlerService::JoinConference(int32_t callId, std::vector<std::string> &numberList)
525 {
526 if (handler_.get() == nullptr) {
527 TELEPHONY_LOGE("handler_ is nullptr");
528 return TELEPHONY_ERR_LOCAL_PTR_NULL;
529 }
530 std::unique_ptr<JoinConferencePara> para = std::make_unique<JoinConferencePara>();
531 if (para.get() == nullptr) {
532 TELEPHONY_LOGE("make_unique JoinConferencePara failed!");
533 return TELEPHONY_ERR_LOCAL_PTR_NULL;
534 }
535 para->callId = callId;
536 para->numberList = numberList;
537 if (!handler_->SendEvent(HANDLER_INVITE_TO_CONFERENCE, std::move(para))) {
538 TELEPHONY_LOGE("send JoinConference event failed!");
539 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
540 }
541 return TELEPHONY_SUCCESS;
542 }
543
CombineConference(int32_t mainCallId)544 int32_t CallRequestHandlerService::CombineConference(int32_t mainCallId)
545 {
546 if (handler_.get() == nullptr) {
547 TELEPHONY_LOGE("handler_ is nullptr");
548 return TELEPHONY_ERR_LOCAL_PTR_NULL;
549 }
550 std::unique_ptr<int32_t> para = std::make_unique<int32_t>(mainCallId);
551 if (para.get() == nullptr) {
552 TELEPHONY_LOGE("make_unique mainCallId failed!");
553 return TELEPHONY_ERR_LOCAL_PTR_NULL;
554 }
555 if (!handler_->SendEvent(HANDLER_COMBINE_CONFERENCE_REQUEST, std::move(para))) {
556 TELEPHONY_LOGE("send CombineConference event failed!");
557 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
558 }
559 return TELEPHONY_SUCCESS;
560 }
561
SeparateConference(int32_t callId)562 int32_t CallRequestHandlerService::SeparateConference(int32_t callId)
563 {
564 if (handler_.get() == nullptr) {
565 TELEPHONY_LOGE("handler_ is nullptr");
566 return TELEPHONY_ERR_LOCAL_PTR_NULL;
567 }
568 std::unique_ptr<int32_t> para = std::make_unique<int32_t>(callId);
569 if (para.get() == nullptr) {
570 TELEPHONY_LOGE("make_unique callId failed!");
571 return TELEPHONY_ERR_LOCAL_PTR_NULL;
572 }
573 if (!handler_->SendEvent(HANDLER_SEPARATE_CONFERENCE_REQUEST, std::move(para))) {
574 TELEPHONY_LOGE("send SeparateConference event failed!");
575 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
576 }
577 return TELEPHONY_SUCCESS;
578 }
579
UpdateImsCallMode(int32_t callId,ImsCallMode mode)580 int32_t CallRequestHandlerService::UpdateImsCallMode(int32_t callId, ImsCallMode mode)
581 {
582 if (handler_.get() == nullptr) {
583 TELEPHONY_LOGE("handler_ is nullptr");
584 return TELEPHONY_ERR_LOCAL_PTR_NULL;
585 }
586 std::unique_ptr<CallMediaUpdatePara> para = std::make_unique<CallMediaUpdatePara>();
587 if (para.get() == nullptr) {
588 TELEPHONY_LOGE("make_unique CallMediaUpdatePara failed!");
589 return TELEPHONY_ERR_LOCAL_PTR_NULL;
590 }
591 para->callId = callId;
592 para->mode = mode;
593 if (!handler_->SendEvent(HANDLER_UPDATE_CALL_MEDIA_MODE_REQUEST, std::move(para))) {
594 TELEPHONY_LOGE("send UpdateImsCallMode event failed!");
595 return CALL_ERR_SYSTEM_EVENT_HANDLE_FAILURE;
596 }
597 return TELEPHONY_SUCCESS;
598 }
599 } // namespace Telephony
600 } // namespace OHOS
601