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 "napi_call_manager_callback.h"
17
18 #include "call_manager_errors.h"
19 #include "telephony_log_wrapper.h"
20
21 #include "napi_call_ability_callback.h"
22
23 namespace OHOS {
24 namespace Telephony {
OnCallDetailsChange(const CallAttributeInfo & info)25 int32_t NapiCallManagerCallback::OnCallDetailsChange(const CallAttributeInfo &info)
26 {
27 int32_t ret = DelayedSingleton<NapiCallAbilityCallback>::GetInstance()->UpdateCallStateInfo(info);
28 if (ret != TELEPHONY_SUCCESS) {
29 TELEPHONY_LOGE("UpdateCallStateInfoHandler failed! errCode:%{public}d", ret);
30 } else {
31 TELEPHONY_LOGI("UpdateCallStateInfoHandler success! state:%{public}d", info.callState);
32 }
33 return ret;
34 }
35
OnCallEventChange(const CallEventInfo & info)36 int32_t NapiCallManagerCallback::OnCallEventChange(const CallEventInfo &info)
37 {
38 int32_t ret = DelayedSingleton<NapiCallAbilityCallback>::GetInstance()->UpdateCallEvent(info);
39 if (ret != TELEPHONY_SUCCESS) {
40 TELEPHONY_LOGE("UpdateCallEvent failed! errCode:%{public}d", ret);
41 } else {
42 TELEPHONY_LOGI("UpdateCallEvent success!");
43 }
44 return ret;
45 }
46
OnCallDisconnectedCause(const DisconnectedDetails & details)47 int32_t NapiCallManagerCallback::OnCallDisconnectedCause(const DisconnectedDetails &details)
48 {
49 int32_t ret = DelayedSingleton<NapiCallAbilityCallback>::GetInstance()->UpdateCallDisconnectedCause(details);
50 if (ret != TELEPHONY_SUCCESS) {
51 TELEPHONY_LOGE("UpdateCallDisconnectedCause failed! errCode:%{public}d", ret);
52 } else {
53 TELEPHONY_LOGI("UpdateCallDisconnectedCause success!");
54 }
55 return ret;
56 }
57
OnReportAsyncResults(CallResultReportId reportId,AppExecFwk::PacMap & resultInfo)58 int32_t NapiCallManagerCallback::OnReportAsyncResults(CallResultReportId reportId, AppExecFwk::PacMap &resultInfo)
59 {
60 int32_t ret =
61 DelayedSingleton<NapiCallAbilityCallback>::GetInstance()->UpdateAsyncResultsInfo(reportId, resultInfo);
62 if (ret != TELEPHONY_SUCCESS) {
63 TELEPHONY_LOGE("UpdateAsyncInfo failed! errCode:%{public}d", ret);
64 } else {
65 TELEPHONY_LOGI("UpdateAsyncInfo success!");
66 }
67 return ret;
68 }
69
OnReportMmiCodeResult(const MmiCodeInfo & info)70 int32_t NapiCallManagerCallback::OnReportMmiCodeResult(const MmiCodeInfo &info)
71 {
72 int32_t ret = DelayedSingleton<NapiCallAbilityCallback>::GetInstance()->UpdateMmiCodeResultsInfo(info);
73 if (ret != TELEPHONY_SUCCESS) {
74 TELEPHONY_LOGE("UpdateMmiCodeInfo failed! errCode:%{public}d", ret);
75 } else {
76 TELEPHONY_LOGI("UpdateMmiCodeInfo success!");
77 }
78 return ret;
79 }
80
OnOttCallRequest(OttCallRequestId requestId,AppExecFwk::PacMap & info)81 int32_t NapiCallManagerCallback::OnOttCallRequest(OttCallRequestId requestId, AppExecFwk::PacMap &info)
82 {
83 int32_t ret = DelayedSingleton<NapiCallAbilityCallback>::GetInstance()->OttCallRequest(requestId, info);
84 if (ret != TELEPHONY_SUCCESS) {
85 TELEPHONY_LOGE("ott call request failed! errCode:%{public}d", ret);
86 } else {
87 TELEPHONY_LOGI("ott call request success!");
88 }
89 return ret;
90 }
91 } // namespace Telephony
92 } // namespace OHOS
93