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 public: 187 const uint32_t REGISTER_HANDLER_ID = 10003; 188 int32_t srvccState_ = SrvccState::SRVCC_NONE; 189 190 private: 191 int64_t CurrentTimeMillis(); 192 void GetCsCallData(const AppExecFwk::InnerEvent::Pointer &event); 193 void GetImsCallData(const AppExecFwk::InnerEvent::Pointer &event); 194 void GetSatelliteCallData(const AppExecFwk::InnerEvent::Pointer &event); 195 void GetCsCallsDataRequest(const AppExecFwk::InnerEvent::Pointer &event); 196 void GetImsCallsDataRequest(const AppExecFwk::InnerEvent::Pointer &event); 197 void GetSatelliteCallsDataRequest(const AppExecFwk::InnerEvent::Pointer &event); 198 void RegisterHandler(const AppExecFwk::InnerEvent::Pointer &event); 199 void GetMMIResponse(const AppExecFwk::InnerEvent::Pointer &event); 200 void GetCallWaitingResponse(const AppExecFwk::InnerEvent::Pointer &event); 201 void SetCallWaitingResponse(const AppExecFwk::InnerEvent::Pointer &event); 202 void GetClirResponse(const AppExecFwk::InnerEvent::Pointer &event); 203 void SetClirResponse(const AppExecFwk::InnerEvent::Pointer &event); 204 void GetClipResponse(const AppExecFwk::InnerEvent::Pointer &event); 205 void SetClipResponse(const AppExecFwk::InnerEvent::Pointer &event); 206 void GetColrResponse(const AppExecFwk::InnerEvent::Pointer &event); 207 void SetColrResponse(const AppExecFwk::InnerEvent::Pointer &event); 208 void GetColpResponse(const AppExecFwk::InnerEvent::Pointer &event); 209 void SetColpResponse(const AppExecFwk::InnerEvent::Pointer &event); 210 void GetCallTransferResponse(const AppExecFwk::InnerEvent::Pointer &event); 211 void SetCallTransferInfoResponse(const AppExecFwk::InnerEvent::Pointer &event); 212 void GetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer &event); 213 void SetCallRestrictionResponse(const AppExecFwk::InnerEvent::Pointer &event); 214 void SetBarringPasswordResponse(const AppExecFwk::InnerEvent::Pointer &event); 215 int32_t ConfirmAndRemoveSsRequestCommand(int32_t index, int32_t &flag); 216 void SendUssdResponse(const AppExecFwk::InnerEvent::Pointer &event); 217 void SendUnlockPinPukResponse(const AppExecFwk::InnerEvent::Pointer &event); 218 void CloseUnFinishedUssdResponse(const AppExecFwk::InnerEvent::Pointer &event); 219 void OnRilAdapterHostDied(const AppExecFwk::InnerEvent::Pointer &event); 220 221 void InitBasicFuncMap(); 222 void InitConfigFuncMap(); 223 void InitSupplementFuncMap(); 224 void InitActiveReportFuncMap(); 225 void InitSatelliteCallFuncMap(); 226 227 void ReportCsCallsData(const CallInfoList &callInfoList); 228 void ReportImsCallsData(const ImsCurrentCallList &imsCallInfoList); 229 void ReportSatelliteCallsData(const SatelliteCurrentCallList &callInfoList); 230 void HandleOperatorConfigChanged(const AppExecFwk::InnerEvent::Pointer &event); 231 void UpdateRsrvccStateReport(const AppExecFwk::InnerEvent::Pointer &event); 232 233 #ifdef CALL_MANAGER_AUTO_START_OPTIMIZE 234 /** 235 * If radio state change get call manager service 236 * 237 * @param AppExecFwk::InnerEvent::Pointer 238 */ 239 void RadioStateChangeProcess(const AppExecFwk::InnerEvent::Pointer &event); 240 241 /** 242 * If get radio state on, get call manager service 243 * 244 * @param AppExecFwk::InnerEvent::Pointer 245 */ 246 void GetRadioStateProcess(const AppExecFwk::InnerEvent::Pointer &event); 247 248 void StartCallManagerService(); 249 #endif 250 251 private: 252 void CellularCallIncomingStartTrace(const int32_t state); 253 void CellularCallIncomingFinishTrace(const int32_t state); 254 255 private: 256 int32_t slotId_ = DEFAULT_SIM_SLOT_ID; 257 int64_t lastCallsDataFlag_ = 0L; 258 using RequestFuncType = void (CellularCallHandler::*)(const AppExecFwk::InnerEvent::Pointer &event); 259 std::map<uint32_t, RequestFuncType> requestFuncMap_; 260 std::shared_ptr<CellularCallRegister> registerInstance_ = DelayedSingleton<CellularCallRegister>::GetInstance(); 261 bool isInCsRedial_ = false; 262 int32_t indexCommand_ = 0; 263 std::map<int32_t, std::shared_ptr<SsRequestCommand>> utCommandMap_; 264 std::mutex mutex_; 265 }; 266 } // namespace Telephony 267 } // namespace OHOS 268 269 #endif 270