• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "ott_call_connection.h"
17 
18 #include "call_manager_errors.h"
19 #include "telephony_log_wrapper.h"
20 
21 #include "call_ability_report_proxy.h"
22 
23 namespace OHOS {
24 namespace Telephony {
Answer(const OttCallRequestInfo & requestInfo)25 int32_t OTTCallConnection::Answer(const OttCallRequestInfo &requestInfo)
26 {
27     AppExecFwk::PacMap info;
28     PackCellularCallInfo(requestInfo, info);
29     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest(
30         OttCallRequestId::OTT_REQUEST_ANSWER, info);
31 }
32 
HangUp(const OttCallRequestInfo & requestInfo)33 int32_t OTTCallConnection::HangUp(const OttCallRequestInfo &requestInfo)
34 {
35     AppExecFwk::PacMap info;
36     PackCellularCallInfo(requestInfo, info);
37     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest(
38         OttCallRequestId::OTT_REQUEST_HANG_UP, info);
39 }
40 
Reject(const OttCallRequestInfo & requestInfo)41 int32_t OTTCallConnection::Reject(const OttCallRequestInfo &requestInfo)
42 {
43     AppExecFwk::PacMap info;
44     PackCellularCallInfo(requestInfo, info);
45     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest(
46         OttCallRequestId::OTT_REQUEST_REJECT, info);
47 }
48 
HoldCall(const OttCallRequestInfo & requestInfo)49 int32_t OTTCallConnection::HoldCall(const OttCallRequestInfo &requestInfo)
50 {
51     AppExecFwk::PacMap info;
52     PackCellularCallInfo(requestInfo, info);
53     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest(
54         OttCallRequestId::OTT_REQUEST_HOLD, info);
55 }
56 
UnHoldCall(const OttCallRequestInfo & requestInfo)57 int32_t OTTCallConnection::UnHoldCall(const OttCallRequestInfo &requestInfo)
58 {
59     AppExecFwk::PacMap info;
60     PackCellularCallInfo(requestInfo, info);
61     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest(
62         OttCallRequestId::OTT_REQUEST_UN_HOLD, info);
63 }
64 
SwitchCall(const OttCallRequestInfo & requestInfo)65 int32_t OTTCallConnection::SwitchCall(const OttCallRequestInfo &requestInfo)
66 {
67     AppExecFwk::PacMap info;
68     PackCellularCallInfo(requestInfo, info);
69     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest(
70         OttCallRequestId::OTT_REQUEST_SWITCH, info);
71 }
72 
CombineConference(const OttCallRequestInfo & requestInfo)73 int32_t OTTCallConnection::CombineConference(const OttCallRequestInfo &requestInfo)
74 {
75     AppExecFwk::PacMap info;
76     PackCellularCallInfo(requestInfo, info);
77     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest(
78         OttCallRequestId::OTT_REQUEST_COMBINE_CONFERENCE, info);
79 }
80 
SeparateConference(const OttCallRequestInfo & requestInfo)81 int32_t OTTCallConnection::SeparateConference(const OttCallRequestInfo &requestInfo)
82 {
83     AppExecFwk::PacMap info;
84     PackCellularCallInfo(requestInfo, info);
85     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest(
86         OttCallRequestId::OTT_REQUEST_SEPARATE_CONFERENCE, info);
87 }
88 
InviteToConference(const OttCallRequestInfo & requestInfo,const std::vector<std::string> & numberList)89 int32_t OTTCallConnection::InviteToConference(
90     const OttCallRequestInfo &requestInfo, const std::vector<std::string> &numberList)
91 {
92     if (numberList.empty()) {
93         TELEPHONY_LOGE("numberList is empty!");
94         return TELEPHONY_ERR_ARGUMENT_INVALID;
95     }
96     AppExecFwk::PacMap info;
97     std::vector<std::string> list = numberList;
98     PackCellularCallInfo(requestInfo, info);
99     info.PutIntValue("listCnt", list.size());
100     std::vector<std::string>::iterator it = list.begin();
101     for (; it != list.end(); ++it) {
102         if (!(*it).empty()) {
103             info.PutStringValue("number", *it);
104         }
105     }
106     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest(
107         OttCallRequestId::OTT_REQUEST_INVITE_TO_CONFERENCE, info);
108 }
109 
UpdateImsCallMode(const OttCallRequestInfo & requestInfo,ImsCallMode mode)110 int32_t OTTCallConnection::UpdateImsCallMode(const OttCallRequestInfo &requestInfo, ImsCallMode mode)
111 {
112     AppExecFwk::PacMap info;
113     PackCellularCallInfo(requestInfo, info);
114     info.PutIntValue("callMediaMode", mode);
115     return DelayedSingleton<CallAbilityReportProxy>::GetInstance()->OttCallRequest(
116         OttCallRequestId::OTT_REQUEST_UPDATE_CALL_MEDIA_MODE, info);
117 }
118 
PackCellularCallInfo(const OttCallRequestInfo & requestInfo,AppExecFwk::PacMap & info)119 void OTTCallConnection::PackCellularCallInfo(const OttCallRequestInfo &requestInfo, AppExecFwk::PacMap &info)
120 {
121     std::string number(requestInfo.phoneNum);
122     std::string name(requestInfo.bundleName);
123     info.PutStringValue("phoneNum", number);
124     info.PutStringValue("bundleName", name);
125     info.PutIntValue("videoState", static_cast<int32_t>(requestInfo.videoState));
126 }
127 } // namespace Telephony
128 } // namespace OHOS