• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "call_manager_utils.h"
17 #include "call_manager_base.h"
18 #include "want_params_wrapper.h"
19 
20 namespace OHOS {
21 namespace Telephony {
22 
WriteCallAttributeInfo(const CallAttributeInfo & info,MessageParcel & messageParcel)23 void CallManagerUtils::WriteCallAttributeInfo(const CallAttributeInfo &info, MessageParcel &messageParcel)
24 {
25     messageParcel.WriteCString(info.accountNumber);
26     messageParcel.WriteCString(info.bundleName);
27     messageParcel.WriteBool(info.speakerphoneOn);
28     messageParcel.WriteInt32(info.accountId);
29     messageParcel.WriteInt32(static_cast<int32_t>(info.videoState));
30     messageParcel.WriteInt64(info.startTime);
31     messageParcel.WriteBool(info.isEcc);
32     messageParcel.WriteInt32(static_cast<int32_t>(info.callType));
33     messageParcel.WriteInt32(info.callId);
34     messageParcel.WriteInt32(static_cast<int32_t>(info.callState));
35     messageParcel.WriteInt32(static_cast<int32_t>(info.conferenceState));
36     messageParcel.WriteInt64(info.callBeginTime);
37     messageParcel.WriteInt64(info.callEndTime);
38     messageParcel.WriteInt64(info.ringBeginTime);
39     messageParcel.WriteInt64(info.ringEndTime);
40     messageParcel.WriteInt32(static_cast<int32_t>(info.callDirection));
41     messageParcel.WriteInt32(static_cast<int32_t>(info.answerType));
42     messageParcel.WriteInt32(info.index);
43     messageParcel.WriteInt32(info.crsType);
44     messageParcel.WriteInt32(info.originalCallType);
45     messageParcel.WriteCString(info.numberLocation);
46     messageParcel.WriteInt32(static_cast<int32_t>(info.numberMarkInfo.markType));
47     messageParcel.WriteCString(info.numberMarkInfo.markContent);
48     messageParcel.WriteInt32(info.numberMarkInfo.markCount);
49     messageParcel.WriteCString(info.numberMarkInfo.markSource);
50     messageParcel.WriteBool(info.numberMarkInfo.isCloud);
51     messageParcel.WriteCString(info.numberMarkInfo.markDetails);
52     messageParcel.WriteCString(info.contactName);
53     messageParcel.WriteString(info.extraParamsString);
54     if (info.callType == CallType::TYPE_VOIP) {
55         messageParcel.WriteString(info.voipCallInfo.voipCallId);
56         messageParcel.WriteString(info.voipCallInfo.userName);
57         messageParcel.WriteString(info.voipCallInfo.abilityName);
58         messageParcel.WriteString(info.voipCallInfo.extensionId);
59         messageParcel.WriteString(info.voipCallInfo.voipBundleName);
60         messageParcel.WriteBool(info.voipCallInfo.showBannerForIncomingCall);
61         messageParcel.WriteBool(info.voipCallInfo.isConferenceCall);
62         messageParcel.WriteBool(info.voipCallInfo.isVoiceAnswerSupported);
63         messageParcel.WriteBool(info.voipCallInfo.hasMicPermission);
64         messageParcel.WriteBool(info.voipCallInfo.isCapsuleSticky);
65         messageParcel.WriteInt32(info.voipCallInfo.uid);
66         messageParcel.WriteUInt8Vector(info.voipCallInfo.userProfile);
67     }
68     messageParcel.WriteInt32(info.phoneOrWatch);
69 }
70 
IsBundleInstalled(const std::string & bundleName,int32_t userId)71 bool CallManagerUtils::IsBundleInstalled(const std::string &bundleName, int32_t userId)
72 {
73     bool isInstalled = false;
74     sptr<ISystemAbilityManager> systemAbilityManager =
75         SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
76     if (!systemAbilityManager) {
77         return false;
78     }
79     sptr<IRemoteObject> remoteObject = systemAbilityManager->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
80     sptr<AppExecFwk::IBundleMgr> proxy = iface_cast<AppExecFwk::IBundleMgr>(remoteObject);
81     if (proxy == nullptr) {
82         return false;
83     }
84     if (FAILED(proxy->IsBundleInstalled(bundleName, userId, 0, isInstalled))) {
85         return false;
86     }
87     return isInstalled;
88 }
89 } // namespace Telephony
90 } // namespace OHOS