1 /*
2 * Copyright (C) 2021-2022 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 "supplement_request_ims.h"
17
18 #include "cellular_call_service.h"
19 #include "ims_call_client.h"
20 #include "radio_event.h"
21 #include "telephony_log_wrapper.h"
22 #include "telephony_types.h"
23
24 namespace OHOS {
25 namespace Telephony {
SetClipRequest(int32_t slotId,int32_t action,int32_t index)26 int32_t SupplementRequestIms::SetClipRequest(int32_t slotId, int32_t action, int32_t index)
27 {
28 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
29 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
30 if (imsCallClient == nullptr) {
31 TELEPHONY_LOGE("ImsCallClient is nullptr.");
32 return CALL_ERR_RESOURCE_UNAVAILABLE;
33 }
34 return imsCallClient->SetClip(slotId, action, index);
35 }
36
GetClipRequest(int32_t slotId,int32_t index)37 int32_t SupplementRequestIms::GetClipRequest(int32_t slotId, int32_t index)
38 {
39 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
40 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
41 if (imsCallClient == nullptr) {
42 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
43 return CALL_ERR_RESOURCE_UNAVAILABLE;
44 }
45 return imsCallClient->GetClip(slotId, index);
46 }
47
SetClirRequest(int32_t slotId,int32_t action,int32_t index)48 int32_t SupplementRequestIms::SetClirRequest(int32_t slotId, int32_t action, int32_t index)
49 {
50 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
51 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
52 if (imsCallClient == nullptr) {
53 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
54 return CALL_ERR_RESOURCE_UNAVAILABLE;
55 }
56 return imsCallClient->SetClir(slotId, action, index);
57 }
58
GetClirRequest(int32_t slotId,int32_t index)59 int32_t SupplementRequestIms::GetClirRequest(int32_t slotId, int32_t index)
60 {
61 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
62 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
63 if (imsCallClient == nullptr) {
64 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
65 return CALL_ERR_RESOURCE_UNAVAILABLE;
66 }
67 return imsCallClient->GetClir(slotId, index);
68 }
69
GetCallTransferRequest(int32_t slotId,int32_t reason,int32_t index)70 int32_t SupplementRequestIms::GetCallTransferRequest(int32_t slotId, int32_t reason, int32_t index)
71 {
72 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
73 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
74 if (imsCallClient == nullptr) {
75 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
76 return CALL_ERR_RESOURCE_UNAVAILABLE;
77 }
78 return imsCallClient->GetCallTransfer(slotId, reason, index);
79 }
80
SetCallTransferRequest(int32_t slotId,const CallTransferInfo & cfInfo,int32_t classType,int32_t index)81 int32_t SupplementRequestIms::SetCallTransferRequest(
82 int32_t slotId, const CallTransferInfo &cfInfo, int32_t classType, int32_t index)
83 {
84 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
85 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
86 if (imsCallClient == nullptr) {
87 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
88 return CALL_ERR_RESOURCE_UNAVAILABLE;
89 }
90 return imsCallClient->SetCallTransfer(slotId, cfInfo, classType, index);
91 }
92
CanSetCallTransferTime(int32_t slotId,bool & result)93 int32_t SupplementRequestIms::CanSetCallTransferTime(int32_t slotId, bool &result)
94 {
95 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
96 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
97 if (imsCallClient == nullptr) {
98 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
99 return CALL_ERR_RESOURCE_UNAVAILABLE;
100 }
101 return imsCallClient->CanSetCallTransferTime(slotId, result);
102 }
103
GetCallRestrictionRequest(int32_t slotId,const std::string & fac,int32_t index)104 int32_t SupplementRequestIms::GetCallRestrictionRequest(int32_t slotId, const std::string &fac, int32_t index)
105 {
106 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
107 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
108 if (imsCallClient == nullptr) {
109 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
110 return CALL_ERR_RESOURCE_UNAVAILABLE;
111 }
112 return imsCallClient->GetCallRestriction(slotId, fac, index);
113 }
114
SetCallRestrictionRequest(int32_t slotId,std::string & fac,int32_t mode,std::string & pw,int32_t index)115 int32_t SupplementRequestIms::SetCallRestrictionRequest(
116 int32_t slotId, std::string &fac, int32_t mode, std::string &pw, int32_t index)
117 {
118 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
119 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
120 if (imsCallClient == nullptr) {
121 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
122 return CALL_ERR_RESOURCE_UNAVAILABLE;
123 }
124 return imsCallClient->SetCallRestriction(slotId, fac, mode, pw, index);
125 }
126
SetCallWaitingRequest(int32_t slotId,bool activate,int32_t classType,int32_t index)127 int32_t SupplementRequestIms::SetCallWaitingRequest(int32_t slotId, bool activate, int32_t classType, int32_t index)
128 {
129 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
130 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
131 if (imsCallClient == nullptr) {
132 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
133 return CALL_ERR_RESOURCE_UNAVAILABLE;
134 }
135 return imsCallClient->SetCallWaiting(slotId, activate, classType, index);
136 }
137
GetCallWaitingRequest(int32_t slotId,int32_t index)138 int32_t SupplementRequestIms::GetCallWaitingRequest(int32_t slotId, int32_t index)
139 {
140 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
141 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
142 if (imsCallClient == nullptr) {
143 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
144 return CALL_ERR_RESOURCE_UNAVAILABLE;
145 }
146 return imsCallClient->GetCallWaiting(slotId, index);
147 }
148
SetColrRequest(int32_t slotId,int32_t presentation,int32_t index)149 int32_t SupplementRequestIms::SetColrRequest(int32_t slotId, int32_t presentation, int32_t index)
150 {
151 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
152 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
153 if (imsCallClient == nullptr) {
154 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
155 return CALL_ERR_RESOURCE_UNAVAILABLE;
156 }
157 return imsCallClient->SetColr(slotId, presentation, index);
158 }
159
GetColrRequest(int32_t slotId,int32_t index)160 int32_t SupplementRequestIms::GetColrRequest(int32_t slotId, int32_t index)
161 {
162 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
163 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
164 if (imsCallClient == nullptr) {
165 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
166 return CALL_ERR_RESOURCE_UNAVAILABLE;
167 }
168 return imsCallClient->GetColr(slotId, index);
169 }
170
SetColpRequest(int32_t slotId,int32_t action,int32_t index)171 int32_t SupplementRequestIms::SetColpRequest(int32_t slotId, int32_t action, int32_t index)
172 {
173 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
174 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
175 if (imsCallClient == nullptr) {
176 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
177 return CALL_ERR_RESOURCE_UNAVAILABLE;
178 }
179 return imsCallClient->SetColp(slotId, action, index);
180 }
181
GetColpRequest(int32_t slotId,int32_t index)182 int32_t SupplementRequestIms::GetColpRequest(int32_t slotId, int32_t index)
183 {
184 TELEPHONY_LOGI("[slot%{public}d] entry", slotId);
185 auto imsCallClient = DelayedSingleton<ImsCallClient>::GetInstance();
186 if (imsCallClient == nullptr) {
187 TELEPHONY_LOGE("[slot%{public}d] ImsCallClient is nullptr.", slotId);
188 return CALL_ERR_RESOURCE_UNAVAILABLE;
189 }
190 return imsCallClient->GetColp(slotId, index);
191 }
192
GetMMIHandler(int32_t slotId) const193 std::shared_ptr<CellularCallHandler> SupplementRequestIms::GetMMIHandler(int32_t slotId) const
194 {
195 auto callService = DelayedSingleton<CellularCallService>::GetInstance();
196 if (callService == nullptr) {
197 TELEPHONY_LOGE("[slot%{public}d] error type: callService is nullptr.", slotId);
198 return nullptr;
199 }
200 return callService->GetHandler(slotId);
201 }
202 } // namespace Telephony
203 } // namespace OHOS
204