1 /*
2 * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "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>(OperationType::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>(OperationType::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>(OperationType::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>(OperationType::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>(OperationType::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>(OperationType::UN_HOLD_CALL), in, out, option);
177 if (error == ERR_NONE) {
178 return out.ReadInt32();
179 }
180 return error;
181 }
182
SwitchCall(const CellularCallInfo & callInfo)183 int32_t CellularCallProxy::SwitchCall(const CellularCallInfo &callInfo)
184 {
185 MessageOption option;
186 MessageParcel in;
187 MessageParcel out;
188 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
189 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
190 }
191 if (!in.WriteInt32(MAX_SIZE)) {
192 return TELEPHONY_ERR_WRITE_DATA_FAIL;
193 }
194 if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
195 return TELEPHONY_ERR_WRITE_DATA_FAIL;
196 }
197 auto remote = Remote();
198 if (remote == nullptr) {
199 TELEPHONY_LOGE("function Remote() return nullptr!");
200 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
201 }
202 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SWITCH_CALL), in, out, option);
203 if (error == ERR_NONE) {
204 return out.ReadInt32();
205 }
206 return error;
207 }
208
RegisterCallManagerCallBack(const sptr<ICallStatusCallback> & callback)209 int32_t CellularCallProxy::RegisterCallManagerCallBack(const sptr<ICallStatusCallback> &callback)
210 {
211 if (callback == nullptr) {
212 return TELEPHONY_ERR_ARGUMENT_INVALID;
213 }
214
215 MessageOption option;
216 MessageParcel in;
217 MessageParcel out;
218 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
219 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
220 }
221 if (!in.WriteInt32(MAX_SIZE)) {
222 return TELEPHONY_ERR_WRITE_DATA_FAIL;
223 }
224 if (!in.WriteRemoteObject(callback->AsObject().GetRefPtr())) {
225 return TELEPHONY_ERR_WRITE_DATA_FAIL;
226 }
227 auto remote = Remote();
228 if (remote == nullptr) {
229 TELEPHONY_LOGE("function Remote() return nullptr!");
230 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
231 }
232 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::REGISTER_CALLBACK), in, out, option);
233 if (error == ERR_NONE) {
234 return out.ReadInt32();
235 }
236 return error;
237 }
238
UnRegisterCallManagerCallBack()239 int32_t CellularCallProxy::UnRegisterCallManagerCallBack()
240 {
241 MessageOption option;
242 MessageParcel in;
243 MessageParcel out;
244 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
245 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
246 }
247 if (!in.WriteInt32(MAX_SIZE)) {
248 return TELEPHONY_ERR_WRITE_DATA_FAIL;
249 }
250 auto remote = Remote();
251 if (remote == nullptr) {
252 TELEPHONY_LOGE("function Remote() return nullptr!");
253 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
254 }
255 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::UNREGISTER_CALLBACK), in, out, option);
256 if (error == ERR_NONE) {
257 return out.ReadInt32();
258 }
259 return error;
260 }
261
IsEmergencyPhoneNumber(int32_t slotId,const std::string & phoneNum,bool & enabled)262 int32_t CellularCallProxy::IsEmergencyPhoneNumber(int32_t slotId, const std::string &phoneNum, bool &enabled)
263 {
264 MessageOption option;
265 MessageParcel in;
266 MessageParcel out;
267 int32_t result = TELEPHONY_SUCCESS;
268 result = SetCommonParamForMessageParcel(slotId, in);
269 if (result != TELEPHONY_SUCCESS) {
270 return result;
271 }
272 if (!in.WriteString(phoneNum)) {
273 return TELEPHONY_ERR_WRITE_DATA_FAIL;
274 }
275 auto remote = Remote();
276 if (remote == nullptr) {
277 TELEPHONY_LOGE("function Remote() return nullptr!");
278 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
279 }
280 int32_t ret = remote->SendRequest(static_cast<uint32_t>(OperationType::EMERGENCY_CALL), in, out, option);
281 if (ret != TELEPHONY_SUCCESS) {
282 TELEPHONY_LOGE("Function FormatPhoneNumberToE164 call failed! errCode:%{public}d", ret);
283 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
284 }
285 result = out.ReadInt32();
286 if (result == TELEPHONY_SUCCESS) {
287 enabled = out.ReadBool();
288 }
289 return result;
290 }
291
CombineConference(const CellularCallInfo & callInfo)292 int32_t CellularCallProxy::CombineConference(const CellularCallInfo &callInfo)
293 {
294 MessageOption option;
295 MessageParcel in;
296 MessageParcel out;
297 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
298 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
299 }
300 if (!in.WriteInt32(MAX_SIZE)) {
301 return TELEPHONY_ERR_WRITE_DATA_FAIL;
302 }
303 if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
304 return TELEPHONY_ERR_WRITE_DATA_FAIL;
305 }
306 auto remote = Remote();
307 if (remote == nullptr) {
308 TELEPHONY_LOGE("function Remote() return nullptr!");
309 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
310 }
311 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::COMBINE_CONFERENCE), in, out, option);
312 if (error == ERR_NONE) {
313 return out.ReadInt32();
314 }
315 return error;
316 }
317
SeparateConference(const CellularCallInfo & callInfo)318 int32_t CellularCallProxy::SeparateConference(const CellularCallInfo &callInfo)
319 {
320 MessageOption option;
321 MessageParcel in;
322 MessageParcel out;
323 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
324 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
325 }
326 if (!in.WriteInt32(MAX_SIZE)) {
327 return TELEPHONY_ERR_WRITE_DATA_FAIL;
328 }
329 if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
330 return TELEPHONY_ERR_WRITE_DATA_FAIL;
331 }
332 auto remote = Remote();
333 if (remote == nullptr) {
334 TELEPHONY_LOGE("function Remote() return nullptr!");
335 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
336 }
337 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SEPARATE_CONFERENCE), in, out, option);
338 if (error == ERR_NONE) {
339 return out.ReadInt32();
340 }
341 return error;
342 }
343
InviteToConference(int32_t slotId,const std::vector<std::string> & numberList)344 int32_t CellularCallProxy::InviteToConference(int32_t slotId, const std::vector<std::string> &numberList)
345 {
346 MessageOption option;
347 MessageParcel in;
348 MessageParcel out;
349 int32_t result = TELEPHONY_SUCCESS;
350 result = SetCommonParamForMessageParcel(slotId, in);
351 if (result != TELEPHONY_SUCCESS) {
352 return result;
353 }
354 if (!in.WriteStringVector(numberList)) {
355 return TELEPHONY_ERR_WRITE_DATA_FAIL;
356 }
357 auto remote = Remote();
358 if (remote == nullptr) {
359 TELEPHONY_LOGE("function Remote() return nullptr!");
360 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
361 }
362 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::INVITE_TO_CONFERENCE), in, out, option);
363 if (error == ERR_NONE) {
364 return out.ReadInt32();
365 }
366 return error;
367 }
368
KickOutFromConference(int32_t slotId,const std::vector<std::string> & numberList)369 int32_t CellularCallProxy::KickOutFromConference(int32_t slotId, const std::vector<std::string> &numberList)
370 {
371 MessageOption option;
372 MessageParcel in;
373 MessageParcel out;
374 int32_t result = TELEPHONY_SUCCESS;
375 result = SetCommonParamForMessageParcel(slotId, in);
376 if (result != TELEPHONY_SUCCESS) {
377 return result;
378 }
379 if (!in.WriteStringVector(numberList)) {
380 return TELEPHONY_ERR_WRITE_DATA_FAIL;
381 }
382 auto remote = Remote();
383 if (remote == nullptr) {
384 TELEPHONY_LOGE("function Remote() return nullptr!");
385 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
386 }
387 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::KICK_OUT_CONFERENCE), in, out, option);
388 if (error == ERR_NONE) {
389 return out.ReadInt32();
390 }
391 return error;
392 }
393
HangUpAllConnection()394 int32_t CellularCallProxy::HangUpAllConnection()
395 {
396 MessageOption option;
397 MessageParcel in;
398 MessageParcel out;
399 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
400 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
401 }
402 if (!in.WriteInt32(MAX_SIZE)) {
403 return TELEPHONY_ERR_WRITE_DATA_FAIL;
404 }
405 auto remote = Remote();
406 if (remote == nullptr) {
407 TELEPHONY_LOGE("function Remote() return nullptr!");
408 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
409 }
410 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::HANG_UP_ALL_CONNECTION), in, out, option);
411 if (error == ERR_NONE) {
412 return out.ReadInt32();
413 }
414 return error;
415 }
416
HangUpAllConnection(int32_t slotId)417 int32_t CellularCallProxy::HangUpAllConnection(int32_t slotId)
418 {
419 return TELEPHONY_ERR_SUCCESS;
420 }
421
UpdateImsCallMode(const CellularCallInfo & callInfo,ImsCallMode mode)422 int32_t CellularCallProxy::UpdateImsCallMode(const CellularCallInfo &callInfo, ImsCallMode mode)
423 {
424 MessageOption option;
425 MessageParcel in;
426 MessageParcel out;
427 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
428 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
429 }
430 if (!in.WriteInt32(MAX_SIZE)) {
431 return TELEPHONY_ERR_WRITE_DATA_FAIL;
432 }
433 if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
434 return TELEPHONY_ERR_WRITE_DATA_FAIL;
435 }
436 if (!in.WriteInt32((int32_t)mode)) {
437 return TELEPHONY_ERR_WRITE_DATA_FAIL;
438 }
439 auto remote = Remote();
440 if (remote == nullptr) {
441 TELEPHONY_LOGE("function Remote() return nullptr!");
442 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
443 }
444 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::UPDATE_CALL_MEDIA_MODE), in, out, option);
445 if (error == ERR_NONE) {
446 return out.ReadInt32();
447 }
448 return error;
449 }
450
StartDtmf(char cDtmfCode,const CellularCallInfo & callInfo)451 int32_t CellularCallProxy::StartDtmf(char cDtmfCode, const CellularCallInfo &callInfo)
452 {
453 MessageOption option;
454 MessageParcel in;
455 MessageParcel out;
456 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
457 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
458 }
459 if (!in.WriteInt32(MAX_SIZE)) {
460 return TELEPHONY_ERR_WRITE_DATA_FAIL;
461 }
462 if (!in.WriteInt8(cDtmfCode)) {
463 return TELEPHONY_ERR_WRITE_DATA_FAIL;
464 }
465 if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
466 return TELEPHONY_ERR_WRITE_DATA_FAIL;
467 }
468 auto remote = Remote();
469 if (remote == nullptr) {
470 TELEPHONY_LOGE("function Remote() return nullptr!");
471 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
472 }
473 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::START_DTMF), in, out, option);
474 if (error == ERR_NONE) {
475 return out.ReadInt32();
476 }
477 return error;
478 }
479
StopDtmf(const CellularCallInfo & callInfo)480 int32_t CellularCallProxy::StopDtmf(const CellularCallInfo &callInfo)
481 {
482 MessageOption option;
483 MessageParcel in;
484 MessageParcel out;
485 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
486 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
487 }
488 if (!in.WriteInt32(MAX_SIZE)) {
489 return TELEPHONY_ERR_WRITE_DATA_FAIL;
490 }
491 if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
492 return TELEPHONY_ERR_WRITE_DATA_FAIL;
493 }
494 auto remote = Remote();
495 if (remote == nullptr) {
496 TELEPHONY_LOGE("function Remote() return nullptr!");
497 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
498 }
499 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::STOP_DTMF), in, out, option);
500 if (error == ERR_NONE) {
501 return out.ReadInt32();
502 }
503 return error;
504 }
505
SendDtmf(char cDtmfCode,const CellularCallInfo & callInfo)506 int32_t CellularCallProxy::SendDtmf(char cDtmfCode, const CellularCallInfo &callInfo)
507 {
508 MessageOption option;
509 MessageParcel in;
510 MessageParcel out;
511 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
512 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
513 }
514 if (!in.WriteInt32(MAX_SIZE)) {
515 return TELEPHONY_ERR_WRITE_DATA_FAIL;
516 }
517 if (!in.WriteInt8(cDtmfCode)) {
518 return TELEPHONY_ERR_WRITE_DATA_FAIL;
519 }
520 if (!in.WriteRawData((const void *)&callInfo, sizeof(CellularCallInfo))) {
521 return TELEPHONY_ERR_WRITE_DATA_FAIL;
522 }
523 auto remote = Remote();
524 if (remote == nullptr) {
525 TELEPHONY_LOGE("function Remote() return nullptr!");
526 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
527 }
528 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SEND_DTMF), in, out, option);
529 if (error == ERR_NONE) {
530 return out.ReadInt32();
531 }
532 return error;
533 }
534
StartRtt(int32_t slotId,const std::string & msg)535 int32_t CellularCallProxy::StartRtt(int32_t slotId, const std::string &msg)
536 {
537 MessageOption option;
538 MessageParcel in;
539 MessageParcel out;
540 int32_t result = TELEPHONY_SUCCESS;
541 result = SetCommonParamForMessageParcel(slotId, in);
542 if (result != TELEPHONY_SUCCESS) {
543 return result;
544 }
545 if (!in.WriteString(msg)) {
546 return TELEPHONY_ERR_WRITE_DATA_FAIL;
547 }
548 auto remote = Remote();
549 if (remote == nullptr) {
550 TELEPHONY_LOGE("function Remote() return nullptr!");
551 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
552 }
553 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::START_RTT), in, out, option);
554 if (error == ERR_NONE) {
555 return out.ReadInt32();
556 }
557 return error;
558 }
559
StopRtt(int32_t slotId)560 int32_t CellularCallProxy::StopRtt(int32_t slotId)
561 {
562 MessageOption option;
563 MessageParcel in;
564 MessageParcel out;
565 int32_t result = TELEPHONY_SUCCESS;
566 result = SetCommonParamForMessageParcel(slotId, in);
567 if (result != TELEPHONY_SUCCESS) {
568 return result;
569 }
570 auto remote = Remote();
571 if (remote == nullptr) {
572 TELEPHONY_LOGE("function Remote() return nullptr!");
573 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
574 }
575 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::STOP_RTT), in, out, option);
576 if (error == ERR_NONE) {
577 return out.ReadInt32();
578 }
579 return error;
580 }
581
SetCallTransferInfo(int32_t slotId,const CallTransferInfo & ctInfo)582 int32_t CellularCallProxy::SetCallTransferInfo(int32_t slotId, const CallTransferInfo &ctInfo)
583 {
584 MessageOption option;
585 MessageParcel in;
586 MessageParcel out;
587 int32_t result = TELEPHONY_SUCCESS;
588 result = SetCommonParamForMessageParcel(slotId, in);
589 if (result != TELEPHONY_SUCCESS) {
590 return result;
591 }
592 if (!in.WriteRawData((const void *)&ctInfo, sizeof(CallTransferInfo))) {
593 return TELEPHONY_ERR_WRITE_DATA_FAIL;
594 }
595 auto remote = Remote();
596 if (remote == nullptr) {
597 TELEPHONY_LOGE("function Remote() return nullptr!");
598 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
599 }
600 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_CALL_TRANSFER), in, out, option);
601 if (error == ERR_NONE) {
602 return out.ReadInt32();
603 }
604 return error;
605 }
606
GetCallTransferInfo(int32_t slotId,CallTransferType type)607 int32_t CellularCallProxy::GetCallTransferInfo(int32_t slotId, CallTransferType type)
608 {
609 MessageOption option;
610 MessageParcel in;
611 MessageParcel out;
612 int32_t result = TELEPHONY_SUCCESS;
613 result = SetCommonParamForMessageParcel(slotId, in);
614 if (result != TELEPHONY_SUCCESS) {
615 return result;
616 }
617 if (!in.WriteInt32((int32_t)type)) {
618 return TELEPHONY_ERR_WRITE_DATA_FAIL;
619 }
620 auto remote = Remote();
621 if (remote == nullptr) {
622 TELEPHONY_LOGE("function Remote() return nullptr!");
623 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
624 }
625 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::GET_CALL_TRANSFER), in, out, option);
626 if (error == ERR_NONE) {
627 return out.ReadInt32();
628 }
629 return error;
630 }
631
SetCallWaiting(int32_t slotId,bool activate)632 int32_t CellularCallProxy::SetCallWaiting(int32_t slotId, bool activate)
633 {
634 MessageOption option;
635 MessageParcel in;
636 MessageParcel out;
637 int32_t result = TELEPHONY_SUCCESS;
638 result = SetCommonParamForMessageParcel(slotId, in);
639 if (result != TELEPHONY_SUCCESS) {
640 return result;
641 }
642 if (!in.WriteBool(activate)) {
643 return TELEPHONY_ERR_WRITE_DATA_FAIL;
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>(OperationType::SET_CALL_WAITING), in, out, option);
651 if (error == ERR_NONE) {
652 return out.ReadInt32();
653 }
654 return error;
655 }
656
GetCallWaiting(int32_t slotId)657 int32_t CellularCallProxy::GetCallWaiting(int32_t slotId)
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 auto remote = Remote();
668 if (remote == nullptr) {
669 TELEPHONY_LOGE("function Remote() return nullptr!");
670 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
671 }
672 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::GET_CALL_WAITING), in, out, option);
673 if (error == ERR_NONE) {
674 return out.ReadInt32();
675 }
676 return error;
677 }
678
SetCallRestriction(int32_t slotId,const CallRestrictionInfo & crInfo)679 int32_t CellularCallProxy::SetCallRestriction(int32_t slotId, const CallRestrictionInfo &crInfo)
680 {
681 MessageOption option;
682 MessageParcel in;
683 MessageParcel out;
684 int32_t result = TELEPHONY_SUCCESS;
685 result = SetCommonParamForMessageParcel(slotId, in);
686 if (result != TELEPHONY_SUCCESS) {
687 return result;
688 }
689 if (!in.WriteRawData((const void *)&crInfo, sizeof(CallRestrictionInfo))) {
690 return TELEPHONY_ERR_WRITE_DATA_FAIL;
691 }
692 auto remote = Remote();
693 if (remote == nullptr) {
694 TELEPHONY_LOGE("function Remote() return nullptr!");
695 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
696 }
697 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_CALL_RESTRICTION), in, out, option);
698 if (error == ERR_NONE) {
699 return out.ReadInt32();
700 }
701 return error;
702 }
703
GetCallRestriction(int32_t slotId,CallRestrictionType facType)704 int32_t CellularCallProxy::GetCallRestriction(int32_t slotId, CallRestrictionType facType)
705 {
706 MessageOption option;
707 MessageParcel in;
708 MessageParcel out;
709 int32_t result = TELEPHONY_SUCCESS;
710 result = SetCommonParamForMessageParcel(slotId, in);
711 if (result != TELEPHONY_SUCCESS) {
712 return result;
713 }
714 if (!in.WriteInt32((int32_t)facType)) {
715 return TELEPHONY_ERR_WRITE_DATA_FAIL;
716 }
717 auto remote = Remote();
718 if (remote == nullptr) {
719 TELEPHONY_LOGE("function Remote() return nullptr!");
720 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
721 }
722 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::GET_CALL_RESTRICTION), in, out, option);
723 if (error == ERR_NONE) {
724 return out.ReadInt32();
725 }
726 return error;
727 }
728
SetDomainPreferenceMode(int32_t slotId,int32_t mode)729 int32_t CellularCallProxy::SetDomainPreferenceMode(int32_t slotId, int32_t mode)
730 {
731 MessageOption option;
732 MessageParcel in;
733 MessageParcel out;
734 int32_t result = TELEPHONY_SUCCESS;
735 result = SetCommonParamForMessageParcel(slotId, in);
736 if (result != TELEPHONY_SUCCESS) {
737 return result;
738 }
739 if (!in.WriteInt32(mode)) {
740 return TELEPHONY_ERR_WRITE_DATA_FAIL;
741 }
742 auto remote = Remote();
743 if (remote == nullptr) {
744 TELEPHONY_LOGE("function Remote() return nullptr!");
745 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
746 }
747 int32_t error =
748 remote->SendRequest(static_cast<uint32_t>(OperationType::SET_DOMAIN_PREFERENCE_MODE), in, out, option);
749 if (error == ERR_NONE) {
750 return out.ReadInt32();
751 }
752 return error;
753 }
754
GetDomainPreferenceMode(int32_t slotId)755 int32_t CellularCallProxy::GetDomainPreferenceMode(int32_t slotId)
756 {
757 MessageOption option;
758 MessageParcel in;
759 MessageParcel out;
760 int32_t result = TELEPHONY_SUCCESS;
761 result = SetCommonParamForMessageParcel(slotId, in);
762 if (result != TELEPHONY_SUCCESS) {
763 return result;
764 }
765 auto remote = Remote();
766 if (remote == nullptr) {
767 TELEPHONY_LOGE("function Remote() return nullptr!");
768 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
769 }
770 int32_t error =
771 remote->SendRequest(static_cast<uint32_t>(OperationType::GET_DOMAIN_PREFERENCE_MODE), in, out, option);
772 if (error == ERR_NONE) {
773 return out.ReadInt32();
774 }
775 return error;
776 }
777
SetImsSwitchStatus(int32_t slotId,bool active)778 int32_t CellularCallProxy::SetImsSwitchStatus(int32_t slotId, bool active)
779 {
780 MessageOption option;
781 MessageParcel in;
782 MessageParcel out;
783 int32_t result = TELEPHONY_SUCCESS;
784 result = SetCommonParamForMessageParcel(slotId, in);
785 if (result != TELEPHONY_SUCCESS) {
786 return result;
787 }
788 if (!in.WriteBool(active)) {
789 return TELEPHONY_ERR_WRITE_DATA_FAIL;
790 }
791 auto remote = Remote();
792 if (remote == nullptr) {
793 TELEPHONY_LOGE("function Remote() return nullptr!");
794 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
795 }
796 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_IMS_SWITCH_STATUS), in, out, option);
797 if (error != ERR_NONE) {
798 TELEPHONY_LOGE("function SetImsSwitchStatus failed! errCode:%{public}d", error);
799 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
800 }
801 return out.ReadInt32();
802 }
803
GetImsSwitchStatus(int32_t slotId,bool & enabled)804 int32_t CellularCallProxy::GetImsSwitchStatus(int32_t slotId, bool &enabled)
805 {
806 MessageOption option;
807 MessageParcel out;
808 MessageParcel in;
809 int32_t result = TELEPHONY_SUCCESS;
810 result = SetCommonParamForMessageParcel(slotId, in);
811 if (result != TELEPHONY_SUCCESS) {
812 return result;
813 }
814 auto remote = Remote();
815 if (remote == nullptr) {
816 TELEPHONY_LOGE("function Remote() return nullptr!");
817 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
818 }
819 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::GET_IMS_SWITCH_STATUS), in, out, option);
820 if (error != ERR_NONE) {
821 TELEPHONY_LOGE("function GetImsSwitchStatus failed! errCode:%{public}d", error);
822 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
823 }
824 enabled = out.ReadBool();
825 return out.ReadInt32();
826 }
827
SetImsConfig(int32_t slotId,ImsConfigItem item,const std::string & value)828 int32_t CellularCallProxy::SetImsConfig(int32_t slotId, ImsConfigItem item, const std::string &value)
829 {
830 MessageOption option;
831 MessageParcel in;
832 MessageParcel out;
833 int32_t result = TELEPHONY_SUCCESS;
834 result = SetCommonParamForMessageParcel(slotId, in);
835 if (result != TELEPHONY_SUCCESS) {
836 return result;
837 }
838 if (!in.WriteInt32(item)) {
839 return TELEPHONY_ERR_WRITE_DATA_FAIL;
840 }
841 if (!in.WriteString(value)) {
842 return TELEPHONY_ERR_WRITE_DATA_FAIL;
843 }
844 auto remote = Remote();
845 if (remote == nullptr) {
846 TELEPHONY_LOGE("function Remote() return nullptr!");
847 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
848 }
849 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_IMS_CONFIG_STRING), in, out, option);
850 if (error == ERR_NONE) {
851 return out.ReadInt32();
852 }
853 return error;
854 }
855
SetImsConfig(int32_t slotId,ImsConfigItem item,int32_t value)856 int32_t CellularCallProxy::SetImsConfig(int32_t slotId, ImsConfigItem item, int32_t value)
857 {
858 MessageOption option;
859 MessageParcel in;
860 MessageParcel out;
861 int32_t result = TELEPHONY_SUCCESS;
862 result = SetCommonParamForMessageParcel(slotId, in);
863 if (result != TELEPHONY_SUCCESS) {
864 return result;
865 }
866 if (!in.WriteInt32(item)) {
867 return TELEPHONY_ERR_WRITE_DATA_FAIL;
868 }
869 if (!in.WriteInt32(value)) {
870 return TELEPHONY_ERR_WRITE_DATA_FAIL;
871 }
872 auto remote = Remote();
873 if (remote == nullptr) {
874 TELEPHONY_LOGE("function Remote() return nullptr!");
875 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
876 }
877 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_IMS_CONFIG_INT), in, out, option);
878 if (error == ERR_NONE) {
879 return out.ReadInt32();
880 }
881 return error;
882 }
883
GetImsConfig(int32_t slotId,ImsConfigItem item)884 int32_t CellularCallProxy::GetImsConfig(int32_t slotId, ImsConfigItem item)
885 {
886 MessageOption option;
887 MessageParcel in;
888 MessageParcel out;
889 int32_t result = TELEPHONY_SUCCESS;
890 result = SetCommonParamForMessageParcel(slotId, in);
891 if (result != TELEPHONY_SUCCESS) {
892 return result;
893 }
894 if (!in.WriteInt32(item)) {
895 return TELEPHONY_ERR_WRITE_DATA_FAIL;
896 }
897 auto remote = Remote();
898 if (remote == nullptr) {
899 TELEPHONY_LOGE("function Remote() return nullptr!");
900 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
901 }
902 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::GET_IMS_CONFIG), in, out, option);
903 if (error == ERR_NONE) {
904 return out.ReadInt32();
905 }
906 return error;
907 }
908
SetImsFeatureValue(int32_t slotId,FeatureType type,int32_t value)909 int32_t CellularCallProxy::SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value)
910 {
911 MessageOption option;
912 MessageParcel in;
913 MessageParcel out;
914 int32_t result = TELEPHONY_SUCCESS;
915 result = SetCommonParamForMessageParcel(slotId, in);
916 if (result != TELEPHONY_SUCCESS) {
917 return result;
918 }
919 if (!in.WriteInt32(type)) {
920 return TELEPHONY_ERR_WRITE_DATA_FAIL;
921 }
922 if (!in.WriteInt32(value)) {
923 return TELEPHONY_ERR_WRITE_DATA_FAIL;
924 }
925 auto remote = Remote();
926 if (remote == nullptr) {
927 TELEPHONY_LOGE("function Remote() return nullptr!");
928 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
929 }
930 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_IMS_FEATURE), in, out, option);
931 if (error == ERR_NONE) {
932 return out.ReadInt32();
933 }
934 return error;
935 }
936
GetImsFeatureValue(int32_t slotId,FeatureType type)937 int32_t CellularCallProxy::GetImsFeatureValue(int32_t slotId, FeatureType type)
938 {
939 MessageOption option;
940 MessageParcel in;
941 MessageParcel out;
942 int32_t result = TELEPHONY_SUCCESS;
943 result = SetCommonParamForMessageParcel(slotId, in);
944 if (result != TELEPHONY_SUCCESS) {
945 return result;
946 }
947 if (!in.WriteInt32(type)) {
948 return TELEPHONY_ERR_WRITE_DATA_FAIL;
949 }
950 auto remote = Remote();
951 if (remote == nullptr) {
952 TELEPHONY_LOGE("function Remote() return nullptr!");
953 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
954 }
955 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::GET_IMS_FEATURE), in, out, option);
956 if (error == ERR_NONE) {
957 return out.ReadInt32();
958 }
959 return error;
960 }
961
CtrlCamera(const std::u16string & cameraId,int32_t callingUid,int32_t callingPid)962 int32_t CellularCallProxy::CtrlCamera(const std::u16string &cameraId, int32_t callingUid, int32_t callingPid)
963 {
964 MessageOption option;
965 MessageParcel in;
966 MessageParcel out;
967 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
968 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
969 }
970 if (!in.WriteInt32(MAX_SIZE)) {
971 return TELEPHONY_ERR_WRITE_DATA_FAIL;
972 }
973 if (!in.WriteString16(cameraId)) {
974 return TELEPHONY_ERR_WRITE_DATA_FAIL;
975 }
976 if (!in.WriteInt32(callingUid)) {
977 return TELEPHONY_ERR_WRITE_DATA_FAIL;
978 }
979 if (!in.WriteInt32(callingPid)) {
980 return TELEPHONY_ERR_WRITE_DATA_FAIL;
981 }
982 auto remote = Remote();
983 if (remote == nullptr) {
984 TELEPHONY_LOGE("function Remote() return nullptr!");
985 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
986 }
987 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::CTRL_CAMERA), in, out, option);
988 if (error == ERR_NONE) {
989 return out.ReadInt32();
990 }
991 return error;
992 }
993
SetPreviewWindow(int32_t x,int32_t y,int32_t z,int32_t width,int32_t height)994 int32_t CellularCallProxy::SetPreviewWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height)
995 {
996 MessageOption option;
997 MessageParcel in;
998 MessageParcel out;
999 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1000 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1001 }
1002 if (!in.WriteInt32(MAX_SIZE)) {
1003 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1004 }
1005 if (!in.WriteInt32(x)) {
1006 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1007 }
1008 if (!in.WriteInt32(y)) {
1009 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1010 }
1011 if (!in.WriteInt32(z)) {
1012 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1013 }
1014 if (!in.WriteInt32(width)) {
1015 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1016 }
1017 if (!in.WriteInt32(height)) {
1018 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1019 }
1020 auto remote = Remote();
1021 if (remote == nullptr) {
1022 TELEPHONY_LOGE("function Remote() return nullptr!");
1023 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1024 }
1025 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_PREVIEW_WINDOW), in, out, option);
1026 if (error == ERR_NONE) {
1027 return out.ReadInt32();
1028 }
1029 return error;
1030 }
1031
SetDisplayWindow(int32_t x,int32_t y,int32_t z,int32_t width,int32_t height)1032 int32_t CellularCallProxy::SetDisplayWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height)
1033 {
1034 MessageOption option;
1035 MessageParcel in;
1036 MessageParcel out;
1037 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1038 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1039 }
1040 if (!in.WriteInt32(MAX_SIZE)) {
1041 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1042 }
1043 if (!in.WriteInt32(x)) {
1044 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1045 }
1046 if (!in.WriteInt32(y)) {
1047 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1048 }
1049 if (!in.WriteInt32(z)) {
1050 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1051 }
1052 if (!in.WriteInt32(width)) {
1053 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1054 }
1055 if (!in.WriteInt32(height)) {
1056 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1057 }
1058 auto remote = Remote();
1059 if (remote == nullptr) {
1060 TELEPHONY_LOGE("function Remote() return nullptr!");
1061 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1062 }
1063 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_DISPLAY_WINDOW), in, out, option);
1064 if (error == ERR_NONE) {
1065 return out.ReadInt32();
1066 }
1067 return error;
1068 }
1069
SetCameraZoom(float zoomRatio)1070 int32_t CellularCallProxy::SetCameraZoom(float zoomRatio)
1071 {
1072 MessageOption option;
1073 MessageParcel in;
1074 MessageParcel out;
1075 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1076 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1077 }
1078 if (!in.WriteInt32(MAX_SIZE)) {
1079 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1080 }
1081 if (!in.WriteFloat(zoomRatio)) {
1082 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1083 }
1084 auto remote = Remote();
1085 if (remote == nullptr) {
1086 TELEPHONY_LOGE("function Remote() return nullptr!");
1087 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1088 }
1089 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_CAMERA_ZOOM), in, out, option);
1090 if (error == ERR_NONE) {
1091 return out.ReadInt32();
1092 }
1093 return error;
1094 }
1095
SetPauseImage(const std::u16string & path)1096 int32_t CellularCallProxy::SetPauseImage(const std::u16string &path)
1097 {
1098 MessageOption option;
1099 MessageParcel in;
1100 MessageParcel out;
1101 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1102 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1103 }
1104 if (!in.WriteInt32(MAX_SIZE)) {
1105 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1106 }
1107 if (!in.WriteString16(path)) {
1108 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1109 }
1110 auto remote = Remote();
1111 if (remote == nullptr) {
1112 TELEPHONY_LOGE("function Remote() return nullptr!");
1113 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1114 }
1115 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_PAUSE_IMAGE), in, out, option);
1116 if (error == ERR_NONE) {
1117 return out.ReadInt32();
1118 }
1119 return error;
1120 }
1121
SetDeviceDirection(int32_t rotation)1122 int32_t CellularCallProxy::SetDeviceDirection(int32_t rotation)
1123 {
1124 MessageOption option;
1125 MessageParcel in;
1126 MessageParcel out;
1127 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1128 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1129 }
1130 if (!in.WriteInt32(MAX_SIZE)) {
1131 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1132 }
1133 if (!in.WriteInt32(rotation)) {
1134 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1135 }
1136 auto remote = Remote();
1137 if (remote == nullptr) {
1138 TELEPHONY_LOGE("function Remote() return nullptr!");
1139 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1140 }
1141 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_DEVICE_DIRECTION), in, out, option);
1142 if (error == ERR_NONE) {
1143 return out.ReadInt32();
1144 }
1145 return error;
1146 }
1147
SetMute(int32_t slotId,int32_t mute)1148 int32_t CellularCallProxy::SetMute(int32_t slotId, int32_t mute)
1149 {
1150 MessageOption option;
1151 MessageParcel in;
1152 MessageParcel out;
1153 int32_t result = TELEPHONY_SUCCESS;
1154 result = SetCommonParamForMessageParcel(slotId, in);
1155 if (result != TELEPHONY_SUCCESS) {
1156 return result;
1157 }
1158 if (!in.WriteInt32(mute)) {
1159 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1160 }
1161 auto remote = Remote();
1162 if (remote == nullptr) {
1163 TELEPHONY_LOGE("function Remote() return nullptr!");
1164 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1165 }
1166 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_MUTE), in, out, option);
1167 if (error == ERR_NONE) {
1168 return out.ReadInt32();
1169 }
1170 return error;
1171 }
1172
GetMute(int32_t slotId)1173 int32_t CellularCallProxy::GetMute(int32_t slotId)
1174 {
1175 MessageOption option;
1176 MessageParcel in;
1177 MessageParcel out;
1178 int32_t result = TELEPHONY_SUCCESS;
1179 result = SetCommonParamForMessageParcel(slotId, in);
1180 if (result != TELEPHONY_SUCCESS) {
1181 return result;
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>(OperationType::GET_MUTE), in, out, option);
1189 if (error == ERR_NONE) {
1190 return out.ReadInt32();
1191 }
1192 return error;
1193 }
1194
SetEmergencyCallList(int32_t slotId,std::vector<EmergencyCall> & eccVec)1195 int32_t CellularCallProxy::SetEmergencyCallList(int32_t slotId, std::vector<EmergencyCall> &eccVec)
1196 {
1197 MessageOption option;
1198 MessageParcel in;
1199 MessageParcel out;
1200 int32_t result = TELEPHONY_SUCCESS;
1201 result = SetCommonParamForMessageParcel(slotId, in);
1202 if (result != TELEPHONY_SUCCESS) {
1203 return result;
1204 }
1205
1206 if (eccVec.size() <= 0) {
1207 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1208 }
1209
1210 if (!in.WriteInt32(static_cast<int32_t>(eccVec.size()))) {
1211 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1212 }
1213
1214 for (auto ecc : eccVec) {
1215 if (!in.WriteRawData((const void *)&ecc, sizeof(EmergencyCall))) {
1216 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1217 }
1218 }
1219
1220 auto remote = Remote();
1221 if (remote == nullptr) {
1222 TELEPHONY_LOGE("function Remote() return nullptr!");
1223 return TELEPHONY_ERR_IPC_CONNECT_STUB_FAIL;
1224 }
1225 int32_t error = remote->SendRequest(static_cast<uint32_t>(OperationType::SET_EMERGENCY_CALL_LIST), in, out, option);
1226 if (error == ERR_NONE) {
1227 return out.ReadInt32();
1228 }
1229 return error;
1230 }
1231
SetCommonParamForMessageParcel(int32_t slotId,MessageParcel & in)1232 int32_t CellularCallProxy::SetCommonParamForMessageParcel(int32_t slotId, MessageParcel &in)
1233 {
1234 if (!in.WriteInterfaceToken(CellularCallProxy::GetDescriptor())) {
1235 return TELEPHONY_ERR_WRITE_DESCRIPTOR_TOKEN_FAIL;
1236 }
1237 if (!in.WriteInt32(MAX_SIZE)) {
1238 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1239 }
1240 if (!in.WriteInt32(slotId)) {
1241 return TELEPHONY_ERR_WRITE_DATA_FAIL;
1242 }
1243 return TELEPHONY_SUCCESS;
1244 }
1245 } // namespace Telephony
1246 } // namespace OHOS
1247