1094332d3Sopenharmony_ci/*
2094332d3Sopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
3094332d3Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4094332d3Sopenharmony_ci * you may not use this file except in compliance with the License.
5094332d3Sopenharmony_ci * You may obtain a copy of the License at
6094332d3Sopenharmony_ci *
7094332d3Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8094332d3Sopenharmony_ci *
9094332d3Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10094332d3Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11094332d3Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12094332d3Sopenharmony_ci * See the License for the specific language governing permissions and
13094332d3Sopenharmony_ci * limitations under the License.
14094332d3Sopenharmony_ci */
15094332d3Sopenharmony_ci
16094332d3Sopenharmony_ci#ifndef OHOS_HDI_RIL_V1_0_RIL_INTERFACE_IMPL_H
17094332d3Sopenharmony_ci#define OHOS_HDI_RIL_V1_0_RIL_INTERFACE_IMPL_H
18094332d3Sopenharmony_ci
19094332d3Sopenharmony_ci#include "hril_manager.h"
20094332d3Sopenharmony_ci
21094332d3Sopenharmony_ci#include <hdf_log.h>
22094332d3Sopenharmony_ci#include <iproxy_broker.h>
23094332d3Sopenharmony_ci#include <iremote_object.h>
24094332d3Sopenharmony_ci
25094332d3Sopenharmony_ci#include "v1_3/iril.h"
26094332d3Sopenharmony_ci#include "vector"
27094332d3Sopenharmony_ci
28094332d3Sopenharmony_cinamespace OHOS {
29094332d3Sopenharmony_cinamespace HDI {
30094332d3Sopenharmony_cinamespace Ril {
31094332d3Sopenharmony_cinamespace V1_3 {
32094332d3Sopenharmony_ciclass RilImpl : public IRil {
33094332d3Sopenharmony_cipublic:
34094332d3Sopenharmony_ci    RilImpl() = default;
35094332d3Sopenharmony_ci    virtual ~RilImpl() = default;
36094332d3Sopenharmony_ci
37094332d3Sopenharmony_ci    // Call
38094332d3Sopenharmony_ci    int32_t SetEmergencyCallList(int32_t slotId, int32_t serialId, const EmergencyInfoList &emergencyInfoList) override;
39094332d3Sopenharmony_ci    int32_t GetEmergencyCallList(int32_t slotId, int32_t serialId) override;
40094332d3Sopenharmony_ci    int32_t GetCallList(int32_t slotId, int32_t serialId) override;
41094332d3Sopenharmony_ci    int32_t Dial(int32_t slotId, int32_t serialId, const DialInfo &dialInfo) override;
42094332d3Sopenharmony_ci    int32_t Reject(int32_t slotId, int32_t serialId) override;
43094332d3Sopenharmony_ci    int32_t Hangup(int32_t slotId, int32_t serialId, int32_t gsmIndex) override;
44094332d3Sopenharmony_ci    int32_t Answer(int32_t slotId, int32_t serialId) override;
45094332d3Sopenharmony_ci    int32_t HoldCall(int32_t slotId, int32_t serialId) override;
46094332d3Sopenharmony_ci    int32_t UnHoldCall(int32_t slotId, int32_t serialId) override;
47094332d3Sopenharmony_ci    int32_t SwitchCall(int32_t slotId, int32_t serialId) override;
48094332d3Sopenharmony_ci    int32_t CombineConference(int32_t slotId, int32_t serialId, int32_t callType) override;
49094332d3Sopenharmony_ci    int32_t SeparateConference(int32_t slotId, int32_t serialId, int32_t callIndex, int32_t callType) override;
50094332d3Sopenharmony_ci    int32_t GetCallWaiting(int32_t slotId, int32_t serialId) override;
51094332d3Sopenharmony_ci    int32_t SetCallWaiting(int32_t slotId, int32_t serialId, int32_t activate) override;
52094332d3Sopenharmony_ci    int32_t GetCallTransferInfo(int32_t slotId, int32_t serialId, int32_t reason) override;
53094332d3Sopenharmony_ci    int32_t SetCallTransferInfo(
54094332d3Sopenharmony_ci        int32_t slotId, int32_t serialId, const CallForwardSetInfo &callForwardSetInfo) override;
55094332d3Sopenharmony_ci    int32_t GetCallRestriction(int32_t slotId, int32_t serialId, const std::string &fac) override;
56094332d3Sopenharmony_ci    int32_t SetCallRestriction(
57094332d3Sopenharmony_ci        int32_t slotId, int32_t serialId, const CallRestrictionInfo &callRestrictionInfo) override;
58094332d3Sopenharmony_ci    int32_t GetClip(int32_t slotId, int32_t serialId) override;
59094332d3Sopenharmony_ci    int32_t SetClip(int32_t slotId, int32_t serialId, int32_t action) override;
60094332d3Sopenharmony_ci    int32_t GetClir(int32_t slotId, int32_t serialId) override;
61094332d3Sopenharmony_ci    int32_t SetClir(int32_t slotId, int32_t serialId, int32_t action) override;
62094332d3Sopenharmony_ci    int32_t SetCallPreferenceMode(int32_t slotId, int32_t serialId, int32_t mode) override;
63094332d3Sopenharmony_ci    int32_t GetCallPreferenceMode(int32_t slotId, int32_t serialId) override;
64094332d3Sopenharmony_ci    int32_t SetUssd(int32_t slotId, int32_t serialId, const std::string &str) override;
65094332d3Sopenharmony_ci    int32_t CloseUnFinishedUssd(int32_t slotId, int32_t serialId) override;
66094332d3Sopenharmony_ci    int32_t GetUssd(int32_t slotId, int32_t serialId) override;
67094332d3Sopenharmony_ci    int32_t SetMute(int32_t slotId, int32_t serialId, int32_t mute) override;
68094332d3Sopenharmony_ci    int32_t GetMute(int32_t slotId, int32_t serialId) override;
69094332d3Sopenharmony_ci    int32_t GetCallFailReason(int32_t slotId, int32_t serialId) override;
70094332d3Sopenharmony_ci    int32_t CallSupplement(int32_t slotId, int32_t serialId, int32_t type) override;
71094332d3Sopenharmony_ci    int32_t SendDtmf(int32_t slotId, int32_t serialId, const DtmfInfo &dtmfInfo) override;
72094332d3Sopenharmony_ci    int32_t StartDtmf(int32_t slotId, int32_t serialId, const DtmfInfo &dtmfInfo) override;
73094332d3Sopenharmony_ci    int32_t StopDtmf(int32_t slotId, int32_t serialId, const DtmfInfo &dtmfInfo) override;
74094332d3Sopenharmony_ci    int32_t SetBarringPassword(int32_t slotId, int32_t serialId, const SetBarringInfo &setBarringInfo) override;
75094332d3Sopenharmony_ci    int32_t SetVonrSwitch(int32_t slotId, int32_t serialId, int32_t status) override;
76094332d3Sopenharmony_ci
77094332d3Sopenharmony_ci    // Data
78094332d3Sopenharmony_ci    int32_t ActivatePdpContext(int32_t slotId, int32_t serialId, const DataCallInfo &dataCallInfo) override;
79094332d3Sopenharmony_ci    int32_t ActivatePdpContextWithApnTypes(int32_t slotId, int32_t serialId,
80094332d3Sopenharmony_ci        const DataCallInfoWithApnTypes &dataCallInfo) override;
81094332d3Sopenharmony_ci    int32_t DeactivatePdpContext(int32_t slotId, int32_t serialId, const UniInfo &uniInfo) override;
82094332d3Sopenharmony_ci    int32_t GetPdpContextList(int32_t slotId, int32_t serialId, const UniInfo &uniInfo) override;
83094332d3Sopenharmony_ci    int32_t SetInitApnInfo(int32_t slotId, int32_t serialId, const DataProfileDataInfo &dataProfileDataInfo) override;
84094332d3Sopenharmony_ci    int32_t GetLinkBandwidthInfo(int32_t slotId, int32_t serialId, int32_t cid) override;
85094332d3Sopenharmony_ci    int32_t GetLinkCapability(int32_t slotId, int32_t serialId) override;
86094332d3Sopenharmony_ci    int32_t SetLinkBandwidthReportingRule(int32_t slotId, int32_t serialId,
87094332d3Sopenharmony_ci        const DataLinkBandwidthReportingRule &dataLinkBandwidthReportingRule) override;
88094332d3Sopenharmony_ci    int32_t SetDataPermitted(int32_t slotId, int32_t serialId, int32_t dataPermitted) override;
89094332d3Sopenharmony_ci    int32_t SetDataProfileInfo(int32_t slotId, int32_t serialId, const DataProfilesInfo &dataProfilesInfo) override;
90094332d3Sopenharmony_ci    int32_t SendDataPerformanceMode(int32_t slotId, int32_t serialId,
91094332d3Sopenharmony_ci        const DataPerformanceInfo &dataPerformanceInfo) override;
92094332d3Sopenharmony_ci    int32_t SendDataSleepMode(int32_t slotId, int32_t serialId, const DataSleepInfo &dataSleepInfo) override;
93094332d3Sopenharmony_ci    int32_t CleanAllConnections(int32_t slotId, int32_t serialId) override;
94094332d3Sopenharmony_ci
95094332d3Sopenharmony_ci    int32_t SetRadioState(int32_t slotId, int32_t serialId, int32_t fun, int32_t rst) override;
96094332d3Sopenharmony_ci    int32_t GetRadioState(int32_t slotId, int32_t serialId) override;
97094332d3Sopenharmony_ci    int32_t GetImei(int32_t slotId, int32_t serialId) override;
98094332d3Sopenharmony_ci    int32_t GetImeiSv(int32_t slotId, int32_t serialId) override;
99094332d3Sopenharmony_ci    int32_t GetMeid(int32_t slotId, int32_t serialId) override;
100094332d3Sopenharmony_ci    int32_t GetVoiceRadioTechnology(int32_t slotId, int32_t serialId) override;
101094332d3Sopenharmony_ci    int32_t GetBasebandVersion(int32_t slotId, int32_t serialId) override;
102094332d3Sopenharmony_ci    int32_t ShutDown(int32_t slotId, int32_t serialId) override;
103094332d3Sopenharmony_ci
104094332d3Sopenharmony_ci    int32_t GetSimIO(int32_t slotId, int32_t serialId, const SimIoRequestInfo &simIO) override;
105094332d3Sopenharmony_ci    int32_t GetSimStatus(int32_t slotId, int32_t serialId) override;
106094332d3Sopenharmony_ci    int32_t GetImsi(int32_t slotId, int32_t serialId) override;
107094332d3Sopenharmony_ci    int32_t GetSimLockStatus(int32_t slotId, int32_t serialId, const SimLockInfo &simLockInfo) override;
108094332d3Sopenharmony_ci    int32_t SetSimLock(int32_t slotId, int32_t serialId, const SimLockInfo &simLockInfo) override;
109094332d3Sopenharmony_ci    int32_t ChangeSimPassword(int32_t slotId, int32_t serialId, const SimPasswordInfo &simPassword) override;
110094332d3Sopenharmony_ci    int32_t UnlockPin(int32_t slotId, int32_t serialId, const std::string &pin) override;
111094332d3Sopenharmony_ci    int32_t UnlockPuk(int32_t slotId, int32_t serialId, const std::string &puk, const std::string &pin) override;
112094332d3Sopenharmony_ci    int32_t UnlockPin2(int32_t slotId, int32_t serialId, const std::string &pin2) override;
113094332d3Sopenharmony_ci    int32_t UnlockPuk2(int32_t slotId, int32_t serialId, const std::string &puk2, const std::string &pin2) override;
114094332d3Sopenharmony_ci    int32_t SetActiveSim(int32_t slotId, int32_t serialId, int32_t index, int32_t enable) override;
115094332d3Sopenharmony_ci    int32_t SimStkSendTerminalResponse(int32_t slotId, int32_t serialId, const std::string &strCmd) override;
116094332d3Sopenharmony_ci    int32_t SimStkSendEnvelope(int32_t slotId, int32_t serialId, const std::string &strCmd) override;
117094332d3Sopenharmony_ci    int32_t SimStkSendCallSetupRequestResult(int32_t slotId, int32_t serialId, int32_t accept) override;
118094332d3Sopenharmony_ci    int32_t SimStkIsReady(int32_t slotId, int32_t serialId) override;
119094332d3Sopenharmony_ci    int32_t GetRadioProtocol(int32_t slotId, int32_t serialId) override;
120094332d3Sopenharmony_ci    int32_t SetRadioProtocol(int32_t slotId, int32_t serialId, const RadioProtocol &radioProtocol) override;
121094332d3Sopenharmony_ci    int32_t SimOpenLogicalChannel(int32_t slotId, int32_t serialId, const std::string &appID, int32_t p2) override;
122094332d3Sopenharmony_ci    int32_t SimCloseLogicalChannel(int32_t slotId, int32_t serialId, int32_t channelId) override;
123094332d3Sopenharmony_ci    int32_t SimTransmitApduLogicalChannel(
124094332d3Sopenharmony_ci        int32_t slotId, int32_t serialId, const ApduSimIORequestInfo &apduSimIO) override;
125094332d3Sopenharmony_ci    int32_t SimTransmitApduBasicChannel(
126094332d3Sopenharmony_ci        int32_t slotId, int32_t serialId, const ApduSimIORequestInfo &apduSimIO) override;
127094332d3Sopenharmony_ci    int32_t SimAuthentication(
128094332d3Sopenharmony_ci        int32_t slotId, int32_t serialId, const SimAuthenticationRequestInfo &simAuthInfo) override;
129094332d3Sopenharmony_ci    int32_t UnlockSimLock(int32_t slotId, int32_t serialId, int32_t lockType, const std::string &key) override;
130094332d3Sopenharmony_ci    int32_t SendSimMatchedOperatorInfo(
131094332d3Sopenharmony_ci        int32_t slotId, int32_t serialId, const NcfgOperatorInfo &ncfgOperatorInfo) override;
132094332d3Sopenharmony_ci
133094332d3Sopenharmony_ci    // Network
134094332d3Sopenharmony_ci    int32_t GetSignalStrength(int32_t slotId, int32_t serialId) override;
135094332d3Sopenharmony_ci    int32_t GetCsRegStatus(int32_t slotId, int32_t serialId) override;
136094332d3Sopenharmony_ci    int32_t GetPsRegStatus(int32_t slotId, int32_t serialId) override;
137094332d3Sopenharmony_ci    int32_t GetOperatorInfo(int32_t slotId, int32_t serialId) override;
138094332d3Sopenharmony_ci    int32_t GetNetworkSearchInformation(int32_t slotId, int32_t serialId) override;
139094332d3Sopenharmony_ci    int32_t GetNetworkSelectionMode(int32_t slotId, int32_t serialId) override;
140094332d3Sopenharmony_ci    int32_t SetNetworkSelectionMode(
141094332d3Sopenharmony_ci        int32_t slotId, int32_t serialId, const SetNetworkModeInfo &networkModeInfo) override;
142094332d3Sopenharmony_ci    int32_t GetNeighboringCellInfoList(int32_t slotId, int32_t serialId) override;
143094332d3Sopenharmony_ci    int32_t GetCurrentCellInfo(int32_t slotId, int32_t serialId) override;
144094332d3Sopenharmony_ci    int32_t SetPreferredNetwork(int32_t slotId, int32_t serialId, int32_t preferredNetworkType) override;
145094332d3Sopenharmony_ci    int32_t GetPreferredNetwork(int32_t slotId, int32_t serialId) override;
146094332d3Sopenharmony_ci    int32_t GetPhysicalChannelConfig(int32_t slotId, int32_t serialId) override;
147094332d3Sopenharmony_ci    int32_t SetLocateUpdates(int32_t slotId, int32_t serialId, const RilRegNotifyMode mode) override;
148094332d3Sopenharmony_ci    int32_t SetNotificationFilter(int32_t slotId, int32_t serialId, int32_t newFilter) override;
149094332d3Sopenharmony_ci    int32_t SetDeviceState(int32_t slotId, int32_t serialId, int32_t deviceStateType, int32_t deviceStateOn) override;
150094332d3Sopenharmony_ci    int32_t SetNrOptionMode(int32_t slotId, int32_t serialId, int32_t mode) override;
151094332d3Sopenharmony_ci    int32_t GetNrOptionMode(int32_t slotId, int32_t serialId) override;
152094332d3Sopenharmony_ci    int32_t GetRrcConnectionState(int32_t slotId, int32_t serialId) override;
153094332d3Sopenharmony_ci    int32_t GetNrSsbId(int32_t slotId, int32_t serialId) override;
154094332d3Sopenharmony_ci
155094332d3Sopenharmony_ci    // Sms
156094332d3Sopenharmony_ci    int32_t SendGsmSms(int32_t slotId, int32_t serialId, const GsmSmsMessageInfo &gsmSmsMessageInfo) override;
157094332d3Sopenharmony_ci    int32_t SendCdmaSms(int32_t slotId, int32_t serialId, const SendCdmaSmsMessageInfo &cdmaSmsMessageInfo) override;
158094332d3Sopenharmony_ci    int32_t AddSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo) override;
159094332d3Sopenharmony_ci    int32_t DelSimMessage(int32_t slotId, int32_t serialId, int32_t index) override;
160094332d3Sopenharmony_ci    int32_t UpdateSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo) override;
161094332d3Sopenharmony_ci    int32_t AddCdmaSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo) override;
162094332d3Sopenharmony_ci    int32_t DelCdmaSimMessage(int32_t slotId, int32_t serialId, int32_t index) override;
163094332d3Sopenharmony_ci    int32_t UpdateCdmaSimMessage(int32_t slotId, int32_t serialId, const SmsMessageIOInfo &smsMessageIOInfo) override;
164094332d3Sopenharmony_ci    int32_t SetSmscAddr(int32_t slotId, int32_t serialId, const ServiceCenterAddress &serviceCenterAddress) override;
165094332d3Sopenharmony_ci    int32_t GetSmscAddr(int32_t slotId, int32_t serialId) override;
166094332d3Sopenharmony_ci    int32_t SetCBConfig(int32_t slotId, int32_t serialId, const CBConfigInfo &cellBroadcastInfo) override;
167094332d3Sopenharmony_ci    int32_t GetCBConfig(int32_t slotId, int32_t serialId) override;
168094332d3Sopenharmony_ci    int32_t SetCdmaCBConfig(
169094332d3Sopenharmony_ci        int32_t slotId, int32_t serialId, const CdmaCBConfigInfoList &cdmaCBConfigInfoList) override;
170094332d3Sopenharmony_ci    int32_t GetCdmaCBConfig(int32_t slotId, int32_t serialId) override;
171094332d3Sopenharmony_ci    int32_t SendSmsMoreMode(int32_t slotId, int32_t serialId, const GsmSmsMessageInfo &gsmSmsMessageInfo) override;
172094332d3Sopenharmony_ci    int32_t SendSmsAck(int32_t slotId, int32_t serialId, const ModeData &modeData) override;
173094332d3Sopenharmony_ci
174094332d3Sopenharmony_ci    int32_t SendRilAck() override;
175094332d3Sopenharmony_ci
176094332d3Sopenharmony_ci    int32_t SetCallback(const sptr<V1_1::IRilCallback> &rilCallback) override;
177094332d3Sopenharmony_ci    int32_t SetCallback1_2(const sptr<V1_2::IRilCallback> &rilCallback) override;
178094332d3Sopenharmony_ci    int32_t SetCallback1_3(const sptr<V1_3::IRilCallback> &rilCallback) override;
179094332d3Sopenharmony_ci    int32_t Init();
180094332d3Sopenharmony_ci    class RilDeathRecipient : public IRemoteObject::DeathRecipient {
181094332d3Sopenharmony_ci    public:
182094332d3Sopenharmony_ci        explicit RilDeathRecipient(const wptr<RilImpl> &rilInterfaceImpl) : rilInterfaceImpl_(rilInterfaceImpl) {}
183094332d3Sopenharmony_ci        virtual ~RilDeathRecipient() = default;
184094332d3Sopenharmony_ci        virtual void OnRemoteDied(const wptr<IRemoteObject> &object) override;
185094332d3Sopenharmony_ci
186094332d3Sopenharmony_ci    private:
187094332d3Sopenharmony_ci        wptr<RilImpl> rilInterfaceImpl_;
188094332d3Sopenharmony_ci    };
189094332d3Sopenharmony_ci
190094332d3Sopenharmony_ci    template<typename FuncType, typename... ParamTypes>
191094332d3Sopenharmony_ci    inline int32_t TaskSchedule(FuncType &&_func, int32_t slotId, ParamTypes &&... _args) const
192094332d3Sopenharmony_ci    {
193094332d3Sopenharmony_ci        if (_func == nullptr || Telephony::HRilManager::manager_ == nullptr) {
194094332d3Sopenharmony_ci            HDF_LOGE("manager or func is null pointer");
195094332d3Sopenharmony_ci            return RIL_ERR_NULL_POINT;
196094332d3Sopenharmony_ci        }
197094332d3Sopenharmony_ci        if (slotId >= Telephony::HRilManager::manager_->GetMaxSimSlotCount()) {
198094332d3Sopenharmony_ci            HDF_LOGE("slotId is inValid");
199094332d3Sopenharmony_ci            return RIL_ERR_INVALID_PARAMETER;
200094332d3Sopenharmony_ci        }
201094332d3Sopenharmony_ci        auto ret = (Telephony::HRilManager::manager_.get()->*(_func))(slotId, std::forward<ParamTypes>(_args)...);
202094332d3Sopenharmony_ci        return ret;
203094332d3Sopenharmony_ci    }
204094332d3Sopenharmony_ci
205094332d3Sopenharmony_ciprivate:
206094332d3Sopenharmony_ci    int32_t UnRegister();
207094332d3Sopenharmony_ci    int32_t AddRilDeathRecipient(const sptr<IRilCallback> &callback);
208094332d3Sopenharmony_ci    int32_t RemoveRilDeathRecipient(const sptr<IRilCallback> &callback);
209094332d3Sopenharmony_ci};
210094332d3Sopenharmony_ci} // namespace V1_3
211094332d3Sopenharmony_ci} // namespace Ril
212094332d3Sopenharmony_ci} // namespace HDI
213094332d3Sopenharmony_ci} // namespace OHOS
214094332d3Sopenharmony_ci#endif // OHOS_HDI_RIL_V1_0_RILIMPL_H
215