• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "cellular_call_proxy.h"
17 #include "call_manager_errors.h"
18 #include "telephony_log_wrapper.h"
19 
20 namespace OHOS {
21 namespace Telephony {
22 constexpr int32_t MAX_SIZE = 10;
23 
Dial(const CellularCallInfo & callInfo)24 int32_t CellularCallProxy::Dial(const CellularCallInfo &callInfo)
25 {
26     MessageOption option;
27     MessageParcel in;
28     MessageParcel out;
29     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
30         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
31     }
32     if (!in.WriteInt32(MAX_SIZE)) {
33         return TELEPHONY_ERR_WRITE_DATA_FAIL;
34     }
35     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
36         return TELEPHONY_ERR_WRITE_DATA_FAIL;
37     }
38     auto remote = Remote();
39     if (remote == nullptr) {
40         TELEPHONY_LOGE("function Remote() return nullptr!");
41         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
42     }
43     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::DIAL), in, out, option);
44     if (error == ERR_NONE) {
45         return out.ReadInt32();
46     }
47     return error;
48 }
49 
HangUp(const CellularCallInfo & callInfo,CallSupplementType type)50 int32_t CellularCallProxy::HangUp(const CellularCallInfo &callInfo, CallSupplementType type)
51 {
52     MessageOption option;
53     MessageParcel in;
54     MessageParcel out;
55     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
56         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
57     }
58     if (!in.WriteInt32(MAX_SIZE)) {
59         return TELEPHONY_ERR_WRITE_DATA_FAIL;
60     }
61     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
62         return TELEPHONY_ERR_WRITE_DATA_FAIL;
63     }
64     if (!in.WriteInt32((int32_t)type)) {
65         return TELEPHONY_ERR_WRITE_DATA_FAIL;
66     }
67     auto remote = Remote();
68     if (remote == nullptr) {
69         TELEPHONY_LOGE("function Remote() return nullptr!");
70         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
71     }
72     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::HANG_UP), in, out, option);
73     if (error == ERR_NONE) {
74         return out.ReadInt32();
75     }
76     return error;
77 }
78 
Reject(const CellularCallInfo & callInfo)79 int32_t CellularCallProxy::Reject(const CellularCallInfo &callInfo)
80 {
81     MessageOption option;
82     MessageParcel in;
83     MessageParcel out;
84     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
85         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
86     }
87     if (!in.WriteInt32(MAX_SIZE)) {
88         return TELEPHONY_ERR_WRITE_DATA_FAIL;
89     }
90     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
91         return TELEPHONY_ERR_WRITE_DATA_FAIL;
92     }
93     auto remote = Remote();
94     if (remote == nullptr) {
95         TELEPHONY_LOGE("function Remote() return nullptr!");
96         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
97     }
98     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::REJECT), in, out, option);
99     if (error == ERR_NONE) {
100         return out.ReadInt32();
101     }
102     return error;
103 }
104 
Answer(const CellularCallInfo & callInfo)105 int32_t CellularCallProxy::Answer(const CellularCallInfo &callInfo)
106 {
107     MessageOption option;
108     MessageParcel in;
109     MessageParcel out;
110     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
111         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
112     }
113     if (!in.WriteInt32(MAX_SIZE)) {
114         return TELEPHONY_ERR_WRITE_DATA_FAIL;
115     }
116     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
117         return TELEPHONY_ERR_WRITE_DATA_FAIL;
118     }
119     auto remote = Remote();
120     if (remote == nullptr) {
121         TELEPHONY_LOGE("function Remote() return nullptr!");
122         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
123     }
124     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::ANSWER), in, out, option);
125     if (error == ERR_NONE) {
126         return out.ReadInt32();
127     }
128     return error;
129 }
130 
HoldCall(const CellularCallInfo & callInfo)131 int32_t CellularCallProxy::HoldCall(const CellularCallInfo &callInfo)
132 {
133     MessageOption option;
134     MessageParcel in;
135     MessageParcel out;
136     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
137         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
138     }
139     if (!in.WriteInt32(MAX_SIZE)) {
140         return TELEPHONY_ERR_WRITE_DATA_FAIL;
141     }
142     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
143         return TELEPHONY_ERR_WRITE_DATA_FAIL;
144     }
145     auto remote = Remote();
146     if (remote == nullptr) {
147         TELEPHONY_LOGE("function Remote() return nullptr!");
148         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
149     }
150     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::HOLD_CALL), in, out, option);
151     if (error == ERR_NONE) {
152         return out.ReadInt32();
153     }
154     return error;
155 }
156 
UnHoldCall(const CellularCallInfo & callInfo)157 int32_t CellularCallProxy::UnHoldCall(const CellularCallInfo &callInfo)
158 {
159     MessageOption option;
160     MessageParcel in;
161     MessageParcel out;
162     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
163         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
164     }
165     if (!in.WriteInt32(MAX_SIZE)) {
166         return TELEPHONY_ERR_WRITE_DATA_FAIL;
167     }
168     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
169         return TELEPHONY_ERR_WRITE_DATA_FAIL;
170     }
171     auto remote = Remote();
172     if (remote == nullptr) {
173         TELEPHONY_LOGE("function Remote() return nullptr!");
174         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
175     }
176     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::UN_HOLD_CALL), in,
177         out, option);
178     if (error == ERR_NONE) {
179         return out.ReadInt32();
180     }
181     return error;
182 }
183 
SwitchCall(const CellularCallInfo & callInfo)184 int32_t CellularCallProxy::SwitchCall(const CellularCallInfo &callInfo)
185 {
186     MessageOption option;
187     MessageParcel in;
188     MessageParcel out;
189     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
190         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
191     }
192     if (!in.WriteInt32(MAX_SIZE)) {
193         return TELEPHONY_ERR_WRITE_DATA_FAIL;
194     }
195     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
196         return TELEPHONY_ERR_WRITE_DATA_FAIL;
197     }
198     auto remote = Remote();
199     if (remote == nullptr) {
200         TELEPHONY_LOGE("function Remote() return nullptr!");
201         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
202     }
203     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SWITCH_CALL), in, out, option);
204     if (error == ERR_NONE) {
205         return out.ReadInt32();
206     }
207     return error;
208 }
209 
RegisterCallManagerCallBack(const sptr<ICallStatusCallback> & callback)210 int32_t CellularCallProxy::RegisterCallManagerCallBack(const sptr<ICallStatusCallback> &callback)
211 {
212     if (callback == nullptr) {
213         return TELEPHONY_ERR_ARGUMENT_INVALID;
214     }
215 
216     MessageOption option;
217     MessageParcel in;
218     MessageParcel out;
219     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
220         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
221     }
222     if (!in.WriteInt32(MAX_SIZE)) {
223         return TELEPHONY_ERR_WRITE_DATA_FAIL;
224     }
225     if (!in.WriteRemoteObject(callback->AsObject().GetRefPtr())) {
226         return TELEPHONY_ERR_WRITE_DATA_FAIL;
227     }
228     auto remote = Remote();
229     if (remote == nullptr) {
230         TELEPHONY_LOGE("function Remote() return nullptr!");
231         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
232     }
233     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::REGISTER_CALLBACK), in,
234         out, option);
235     if (error == ERR_NONE) {
236         return out.ReadInt32();
237     }
238     return error;
239 }
240 
UnRegisterCallManagerCallBack()241 int32_t CellularCallProxy::UnRegisterCallManagerCallBack()
242 {
243     MessageOption option;
244     MessageParcel in;
245     MessageParcel out;
246     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
247         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
248     }
249     if (!in.WriteInt32(MAX_SIZE)) {
250         return TELEPHONY_ERR_WRITE_DATA_FAIL;
251     }
252     auto remote = Remote();
253     if (remote == nullptr) {
254         TELEPHONY_LOGE("function Remote() return nullptr!");
255         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
256     }
257     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::UNREGISTER_CALLBACK), in,
258         out, option);
259     if (error == ERR_NONE) {
260         return out.ReadInt32();
261     }
262     return error;
263 }
264 
IsEmergencyPhoneNumber(int32_t slotId,const std::string & phoneNum,bool & enabled)265 int32_t CellularCallProxy::IsEmergencyPhoneNumber(int32_t slotId, const std::string &phoneNum, bool &enabled)
266 {
267     MessageOption option;
268     MessageParcel in;
269     MessageParcel out;
270     int32_t result = TELEPHONY_SUCCESS;
271     result = SetCommonParamForMessageParcel(slotId, in);
272     if (result != TELEPHONY_SUCCESS) {
273         return result;
274     }
275     if (!in.WriteString(phoneNum)) {
276         return TELEPHONY_ERR_WRITE_DATA_FAIL;
277     }
278     auto remote = Remote();
279     if (remote == nullptr) {
280         TELEPHONY_LOGE("function Remote() return nullptr!");
281         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
282     }
283     int32_t ret = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::EMERGENCY_CALL), in,
284         out, option);
285     if (ret != TELEPHONY_SUCCESS) {
286         TELEPHONY_LOGE("Function FormatPhoneNumberToE164 call failed! errCode:%{public}d", ret);
287         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
288     }
289     result = out.ReadInt32();
290     if (result == TELEPHONY_SUCCESS) {
291         enabled = out.ReadBool();
292     }
293     return result;
294 }
295 
CombineConference(const CellularCallInfo & callInfo)296 int32_t CellularCallProxy::CombineConference(const CellularCallInfo &callInfo)
297 {
298     MessageOption option;
299     MessageParcel in;
300     MessageParcel out;
301     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
302         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
303     }
304     if (!in.WriteInt32(MAX_SIZE)) {
305         return TELEPHONY_ERR_WRITE_DATA_FAIL;
306     }
307     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
308         return TELEPHONY_ERR_WRITE_DATA_FAIL;
309     }
310     auto remote = Remote();
311     if (remote == nullptr) {
312         TELEPHONY_LOGE("function Remote() return nullptr!");
313         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
314     }
315     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::COMBINE_CONFERENCE), in,
316         out, option);
317     if (error == ERR_NONE) {
318         return out.ReadInt32();
319     }
320     return error;
321 }
322 
SeparateConference(const CellularCallInfo & callInfo)323 int32_t CellularCallProxy::SeparateConference(const CellularCallInfo &callInfo)
324 {
325     MessageOption option;
326     MessageParcel in;
327     MessageParcel out;
328     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
329         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
330     }
331     if (!in.WriteInt32(MAX_SIZE)) {
332         return TELEPHONY_ERR_WRITE_DATA_FAIL;
333     }
334     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
335         return TELEPHONY_ERR_WRITE_DATA_FAIL;
336     }
337     auto remote = Remote();
338     if (remote == nullptr) {
339         TELEPHONY_LOGE("function Remote() return nullptr!");
340         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
341     }
342     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SEPARATE_CONFERENCE), in,
343         out, option);
344     if (error == ERR_NONE) {
345         return out.ReadInt32();
346     }
347     return error;
348 }
349 
InviteToConference(int32_t slotId,const std::vector<std::string> & numberList)350 int32_t CellularCallProxy::InviteToConference(int32_t slotId, const std::vector<std::string> &numberList)
351 {
352     MessageOption option;
353     MessageParcel in;
354     MessageParcel out;
355     int32_t result = TELEPHONY_SUCCESS;
356     result = SetCommonParamForMessageParcel(slotId, in);
357     if (result != TELEPHONY_SUCCESS) {
358         return result;
359     }
360     if (!in.WriteStringVector(numberList)) {
361         return TELEPHONY_ERR_WRITE_DATA_FAIL;
362     }
363     auto remote = Remote();
364     if (remote == nullptr) {
365         TELEPHONY_LOGE("function Remote() return nullptr!");
366         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
367     }
368     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::INVITE_TO_CONFERENCE), in,
369         out, option);
370     if (error == ERR_NONE) {
371         return out.ReadInt32();
372     }
373     return error;
374 }
375 
KickOutFromConference(const CellularCallInfo & callInfo)376 int32_t CellularCallProxy::KickOutFromConference(const CellularCallInfo &callInfo)
377 {
378     MessageOption option;
379     MessageParcel in;
380     MessageParcel out;
381     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
382         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
383     }
384     if (!in.WriteInt32(MAX_SIZE)) {
385         return TELEPHONY_ERR_WRITE_DATA_FAIL;
386     }
387     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
388         return TELEPHONY_ERR_WRITE_DATA_FAIL;
389     }
390     auto remote = Remote();
391     if (remote == nullptr) {
392         TELEPHONY_LOGE("function Remote() return nullptr!");
393         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
394     }
395     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::KICK_OUT_CONFERENCE), in,
396         out, option);
397     if (error == ERR_NONE) {
398         return out.ReadInt32();
399     }
400     return error;
401 }
402 
HangUpAllConnection()403 int32_t CellularCallProxy::HangUpAllConnection()
404 {
405     MessageOption option;
406     MessageParcel in;
407     MessageParcel out;
408     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
409         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
410     }
411     if (!in.WriteInt32(MAX_SIZE)) {
412         return TELEPHONY_ERR_WRITE_DATA_FAIL;
413     }
414     auto remote = Remote();
415     if (remote == nullptr) {
416         TELEPHONY_LOGE("function Remote() return nullptr!");
417         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
418     }
419     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::HANG_UP_ALL_CONNECTION), in,
420         out, option);
421     if (error == ERR_NONE) {
422         return out.ReadInt32();
423     }
424     return error;
425 }
426 
SetReadyToCall(int32_t slotId,int32_t callType,bool isReadyToCall)427 int32_t CellularCallProxy::SetReadyToCall(int32_t slotId, int32_t callType, bool isReadyToCall)
428 {
429     MessageOption option;
430     MessageParcel in;
431     MessageParcel out;
432     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
433         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
434     }
435     if (!in.WriteInt32(slotId)) {
436         return TELEPHONY_ERR_WRITE_DATA_FAIL;
437     }
438     if (!in.WriteInt32(callType)) {
439         return TELEPHONY_ERR_WRITE_DATA_FAIL;
440     }
441     if (!in.WriteBool(isReadyToCall)) {
442         return TELEPHONY_ERR_WRITE_DATA_FAIL;
443     }
444     auto remote = Remote();
445     if (remote == nullptr) {
446         TELEPHONY_LOGE("[slot%{public}d] function Remote() return nullptr!", slotId);
447         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
448     }
449     int32_t error =
450         remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_READY_TO_CALL), in, out, option);
451     if (error != ERR_NONE) {
452         TELEPHONY_LOGE("Function SetReadyToCall! errCode:%{public}d", error);
453         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
454     }
455     return out.ReadInt32();
456 }
457 
HangUpAllConnection(int32_t slotId)458 int32_t CellularCallProxy::HangUpAllConnection(int32_t slotId)
459 {
460     return TELEPHONY_ERR_SUCCESS;
461 }
462 
UpdateImsCallMode(const CellularCallInfo & callInfo,ImsCallMode mode)463 int32_t CellularCallProxy::UpdateImsCallMode(const CellularCallInfo &callInfo, ImsCallMode mode)
464 {
465     MessageOption option;
466     MessageParcel in;
467     MessageParcel out;
468     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
469         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
470     }
471     if (!in.WriteInt32(MAX_SIZE)) {
472         return TELEPHONY_ERR_WRITE_DATA_FAIL;
473     }
474     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
475         return TELEPHONY_ERR_WRITE_DATA_FAIL;
476     }
477     if (!in.WriteInt32((int32_t)mode)) {
478         return TELEPHONY_ERR_WRITE_DATA_FAIL;
479     }
480     auto remote = Remote();
481     if (remote == nullptr) {
482         TELEPHONY_LOGE("function Remote() return nullptr!");
483         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
484     }
485     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::UPDATE_CALL_MEDIA_MODE), in,
486         out, option);
487     if (error == ERR_NONE) {
488         return out.ReadInt32();
489     }
490     return error;
491 }
492 
StartDtmf(char cDtmfCode,const CellularCallInfo & callInfo)493 int32_t CellularCallProxy::StartDtmf(char cDtmfCode, const CellularCallInfo &callInfo)
494 {
495     MessageOption option;
496     MessageParcel in;
497     MessageParcel out;
498     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
499         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
500     }
501     if (!in.WriteInt32(MAX_SIZE)) {
502         return TELEPHONY_ERR_WRITE_DATA_FAIL;
503     }
504     if (!in.WriteInt8(cDtmfCode)) {
505         return TELEPHONY_ERR_WRITE_DATA_FAIL;
506     }
507     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
508         return TELEPHONY_ERR_WRITE_DATA_FAIL;
509     }
510     auto remote = Remote();
511     if (remote == nullptr) {
512         TELEPHONY_LOGE("function Remote() return nullptr!");
513         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
514     }
515     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::START_DTMF), in, out, option);
516     if (error == ERR_NONE) {
517         return out.ReadInt32();
518     }
519     return error;
520 }
521 
StopDtmf(const CellularCallInfo & callInfo)522 int32_t CellularCallProxy::StopDtmf(const CellularCallInfo &callInfo)
523 {
524     MessageOption option;
525     MessageParcel in;
526     MessageParcel out;
527     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
528         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
529     }
530     if (!in.WriteInt32(MAX_SIZE)) {
531         return TELEPHONY_ERR_WRITE_DATA_FAIL;
532     }
533     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
534         return TELEPHONY_ERR_WRITE_DATA_FAIL;
535     }
536     auto remote = Remote();
537     if (remote == nullptr) {
538         TELEPHONY_LOGE("function Remote() return nullptr!");
539         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
540     }
541     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::STOP_DTMF), in, out, option);
542     if (error == ERR_NONE) {
543         return out.ReadInt32();
544     }
545     return error;
546 }
547 
PostDialProceed(const CellularCallInfo & callInfo,const bool proceed)548 int32_t CellularCallProxy::PostDialProceed(const CellularCallInfo &callInfo, const bool proceed)
549 {
550     MessageOption option;
551     MessageParcel in;
552     MessageParcel out;
553     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
554         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
555     }
556     if (!in.WriteInt32(MAX_SIZE)) {
557         TELEPHONY_LOGE("WriteInt32 fail!");
558         return TELEPHONY_ERR_WRITE_DATA_FAIL;
559     }
560     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
561         TELEPHONY_LOGE("WriteRawData fail!");
562         return TELEPHONY_ERR_WRITE_DATA_FAIL;
563     }
564     if (!in.WriteBool(proceed)) {
565         TELEPHONY_LOGE("WriteBool fail!");
566         return TELEPHONY_ERR_WRITE_DATA_FAIL;
567     }
568     auto remote = Remote();
569     if (remote == nullptr) {
570         TELEPHONY_LOGE("function Remote() return nullptr!");
571         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
572     }
573     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::POST_DIAL_PROCEED),
574         in, out, option);
575     if (error == ERR_NONE) {
576         return out.ReadInt32();
577     }
578     return error;
579 }
580 
SendDtmf(char cDtmfCode,const CellularCallInfo & callInfo)581 int32_t CellularCallProxy::SendDtmf(char cDtmfCode, const CellularCallInfo &callInfo)
582 {
583     MessageOption option;
584     MessageParcel in;
585     MessageParcel out;
586     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
587         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
588     }
589     if (!in.WriteInt32(MAX_SIZE)) {
590         return TELEPHONY_ERR_WRITE_DATA_FAIL;
591     }
592     if (!in.WriteInt8(cDtmfCode)) {
593         return TELEPHONY_ERR_WRITE_DATA_FAIL;
594     }
595     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
596         return TELEPHONY_ERR_WRITE_DATA_FAIL;
597     }
598     auto remote = Remote();
599     if (remote == nullptr) {
600         TELEPHONY_LOGE("function Remote() return nullptr!");
601         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
602     }
603     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SEND_DTMF), in, out, option);
604     if (error == ERR_NONE) {
605         return out.ReadInt32();
606     }
607     return error;
608 }
609 
StartRtt(int32_t slotId,const std::string & msg)610 int32_t CellularCallProxy::StartRtt(int32_t slotId, const std::string &msg)
611 {
612     MessageOption option;
613     MessageParcel in;
614     MessageParcel out;
615     int32_t result = TELEPHONY_SUCCESS;
616     result = SetCommonParamForMessageParcel(slotId, in);
617     if (result != TELEPHONY_SUCCESS) {
618         return result;
619     }
620     if (!in.WriteString(msg)) {
621         return TELEPHONY_ERR_WRITE_DATA_FAIL;
622     }
623     auto remote = Remote();
624     if (remote == nullptr) {
625         TELEPHONY_LOGE("function Remote() return nullptr!");
626         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
627     }
628     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::START_RTT), in, out, option);
629     if (error == ERR_NONE) {
630         return out.ReadInt32();
631     }
632     return error;
633 }
634 
StopRtt(int32_t slotId)635 int32_t CellularCallProxy::StopRtt(int32_t slotId)
636 {
637     MessageOption option;
638     MessageParcel in;
639     MessageParcel out;
640     int32_t result = TELEPHONY_SUCCESS;
641     result = SetCommonParamForMessageParcel(slotId, in);
642     if (result != TELEPHONY_SUCCESS) {
643         return result;
644     }
645     auto remote = Remote();
646     if (remote == nullptr) {
647         TELEPHONY_LOGE("function Remote() return nullptr!");
648         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
649     }
650     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::STOP_RTT), in, out, option);
651     if (error == ERR_NONE) {
652         return out.ReadInt32();
653     }
654     return error;
655 }
656 
SetCallTransferInfo(int32_t slotId,const CallTransferInfo & ctInfo)657 int32_t CellularCallProxy::SetCallTransferInfo(int32_t slotId, const CallTransferInfo &ctInfo)
658 {
659     MessageOption option;
660     MessageParcel in;
661     MessageParcel out;
662     int32_t result = TELEPHONY_SUCCESS;
663     result = SetCommonParamForMessageParcel(slotId, in);
664     if (result != TELEPHONY_SUCCESS) {
665         return result;
666     }
667     if (!in.WriteRawData((const void *)&ctInfo, sizeof(CallTransferInfo))) {
668         return TELEPHONY_ERR_WRITE_DATA_FAIL;
669     }
670     auto remote = Remote();
671     if (remote == nullptr) {
672         TELEPHONY_LOGE("function Remote() return nullptr!");
673         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
674     }
675     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_CALL_TRANSFER), in,
676         out, option);
677     if (error == ERR_NONE) {
678         return out.ReadInt32();
679     }
680     return error;
681 }
682 
CanSetCallTransferTime(int32_t slotId,bool & result)683 int32_t CellularCallProxy::CanSetCallTransferTime(int32_t slotId, bool &result)
684 {
685     MessageOption option;
686     MessageParcel in;
687     MessageParcel out;
688     int32_t ret = TELEPHONY_SUCCESS;
689     ret = SetCommonParamForMessageParcel(slotId, in);
690     if (ret != TELEPHONY_SUCCESS) {
691         return ret;
692     }
693     if (!in.WriteBool(result)) {
694         return TELEPHONY_ERR_WRITE_DATA_FAIL;
695     }
696     auto remote = Remote();
697     if (remote == nullptr) {
698         TELEPHONY_LOGE("[slot%{public}d] function Remote() return nullptr!", slotId);
699         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
700     }
701     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::CAN_SET_CALL_TRANSFER_TIME),
702         in, out, option);
703     if (error == ERR_NONE) {
704         result = out.ReadBool();
705         return out.ReadInt32();
706     }
707 
708     return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
709 }
710 
GetCallTransferInfo(int32_t slotId,CallTransferType type)711 int32_t CellularCallProxy::GetCallTransferInfo(int32_t slotId, CallTransferType type)
712 {
713     MessageOption option;
714     MessageParcel in;
715     MessageParcel out;
716     int32_t result = TELEPHONY_SUCCESS;
717     result = SetCommonParamForMessageParcel(slotId, in);
718     if (result != TELEPHONY_SUCCESS) {
719         return result;
720     }
721     if (!in.WriteInt32((int32_t)type)) {
722         return TELEPHONY_ERR_WRITE_DATA_FAIL;
723     }
724     auto remote = Remote();
725     if (remote == nullptr) {
726         TELEPHONY_LOGE("function Remote() return nullptr!");
727         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
728     }
729     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_CALL_TRANSFER), in,
730         out, option);
731     if (error == ERR_NONE) {
732         return out.ReadInt32();
733     }
734     return error;
735 }
736 
SetCallWaiting(int32_t slotId,bool activate)737 int32_t CellularCallProxy::SetCallWaiting(int32_t slotId, bool activate)
738 {
739     MessageOption option;
740     MessageParcel in;
741     MessageParcel out;
742     int32_t result = TELEPHONY_SUCCESS;
743     result = SetCommonParamForMessageParcel(slotId, in);
744     if (result != TELEPHONY_SUCCESS) {
745         return result;
746     }
747     if (!in.WriteBool(activate)) {
748         return TELEPHONY_ERR_WRITE_DATA_FAIL;
749     }
750     auto remote = Remote();
751     if (remote == nullptr) {
752         TELEPHONY_LOGE("function Remote() return nullptr!");
753         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
754     }
755     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_CALL_WAITING), in,
756         out, option);
757     if (error == ERR_NONE) {
758         return out.ReadInt32();
759     }
760     return error;
761 }
762 
GetCallWaiting(int32_t slotId)763 int32_t CellularCallProxy::GetCallWaiting(int32_t slotId)
764 {
765     MessageOption option;
766     MessageParcel in;
767     MessageParcel out;
768     int32_t result = TELEPHONY_SUCCESS;
769     result = SetCommonParamForMessageParcel(slotId, in);
770     if (result != TELEPHONY_SUCCESS) {
771         return result;
772     }
773     auto remote = Remote();
774     if (remote == nullptr) {
775         TELEPHONY_LOGE("function Remote() return nullptr!");
776         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
777     }
778     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_CALL_WAITING), in,
779         out, option);
780     if (error == ERR_NONE) {
781         return out.ReadInt32();
782     }
783     return error;
784 }
785 
SetCallRestriction(int32_t slotId,const CallRestrictionInfo & crInfo)786 int32_t CellularCallProxy::SetCallRestriction(int32_t slotId, const CallRestrictionInfo &crInfo)
787 {
788     MessageOption option;
789     MessageParcel in;
790     MessageParcel out;
791     int32_t result = TELEPHONY_SUCCESS;
792     result = SetCommonParamForMessageParcel(slotId, in);
793     if (result != TELEPHONY_SUCCESS) {
794         return result;
795     }
796     if (!in.WriteRawData((const void *)&crInfo, sizeof(CallRestrictionInfo))) {
797         return TELEPHONY_ERR_WRITE_DATA_FAIL;
798     }
799     auto remote = Remote();
800     if (remote == nullptr) {
801         TELEPHONY_LOGE("function Remote() return nullptr!");
802         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
803     }
804     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_CALL_RESTRICTION), in,
805         out, option);
806     if (error == ERR_NONE) {
807         return out.ReadInt32();
808     }
809     return error;
810 }
811 
GetCallRestriction(int32_t slotId,CallRestrictionType facType)812 int32_t CellularCallProxy::GetCallRestriction(int32_t slotId, CallRestrictionType facType)
813 {
814     MessageOption option;
815     MessageParcel in;
816     MessageParcel out;
817     int32_t result = TELEPHONY_SUCCESS;
818     result = SetCommonParamForMessageParcel(slotId, in);
819     if (result != TELEPHONY_SUCCESS) {
820         return result;
821     }
822     if (!in.WriteInt32((int32_t)facType)) {
823         return TELEPHONY_ERR_WRITE_DATA_FAIL;
824     }
825     auto remote = Remote();
826     if (remote == nullptr) {
827         TELEPHONY_LOGE("function Remote() return nullptr!");
828         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
829     }
830     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_CALL_RESTRICTION), in,
831         out, option);
832     if (error == ERR_NONE) {
833         return out.ReadInt32();
834     }
835     return error;
836 }
837 
SetCallRestrictionPassword(int32_t slotId,CallRestrictionType fac,const char * oldPassword,const char * newPassword)838 int32_t CellularCallProxy::SetCallRestrictionPassword(
839     int32_t slotId, CallRestrictionType fac, const char *oldPassword, const char *newPassword)
840 {
841     MessageOption option;
842     MessageParcel in;
843     MessageParcel out;
844     int32_t result = TELEPHONY_SUCCESS;
845     result = SetCommonParamForMessageParcel(slotId, in);
846     if (result != TELEPHONY_SUCCESS) {
847         return result;
848     }
849     if (!in.WriteInt32(static_cast<int32_t>(fac))) {
850         return TELEPHONY_ERR_WRITE_DATA_FAIL;
851     }
852     if (!in.WriteCString(oldPassword)) {
853         return TELEPHONY_ERR_WRITE_DATA_FAIL;
854     }
855     if (!in.WriteCString(newPassword)) {
856         return TELEPHONY_ERR_WRITE_DATA_FAIL;
857     }
858     auto remote = Remote();
859     if (remote == nullptr) {
860         TELEPHONY_LOGE("function Remote() return nullptr!");
861         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
862     }
863     int32_t error = remote->SendRequest(
864         static_cast<uint32_t>(CellularCallInterfaceCode::SET_CALL_RESTRICTION_PWD), in, out, option);
865     if (error == ERR_NONE) {
866         return out.ReadInt32();
867     }
868     return error;
869 }
870 
SetDomainPreferenceMode(int32_t slotId,int32_t mode)871 int32_t CellularCallProxy::SetDomainPreferenceMode(int32_t slotId, int32_t mode)
872 {
873     MessageOption option;
874     MessageParcel in;
875     MessageParcel out;
876     int32_t result = TELEPHONY_SUCCESS;
877     result = SetCommonParamForMessageParcel(slotId, in);
878     if (result != TELEPHONY_SUCCESS) {
879         return result;
880     }
881     if (!in.WriteInt32(mode)) {
882         return TELEPHONY_ERR_WRITE_DATA_FAIL;
883     }
884     auto remote = Remote();
885     if (remote == nullptr) {
886         TELEPHONY_LOGE("function Remote() return nullptr!");
887         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
888     }
889     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_DOMAIN_PREFERENCE_MODE),
890         in, out, option);
891     if (error == ERR_NONE) {
892         return out.ReadInt32();
893     }
894     return error;
895 }
896 
GetDomainPreferenceMode(int32_t slotId)897 int32_t CellularCallProxy::GetDomainPreferenceMode(int32_t slotId)
898 {
899     MessageOption option;
900     MessageParcel in;
901     MessageParcel out;
902     int32_t result = TELEPHONY_SUCCESS;
903     result = SetCommonParamForMessageParcel(slotId, in);
904     if (result != TELEPHONY_SUCCESS) {
905         return result;
906     }
907     auto remote = Remote();
908     if (remote == nullptr) {
909         TELEPHONY_LOGE("function Remote() return nullptr!");
910         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
911     }
912     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_DOMAIN_PREFERENCE_MODE),
913         in, out, option);
914     if (error == ERR_NONE) {
915         return out.ReadInt32();
916     }
917     return error;
918 }
919 
SetImsSwitchStatus(int32_t slotId,bool active)920 int32_t CellularCallProxy::SetImsSwitchStatus(int32_t slotId, bool active)
921 {
922     MessageOption option;
923     MessageParcel in;
924     MessageParcel out;
925     int32_t result = TELEPHONY_SUCCESS;
926     result = SetCommonParamForMessageParcel(slotId, in);
927     if (result != TELEPHONY_SUCCESS) {
928         return result;
929     }
930     if (!in.WriteBool(active)) {
931         return TELEPHONY_ERR_WRITE_DATA_FAIL;
932     }
933     auto remote = Remote();
934     if (remote == nullptr) {
935         TELEPHONY_LOGE("function Remote() return nullptr!");
936         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
937     }
938     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_IMS_SWITCH_STATUS),
939         in, out, option);
940     if (error != ERR_NONE) {
941         TELEPHONY_LOGE("function SetImsSwitchStatus failed! errCode:%{public}d", error);
942         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
943     }
944     return out.ReadInt32();
945 }
946 
GetImsSwitchStatus(int32_t slotId,bool & enabled)947 int32_t CellularCallProxy::GetImsSwitchStatus(int32_t slotId, bool &enabled)
948 {
949     MessageOption option;
950     MessageParcel out;
951     MessageParcel in;
952     int32_t result = TELEPHONY_SUCCESS;
953     result = SetCommonParamForMessageParcel(slotId, in);
954     if (result != TELEPHONY_SUCCESS) {
955         return result;
956     }
957     auto remote = Remote();
958     if (remote == nullptr) {
959         TELEPHONY_LOGE("function Remote() return nullptr!");
960         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
961     }
962     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_IMS_SWITCH_STATUS),
963         in, out, option);
964     if (error != ERR_NONE) {
965         TELEPHONY_LOGE("function GetImsSwitchStatus failed! errCode:%{public}d", error);
966         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
967     }
968     enabled = out.ReadBool();
969     return out.ReadInt32();
970 }
971 
SetVoNRState(int32_t slotId,int32_t state)972 int32_t CellularCallProxy::SetVoNRState(int32_t slotId, int32_t state)
973 {
974     MessageOption option;
975     MessageParcel in;
976     MessageParcel out;
977     int32_t result = TELEPHONY_SUCCESS;
978     result = SetCommonParamForMessageParcel(slotId, in);
979     if (result != TELEPHONY_SUCCESS) {
980         return result;
981     }
982     if (!in.WriteInt32(state)) {
983         return TELEPHONY_ERR_WRITE_DATA_FAIL;
984     }
985     auto remote = Remote();
986     if (remote == nullptr) {
987         TELEPHONY_LOGE("function Remote() return nullptr!");
988         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
989     }
990     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_VONR_SWITCH_STATUS), in,
991         out, option);
992     if (error != ERR_NONE) {
993         TELEPHONY_LOGE("function SetVoNRState failed! errCode:%{public}d", error);
994         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
995     }
996     return out.ReadInt32();
997 }
998 
GetVoNRState(int32_t slotId,int32_t & state)999 int32_t CellularCallProxy::GetVoNRState(int32_t slotId, int32_t &state)
1000 {
1001     MessageOption option;
1002     MessageParcel out;
1003     MessageParcel in;
1004     int32_t result = TELEPHONY_SUCCESS;
1005     result = SetCommonParamForMessageParcel(slotId, in);
1006     if (result != TELEPHONY_SUCCESS) {
1007         return result;
1008     }
1009     auto remote = Remote();
1010     if (remote == nullptr) {
1011         TELEPHONY_LOGE("function Remote() return nullptr!");
1012         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1013     }
1014     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_VONR_SWITCH_STATUS), in,
1015         out, option);
1016     if (error != ERR_NONE) {
1017         TELEPHONY_LOGE("function GetImsSwitchStatus failed! errCode:%{public}d", error);
1018         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1019     }
1020     state = out.ReadInt32();
1021     return out.ReadInt32();
1022 }
1023 
SetImsConfig(int32_t slotId,ImsConfigItem item,const std::string & value)1024 int32_t CellularCallProxy::SetImsConfig(int32_t slotId, ImsConfigItem item, const std::string &value)
1025 {
1026     MessageOption option;
1027     MessageParcel in;
1028     MessageParcel out;
1029     int32_t result = TELEPHONY_SUCCESS;
1030     result = SetCommonParamForMessageParcel(slotId, in);
1031     if (result != TELEPHONY_SUCCESS) {
1032         return result;
1033     }
1034     if (!in.WriteInt32(item)) {
1035         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1036     }
1037     if (!in.WriteString(value)) {
1038         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1039     }
1040     auto remote = Remote();
1041     if (remote == nullptr) {
1042         TELEPHONY_LOGE("function Remote() return nullptr!");
1043         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1044     }
1045     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_IMS_CONFIG_STRING), in,
1046         out, option);
1047     if (error == ERR_NONE) {
1048         return out.ReadInt32();
1049     }
1050     return error;
1051 }
1052 
SetImsConfig(int32_t slotId,ImsConfigItem item,int32_t value)1053 int32_t CellularCallProxy::SetImsConfig(int32_t slotId, ImsConfigItem item, int32_t value)
1054 {
1055     MessageOption option;
1056     MessageParcel in;
1057     MessageParcel out;
1058     int32_t result = TELEPHONY_SUCCESS;
1059     result = SetCommonParamForMessageParcel(slotId, in);
1060     if (result != TELEPHONY_SUCCESS) {
1061         return result;
1062     }
1063     if (!in.WriteInt32(item)) {
1064         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1065     }
1066     if (!in.WriteInt32(value)) {
1067         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1068     }
1069     auto remote = Remote();
1070     if (remote == nullptr) {
1071         TELEPHONY_LOGE("function Remote() return nullptr!");
1072         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1073     }
1074     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_IMS_CONFIG_INT), in,
1075         out, option);
1076     if (error == ERR_NONE) {
1077         return out.ReadInt32();
1078     }
1079     return error;
1080 }
1081 
GetImsConfig(int32_t slotId,ImsConfigItem item)1082 int32_t CellularCallProxy::GetImsConfig(int32_t slotId, ImsConfigItem item)
1083 {
1084     MessageOption option;
1085     MessageParcel in;
1086     MessageParcel out;
1087     int32_t result = TELEPHONY_SUCCESS;
1088     result = SetCommonParamForMessageParcel(slotId, in);
1089     if (result != TELEPHONY_SUCCESS) {
1090         return result;
1091     }
1092     if (!in.WriteInt32(item)) {
1093         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1094     }
1095     auto remote = Remote();
1096     if (remote == nullptr) {
1097         TELEPHONY_LOGE("function Remote() return nullptr!");
1098         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1099     }
1100     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_IMS_CONFIG), in,
1101         out, option);
1102     if (error == ERR_NONE) {
1103         return out.ReadInt32();
1104     }
1105     return error;
1106 }
1107 
SetImsFeatureValue(int32_t slotId,FeatureType type,int32_t value)1108 int32_t CellularCallProxy::SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value)
1109 {
1110     MessageOption option;
1111     MessageParcel in;
1112     MessageParcel out;
1113     int32_t result = TELEPHONY_SUCCESS;
1114     result = SetCommonParamForMessageParcel(slotId, in);
1115     if (result != TELEPHONY_SUCCESS) {
1116         return result;
1117     }
1118     if (!in.WriteInt32(type)) {
1119         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1120     }
1121     if (!in.WriteInt32(value)) {
1122         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1123     }
1124     auto remote = Remote();
1125     if (remote == nullptr) {
1126         TELEPHONY_LOGE("function Remote() return nullptr!");
1127         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1128     }
1129     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_IMS_FEATURE), in,
1130         out, option);
1131     if (error == ERR_NONE) {
1132         return out.ReadInt32();
1133     }
1134     return error;
1135 }
1136 
GetImsFeatureValue(int32_t slotId,FeatureType type)1137 int32_t CellularCallProxy::GetImsFeatureValue(int32_t slotId, FeatureType type)
1138 {
1139     MessageOption option;
1140     MessageParcel in;
1141     MessageParcel out;
1142     int32_t result = TELEPHONY_SUCCESS;
1143     result = SetCommonParamForMessageParcel(slotId, in);
1144     if (result != TELEPHONY_SUCCESS) {
1145         return result;
1146     }
1147     if (!in.WriteInt32(type)) {
1148         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1149     }
1150     auto remote = Remote();
1151     if (remote == nullptr) {
1152         TELEPHONY_LOGE("function Remote() return nullptr!");
1153         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1154     }
1155     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_IMS_FEATURE), in,
1156         out, option);
1157     if (error == ERR_NONE) {
1158         return out.ReadInt32();
1159     }
1160     return error;
1161 }
1162 
CtrlCamera(const std::u16string & cameraId,int32_t callingUid,int32_t callingPid)1163 int32_t CellularCallProxy::CtrlCamera(const std::u16string &cameraId, int32_t callingUid, int32_t callingPid)
1164 {
1165     MessageOption option;
1166     MessageParcel in;
1167     MessageParcel out;
1168     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1169         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1170     }
1171     if (!in.WriteInt32(MAX_SIZE)) {
1172         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1173     }
1174     if (!in.WriteString16(cameraId)) {
1175         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1176     }
1177     if (!in.WriteInt32(callingUid)) {
1178         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1179     }
1180     if (!in.WriteInt32(callingPid)) {
1181         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1182     }
1183     auto remote = Remote();
1184     if (remote == nullptr) {
1185         TELEPHONY_LOGE("function Remote() return nullptr!");
1186         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1187     }
1188     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::CTRL_CAMERA), in, out, option);
1189     if (error == ERR_NONE) {
1190         return out.ReadInt32();
1191     }
1192     return error;
1193 }
1194 
SetPreviewWindow(int32_t x,int32_t y,int32_t z,int32_t width,int32_t height)1195 int32_t CellularCallProxy::SetPreviewWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height)
1196 {
1197     MessageOption option;
1198     MessageParcel in;
1199     MessageParcel out;
1200     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1201         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1202     }
1203     if (!in.WriteInt32(MAX_SIZE)) {
1204         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1205     }
1206     if (!in.WriteInt32(x)) {
1207         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1208     }
1209     if (!in.WriteInt32(y)) {
1210         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1211     }
1212     if (!in.WriteInt32(z)) {
1213         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1214     }
1215     if (!in.WriteInt32(width)) {
1216         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1217     }
1218     if (!in.WriteInt32(height)) {
1219         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1220     }
1221     auto remote = Remote();
1222     if (remote == nullptr) {
1223         TELEPHONY_LOGE("function Remote() return nullptr!");
1224         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1225     }
1226     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_PREVIEW_WINDOW), in,
1227         out, option);
1228     if (error == ERR_NONE) {
1229         return out.ReadInt32();
1230     }
1231     return error;
1232 }
1233 
SetDisplayWindow(int32_t x,int32_t y,int32_t z,int32_t width,int32_t height)1234 int32_t CellularCallProxy::SetDisplayWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height)
1235 {
1236     MessageOption option;
1237     MessageParcel in;
1238     MessageParcel out;
1239     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1240         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1241     }
1242     if (!in.WriteInt32(MAX_SIZE)) {
1243         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1244     }
1245     if (!in.WriteInt32(x)) {
1246         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1247     }
1248     if (!in.WriteInt32(y)) {
1249         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1250     }
1251     if (!in.WriteInt32(z)) {
1252         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1253     }
1254     if (!in.WriteInt32(width)) {
1255         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1256     }
1257     if (!in.WriteInt32(height)) {
1258         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1259     }
1260     auto remote = Remote();
1261     if (remote == nullptr) {
1262         TELEPHONY_LOGE("function Remote() return nullptr!");
1263         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1264     }
1265     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_DISPLAY_WINDOW), in,
1266         out, option);
1267     if (error == ERR_NONE) {
1268         return out.ReadInt32();
1269     }
1270     return error;
1271 }
1272 
SetCameraZoom(float zoomRatio)1273 int32_t CellularCallProxy::SetCameraZoom(float zoomRatio)
1274 {
1275     MessageOption option;
1276     MessageParcel in;
1277     MessageParcel out;
1278     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1279         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1280     }
1281     if (!in.WriteInt32(MAX_SIZE)) {
1282         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1283     }
1284     if (!in.WriteFloat(zoomRatio)) {
1285         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1286     }
1287     auto remote = Remote();
1288     if (remote == nullptr) {
1289         TELEPHONY_LOGE("function Remote() return nullptr!");
1290         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1291     }
1292     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_CAMERA_ZOOM), in,
1293         out, option);
1294     if (error == ERR_NONE) {
1295         return out.ReadInt32();
1296     }
1297     return error;
1298 }
1299 
SetPauseImage(const std::u16string & path)1300 int32_t CellularCallProxy::SetPauseImage(const std::u16string &path)
1301 {
1302     MessageOption option;
1303     MessageParcel in;
1304     MessageParcel out;
1305     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1306         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1307     }
1308     if (!in.WriteInt32(MAX_SIZE)) {
1309         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1310     }
1311     if (!in.WriteString16(path)) {
1312         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1313     }
1314     auto remote = Remote();
1315     if (remote == nullptr) {
1316         TELEPHONY_LOGE("function Remote() return nullptr!");
1317         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1318     }
1319     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_PAUSE_IMAGE), in,
1320         out, option);
1321     if (error == ERR_NONE) {
1322         return out.ReadInt32();
1323     }
1324     return error;
1325 }
1326 
SetDeviceDirection(int32_t rotation)1327 int32_t CellularCallProxy::SetDeviceDirection(int32_t rotation)
1328 {
1329     MessageOption option;
1330     MessageParcel in;
1331     MessageParcel out;
1332     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1333         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1334     }
1335     if (!in.WriteInt32(MAX_SIZE)) {
1336         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1337     }
1338     if (!in.WriteInt32(rotation)) {
1339         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1340     }
1341     auto remote = Remote();
1342     if (remote == nullptr) {
1343         TELEPHONY_LOGE("function Remote() return nullptr!");
1344         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1345     }
1346     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_DEVICE_DIRECTION), in,
1347         out, option);
1348     if (error == ERR_NONE) {
1349         return out.ReadInt32();
1350     }
1351     return error;
1352 }
1353 
SetMute(int32_t slotId,int32_t mute)1354 int32_t CellularCallProxy::SetMute(int32_t slotId, int32_t mute)
1355 {
1356     MessageOption option;
1357     MessageParcel in;
1358     MessageParcel out;
1359     int32_t result = TELEPHONY_SUCCESS;
1360     result = SetCommonParamForMessageParcel(slotId, in);
1361     if (result != TELEPHONY_SUCCESS) {
1362         return result;
1363     }
1364     if (!in.WriteInt32(mute)) {
1365         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1366     }
1367     auto remote = Remote();
1368     if (remote == nullptr) {
1369         TELEPHONY_LOGE("function Remote() return nullptr!");
1370         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1371     }
1372     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_MUTE), in, out, option);
1373     if (error == ERR_NONE) {
1374         return out.ReadInt32();
1375     }
1376     return error;
1377 }
1378 
GetMute(int32_t slotId)1379 int32_t CellularCallProxy::GetMute(int32_t slotId)
1380 {
1381     MessageOption option;
1382     MessageParcel in;
1383     MessageParcel out;
1384     int32_t result = TELEPHONY_SUCCESS;
1385     result = SetCommonParamForMessageParcel(slotId, in);
1386     if (result != TELEPHONY_SUCCESS) {
1387         return result;
1388     }
1389     auto remote = Remote();
1390     if (remote == nullptr) {
1391         TELEPHONY_LOGE("function Remote() return nullptr!");
1392         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1393     }
1394     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_MUTE), in, out, option);
1395     if (error == ERR_NONE) {
1396         return out.ReadInt32();
1397     }
1398     return error;
1399 }
1400 
SetEmergencyCallList(int32_t slotId,std::vector<EmergencyCall> & eccVec)1401 int32_t CellularCallProxy::SetEmergencyCallList(int32_t slotId, std::vector<EmergencyCall>  &eccVec)
1402 {
1403     MessageOption option;
1404     MessageParcel in;
1405     MessageParcel out;
1406     int32_t result = TELEPHONY_SUCCESS;
1407     result = SetCommonParamForMessageParcel(slotId, in);
1408     if (result != TELEPHONY_SUCCESS) {
1409         return result;
1410     }
1411 
1412     if (eccVec.size() <= 0) {
1413         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1414     }
1415 
1416     if (!in.WriteInt32(static_cast<int32_t>(eccVec.size()))) {
1417         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1418     }
1419 
1420     for (auto ecc : eccVec) {
1421         if (!(in.WriteString(ecc.eccNum) && in.WriteString(ecc.mcc) &&
1422                 in.WriteInt32(static_cast<int32_t>(ecc.eccType)) &&
1423                 in.WriteInt32(static_cast<int32_t>(ecc.simpresent)) &&
1424                 in.WriteInt32(static_cast<int32_t>(ecc.abnormalService)))) {
1425             return TELEPHONY_ERR_WRITE_DATA_FAIL;
1426         }
1427     }
1428 
1429     auto remote = Remote();
1430     if (remote == nullptr) {
1431         TELEPHONY_LOGE("function Remote() return nullptr!");
1432         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1433     }
1434     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_EMERGENCY_CALL_LIST),
1435         in, out, option);
1436     if (error == ERR_NONE) {
1437         return out.ReadInt32();
1438     }
1439     return error;
1440 }
1441 
SetCommonParamForMessageParcel(int32_t slotId,MessageParcel & in)1442 int32_t CellularCallProxy::SetCommonParamForMessageParcel(int32_t slotId, MessageParcel &in)
1443 {
1444     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1445         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1446     }
1447     if (!in.WriteInt32(MAX_SIZE)) {
1448         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1449     }
1450     if (!in.WriteInt32(slotId)) {
1451         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1452     }
1453     return TELEPHONY_SUCCESS;
1454 }
1455 
CloseUnFinishedUssd(int32_t slotId)1456 int32_t CellularCallProxy::CloseUnFinishedUssd(int32_t slotId)
1457 {
1458     MessageOption option;
1459     MessageParcel in;
1460     MessageParcel out;
1461     int32_t result = TELEPHONY_SUCCESS;
1462     result = SetCommonParamForMessageParcel(slotId, in);
1463     if (result != TELEPHONY_SUCCESS) {
1464         return result;
1465     }
1466     auto remote = Remote();
1467     if (remote == nullptr) {
1468         TELEPHONY_LOGE("function Remote() return nullptr!");
1469         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1470     }
1471     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::CLOSE_UNFINISHED_USSD),
1472         in, out, option);
1473     if (error == ERR_NONE) {
1474         return out.ReadInt32();
1475     }
1476     return error;
1477 }
1478 
ClearAllCalls(const std::vector<CellularCallInfo> & infos)1479 int32_t CellularCallProxy::ClearAllCalls(const std::vector<CellularCallInfo> &infos)
1480 {
1481     MessageOption option;
1482     MessageParcel in;
1483     MessageParcel out;
1484     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1485         TELEPHONY_LOGE("WriteInterfaceToken fail!");
1486         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1487     }
1488 
1489     int32_t infoSize = static_cast<int32_t>(infos.size());
1490     if (!in.WriteInt32(infoSize)) {
1491         TELEPHONY_LOGE("WriteInt32 fail!");
1492         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1493     }
1494     for (auto &info : infos) {
1495         if (!in.WriteRawData(static_cast<const void *>(&info), sizeof(CellularCallInfo))) {
1496             TELEPHONY_LOGE("WriteRawData fail!");
1497             return TELEPHONY_ERR_WRITE_DATA_FAIL;
1498         }
1499     }
1500     auto remote = Remote();
1501     if (remote == nullptr) {
1502         TELEPHONY_LOGE("function Remote() return nullptr!");
1503         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1504     }
1505     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::CLEAR_ALL_CALLS),
1506         in, out, option);
1507     if (error == ERR_NONE) {
1508         return out.ReadInt32();
1509     }
1510     return error;
1511 }
1512 } // namespace Telephony
1513 } // namespace OHOS
1514