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 "call_manager_callback_test.h"
17 
18 namespace OHOS {
19 namespace Telephony {
20 constexpr int16_t RETURN_SUCCESS = 0;
21 
OnCallDetailsChange(const CallAttributeInfo & info)22 int32_t CallManagerCallbackTest::OnCallDetailsChange(const CallAttributeInfo &info)
23 {
24     std::cout << "----------OnCallDetailsChange--------" << std::endl
25               << "callId:" << info.callId << std::endl
26               << "callType:" << (int32_t)info.callType << std::endl
27               << "callState:" << (int32_t)info.callState << std::endl
28               << "conferenceState:" << (int32_t)info.conferenceState << std::endl
29               << "accountNumber:" << info.accountNumber << std::endl;
30     return RETURN_SUCCESS;
31 }
32 
OnCallEventChange(const CallEventInfo & info)33 int32_t CallManagerCallbackTest::OnCallEventChange(const CallEventInfo &info)
34 {
35     std::cout << "----------OnCallEventChange--------" << std::endl
36               << "eventId:" << (int32_t)info.eventId << std::endl;
37     return RETURN_SUCCESS;
38 }
39 
OnCallDisconnectedCause(const DisconnectedDetails & details)40 int32_t CallManagerCallbackTest::OnCallDisconnectedCause(const DisconnectedDetails &details)
41 {
42     std::cout << "----------OnCallDisconnectedCause--------" << std::endl
43               << "cause:" << (int32_t)(details.reason) << std::endl;
44     return RETURN_SUCCESS;
45 }
46 
OnReportAsyncResults(CallResultReportId reportId,AppExecFwk::PacMap & resultInfo)47 int32_t CallManagerCallbackTest::OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo)
48 {
49     std::cout << "----------OnReportAsyncResults--------" << std::endl
50               << "reportId:" << (int32_t)reportId << std::endl;
51     switch (reportId) {
52         case CallResultReportId::GET_CALL_WAITING_REPORT_ID:
53             std::cout << "result:" << (int32_t)resultInfo.GetIntValue("result", -1) << std::endl
54                       << "status:" << (int32_t)resultInfo.GetIntValue("status", -1) << std::endl
55                       << "classCw:" << (int32_t)resultInfo.GetIntValue("classCw", -1) << std::endl;
56             break;
57         case CallResultReportId::SET_CALL_WAITING_REPORT_ID:
58             std::cout << "result:" << (int32_t)resultInfo.GetIntValue("result", -1) << std::endl;
59             break;
60         case CallResultReportId::GET_CALL_RESTRICTION_REPORT_ID:
61             std::cout << "result:" << (int32_t)resultInfo.GetIntValue("result", -1) << std::endl
62                       << "status:" << (int32_t)resultInfo.GetIntValue("status", -1) << std::endl
63                       << "classCw:" << (int32_t)resultInfo.GetIntValue("classCw", -1) << std::endl;
64             break;
65         case CallResultReportId::SET_CALL_RESTRICTION_REPORT_ID:
66             std::cout << "result:" << (int32_t)resultInfo.GetIntValue("result", -1) << std::endl;
67             break;
68         case CallResultReportId::SET_CALL_RESTRICTION_PWD_REPORT_ID:
69             std::cout << "result:" << (int32_t)resultInfo.GetIntValue("result", -1) << std::endl;
70             break;
71         case CallResultReportId::GET_CALL_TRANSFER_REPORT_ID:
72             std::cout << "result:" << (int32_t)resultInfo.GetIntValue("result", -1) << std::endl
73                       << "status:" << (int32_t)resultInfo.GetIntValue("status", -1) << std::endl
74                       << "classx:" << (int32_t)resultInfo.GetIntValue("classx", -1) << std::endl
75                       << "number:" << resultInfo.GetStringValue("number", "") << std::endl
76                       << "type:" << (int32_t)resultInfo.GetIntValue("type", -1) << std::endl
77                       << "reason:" << (int32_t)resultInfo.GetIntValue("reason", -1) << std::endl
78                       << "time:" << (int32_t)resultInfo.GetIntValue("time", -1) << std::endl
79                       << "startHour:" << (int32_t)resultInfo.GetIntValue("startHour", -1) << std::endl
80                       << "startMinute:" << (int32_t)resultInfo.GetIntValue("startMinute", -1) << std::endl
81                       << "endHour:" << (int32_t)resultInfo.GetIntValue("endHour", -1) << std::endl
82                       << "endMinute:" << (int32_t)resultInfo.GetIntValue("endMinute", -1) << std::endl;
83             break;
84         case CallResultReportId::SET_CALL_TRANSFER_REPORT_ID:
85             std::cout << "result:" << (int32_t)resultInfo.GetIntValue("result", -1) << std::endl;
86             break;
87         default:
88             break;
89     }
90     return RETURN_SUCCESS;
91 }
92 
OnOttCallRequest(OttCallRequestId requestId,AppExecFwk::PacMap & info)93 int32_t CallManagerCallbackTest::OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info)
94 {
95     std::cout << "----------OnOttCallRequest--------" << std::endl
96               << "requestId:" << (int32_t)requestId << std::endl;
97     return RETURN_SUCCESS;
98 }
99 
OnReportMmiCodeResult(const MmiCodeInfo & info)100 int32_t CallManagerCallbackTest::OnReportMmiCodeResult(const MmiCodeInfo &info)
101 {
102     std::cout << "----------OnReportMmiCodeResult--------" << std::endl
103               << "result:" << info.result << std::endl
104               << "message:" << info.message << std::endl;
105     return RETURN_SUCCESS;
106 }
107 
OnReportAudioDeviceChange(const AudioDeviceInfo & info)108 int32_t CallManagerCallbackTest::OnReportAudioDeviceChange(const AudioDeviceInfo &info)
109 {
110     std::cout << "----------OnReportAudioDeviceChange--------" << std::endl
111               << "currentAudioDeviceType:" << static_cast<int32_t>(info.currentAudioDevice.deviceType) << " "
112               << "address:" << info.currentAudioDevice.address << std::endl
113               << "isMute:" << info.isMuted << std::endl;
114     for (size_t i = 0; i < info.audioDeviceList.size(); i++) {
115         std::cout << "audioDeviceList[" << i
116                   << "] deviceType:" << static_cast<int32_t>(info.audioDeviceList[i].deviceType) << " "
117                   << "audioDeviceList[" << i << "] address:" << info.audioDeviceList[i].address << std::endl;
118     }
119     return RETURN_SUCCESS;
120 }
121 
OnReportPostDialDelay(const std::string & str)122 int32_t CallManagerCallbackTest::OnReportPostDialDelay(const std::string &str)
123 {
124     std::cout << "----------OnReportPostDialDelay--------" << std::endl << "str:" << str << std::endl;
125     return RETURN_SUCCESS;
126 }
127 
OnUpdateImsCallModeChange(const CallMediaModeInfo & imsCallModeInfo)128 int32_t CallManagerCallbackTest::OnUpdateImsCallModeChange(const CallMediaModeInfo &imsCallModeInfo)
129 {
130     std::cout << "----------OnUpdateImsCallModeChange--------" << std::endl
131               << "callId:" << imsCallModeInfo.callId << std::endl
132               << "isRequestInfo:" << imsCallModeInfo.isRequestInfo << std::endl
133               << "result:" << (int32_t)imsCallModeInfo.result << std::endl
134               << "callMode:" << (int32_t)imsCallModeInfo.callMode << std::endl;
135     return RETURN_SUCCESS;
136 }
137 
OnCallSessionEventChange(const CallSessionEvent & callSessionEventOptions)138 int32_t CallManagerCallbackTest::OnCallSessionEventChange(const CallSessionEvent &callSessionEventOptions)
139 {
140     std::cout << "----------OnCallSessionEventChange--------" << std::endl
141               << "callId:" << callSessionEventOptions.callId << std::endl
142               << "eventId:" << (int32_t)callSessionEventOptions.eventId << std::endl;
143     return RETURN_SUCCESS;
144 }
145 
OnPeerDimensionsChange(const PeerDimensionsDetail & peerDimensionsDetail)146 int32_t CallManagerCallbackTest::OnPeerDimensionsChange(const PeerDimensionsDetail &peerDimensionsDetail)
147 {
148     std::cout << "----------OnPeerDimensionsChange--------" << std::endl
149               << "callId:" << peerDimensionsDetail.callId << std::endl
150               << "width:" << peerDimensionsDetail.width << std::endl
151               << "height:" << peerDimensionsDetail.height << std::endl;
152     return RETURN_SUCCESS;
153 }
154 
OnCallDataUsageChange(const int64_t dataUsage)155 int32_t CallManagerCallbackTest::OnCallDataUsageChange(const int64_t dataUsage)
156 {
157     std::cout << "----------OnCallDataUsageChange--------" << std::endl
158               << "dataUsage:" << dataUsage << std::endl;
159     return RETURN_SUCCESS;
160 }
161 
OnUpdateCameraCapabilities(const CameraCapabilities & cameraCapabilities)162 int32_t CallManagerCallbackTest::OnUpdateCameraCapabilities(const CameraCapabilities &cameraCapabilities)
163 {
164     std::cout << "----------OnUpdateCameraCapabilities--------" << std::endl
165               << "callId:" << cameraCapabilities.callId << std::endl
166               << "width:" << cameraCapabilities.width << std::endl
167               << "height:" << cameraCapabilities.height << std::endl;
168     return RETURN_SUCCESS;
169 }
170 } // namespace Telephony
171 } // namespace OHOS
172