1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "native_call_manager_utils.h"
17 #include "call_manager_base.h"
18 #include <securec.h>
19 #include "telephony_log_wrapper.h"
20 #include "want_params_wrapper.h"
21 
22 namespace OHOS {
23 namespace Telephony {
24 
ReadCallAttributeInfo(MessageParcel &messageParcel)25 CallAttributeInfo NativeCallManagerUtils::ReadCallAttributeInfo(MessageParcel &messageParcel)
26 {
27     CallAttributeInfo info;
28     if (strncpy_s(info.accountNumber, kMaxNumberLen + 1, messageParcel.ReadCString(), kMaxNumberLen + 1) != EOK) {
29         TELEPHONY_LOGE("strncpy_s accountNumber failed");
30     }
31     if (strncpy_s(info.bundleName, kMaxNumberLen + 1, messageParcel.ReadCString(), kMaxNumberLen + 1) != EOK) {
32         TELEPHONY_LOGE("strncpy_s bundleName failed");
33     }
34     info.speakerphoneOn = messageParcel.ReadBool();
35     info.accountId = messageParcel.ReadInt32();
36     info.videoState = static_cast<VideoStateType>(messageParcel.ReadInt32());
37     info.startTime = messageParcel.ReadInt64();
38     info.isEcc = messageParcel.ReadBool();
39     info.callType = static_cast<CallType>(messageParcel.ReadInt32());
40     info.callId = messageParcel.ReadInt32();
41     info.callState = static_cast<TelCallState>(messageParcel.ReadInt32());
42     info.conferenceState = static_cast<TelConferenceState>(messageParcel.ReadInt32());
43     info.callBeginTime = messageParcel.ReadInt64();
44     info.callEndTime = messageParcel.ReadInt64();
45     info.ringBeginTime = messageParcel.ReadInt64();
46     info.ringEndTime = messageParcel.ReadInt64();
47     info.callDirection = static_cast<CallDirection>(messageParcel.ReadInt32());
48     info.answerType = static_cast<CallAnswerType>(messageParcel.ReadInt32());
49     info.index = messageParcel.ReadInt32();
50     info.crsType = messageParcel.ReadInt32();
51     info.originalCallType = messageParcel.ReadInt32();
52     if (strncpy_s(info.numberLocation, kMaxNumberLen + 1, messageParcel.ReadCString(), kMaxNumberLen + 1) != EOK) {
53         TELEPHONY_LOGE("strncpy_s numberLocation failed");
54     }
55     info.numberMarkInfo.markType = static_cast<MarkType>(messageParcel.ReadInt32());
56     if (strncpy_s(info.numberMarkInfo.markContent, kMaxNumberLen + 1, messageParcel.ReadCString(), kMaxNumberLen + 1)
57         != EOK) {
58         TELEPHONY_LOGE("strncpy_s markContent failed");
59     }
60     info.numberMarkInfo.markCount = messageParcel.ReadInt32();
61     if (strncpy_s(info.numberMarkInfo.markSource, kMaxNumberLen + 1, messageParcel.ReadCString(), kMaxNumberLen + 1)
62         != EOK) {
63         TELEPHONY_LOGE("strncpy_s markSource failed");
64     }
65     info.numberMarkInfo.isCloud = messageParcel.ReadBool();
66     if (strncpy_s(info.numberMarkInfo.markDetails, kMaxNumberLen + 1, messageParcel.ReadCString(), kMaxNumberLen + 1)
67         != EOK) {
68         TELEPHONY_LOGE("strncpy_s markDetails failed");
69     }
70     if (strncpy_s(info.contactName, kMaxNumberLen + 1, messageParcel.ReadCString(), kMaxNumberLen + 1) != EOK) {
71         TELEPHONY_LOGE("strncpy_s contactName failed");
72     }
73     info.extraParamsString = messageParcel.ReadString();
74     if (info.callType == CallType::TYPE_VOIP) {
75         info.voipCallInfo.voipCallId = messageParcel.ReadString();
76         info.voipCallInfo.userName = messageParcel.ReadString();
77         info.voipCallInfo.abilityName = messageParcel.ReadString();
78         info.voipCallInfo.extensionId = messageParcel.ReadString();
79         info.voipCallInfo.voipBundleName = messageParcel.ReadString();
80         info.voipCallInfo.showBannerForIncomingCall = messageParcel.ReadBool();
81         info.voipCallInfo.isConferenceCall = messageParcel.ReadBool();
82         info.voipCallInfo.isVoiceAnswerSupported = messageParcel.ReadBool();
83         info.voipCallInfo.hasMicPermission = messageParcel.ReadBool();
84         info.voipCallInfo.uid = messageParcel.ReadInt32();
85         std::vector<uint8_t> userProfile = {};
86         messageParcel.ReadUInt8Vector(&userProfile);
87         (info.voipCallInfo.userProfile).assign(userProfile.begin(), userProfile.end());
88     }
89     return info;
90 }
91 
92 } // namespace Telephony
93 } // namespace OHOS