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