• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 } // namespace Telephony
122 } // namespace OHOS
123