1 /*
2 * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
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 "media_telephony_listener.h"
17 #include "media_log.h"
18 #include "incall_observer.h"
19 #include "call_manager_client.h"
20 #include "core_service_client.h"
21 #include "call_manager_base.h"
22 #include <locale>
23 #include <codecvt>
24
25 namespace {
26 constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_PLAYER, "MediaTelephonyListener"};
27 }
28
29 using namespace OHOS::Telephony;
30 namespace OHOS {
31 namespace Media {
MediaTelephonyListener()32 MediaTelephonyListener::MediaTelephonyListener()
33 {
34 MEDIA_LOGI("0x%{public}06" PRIXPTR " Instances create", FAKE_POINTER(this));
35 }
36
~MediaTelephonyListener()37 MediaTelephonyListener::~MediaTelephonyListener()
38 {
39 MEDIA_LOGI("0x%{public}06" PRIXPTR " Instances destroy", FAKE_POINTER(this));
40 }
41
OnCallStateUpdated(int32_t slotId,int32_t callState,const std::u16string & phoneNumber)42 void MediaTelephonyListener::OnCallStateUpdated(int32_t slotId, int32_t callState, const std::u16string &phoneNumber)
43 {
44 MEDIA_LOGI("OnCallStateUpdated slotId = %{public}d, callState = %{public}d", slotId, callState);
45 if (slotId < 0) {
46 return;
47 }
48 // skip no sim card CALL_STATUS_UNKNOWN
49 if (callState == static_cast<int32_t>(TelCallState::CALL_STATUS_ANSWERED) ||
50 callState == static_cast<int32_t>(TelCallState::CALL_STATUS_ALERTING) ||
51 callState == static_cast<int32_t>(TelCallState::CALL_STATUS_DIALING) ||
52 callState == static_cast<int32_t>(TelCallState::CALL_STATUS_HOLDING) ||
53 callState == static_cast<int32_t>(TelCallState::CALL_STATUS_ACTIVE) ||
54 callState == static_cast<int32_t>(TelCallState::CALL_STATUS_WAITING)) {
55 MEDIA_LOGD("OnCallStateUpdated IN Report in call");
56 InCallObserver::GetInstance().OnCallStateUpdated(true);
57 } else if (callState == static_cast<int32_t>(TelCallState::CALL_STATUS_DISCONNECTED)) {
58 // CALL_STATUS_DISCONNECTING 重复状态不需要
59 MEDIA_LOGD("OnCallStateUpdated IN Report stop call");
60 InCallObserver::GetInstance().OnCallStateUpdated(false);
61 }
62 }
63
OnSignalInfoUpdated(int32_t slotId,const std::vector<sptr<OHOS::Telephony::SignalInformation>> & vec)64 void MediaTelephonyListener::OnSignalInfoUpdated(int32_t slotId,
65 const std::vector<sptr<OHOS::Telephony::SignalInformation>> &vec)
66 {
67 MEDIA_LOGI("OnSignalInfoUpdated slotId = %{public}d, signalInfoList.size = %{public}zu", slotId, vec.size());
68 }
69
OnNetworkStateUpdated(int32_t slotId,const sptr<OHOS::Telephony::NetworkState> & networkState)70 void MediaTelephonyListener::OnNetworkStateUpdated(int32_t slotId,
71 const sptr<OHOS::Telephony::NetworkState> &networkState)
72 {
73 MEDIA_LOGI("OnNetworkStateUpdated slotId = %{public}d, networkState = %{public}d", slotId,
74 networkState == nullptr);
75 }
76
OnCellInfoUpdated(int32_t slotId,const std::vector<sptr<OHOS::Telephony::CellInformation>> & vec)77 void MediaTelephonyListener::OnCellInfoUpdated(int32_t slotId,
78 const std::vector<sptr<OHOS::Telephony::CellInformation>> &vec)
79 {
80 MEDIA_LOGI("OnCellInfoUpdated slotId = %{public}d, cell info size = %{public}zu", slotId, vec.size());
81 }
82
OnSimStateUpdated(int32_t slotId,OHOS::Telephony::CardType type,OHOS::Telephony::SimState state,OHOS::Telephony::LockReason reason)83 void MediaTelephonyListener::OnSimStateUpdated(int32_t slotId, OHOS::Telephony::CardType type,
84 OHOS::Telephony::SimState state, OHOS::Telephony::LockReason reason)
85 {
86 (void)type;
87 (void)reason;
88 MEDIA_LOGI("OnSimStateUpdated slotId = %{public}d, simState = %{public}d", slotId, state);
89 }
90
OnCellularDataConnectStateUpdated(int32_t slotId,int32_t dataState,int32_t networkType)91 void MediaTelephonyListener::OnCellularDataConnectStateUpdated(int32_t slotId, int32_t dataState, int32_t networkType)
92 {
93 MEDIA_LOGI("OnCellularDataConnectStateUpdated slotId=%{public}d, dataState=%{public}d, networkType="
94 "%{public}d", slotId, dataState, networkType);
95 }
96
OnCellularDataFlowUpdated(int32_t slotId,int32_t dataFlowType)97 void MediaTelephonyListener::OnCellularDataFlowUpdated(int32_t slotId, int32_t dataFlowType)
98 {
99 MEDIA_LOGI("OnCellularDataFlowUpdated slotId = %{public}d, dataFlowType = %{public}d", slotId, dataFlowType);
100 }
101
OnCfuIndicatorUpdated(int32_t slotId,bool cfuResult)102 void MediaTelephonyListener::OnCfuIndicatorUpdated(int32_t slotId, bool cfuResult)
103 {
104 MEDIA_LOGI("OnCfuIndicatorUpdated slotId = %{public}d, cfuResult = %{public}d", slotId, cfuResult);
105 }
106
OnVoiceMailMsgIndicatorUpdated(int32_t slotId,bool voiceMailMsgResult)107 void MediaTelephonyListener::OnVoiceMailMsgIndicatorUpdated(int32_t slotId, bool voiceMailMsgResult)
108 {
109 MEDIA_LOGI("OnVoiceMailMsgIndicatorUpdated slotId = %{public}d, voiceMailMsgResult = %{public}d", slotId,
110 voiceMailMsgResult);
111 }
112
OnIccAccountUpdated()113 void MediaTelephonyListener::OnIccAccountUpdated()
114 {
115 MEDIA_LOGI("OnIccAccountUpdated begin");
116 }
117 }
118 }
119