• 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 
SendUpdateCallMediaModeRequest(const CellularCallInfo & callInfo,ImsCallMode mode)463 int32_t CellularCallProxy::SendUpdateCallMediaModeRequest(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(static_cast<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(
486         static_cast<uint32_t>(CellularCallInterfaceCode::SEND_CALL_MEDIA_MODE_REQUEST), in, out, option);
487     if (error == ERR_NONE) {
488         return out.ReadInt32();
489     }
490     return error;
491 }
492 
SendUpdateCallMediaModeResponse(const CellularCallInfo & callInfo,ImsCallMode mode)493 int32_t CellularCallProxy::SendUpdateCallMediaModeResponse(const CellularCallInfo &callInfo, ImsCallMode mode)
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.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
505         return TELEPHONY_ERR_WRITE_DATA_FAIL;
506     }
507     if (!in.WriteInt32(static_cast<int32_t>(mode))) {
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(
516         static_cast<uint32_t>(CellularCallInterfaceCode::SEND_CALL_MEDIA_MODE_RESPONSE), in, out, option);
517     if (error == ERR_NONE) {
518         return out.ReadInt32();
519     }
520     return error;
521 }
522 
StartDtmf(char cDtmfCode,const CellularCallInfo & callInfo)523 int32_t CellularCallProxy::StartDtmf(char cDtmfCode, const CellularCallInfo &callInfo)
524 {
525     MessageOption option;
526     MessageParcel in;
527     MessageParcel out;
528     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
529         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
530     }
531     if (!in.WriteInt32(MAX_SIZE)) {
532         return TELEPHONY_ERR_WRITE_DATA_FAIL;
533     }
534     if (!in.WriteInt8(cDtmfCode)) {
535         return TELEPHONY_ERR_WRITE_DATA_FAIL;
536     }
537     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
538         return TELEPHONY_ERR_WRITE_DATA_FAIL;
539     }
540     auto remote = Remote();
541     if (remote == nullptr) {
542         TELEPHONY_LOGE("function Remote() return nullptr!");
543         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
544     }
545     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::START_DTMF), in, out, option);
546     if (error == ERR_NONE) {
547         return out.ReadInt32();
548     }
549     return error;
550 }
551 
StopDtmf(const CellularCallInfo & callInfo)552 int32_t CellularCallProxy::StopDtmf(const CellularCallInfo &callInfo)
553 {
554     MessageOption option;
555     MessageParcel in;
556     MessageParcel out;
557     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
558         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
559     }
560     if (!in.WriteInt32(MAX_SIZE)) {
561         return TELEPHONY_ERR_WRITE_DATA_FAIL;
562     }
563     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
564         return TELEPHONY_ERR_WRITE_DATA_FAIL;
565     }
566     auto remote = Remote();
567     if (remote == nullptr) {
568         TELEPHONY_LOGE("function Remote() return nullptr!");
569         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
570     }
571     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::STOP_DTMF), in, out, option);
572     if (error == ERR_NONE) {
573         return out.ReadInt32();
574     }
575     return error;
576 }
577 
PostDialProceed(const CellularCallInfo & callInfo,const bool proceed)578 int32_t CellularCallProxy::PostDialProceed(const CellularCallInfo &callInfo, const bool proceed)
579 {
580     MessageOption option;
581     MessageParcel in;
582     MessageParcel out;
583     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
584         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
585     }
586     if (!in.WriteInt32(MAX_SIZE)) {
587         TELEPHONY_LOGE("WriteInt32 fail!");
588         return TELEPHONY_ERR_WRITE_DATA_FAIL;
589     }
590     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
591         TELEPHONY_LOGE("WriteRawData fail!");
592         return TELEPHONY_ERR_WRITE_DATA_FAIL;
593     }
594     if (!in.WriteBool(proceed)) {
595         TELEPHONY_LOGE("WriteBool fail!");
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::POST_DIAL_PROCEED),
604         in, out, option);
605     if (error == ERR_NONE) {
606         return out.ReadInt32();
607     }
608     return error;
609 }
610 
SendDtmf(char cDtmfCode,const CellularCallInfo & callInfo)611 int32_t CellularCallProxy::SendDtmf(char cDtmfCode, const CellularCallInfo &callInfo)
612 {
613     MessageOption option;
614     MessageParcel in;
615     MessageParcel out;
616     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
617         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
618     }
619     if (!in.WriteInt32(MAX_SIZE)) {
620         return TELEPHONY_ERR_WRITE_DATA_FAIL;
621     }
622     if (!in.WriteInt8(cDtmfCode)) {
623         return TELEPHONY_ERR_WRITE_DATA_FAIL;
624     }
625     if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
626         return TELEPHONY_ERR_WRITE_DATA_FAIL;
627     }
628     auto remote = Remote();
629     if (remote == nullptr) {
630         TELEPHONY_LOGE("function Remote() return nullptr!");
631         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
632     }
633     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SEND_DTMF), in, out, option);
634     if (error == ERR_NONE) {
635         return out.ReadInt32();
636     }
637     return error;
638 }
639 
StartRtt(int32_t slotId,const std::string & msg)640 int32_t CellularCallProxy::StartRtt(int32_t slotId, const std::string &msg)
641 {
642     MessageOption option;
643     MessageParcel in;
644     MessageParcel out;
645     int32_t result = TELEPHONY_SUCCESS;
646     result = SetCommonParamForMessageParcel(slotId, in);
647     if (result != TELEPHONY_SUCCESS) {
648         return result;
649     }
650     if (!in.WriteString(msg)) {
651         return TELEPHONY_ERR_WRITE_DATA_FAIL;
652     }
653     auto remote = Remote();
654     if (remote == nullptr) {
655         TELEPHONY_LOGE("function Remote() return nullptr!");
656         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
657     }
658     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::START_RTT), in, out, option);
659     if (error == ERR_NONE) {
660         return out.ReadInt32();
661     }
662     return error;
663 }
664 
StopRtt(int32_t slotId)665 int32_t CellularCallProxy::StopRtt(int32_t slotId)
666 {
667     MessageOption option;
668     MessageParcel in;
669     MessageParcel out;
670     int32_t result = TELEPHONY_SUCCESS;
671     result = SetCommonParamForMessageParcel(slotId, in);
672     if (result != TELEPHONY_SUCCESS) {
673         return result;
674     }
675     auto remote = Remote();
676     if (remote == nullptr) {
677         TELEPHONY_LOGE("function Remote() return nullptr!");
678         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
679     }
680     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::STOP_RTT), in, out, option);
681     if (error == ERR_NONE) {
682         return out.ReadInt32();
683     }
684     return error;
685 }
686 
SetCallTransferInfo(int32_t slotId,const CallTransferInfo & ctInfo)687 int32_t CellularCallProxy::SetCallTransferInfo(int32_t slotId, const CallTransferInfo &ctInfo)
688 {
689     MessageOption option;
690     MessageParcel in;
691     MessageParcel out;
692     int32_t result = TELEPHONY_SUCCESS;
693     result = SetCommonParamForMessageParcel(slotId, in);
694     if (result != TELEPHONY_SUCCESS) {
695         return result;
696     }
697     if (!in.WriteRawData((const void *)&ctInfo, sizeof(CallTransferInfo))) {
698         return TELEPHONY_ERR_WRITE_DATA_FAIL;
699     }
700     auto remote = Remote();
701     if (remote == nullptr) {
702         TELEPHONY_LOGE("function Remote() return nullptr!");
703         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
704     }
705     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_CALL_TRANSFER), in,
706         out, option);
707     if (error == ERR_NONE) {
708         return out.ReadInt32();
709     }
710     return error;
711 }
712 
CanSetCallTransferTime(int32_t slotId,bool & result)713 int32_t CellularCallProxy::CanSetCallTransferTime(int32_t slotId, bool &result)
714 {
715     MessageOption option;
716     MessageParcel in;
717     MessageParcel out;
718     int32_t ret = TELEPHONY_SUCCESS;
719     ret = SetCommonParamForMessageParcel(slotId, in);
720     if (ret != TELEPHONY_SUCCESS) {
721         return ret;
722     }
723     if (!in.WriteBool(result)) {
724         return TELEPHONY_ERR_WRITE_DATA_FAIL;
725     }
726     auto remote = Remote();
727     if (remote == nullptr) {
728         TELEPHONY_LOGE("[slot%{public}d] function Remote() return nullptr!", slotId);
729         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
730     }
731     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::CAN_SET_CALL_TRANSFER_TIME),
732         in, out, option);
733     if (error == ERR_NONE) {
734         result = out.ReadBool();
735         return out.ReadInt32();
736     }
737 
738     return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
739 }
740 
GetCallTransferInfo(int32_t slotId,CallTransferType type)741 int32_t CellularCallProxy::GetCallTransferInfo(int32_t slotId, CallTransferType type)
742 {
743     MessageOption option;
744     MessageParcel in;
745     MessageParcel out;
746     int32_t result = TELEPHONY_SUCCESS;
747     result = SetCommonParamForMessageParcel(slotId, in);
748     if (result != TELEPHONY_SUCCESS) {
749         return result;
750     }
751     if (!in.WriteInt32((int32_t)type)) {
752         return TELEPHONY_ERR_WRITE_DATA_FAIL;
753     }
754     auto remote = Remote();
755     if (remote == nullptr) {
756         TELEPHONY_LOGE("function Remote() return nullptr!");
757         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
758     }
759     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_CALL_TRANSFER), in,
760         out, option);
761     if (error == ERR_NONE) {
762         return out.ReadInt32();
763     }
764     return error;
765 }
766 
SetCallWaiting(int32_t slotId,bool activate)767 int32_t CellularCallProxy::SetCallWaiting(int32_t slotId, bool activate)
768 {
769     MessageOption option;
770     MessageParcel in;
771     MessageParcel out;
772     int32_t result = TELEPHONY_SUCCESS;
773     result = SetCommonParamForMessageParcel(slotId, in);
774     if (result != TELEPHONY_SUCCESS) {
775         return result;
776     }
777     if (!in.WriteBool(activate)) {
778         return TELEPHONY_ERR_WRITE_DATA_FAIL;
779     }
780     auto remote = Remote();
781     if (remote == nullptr) {
782         TELEPHONY_LOGE("function Remote() return nullptr!");
783         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
784     }
785     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_CALL_WAITING), in,
786         out, option);
787     if (error == ERR_NONE) {
788         return out.ReadInt32();
789     }
790     return error;
791 }
792 
GetCallWaiting(int32_t slotId)793 int32_t CellularCallProxy::GetCallWaiting(int32_t slotId)
794 {
795     MessageOption option;
796     MessageParcel in;
797     MessageParcel out;
798     int32_t result = TELEPHONY_SUCCESS;
799     result = SetCommonParamForMessageParcel(slotId, in);
800     if (result != TELEPHONY_SUCCESS) {
801         return result;
802     }
803     auto remote = Remote();
804     if (remote == nullptr) {
805         TELEPHONY_LOGE("function Remote() return nullptr!");
806         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
807     }
808     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_CALL_WAITING), in,
809         out, option);
810     if (error == ERR_NONE) {
811         return out.ReadInt32();
812     }
813     return error;
814 }
815 
GetVideoCallWaiting(int32_t slotId,bool & enabled)816 int32_t CellularCallProxy::GetVideoCallWaiting(int32_t slotId, bool &enabled)
817 {
818     MessageOption option;
819     MessageParcel in;
820     MessageParcel out;
821     int32_t result = TELEPHONY_SUCCESS;
822     result = SetCommonParamForMessageParcel(slotId, in);
823     if (result != TELEPHONY_SUCCESS) {
824         return result;
825     }
826     auto remote = Remote();
827     if (remote == nullptr) {
828         TELEPHONY_LOGE("function Remote() return nullptr!");
829         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
830     }
831     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_VIDEO_CALL_WAITING), in,
832     out, option);
833     if (error == ERR_NONE) {
834         enabled = out.ReadBool();
835         return out.ReadInt32();
836     }
837     return error;
838 }
839 
SetCallRestriction(int32_t slotId,const CallRestrictionInfo & crInfo)840 int32_t CellularCallProxy::SetCallRestriction(int32_t slotId, const CallRestrictionInfo &crInfo)
841 {
842     MessageOption option;
843     MessageParcel in;
844     MessageParcel out;
845     int32_t result = TELEPHONY_SUCCESS;
846     result = SetCommonParamForMessageParcel(slotId, in);
847     if (result != TELEPHONY_SUCCESS) {
848         return result;
849     }
850     if (!in.WriteRawData((const void *)&crInfo, sizeof(CallRestrictionInfo))) {
851         return TELEPHONY_ERR_WRITE_DATA_FAIL;
852     }
853     auto remote = Remote();
854     if (remote == nullptr) {
855         TELEPHONY_LOGE("function Remote() return nullptr!");
856         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
857     }
858     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_CALL_RESTRICTION), in,
859         out, option);
860     if (error == ERR_NONE) {
861         return out.ReadInt32();
862     }
863     return error;
864 }
865 
GetCallRestriction(int32_t slotId,CallRestrictionType facType)866 int32_t CellularCallProxy::GetCallRestriction(int32_t slotId, CallRestrictionType facType)
867 {
868     MessageOption option;
869     MessageParcel in;
870     MessageParcel out;
871     int32_t result = TELEPHONY_SUCCESS;
872     result = SetCommonParamForMessageParcel(slotId, in);
873     if (result != TELEPHONY_SUCCESS) {
874         return result;
875     }
876     if (!in.WriteInt32((int32_t)facType)) {
877         return TELEPHONY_ERR_WRITE_DATA_FAIL;
878     }
879     auto remote = Remote();
880     if (remote == nullptr) {
881         TELEPHONY_LOGE("function Remote() return nullptr!");
882         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
883     }
884     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_CALL_RESTRICTION), in,
885         out, option);
886     if (error == ERR_NONE) {
887         return out.ReadInt32();
888     }
889     return error;
890 }
891 
SetCallRestrictionPassword(int32_t slotId,CallRestrictionType fac,const char * oldPassword,const char * newPassword)892 int32_t CellularCallProxy::SetCallRestrictionPassword(
893     int32_t slotId, CallRestrictionType fac, const char *oldPassword, const char *newPassword)
894 {
895     MessageOption option;
896     MessageParcel in;
897     MessageParcel out;
898     int32_t result = TELEPHONY_SUCCESS;
899     result = SetCommonParamForMessageParcel(slotId, in);
900     if (result != TELEPHONY_SUCCESS) {
901         return result;
902     }
903     if (!in.WriteInt32(static_cast<int32_t>(fac))) {
904         return TELEPHONY_ERR_WRITE_DATA_FAIL;
905     }
906     if (!in.WriteCString(oldPassword)) {
907         return TELEPHONY_ERR_WRITE_DATA_FAIL;
908     }
909     if (!in.WriteCString(newPassword)) {
910         return TELEPHONY_ERR_WRITE_DATA_FAIL;
911     }
912     auto remote = Remote();
913     if (remote == nullptr) {
914         TELEPHONY_LOGE("function Remote() return nullptr!");
915         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
916     }
917     int32_t error = remote->SendRequest(
918         static_cast<uint32_t>(CellularCallInterfaceCode::SET_CALL_RESTRICTION_PWD), in, out, option);
919     if (error == ERR_NONE) {
920         return out.ReadInt32();
921     }
922     return error;
923 }
924 
SetDomainPreferenceMode(int32_t slotId,int32_t mode)925 int32_t CellularCallProxy::SetDomainPreferenceMode(int32_t slotId, int32_t mode)
926 {
927     MessageOption option;
928     MessageParcel in;
929     MessageParcel out;
930     int32_t result = TELEPHONY_SUCCESS;
931     result = SetCommonParamForMessageParcel(slotId, in);
932     if (result != TELEPHONY_SUCCESS) {
933         return result;
934     }
935     if (!in.WriteInt32(mode)) {
936         return TELEPHONY_ERR_WRITE_DATA_FAIL;
937     }
938     auto remote = Remote();
939     if (remote == nullptr) {
940         TELEPHONY_LOGE("function Remote() return nullptr!");
941         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
942     }
943     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_DOMAIN_PREFERENCE_MODE),
944         in, out, option);
945     if (error == ERR_NONE) {
946         return out.ReadInt32();
947     }
948     return error;
949 }
950 
GetDomainPreferenceMode(int32_t slotId)951 int32_t CellularCallProxy::GetDomainPreferenceMode(int32_t slotId)
952 {
953     MessageOption option;
954     MessageParcel in;
955     MessageParcel out;
956     int32_t result = TELEPHONY_SUCCESS;
957     result = SetCommonParamForMessageParcel(slotId, in);
958     if (result != TELEPHONY_SUCCESS) {
959         return result;
960     }
961     auto remote = Remote();
962     if (remote == nullptr) {
963         TELEPHONY_LOGE("function Remote() return nullptr!");
964         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
965     }
966     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_DOMAIN_PREFERENCE_MODE),
967         in, out, option);
968     if (error == ERR_NONE) {
969         return out.ReadInt32();
970     }
971     return error;
972 }
973 
SetImsSwitchStatus(int32_t slotId,bool active)974 int32_t CellularCallProxy::SetImsSwitchStatus(int32_t slotId, bool active)
975 {
976     MessageOption option;
977     MessageParcel in;
978     MessageParcel out;
979     int32_t result = TELEPHONY_SUCCESS;
980     result = SetCommonParamForMessageParcel(slotId, in);
981     if (result != TELEPHONY_SUCCESS) {
982         return result;
983     }
984     if (!in.WriteBool(active)) {
985         return TELEPHONY_ERR_WRITE_DATA_FAIL;
986     }
987     auto remote = Remote();
988     if (remote == nullptr) {
989         TELEPHONY_LOGE("function Remote() return nullptr!");
990         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
991     }
992     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_IMS_SWITCH_STATUS),
993         in, out, option);
994     if (error != ERR_NONE) {
995         TELEPHONY_LOGE("function SetImsSwitchStatus failed! errCode:%{public}d", error);
996         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
997     }
998     return out.ReadInt32();
999 }
1000 
GetImsSwitchStatus(int32_t slotId,bool & enabled)1001 int32_t CellularCallProxy::GetImsSwitchStatus(int32_t slotId, bool &enabled)
1002 {
1003     MessageOption option;
1004     MessageParcel out;
1005     MessageParcel in;
1006     int32_t result = TELEPHONY_SUCCESS;
1007     result = SetCommonParamForMessageParcel(slotId, in);
1008     if (result != TELEPHONY_SUCCESS) {
1009         return result;
1010     }
1011     auto remote = Remote();
1012     if (remote == nullptr) {
1013         TELEPHONY_LOGE("function Remote() return nullptr!");
1014         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1015     }
1016     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_IMS_SWITCH_STATUS),
1017         in, out, option);
1018     if (error != ERR_NONE) {
1019         TELEPHONY_LOGE("function GetImsSwitchStatus failed! errCode:%{public}d", error);
1020         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1021     }
1022     enabled = out.ReadBool();
1023     return out.ReadInt32();
1024 }
1025 
GetCarrierVtConfig(int32_t slotId,bool & enabled)1026 int32_t CellularCallProxy::GetCarrierVtConfig(int32_t slotId, bool &enabled)
1027 {
1028     MessageOption option;
1029     MessageParcel out;
1030     MessageParcel in;
1031     int32_t result = TELEPHONY_SUCCESS;
1032     result = SetCommonParamForMessageParcel(slotId, in);
1033     if (result != TELEPHONY_SUCCESS) {
1034         return result;
1035     }
1036     auto remote = Remote();
1037     if (remote == nullptr) {
1038         TELEPHONY_LOGE("function Remote() return nullptr!");
1039         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1040     }
1041     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_CARRIER_VT_CONFIG),
1042         in, out, option);
1043     if (error != ERR_NONE) {
1044         TELEPHONY_LOGE("function GetCarrierVtConfig failed! errCode:%{public}d", error);
1045         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1046     }
1047     enabled = out.ReadBool();
1048     return out.ReadInt32();
1049 }
1050 
SetVoNRState(int32_t slotId,int32_t state)1051 int32_t CellularCallProxy::SetVoNRState(int32_t slotId, int32_t state)
1052 {
1053     MessageOption option;
1054     MessageParcel in;
1055     MessageParcel out;
1056     int32_t result = TELEPHONY_SUCCESS;
1057     result = SetCommonParamForMessageParcel(slotId, in);
1058     if (result != TELEPHONY_SUCCESS) {
1059         return result;
1060     }
1061     if (!in.WriteInt32(state)) {
1062         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1063     }
1064     auto remote = Remote();
1065     if (remote == nullptr) {
1066         TELEPHONY_LOGE("function Remote() return nullptr!");
1067         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1068     }
1069     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_VONR_SWITCH_STATUS), in,
1070         out, option);
1071     if (error != ERR_NONE) {
1072         TELEPHONY_LOGE("function SetVoNRState failed! errCode:%{public}d", error);
1073         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1074     }
1075     return out.ReadInt32();
1076 }
1077 
GetVoNRState(int32_t slotId,int32_t & state)1078 int32_t CellularCallProxy::GetVoNRState(int32_t slotId, int32_t &state)
1079 {
1080     MessageOption option;
1081     MessageParcel out;
1082     MessageParcel in;
1083     int32_t result = TELEPHONY_SUCCESS;
1084     result = SetCommonParamForMessageParcel(slotId, in);
1085     if (result != TELEPHONY_SUCCESS) {
1086         return result;
1087     }
1088     auto remote = Remote();
1089     if (remote == nullptr) {
1090         TELEPHONY_LOGE("function Remote() return nullptr!");
1091         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1092     }
1093     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_VONR_SWITCH_STATUS), in,
1094         out, option);
1095     if (error != ERR_NONE) {
1096         TELEPHONY_LOGE("function GetImsSwitchStatus failed! errCode:%{public}d", error);
1097         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1098     }
1099     state = out.ReadInt32();
1100     return out.ReadInt32();
1101 }
1102 
SetImsConfig(int32_t slotId,ImsConfigItem item,const std::string & value)1103 int32_t CellularCallProxy::SetImsConfig(int32_t slotId, ImsConfigItem item, const std::string &value)
1104 {
1105     MessageOption option;
1106     MessageParcel in;
1107     MessageParcel out;
1108     int32_t result = TELEPHONY_SUCCESS;
1109     result = SetCommonParamForMessageParcel(slotId, in);
1110     if (result != TELEPHONY_SUCCESS) {
1111         return result;
1112     }
1113     if (!in.WriteInt32(item)) {
1114         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1115     }
1116     if (!in.WriteString(value)) {
1117         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1118     }
1119     auto remote = Remote();
1120     if (remote == nullptr) {
1121         TELEPHONY_LOGE("function Remote() return nullptr!");
1122         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1123     }
1124     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_IMS_CONFIG_STRING), in,
1125         out, option);
1126     if (error == ERR_NONE) {
1127         return out.ReadInt32();
1128     }
1129     return error;
1130 }
1131 
SetImsConfig(int32_t slotId,ImsConfigItem item,int32_t value)1132 int32_t CellularCallProxy::SetImsConfig(int32_t slotId, ImsConfigItem item, int32_t value)
1133 {
1134     MessageOption option;
1135     MessageParcel in;
1136     MessageParcel out;
1137     int32_t result = TELEPHONY_SUCCESS;
1138     result = SetCommonParamForMessageParcel(slotId, in);
1139     if (result != TELEPHONY_SUCCESS) {
1140         return result;
1141     }
1142     if (!in.WriteInt32(item)) {
1143         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1144     }
1145     if (!in.WriteInt32(value)) {
1146         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1147     }
1148     auto remote = Remote();
1149     if (remote == nullptr) {
1150         TELEPHONY_LOGE("function Remote() return nullptr!");
1151         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1152     }
1153     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_IMS_CONFIG_INT), in,
1154         out, option);
1155     if (error == ERR_NONE) {
1156         return out.ReadInt32();
1157     }
1158     return error;
1159 }
1160 
GetImsConfig(int32_t slotId,ImsConfigItem item)1161 int32_t CellularCallProxy::GetImsConfig(int32_t slotId, ImsConfigItem item)
1162 {
1163     MessageOption option;
1164     MessageParcel in;
1165     MessageParcel out;
1166     int32_t result = TELEPHONY_SUCCESS;
1167     result = SetCommonParamForMessageParcel(slotId, in);
1168     if (result != TELEPHONY_SUCCESS) {
1169         return result;
1170     }
1171     if (!in.WriteInt32(item)) {
1172         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1173     }
1174     auto remote = Remote();
1175     if (remote == nullptr) {
1176         TELEPHONY_LOGE("function Remote() return nullptr!");
1177         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1178     }
1179     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_IMS_CONFIG), in,
1180         out, option);
1181     if (error == ERR_NONE) {
1182         return out.ReadInt32();
1183     }
1184     return error;
1185 }
1186 
SetImsFeatureValue(int32_t slotId,FeatureType type,int32_t value)1187 int32_t CellularCallProxy::SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value)
1188 {
1189     MessageOption option;
1190     MessageParcel in;
1191     MessageParcel out;
1192     int32_t result = TELEPHONY_SUCCESS;
1193     result = SetCommonParamForMessageParcel(slotId, in);
1194     if (result != TELEPHONY_SUCCESS) {
1195         return result;
1196     }
1197     if (!in.WriteInt32(type)) {
1198         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1199     }
1200     if (!in.WriteInt32(value)) {
1201         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1202     }
1203     auto remote = Remote();
1204     if (remote == nullptr) {
1205         TELEPHONY_LOGE("function Remote() return nullptr!");
1206         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1207     }
1208     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_IMS_FEATURE), in,
1209         out, option);
1210     if (error == ERR_NONE) {
1211         return out.ReadInt32();
1212     }
1213     return error;
1214 }
1215 
GetImsFeatureValue(int32_t slotId,FeatureType type)1216 int32_t CellularCallProxy::GetImsFeatureValue(int32_t slotId, FeatureType type)
1217 {
1218     MessageOption option;
1219     MessageParcel in;
1220     MessageParcel out;
1221     int32_t result = TELEPHONY_SUCCESS;
1222     result = SetCommonParamForMessageParcel(slotId, in);
1223     if (result != TELEPHONY_SUCCESS) {
1224         return result;
1225     }
1226     if (!in.WriteInt32(type)) {
1227         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1228     }
1229     auto remote = Remote();
1230     if (remote == nullptr) {
1231         TELEPHONY_LOGE("function Remote() return nullptr!");
1232         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1233     }
1234     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_IMS_FEATURE), in,
1235         out, option);
1236     if (error == ERR_NONE) {
1237         return out.ReadInt32();
1238     }
1239     return error;
1240 }
1241 
ControlCamera(int32_t slotId,int32_t index,const std::string & cameraId)1242 int32_t CellularCallProxy::ControlCamera(int32_t slotId, int32_t index, const std::string &cameraId)
1243 {
1244     MessageOption option;
1245     MessageParcel in;
1246     MessageParcel out;
1247     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1248         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1249     }
1250     if (!in.WriteInt32(MAX_SIZE)) {
1251         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1252     }
1253     if (!in.WriteInt32(slotId)) {
1254         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1255     }
1256     if (!in.WriteInt32(index)) {
1257         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1258     }
1259     if (!in.WriteString(cameraId)) {
1260         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1261     }
1262     auto remote = Remote();
1263     if (remote == nullptr) {
1264         TELEPHONY_LOGE("function Remote() return nullptr!");
1265         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1266     }
1267     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::CTRL_CAMERA), in, out, option);
1268     if (error == ERR_NONE) {
1269         return out.ReadInt32();
1270     }
1271     return error;
1272 }
1273 
SetPreviewWindow(int32_t slotId,int32_t index,const std::string & surfaceId,sptr<Surface> surface)1274 int32_t CellularCallProxy::SetPreviewWindow(
1275     int32_t slotId, int32_t index, const std::string &surfaceId, sptr<Surface> surface)
1276 {
1277     MessageOption option;
1278     MessageParcel in;
1279     MessageParcel out;
1280     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1281         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1282     }
1283     if (!in.WriteInt32(MAX_SIZE)) {
1284         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1285     }
1286     if (!in.WriteInt32(slotId)) {
1287         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1288     }
1289     if (!in.WriteInt32(index)) {
1290         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1291     }
1292     if (!in.WriteString(surfaceId)) {
1293         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1294     }
1295     if (surface != nullptr) {
1296         sptr<IBufferProducer> producer = surface->GetProducer();
1297         if (producer != nullptr) {
1298             in.WriteRemoteObject(producer->AsObject());
1299         }
1300     }
1301     auto remote = Remote();
1302     if (remote == nullptr) {
1303         TELEPHONY_LOGE("function Remote() return nullptr!");
1304         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1305     }
1306     int32_t error =
1307         remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_PREVIEW_WINDOW), in, out, option);
1308     if (error == ERR_NONE) {
1309         return out.ReadInt32();
1310     }
1311     return error;
1312 }
1313 
SetDisplayWindow(int32_t slotId,int32_t index,const std::string & surfaceId,sptr<Surface> surface)1314 int32_t CellularCallProxy::SetDisplayWindow(
1315     int32_t slotId, int32_t index, const std::string &surfaceId, sptr<Surface> surface)
1316 {
1317     MessageOption option;
1318     MessageParcel in;
1319     MessageParcel out;
1320     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1321         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1322     }
1323     if (!in.WriteInt32(MAX_SIZE)) {
1324         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1325     }
1326     if (!in.WriteInt32(slotId)) {
1327         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1328     }
1329     if (!in.WriteInt32(index)) {
1330         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1331     }
1332     if (!in.WriteString(surfaceId)) {
1333         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1334     }
1335     if (surface != nullptr) {
1336         sptr<IBufferProducer> producer = surface->GetProducer();
1337         if (producer != nullptr) {
1338             in.WriteRemoteObject(producer->AsObject());
1339         }
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 =
1347         remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_DISPLAY_WINDOW), in, out, option);
1348     if (error == ERR_NONE) {
1349         return out.ReadInt32();
1350     }
1351     return error;
1352 }
1353 
SetCameraZoom(float zoomRatio)1354 int32_t CellularCallProxy::SetCameraZoom(float zoomRatio)
1355 {
1356     MessageOption option;
1357     MessageParcel in;
1358     MessageParcel out;
1359     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1360         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1361     }
1362     if (!in.WriteInt32(MAX_SIZE)) {
1363         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1364     }
1365     if (!in.WriteFloat(zoomRatio)) {
1366         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1367     }
1368     auto remote = Remote();
1369     if (remote == nullptr) {
1370         TELEPHONY_LOGE("function Remote() return nullptr!");
1371         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1372     }
1373     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_CAMERA_ZOOM), in,
1374         out, option);
1375     if (error == ERR_NONE) {
1376         return out.ReadInt32();
1377     }
1378     return error;
1379 }
1380 
SetPausePicture(int32_t slotId,int32_t index,const std::string & path)1381 int32_t CellularCallProxy::SetPausePicture(int32_t slotId, int32_t index, const std::string &path)
1382 {
1383     MessageOption option;
1384     MessageParcel in;
1385     MessageParcel out;
1386     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1387         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1388     }
1389     if (!in.WriteInt32(MAX_SIZE)) {
1390         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1391     }
1392     if (!in.WriteInt32(slotId)) {
1393         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1394     }
1395     if (!in.WriteInt32(index)) {
1396         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1397     }
1398     if (!in.WriteString(path)) {
1399         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1400     }
1401     auto remote = Remote();
1402     if (remote == nullptr) {
1403         TELEPHONY_LOGE("function Remote() return nullptr!");
1404         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1405     }
1406     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_PAUSE_IMAGE), in,
1407         out, option);
1408     if (error == ERR_NONE) {
1409         return out.ReadInt32();
1410     }
1411     return error;
1412 }
1413 
SetDeviceDirection(int32_t slotId,int32_t index,int32_t rotation)1414 int32_t CellularCallProxy::SetDeviceDirection(int32_t slotId, int32_t index, int32_t rotation)
1415 {
1416     MessageOption option;
1417     MessageParcel in;
1418     MessageParcel out;
1419     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1420         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1421     }
1422     if (!in.WriteInt32(MAX_SIZE)) {
1423         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1424     }
1425     if (!in.WriteInt32(slotId)) {
1426         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1427     }
1428     if (!in.WriteInt32(index)) {
1429         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1430     }
1431     if (!in.WriteInt32(rotation)) {
1432         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1433     }
1434     auto remote = Remote();
1435     if (remote == nullptr) {
1436         TELEPHONY_LOGE("function Remote() return nullptr!");
1437         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1438     }
1439     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_DEVICE_DIRECTION), in,
1440         out, option);
1441     if (error == ERR_NONE) {
1442         return out.ReadInt32();
1443     }
1444     return error;
1445 }
1446 
SetMute(int32_t slotId,int32_t mute)1447 int32_t CellularCallProxy::SetMute(int32_t slotId, int32_t mute)
1448 {
1449     MessageOption option;
1450     MessageParcel in;
1451     MessageParcel out;
1452     int32_t result = TELEPHONY_SUCCESS;
1453     result = SetCommonParamForMessageParcel(slotId, in);
1454     if (result != TELEPHONY_SUCCESS) {
1455         return result;
1456     }
1457     if (!in.WriteInt32(mute)) {
1458         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1459     }
1460     auto remote = Remote();
1461     if (remote == nullptr) {
1462         TELEPHONY_LOGE("function Remote() return nullptr!");
1463         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1464     }
1465     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_MUTE), in, out, option);
1466     if (error == ERR_NONE) {
1467         return out.ReadInt32();
1468     }
1469     return error;
1470 }
1471 
GetMute(int32_t slotId)1472 int32_t CellularCallProxy::GetMute(int32_t slotId)
1473 {
1474     MessageOption option;
1475     MessageParcel in;
1476     MessageParcel out;
1477     int32_t result = TELEPHONY_SUCCESS;
1478     result = SetCommonParamForMessageParcel(slotId, in);
1479     if (result != TELEPHONY_SUCCESS) {
1480         return result;
1481     }
1482     auto remote = Remote();
1483     if (remote == nullptr) {
1484         TELEPHONY_LOGE("function Remote() return nullptr!");
1485         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1486     }
1487     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::GET_MUTE), in, out, option);
1488     if (error == ERR_NONE) {
1489         return out.ReadInt32();
1490     }
1491     return error;
1492 }
1493 
SetEmergencyCallList(int32_t slotId,std::vector<EmergencyCall> & eccVec)1494 int32_t CellularCallProxy::SetEmergencyCallList(int32_t slotId, std::vector<EmergencyCall>  &eccVec)
1495 {
1496     MessageOption option;
1497     MessageParcel in;
1498     MessageParcel out;
1499     int32_t result = TELEPHONY_SUCCESS;
1500     result = SetCommonParamForMessageParcel(slotId, in);
1501     if (result != TELEPHONY_SUCCESS) {
1502         return result;
1503     }
1504 
1505     if (eccVec.size() <= 0) {
1506         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1507     }
1508 
1509     if (!in.WriteInt32(static_cast<int32_t>(eccVec.size()))) {
1510         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1511     }
1512 
1513     for (auto ecc : eccVec) {
1514         if (!(in.WriteString(ecc.eccNum) && in.WriteString(ecc.mcc) &&
1515                 in.WriteInt32(static_cast<int32_t>(ecc.eccType)) &&
1516                 in.WriteInt32(static_cast<int32_t>(ecc.simpresent)) &&
1517                 in.WriteInt32(static_cast<int32_t>(ecc.abnormalService)))) {
1518             return TELEPHONY_ERR_WRITE_DATA_FAIL;
1519         }
1520     }
1521 
1522     auto remote = Remote();
1523     if (remote == nullptr) {
1524         TELEPHONY_LOGE("function Remote() return nullptr!");
1525         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1526     }
1527     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SET_EMERGENCY_CALL_LIST),
1528         in, out, option);
1529     if (error == ERR_NONE) {
1530         return out.ReadInt32();
1531     }
1532     return error;
1533 }
1534 
SetCommonParamForMessageParcel(int32_t slotId,MessageParcel & in)1535 int32_t CellularCallProxy::SetCommonParamForMessageParcel(int32_t slotId, MessageParcel &in)
1536 {
1537     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1538         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1539     }
1540     if (!in.WriteInt32(MAX_SIZE)) {
1541         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1542     }
1543     if (!in.WriteInt32(slotId)) {
1544         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1545     }
1546     return TELEPHONY_SUCCESS;
1547 }
1548 
CloseUnFinishedUssd(int32_t slotId)1549 int32_t CellularCallProxy::CloseUnFinishedUssd(int32_t slotId)
1550 {
1551     MessageOption option;
1552     MessageParcel in;
1553     MessageParcel out;
1554     int32_t result = TELEPHONY_SUCCESS;
1555     result = SetCommonParamForMessageParcel(slotId, in);
1556     if (result != TELEPHONY_SUCCESS) {
1557         return result;
1558     }
1559     auto remote = Remote();
1560     if (remote == nullptr) {
1561         TELEPHONY_LOGE("function Remote() return nullptr!");
1562         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1563     }
1564     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::CLOSE_UNFINISHED_USSD),
1565         in, out, option);
1566     if (error == ERR_NONE) {
1567         return out.ReadInt32();
1568     }
1569     return error;
1570 }
1571 
ClearAllCalls(const std::vector<CellularCallInfo> & infos)1572 int32_t CellularCallProxy::ClearAllCalls(const std::vector<CellularCallInfo> &infos)
1573 {
1574     MessageOption option;
1575     MessageParcel in;
1576     MessageParcel out;
1577     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1578         TELEPHONY_LOGE("WriteInterfaceToken fail!");
1579         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1580     }
1581 
1582     int32_t infoSize = static_cast<int32_t>(infos.size());
1583     if (!in.WriteInt32(infoSize)) {
1584         TELEPHONY_LOGE("WriteInt32 fail!");
1585         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1586     }
1587     for (auto &info : infos) {
1588         if (!in.WriteRawData(static_cast<const void *>(&info), sizeof(CellularCallInfo))) {
1589             TELEPHONY_LOGE("WriteRawData fail!");
1590             return TELEPHONY_ERR_WRITE_DATA_FAIL;
1591         }
1592     }
1593     auto remote = Remote();
1594     if (remote == nullptr) {
1595         TELEPHONY_LOGE("function Remote() return nullptr!");
1596         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1597     }
1598     int32_t error = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::CLEAR_ALL_CALLS),
1599         in, out, option);
1600     if (error == ERR_NONE) {
1601         return out.ReadInt32();
1602     }
1603     return error;
1604 }
1605 
CancelCallUpgrade(int32_t slotId,int32_t index)1606 int32_t CellularCallProxy::CancelCallUpgrade(int32_t slotId, int32_t index)
1607 {
1608     MessageOption option;
1609     MessageParcel in;
1610     MessageParcel out;
1611     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1612         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1613     }
1614     if (!in.WriteInt32(MAX_SIZE)) {
1615         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1616     }
1617     if (!in.WriteInt32(slotId)) {
1618         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1619     }
1620     if (!in.WriteInt32(index)) {
1621         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1622     }
1623     auto remote = Remote();
1624     if (remote == nullptr) {
1625         TELEPHONY_LOGE("function Remote() return nullptr!");
1626         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1627     }
1628     int32_t error = remote->SendRequest(
1629         static_cast<uint32_t>(CellularCallInterfaceCode::CANCEL_CALL_UPGRADE), in, out, option);
1630     if (error == ERR_NONE) {
1631         return out.ReadInt32();
1632     }
1633     return error;
1634 }
1635 
RequestCameraCapabilities(int32_t slotId,int32_t index)1636 int32_t CellularCallProxy::RequestCameraCapabilities(int32_t slotId, int32_t index)
1637 {
1638     MessageOption option;
1639     MessageParcel in;
1640     MessageParcel out;
1641     if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1642         return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1643     }
1644     if (!in.WriteInt32(MAX_SIZE)) {
1645         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1646     }
1647     if (!in.WriteInt32(slotId)) {
1648         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1649     }
1650     if (!in.WriteInt32(index)) {
1651         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1652     }
1653     auto remote = Remote();
1654     if (remote == nullptr) {
1655         TELEPHONY_LOGE("function Remote() return nullptr!");
1656         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1657     }
1658     int32_t error = remote->SendRequest(
1659         static_cast<uint32_t>(CellularCallInterfaceCode::REQUEST_CAMERA_CAPABILITY), in, out, option);
1660     if (error == ERR_NONE) {
1661         return out.ReadInt32();
1662     }
1663     return error;
1664 }
1665 
SendUssdResponse(int32_t slotId,const std::string & content)1666 int32_t CellularCallProxy::SendUssdResponse(int32_t slotId, const std::string &content)
1667 {
1668     MessageOption option;
1669     MessageParcel in;
1670     MessageParcel out;
1671     int32_t result = TELEPHONY_SUCCESS;
1672     result = SetCommonParamForMessageParcel(slotId, in);
1673     if (result != TELEPHONY_SUCCESS) {
1674         return result;
1675     }
1676     if (!in.WriteString(content)) {
1677         return TELEPHONY_ERR_WRITE_DATA_FAIL;
1678     }
1679     auto remote = Remote();
1680     if (remote == nullptr) {
1681         TELEPHONY_LOGE("function Remote() return nullptr!");
1682         return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1683     }
1684     int32_t ret = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::SEND_USSD_RESPONSE),
1685         in, out, option);
1686     if (ret == ERR_NONE) {
1687         return out.ReadInt32();
1688     }
1689     return ret;
1690 }
1691 
IsMmiCode(int32_t slotId,std::string & number)1692 bool CellularCallProxy::IsMmiCode(int32_t slotId, std::string &number)
1693 {
1694     MessageOption option;
1695     MessageParcel in;
1696     MessageParcel out;
1697     int32_t result = TELEPHONY_SUCCESS;
1698     result = SetCommonParamForMessageParcel(slotId, in);
1699     if (result != TELEPHONY_SUCCESS) {
1700         return false;
1701     }
1702     if (!in.WriteString(number)) {
1703         return false;
1704     }
1705     auto remote = Remote();
1706     if (remote == nullptr) {
1707         TELEPHONY_LOGE("function Remote() return nullptr!");
1708         return false;
1709     }
1710     int32_t ret = remote->SendRequest(static_cast<uint32_t>(CellularCallInterfaceCode::IS_MMI_CODE),
1711         in, out, option);
1712     if (ret == ERR_NONE) {
1713         return out.ReadBool();
1714     }
1715     return false;
1716 }
1717 } // namespace Telephony
1718 } // namespace OHOS
1719