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 #ifndef CELLULAR_CALL_HANDLER_H 17 #define CELLULAR_CALL_HANDLER_H 18 19 #include <memory> 20 #include <mutex> 21 22 #include "cellular_call_config.h" 23 #include "cellular_call_data_struct.h" 24 #include "cellular_call_register.h" 25 #include "common_event.h" 26 #include "common_event_manager.h" 27 #include "common_event_support.h" 28 #include "cs_control.h" 29 #include "ims_call_types.h" 30 #include "ims_control.h" 31 #include "telephony_log_wrapper.h" 32 33 namespace OHOS { 34 namespace Telephony { 35 class CellularCallHandler : public AppExecFwk::EventHandler, public EventFwk::CommonEventSubscriber { 36 public: 37 /** 38 * CellularCallHandler constructor 39 * 40 * @param runner 41 * @param subscriberInfo 42 */ 43 explicit CellularCallHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner, 44 const EventFwk::CommonEventSubscribeInfo &subscriberInfo); 45 46 /** 47 * ~CellularCallHandler destructor 48 */ 49 ~CellularCallHandler() = default; 50 51 /** 52 * ProcessEvent. 53 * 54 * @param CellularCallRadioResponseEvent, Process Radio Response Event . 55 */ 56 void ProcessEvent(const AppExecFwk::InnerEvent::Pointer &event) override; 57 58 /** 59 * Receive Operator Config Change event and process. 60 * 61 * @param CommonEventData, Process Operator Config Change . 62 */ 63 void OnReceiveEvent(const EventFwk::CommonEventData &data) override; 64 65 /** 66 * Set Slot Id 67 * 68 * @param id 69 */ 70 void SetSlotId(int32_t id); 71 72 /** 73 * Get Slot Id 74 * @return id 75 */ 76 int32_t GetSlotId(); 77 78 void RegisterImsCallCallbackHandler(); 79 80 void SimStateChangeReport(const AppExecFwk::InnerEvent::Pointer &event); 81 82 void SimRecordsLoadedReport(const AppExecFwk::InnerEvent::Pointer &event); 83 84 void DialResponse(const AppExecFwk::InnerEvent::Pointer &event); 85 86 void CommonResultEventHandling(const AppExecFwk::InnerEvent::Pointer &event, CellularCallEventInfo &eventInfo); 87 88 void CommonResultResponse(const AppExecFwk::InnerEvent::Pointer &event); 89 90 void ExecutePostDial(const AppExecFwk::InnerEvent::Pointer &event); 91 92 void SendDtmfResponse(const AppExecFwk::InnerEvent::Pointer &event); 93 94 void StartDtmfResponse(const AppExecFwk::InnerEvent::Pointer &event); 95 96 void StopDtmfResponse(const AppExecFwk::InnerEvent::Pointer &event); 97 98 void GetCsCallsDataResponse(const AppExecFwk::InnerEvent::Pointer &event); 99 100 void GetImsCallsDataResponse(const AppExecFwk::InnerEvent::Pointer &event); 101 102 void CsCallStatusInfoReport(const AppExecFwk::InnerEvent::Pointer &event); 103 104 void ImsCallStatusInfoReport(const AppExecFwk::InnerEvent::Pointer &event); 105 106 void ReportEccChanged(const AppExecFwk::InnerEvent::Pointer &event); 107 108 void SetDomainPreferenceModeResponse(const AppExecFwk::InnerEvent::Pointer &event); 109 110 void GetDomainPreferenceModeResponse(const AppExecFwk::InnerEvent::Pointer &event); 111 112 void SetImsSwitchStatusResponse(const AppExecFwk::InnerEvent::Pointer &event); 113 114 void GetImsSwitchStatusResponse(const AppExecFwk::InnerEvent::Pointer &event); 115 116 void SetVoNRSwitchStatusResponse(const AppExecFwk::InnerEvent::Pointer &event); 117 118 void UssdNotifyResponse(const AppExecFwk::InnerEvent::Pointer &event); 119 120 void SsNotifyResponse(const AppExecFwk::InnerEvent::Pointer &event); 121 122 void CallRingBackVoiceResponse(const AppExecFwk::InnerEvent::Pointer &event); 123 124 void SetMuteResponse(const AppExecFwk::InnerEvent::Pointer &event); 125 126 void GetMuteResponse(const AppExecFwk::InnerEvent::Pointer &event); 127 128 void GetEmergencyCallListResponse(const AppExecFwk::InnerEvent::Pointer &event); 129 130 void SetEmergencyCallListResponse(const AppExecFwk::InnerEvent::Pointer &event); 131 132 void GetCallFailReasonResponse(const AppExecFwk::InnerEvent::Pointer &event); 133 134 void UpdateSrvccStateReport(const AppExecFwk::InnerEvent::Pointer &event); 135 136 void SrvccStateCompleted(); 137 138 /** 139 * request the ut command index which will be used to report the result 140 * 141 * @param index 142 */ 143 void RequestSsRequestCommandIndex(int32_t &index); 144 145 /** 146 * save the ut command which will be used to report the result 147 * 148 * @param SsRequestCommand 149 * @param index 150 */ 151 void SaveSsRequestCommand(const std::shared_ptr<SsRequestCommand> &utCommand, int32_t index); 152 153 int32_t GetSsRequestCommand(int32_t index, SsRequestCommand &ss); 154 155 public: 156 const uint32_t REGISTER_HANDLER_ID = 10003; 157 int32_t srvccState_ = SrvccState::SRVCC_NONE; 158 159 private: 160 int64_t CurrentTimeMillis(); 161 void GetCsCallData(const AppExecFwk::InnerEvent::Pointer &event); 162 void GetImsCallData(const AppExecFwk::InnerEvent::Pointer &event); 163 void GetCsCallsDataRequest(const AppExecFwk::InnerEvent::Pointer &event); 164 void GetImsCallsDataRequest(const AppExecFwk::InnerEvent::Pointer &event); 165 void RegisterHandler(const AppExecFwk::InnerEvent::Pointer &event); 166 void GetMMIResponse(const AppExecFwk::InnerEvent::Pointer &event); 167 void GetCallWaitingResponse(const AppExecFwk::InnerEvent::Pointer &event); 168 void SetCallWaitingResponse(const AppExecFwk::InnerEvent::Pointer &event); 169 void GetClirResponse(const AppExecFwk::InnerEvent::Pointer &event); 170 void SetClirResponse(const AppExecFwk::InnerEvent::Pointer &event); 171 void GetClipResponse(const AppExecFwk::InnerEvent::Pointer &event); 172 void SetClipResponse(const AppExecFwk::InnerEvent::Pointer &event); 173 void GetColrResponse(const AppExecFwk::InnerEvent::Pointer &event); 174 void SetColrResponse(const AppExecFwk::InnerEvent::Pointer &event); 175 void GetColpResponse(const AppExecFwk::InnerEvent::Pointer &event); 176 void SetColpResponse(const AppExecFwk::InnerEvent::Pointer &event); 177 void GetCallTransferResponse(const AppExecFwk::InnerEvent::Pointer &event); 178 void SetCallTransferInfoResponse(const AppExecFwk::InnerEvent::Pointer &event); 179 void GetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer &event); 180 void SetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer &event); 181 void SetBarringPasswordResponse(const AppExecFwk::InnerEvent::Pointer &event); 182 int32_t ConfirmAndRemoveSsRequestCommand(int32_t index, int32_t &flag); 183 void SendUssdResponse(const AppExecFwk::InnerEvent::Pointer &event); 184 void SendUnlockPinPukResponse(const AppExecFwk::InnerEvent::Pointer &event); 185 void CloseUnFinishedUssdResponse(const AppExecFwk::InnerEvent::Pointer &event); 186 187 void InitBasicFuncMap(); 188 void InitConfigFuncMap(); 189 void InitSupplementFuncMap(); 190 void InitActiveReportFuncMap(); 191 192 void ReportCsCallsData(const CallInfoList &callInfoList); 193 void ReportImsCallsData(const ImsCurrentCallList &imsCallInfoList); 194 void HandleOperatorConfigChanged(const AppExecFwk::InnerEvent::Pointer &event); 195 void UpdateRsrvccStateReport(const AppExecFwk::InnerEvent::Pointer &event); 196 197 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE 198 /** 199 * If radio state change get call manager service 200 * 201 * @param AppExecFwk::InnerEvent::Pointer 202 */ 203 void RadioStateChangeProcess(const AppExecFwk::InnerEvent::Pointer &event); 204 205 /** 206 * If get radio state on, get call manager service 207 * 208 * @param AppExecFwk::InnerEvent::Pointer 209 */ 210 void GetRadioStateProcess(const AppExecFwk::InnerEvent::Pointer &event); 211 212 void StartCallManagerService(); 213 #endif 214 215 private: 216 void CellularCallIncomingStartTrace(const int32_t state); 217 void CellularCallIncomingFinishTrace(const int32_t state); 218 219 private: 220 int32_t slotId_ = DEFAULT_SIM_SLOT_ID; 221 int64_t lastCallsDataFlag_ = 0L; 222 using RequestFuncType = void (CellularCallHandler::*)(const AppExecFwk::InnerEvent::Pointer &event); 223 std::map<uint32_t, RequestFuncType> requestFuncMap_; 224 std::shared_ptr<CellularCallRegister> registerInstance_ = DelayedSingleton<CellularCallRegister>::GetInstance(); 225 bool isInCsRedial_ = false; 226 int32_t indexCommand_ = 0; 227 std::map<int32_t, std::shared_ptr<SsRequestCommand>> utCommandMap_; 228 std::mutex mutex_; 229 }; 230 } // namespace Telephony 231 } // namespace OHOS 232 233 #endif 234