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