1 /* 2 * Copyright (c) 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 OHOS_HDI_RIL_V1_0_RIL_INTERFACE_IMPL_H 17 #define OHOS_HDI_RIL_V1_0_RIL_INTERFACE_IMPL_H 18 19 #include "hril_manager.h" 20 21 #include <hdf_log.h> 22 #include <iproxy_broker.h> 23 #include <iremote_object.h> 24 25 #include "v1_1/iril.h" 26 #include "vector" 27 28 namespace OHOS { 29 namespace HDI { 30 namespace Ril { 31 namespace V1_1 { 32 class RilImpl : public IRil { 33 public: 34 RilImpl() = default; 35 virtual ~RilImpl() = default; 36 37 // Call 38 int32_t SetEmergencyCallList(int32_t slotId, int32_t serialId, const EmergencyInfoList &emergencyInfoList) override; 39 int32_t GetEmergencyCallList(int32_t slotId, int32_t serialId) override; 40 int32_t GetCallList(int32_t slotId, int32_t serialId) override; 41 int32_t Dial(int32_t slotId, int32_t serialId, const DialInfo &dialInfo) override; 42 int32_t Reject(int32_t slotId, int32_t serialId) override; 43 int32_t Hangup(int32_t slotId, int32_t serialId, int32_t gsmIndex) override; 44 int32_t Answer(int32_t slotId, int32_t serialId) override; 45 int32_t HoldCall(int32_t slotId, int32_t serialId) override; 46 int32_t UnHoldCall(int32_t slotId, int32_t serialId) override; 47 int32_t SwitchCall(int32_t slotId, int32_t serialId) override; 48 int32_t CombineConference(int32_t slotId, int32_t serialId, int32_t callType) override; 49 int32_t SeparateConference(int32_t slotId, int32_t serialId, int32_t callIndex, int32_t callType) override; 50 int32_t GetCallWaiting(int32_t slotId, int32_t serialId) override; 51 int32_t SetCallWaiting(int32_t slotId, int32_t serialId, int32_t activate) override; 52 int32_t GetCallTransferInfo(int32_t slotId, int32_t serialId, int32_t reason) override; 53 int32_t SetCallTransferInfo( 54 int32_t slotId, int32_t serialId, const CallForwardSetInfo &callForwardSetInfo) override; 55 int32_t GetCallRestriction(int32_t slotId, int32_t serialId, const std::string &fac) override; 56 int32_t SetCallRestriction( 57 int32_t slotId, int32_t serialId, const CallRestrictionInfo &callRestrictionInfo) override; 58 int32_t GetClip(int32_t slotId, int32_t serialId) override; 59 int32_t SetClip(int32_t slotId, int32_t serialId, int32_t action) override; 60 int32_t GetClir(int32_t slotId, int32_t serialId) override; 61 int32_t SetClir(int32_t slotId, int32_t serialId, int32_t action) override; 62 int32_t SetCallPreferenceMode(int32_t slotId, int32_t serialId, int32_t mode) override; 63 int32_t GetCallPreferenceMode(int32_t slotId, int32_t serialId) override; 64 int32_t SetUssd(int32_t slotId, int32_t serialId, const std::string &str) override; 65 int32_t CloseUnFinishedUssd(int32_t slotId, int32_t serialId) override; 66 int32_t GetUssd(int32_t slotId, int32_t serialId) override; 67 int32_t SetMute(int32_t slotId, int32_t serialId, int32_t mute) override; 68 int32_t GetMute(int32_t slotId, int32_t serialId) override; 69 int32_t GetCallFailReason(int32_t slotId, int32_t serialId) override; 70 int32_t CallSupplement(int32_t slotId, int32_t serialId, int32_t type) override; 71 int32_t SendDtmf(int32_t slotId, int32_t serialId, const DtmfInfo &dtmfInfo) override; 72 int32_t StartDtmf(int32_t slotId, int32_t serialId, const DtmfInfo &dtmfInfo) override; 73 int32_t StopDtmf(int32_t slotId, int32_t serialId, const DtmfInfo &dtmfInfo) override; 74 int32_t SetBarringPassword(int32_t slotId, int32_t serialId, const SetBarringInfo &setBarringInfo) override; 75 int32_t SetVonrSwitch(int32_t slotId, int32_t serialId, int32_t status) override; 76 77 // Data 78 int32_t ActivatePdpContext(int32_t slotId, int32_t serialId, const DataCallInfo &dataCallInfo) override; 79 int32_t DeactivatePdpContext(int32_t slotId, int32_t serialId, const UniInfo &uniInfo) override; 80 int32_t GetPdpContextList(int32_t slotId, int32_t serialId, const UniInfo &uniInfo) override; 81 int32_t SetInitApnInfo(int32_t slotId, int32_t serialId, const DataProfileDataInfo &dataProfileDataInfo) override; 82 int32_t GetLinkBandwidthInfo(int32_t slotId, int32_t serialId, int32_t cid) override; 83 int32_t GetLinkCapability(int32_t slotId, int32_t serialId) override; 84 int32_t SetLinkBandwidthReportingRule(int32_t slotId, int32_t serialId, 85 const DataLinkBandwidthReportingRule &dataLinkBandwidthReportingRule) override; 86 int32_t SetDataPermitted(int32_t slotId, int32_t serialId, int32_t dataPermitted) override; 87 int32_t SetDataProfileInfo(int32_t slotId, int32_t serialId, const DataProfilesInfo &dataProfilesInfo) override; 88 int32_t SendDataPerformanceMode(int32_t slotId, int32_t serialId, 89 const DataPerformanceInfo &dataPerformanceInfo) override; 90 int32_t SendDataSleepMode(int32_t slotId, int32_t serialId, const DataSleepInfo &dataSleepInfo) override; 91 92 int32_t SetRadioState(int32_t slotId, int32_t serialId, int32_t fun, int32_t rst) override; 93 int32_t GetRadioState(int32_t slotId, int32_t serialId) override; 94 int32_t GetImei(int32_t slotId, int32_t serialId) override; 95 int32_t GetMeid(int32_t slotId, int32_t serialId) override; 96 int32_t GetVoiceRadioTechnology(int32_t slotId, int32_t serialId) override; 97 int32_t GetBasebandVersion(int32_t slotId, int32_t serialId) override; 98 int32_t ShutDown(int32_t slotId, int32_t serialId) override; 99 100 int32_t GetSimIO(int32_t slotId, int32_t serialId, const SimIoRequestInfo &simIO) override; 101 int32_t GetSimStatus(int32_t slotId, int32_t serialId) override; 102 int32_t GetImsi(int32_t slotId, int32_t serialId) override; 103 int32_t GetSimLockStatus(int32_t slotId, int32_t serialId, const SimLockInfo &simLockInfo) override; 104 int32_t SetSimLock(int32_t slotId, int32_t serialId, const SimLockInfo &simLockInfo) override; 105 int32_t ChangeSimPassword(int32_t slotId, int32_t serialId, const SimPasswordInfo &simPassword) override; 106 int32_t UnlockPin(int32_t slotId, int32_t serialId, const std::string &pin) override; 107 int32_t UnlockPuk(int32_t slotId, int32_t serialId, const std::string &puk, const std::string &pin) override; 108 int32_t UnlockPin2(int32_t slotId, int32_t serialId, const std::string &pin2) override; 109 int32_t UnlockPuk2(int32_t slotId, int32_t serialId, const std::string &puk2, const std::string &pin2) override; 110 int32_t SetActiveSim(int32_t slotId, int32_t serialId, int32_t index, int32_t enable) override; 111 int32_t SimStkSendTerminalResponse(int32_t slotId, int32_t serialId, const std::string &strCmd) override; 112 int32_t SimStkSendEnvelope(int32_t slotId, int32_t serialId, const std::string &strCmd) override; 113 int32_t SimStkSendCallSetupRequestResult(int32_t slotId, int32_t serialId, int32_t accept) override; 114 int32_t SimStkIsReady(int32_t slotId, int32_t serialId) override; 115 int32_t GetRadioProtocol(int32_t slotId, int32_t serialId) override; 116 int32_t SetRadioProtocol(int32_t slotId, int32_t serialId, const RadioProtocol &radioProtocol) override; 117 int32_t SimOpenLogicalChannel(int32_t slotId, int32_t serialId, const std::string &appID, int32_t p2) override; 118 int32_t SimCloseLogicalChannel(int32_t slotId, int32_t serialId, int32_t channelId) override; 119 int32_t SimTransmitApduLogicalChannel( 120 int32_t slotId, int32_t serialId, const ApduSimIORequestInfo &apduSimIO) override; 121 int32_t SimTransmitApduBasicChannel( 122 int32_t slotId, int32_t serialId, const ApduSimIORequestInfo &apduSimIO) override; 123 int32_t SimAuthentication( 124 int32_t slotId, int32_t serialId, const SimAuthenticationRequestInfo &simAuthInfo) override; 125 int32_t UnlockSimLock(int32_t slotId, int32_t serialId, int32_t lockType, const std::string &key) override; 126 127 // Network 128 int32_t GetSignalStrength(int32_t slotId, int32_t serialId) override; 129 int32_t GetCsRegStatus(int32_t slotId, int32_t serialId) override; 130 int32_t GetPsRegStatus(int32_t slotId, int32_t serialId) override; 131 int32_t GetOperatorInfo(int32_t slotId, int32_t serialId) override; 132 int32_t GetNetworkSearchInformation(int32_t slotId, int32_t serialId) override; 133 int32_t GetNetworkSelectionMode(int32_t slotId, int32_t serialId) override; 134 int32_t SetNetworkSelectionMode( 135 int32_t slotId, int32_t serialId, const SetNetworkModeInfo &networkModeInfo) override; 136 int32_t GetNeighboringCellInfoList(int32_t slotId, int32_t serialId) override; 137 int32_t GetCurrentCellInfo(int32_t slotId, int32_t serialId) override; 138 int32_t SetPreferredNetwork(int32_t slotId, int32_t serialId, int32_t preferredNetworkType) override; 139 int32_t GetPreferredNetwork(int32_t slotId, int32_t serialId) override; 140 int32_t GetPhysicalChannelConfig(int32_t slotId, int32_t serialId) override; 141 int32_t SetLocateUpdates(int32_t slotId, int32_t serialId, const RilRegNotifyMode mode) override; 142 int32_t SetNotificationFilter(int32_t slotId, int32_t serialId, int32_t newFilter) override; 143 int32_t SetDeviceState(int32_t slotId, int32_t serialId, int32_t deviceStateType, int32_t deviceStateOn) override; 144 int32_t SetNrOptionMode(int32_t slotId, int32_t serialId, int32_t mode) override; 145 int32_t GetNrOptionMode(int32_t slotId, int32_t serialId) override; 146 int32_t GetRrcConnectionState(int32_t slotId, int32_t serialId) override; 147 148 // Sms 149 int32_t SendGsmSms(int32_t slotId, int32_t serialId, const GsmSmsMessageInfo &gsmSmsMessageInfo) override; 150 int32_t SendCdmaSms(int32_t slotId, int32_t serialId, const SendCdmaSmsMessageInfo &cdmaSmsMessageInfo) override; 151 int32_t AddSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo) override; 152 int32_t DelSimMessage(int32_t slotId, int32_t serialId, int32_t index) override; 153 int32_t UpdateSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo) override; 154 int32_t AddCdmaSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo) override; 155 int32_t DelCdmaSimMessage(int32_t slotId, int32_t serialId, int32_t index) override; 156 int32_t UpdateCdmaSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo) override; 157 int32_t SetSmscAddr(int32_t slotId, int32_t serialId, const ServiceCenterAddress &serviceCenterAddress) override; 158 int32_t GetSmscAddr(int32_t slotId, int32_t serialId) override; 159 int32_t SetCBConfig(int32_t slotId, int32_t serialId, const CBConfigInfo &cellBroadcastInfo) override; 160 int32_t GetCBConfig(int32_t slotId, int32_t serialId) override; 161 int32_t SetCdmaCBConfig( 162 int32_t slotId, int32_t serialId, const CdmaCBConfigInfoList &cdmaCBConfigInfoList) override; 163 int32_t GetCdmaCBConfig(int32_t slotId, int32_t serialId) override; 164 int32_t SendSmsMoreMode(int32_t slotId, int32_t serialId, const GsmSmsMessageInfo &gsmSmsMessageInfo) override; 165 int32_t SendSmsAck(int32_t slotId, int32_t serialId, const ModeData &modeData) override; 166 167 int32_t SendRilAck() override; 168 169 int32_t SetCallback(const sptr<IRilCallback> &rilCallback) override; 170 int32_t Init(); 171 class RilDeathRecipient : public IRemoteObject::DeathRecipient { 172 public: RilDeathRecipient(const wptr<RilImpl> & rilInterfaceImpl)173 explicit RilDeathRecipient(const wptr<RilImpl> &rilInterfaceImpl) : rilInterfaceImpl_(rilInterfaceImpl) {} 174 virtual ~RilDeathRecipient() = default; 175 virtual void OnRemoteDied(const wptr<IRemoteObject> &object) override; 176 177 private: 178 wptr<RilImpl> rilInterfaceImpl_; 179 }; 180 181 template<typename FuncType, typename... ParamTypes> TaskSchedule(FuncType && _func,int32_t slotId,ParamTypes &&..._args)182 inline int32_t TaskSchedule(FuncType &&_func, int32_t slotId, ParamTypes &&... _args) const 183 { 184 if (_func == nullptr || Telephony::HRilManager::manager_ == nullptr) { 185 HDF_LOGE("manager or func is null pointer"); 186 return RIL_ERR_NULL_POINT; 187 } 188 if (slotId >= Telephony::HRilManager::manager_->GetMaxSimSlotCount()) { 189 HDF_LOGE("slotId is inValid"); 190 return RIL_ERR_INVALID_PARAMETER; 191 } 192 auto ret = (Telephony::HRilManager::manager_.get()->*(_func))(slotId, std::forward<ParamTypes>(_args)...); 193 return ret; 194 } 195 196 private: 197 int32_t UnRegister(); 198 int32_t AddRilDeathRecipient(const sptr<IRilCallback> &callback); 199 int32_t RemoveRilDeathRecipient(const sptr<IRilCallback> &callback); 200 }; 201 } // namespace V1_1 202 } // namespace Ril 203 } // namespace HDI 204 } // namespace OHOS 205 #endif // OHOS_HDI_RIL_V1_0_RILIMPL_H 206