111fccf17Sopenharmony_ci/* 211fccf17Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd. 311fccf17Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 411fccf17Sopenharmony_ci * you may not use this file except in compliance with the License. 511fccf17Sopenharmony_ci * You may obtain a copy of the License at 611fccf17Sopenharmony_ci * 711fccf17Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 811fccf17Sopenharmony_ci * 911fccf17Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1011fccf17Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1111fccf17Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1211fccf17Sopenharmony_ci * See the License for the specific language governing permissions and 1311fccf17Sopenharmony_ci * limitations under the License. 1411fccf17Sopenharmony_ci */ 1511fccf17Sopenharmony_ci 1611fccf17Sopenharmony_ci#ifndef OHOS_HRIL_SIM_H 1711fccf17Sopenharmony_ci#define OHOS_HRIL_SIM_H 1811fccf17Sopenharmony_ci 1911fccf17Sopenharmony_ci#include "hril_base.h" 2011fccf17Sopenharmony_ci 2111fccf17Sopenharmony_cinamespace OHOS { 2211fccf17Sopenharmony_cinamespace Telephony { 2311fccf17Sopenharmony_ciclass HRilSim : public HRilBase { 2411fccf17Sopenharmony_cipublic: 2511fccf17Sopenharmony_ci HRilSim(int32_t slotId); 2611fccf17Sopenharmony_ci virtual ~HRilSim() = default; 2711fccf17Sopenharmony_ci 2811fccf17Sopenharmony_ci void ProcessSimRequest(int32_t code, struct HdfSBuf *data); 2911fccf17Sopenharmony_ci void ProcessSimResponse( 3011fccf17Sopenharmony_ci int32_t code, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen); 3111fccf17Sopenharmony_ci void ProcessSimNotify(const struct ReportInfo *reportInfo, const void *response, size_t responseLen); 3211fccf17Sopenharmony_ci bool IsSimRespOrNotify(uint32_t code); 3311fccf17Sopenharmony_ci void RegisterSimFuncs(const HRilSimReq *simFuncs); 3411fccf17Sopenharmony_ci int32_t GetSimIO(int32_t serialId, const OHOS::HDI::Ril::V1_1::SimIoRequestInfo &simIO); 3511fccf17Sopenharmony_ci int32_t GetSimStatus(int32_t serialId); 3611fccf17Sopenharmony_ci int32_t GetImsi(int32_t serialId); 3711fccf17Sopenharmony_ci int32_t GetSimLockStatus(int32_t serialId, const OHOS::HDI::Ril::V1_1::SimLockInfo &simLockInfo); 3811fccf17Sopenharmony_ci int32_t SetSimLock(int32_t serialId, const OHOS::HDI::Ril::V1_1::SimLockInfo &simLockInfo); 3911fccf17Sopenharmony_ci int32_t ChangeSimPassword(int32_t serialId, const OHOS::HDI::Ril::V1_1::SimPasswordInfo &simPassword); 4011fccf17Sopenharmony_ci int32_t UnlockPin(int32_t serialId, const std::string &pin); 4111fccf17Sopenharmony_ci int32_t UnlockPuk(int32_t serialId, const std::string &puk, const std::string &pin); 4211fccf17Sopenharmony_ci int32_t UnlockPin2(int32_t serialId, const std::string &pin2); 4311fccf17Sopenharmony_ci int32_t UnlockPuk2(int32_t serialId, const std::string &puk2, const std::string &pin2); 4411fccf17Sopenharmony_ci int32_t SetActiveSim(int32_t serialId, int32_t index, int32_t enable); 4511fccf17Sopenharmony_ci int32_t SimStkSendTerminalResponse(int32_t serialId, const std::string &strCmd); 4611fccf17Sopenharmony_ci int32_t SimStkSendEnvelope(int32_t serialId, const std::string &strCmd); 4711fccf17Sopenharmony_ci int32_t SimStkSendCallSetupRequestResult(int32_t serialId, int32_t accept); 4811fccf17Sopenharmony_ci int32_t SimStkIsReady(int32_t serialId); 4911fccf17Sopenharmony_ci int32_t GetRadioProtocol(int32_t serialId); 5011fccf17Sopenharmony_ci int32_t SetRadioProtocol(int32_t serialId, const HDI::Ril::V1_1::RadioProtocol &radioProtocol); 5111fccf17Sopenharmony_ci int32_t SimOpenLogicalChannel(int32_t serialId, const std::string &appID, int32_t p2); 5211fccf17Sopenharmony_ci int32_t SimCloseLogicalChannel(int32_t serialId, int32_t channelId); 5311fccf17Sopenharmony_ci int32_t SimTransmitApduLogicalChannel( 5411fccf17Sopenharmony_ci int32_t serialId, const OHOS::HDI::Ril::V1_1::ApduSimIORequestInfo &apduSimIO); 5511fccf17Sopenharmony_ci int32_t SimTransmitApduBasicChannel(int32_t serialId, const OHOS::HDI::Ril::V1_1::ApduSimIORequestInfo &apduSimIO); 5611fccf17Sopenharmony_ci int32_t SimAuthentication(int32_t serialId, const OHOS::HDI::Ril::V1_1::SimAuthenticationRequestInfo &simAuthInfo); 5711fccf17Sopenharmony_ci int32_t UnlockSimLock(int32_t serialId, int32_t lockType, const std::string &key); 5811fccf17Sopenharmony_ci int32_t SendSimMatchedOperatorInfo( 5911fccf17Sopenharmony_ci int32_t serialId, const OHOS::HDI::Ril::V1_2::NcfgOperatorInfo &ncfgOperatorInfo); 6011fccf17Sopenharmony_ci 6111fccf17Sopenharmony_ciprivate: 6211fccf17Sopenharmony_ci void AddBasicHandlerToMap(); 6311fccf17Sopenharmony_ci void AddSimLockHandlerToMap(); 6411fccf17Sopenharmony_ci void AddStkHandlerToMap(); 6511fccf17Sopenharmony_ci void AddNotificationHandlerToMap(); 6611fccf17Sopenharmony_ci int32_t GetSimIOResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 6711fccf17Sopenharmony_ci const void *response, size_t responseLen); 6811fccf17Sopenharmony_ci int32_t GetSimCardStatusResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 6911fccf17Sopenharmony_ci const void *response, size_t responseLen); 7011fccf17Sopenharmony_ci int32_t GetImsiResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 7111fccf17Sopenharmony_ci const void *response, size_t responseLen); 7211fccf17Sopenharmony_ci int32_t GetSimLockStatusResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 7311fccf17Sopenharmony_ci const void *response, size_t responseLen); 7411fccf17Sopenharmony_ci int32_t SetSimLockResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 7511fccf17Sopenharmony_ci const void *response, size_t responseLen); 7611fccf17Sopenharmony_ci int32_t ChangeSimPasswordResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 7711fccf17Sopenharmony_ci const void *response, size_t responseLen); 7811fccf17Sopenharmony_ci int32_t UnlockPinResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 7911fccf17Sopenharmony_ci const void *response, size_t responseLen); 8011fccf17Sopenharmony_ci int32_t UnlockPukResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 8111fccf17Sopenharmony_ci const void *response, size_t responseLen); 8211fccf17Sopenharmony_ci int32_t UnlockPin2Response(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 8311fccf17Sopenharmony_ci const void *response, size_t responseLen); 8411fccf17Sopenharmony_ci int32_t UnlockPuk2Response(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 8511fccf17Sopenharmony_ci const void *response, size_t responseLen); 8611fccf17Sopenharmony_ci int32_t SetActiveSimResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 8711fccf17Sopenharmony_ci const void *response, size_t responseLen); 8811fccf17Sopenharmony_ci int32_t SimStkSendTerminalResponseResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 8911fccf17Sopenharmony_ci const void *response, size_t responseLen); 9011fccf17Sopenharmony_ci int32_t SimStkSendEnvelopeResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 9111fccf17Sopenharmony_ci const void *response, size_t responseLen); 9211fccf17Sopenharmony_ci int32_t SimStkSendCallSetupRequestResultResponse(int32_t requestNum, 9311fccf17Sopenharmony_ci HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen); 9411fccf17Sopenharmony_ci int32_t SimStkIsReadyResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 9511fccf17Sopenharmony_ci const void *response, size_t responseLen); 9611fccf17Sopenharmony_ci int32_t GetRadioProtocolResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 9711fccf17Sopenharmony_ci const void *response, size_t responseLen); 9811fccf17Sopenharmony_ci int32_t SetRadioProtocolResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 9911fccf17Sopenharmony_ci const void *response, size_t responseLen); 10011fccf17Sopenharmony_ci int32_t SimOpenLogicalChannelResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 10111fccf17Sopenharmony_ci const void *response, size_t responseLen); 10211fccf17Sopenharmony_ci int32_t SimCloseLogicalChannelResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 10311fccf17Sopenharmony_ci const void *response, size_t responseLen); 10411fccf17Sopenharmony_ci int32_t SimTransmitApduLogicalChannelResponse(int32_t requestNum, 10511fccf17Sopenharmony_ci HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen); 10611fccf17Sopenharmony_ci int32_t SimTransmitApduBasicChannelResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 10711fccf17Sopenharmony_ci const void *response, size_t responseLen); 10811fccf17Sopenharmony_ci int32_t SimAuthenticationResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 10911fccf17Sopenharmony_ci const void *response, size_t responseLen); 11011fccf17Sopenharmony_ci int32_t UnlockSimLockResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 11111fccf17Sopenharmony_ci const void *response, size_t responseLen); 11211fccf17Sopenharmony_ci HDI::Ril::V1_1::IccIoResultInfo ProcessIccIoResponse(HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 11311fccf17Sopenharmony_ci const void *response, size_t responseLen); 11411fccf17Sopenharmony_ci int32_t SendSimMatchedOperatorInfoResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 11511fccf17Sopenharmony_ci const void *response, size_t responseLen); 11611fccf17Sopenharmony_ci 11711fccf17Sopenharmony_ci int32_t SimStateUpdated(int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen); 11811fccf17Sopenharmony_ci int32_t SimStkSessionEndNotify( 11911fccf17Sopenharmony_ci int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen); 12011fccf17Sopenharmony_ci int32_t SimStkProactiveNotify( 12111fccf17Sopenharmony_ci int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen); 12211fccf17Sopenharmony_ci int32_t SimStkAlphaNotify(int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen); 12311fccf17Sopenharmony_ci int32_t SimStkEventNotify(int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen); 12411fccf17Sopenharmony_ci int32_t SimStkCallSetupNotify( 12511fccf17Sopenharmony_ci int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen); 12611fccf17Sopenharmony_ci int32_t SimRefreshNotify(int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen); 12711fccf17Sopenharmony_ci int32_t SimRadioProtocolUpdated( 12811fccf17Sopenharmony_ci int32_t notifyType, const HRilErrNumber error, const void *response, size_t responseLen); 12911fccf17Sopenharmony_ci 13011fccf17Sopenharmony_ciprivate: 13111fccf17Sopenharmony_ci bool IsSimResponse(uint32_t code); 13211fccf17Sopenharmony_ci bool IsSimNotification(uint32_t code); 13311fccf17Sopenharmony_ci void CopyToHRilSimIO(std::unique_ptr<HRilSimIO> &rilSimIO, const OHOS::HDI::Ril::V1_1::SimIoRequestInfo &simIO); 13411fccf17Sopenharmony_ci void CopyToHRilSimLock( 13511fccf17Sopenharmony_ci std::unique_ptr<HRilSimClock> &rilSimLock, const OHOS::HDI::Ril::V1_1::SimLockInfo &simLockInfo); 13611fccf17Sopenharmony_ci void CopyToHRilSimPassword( 13711fccf17Sopenharmony_ci std::unique_ptr<HRilSimPassword> &rilSimPassword, const OHOS::HDI::Ril::V1_1::SimPasswordInfo &simPassword); 13811fccf17Sopenharmony_ci void CopyToHRilApduSimIO( 13911fccf17Sopenharmony_ci std::unique_ptr<HRilApduSimIO> &rilApduSimIO, const OHOS::HDI::Ril::V1_1::ApduSimIORequestInfo &apduSimIO); 14011fccf17Sopenharmony_ci void CopyToHRilSimAuthentication(std::unique_ptr<HRilSimAuthenticationRequestInfo> &rilSimAuthInfo, 14111fccf17Sopenharmony_ci const OHOS::HDI::Ril::V1_1::SimAuthenticationRequestInfo &simAuthInfo); 14211fccf17Sopenharmony_ci void CopyToHRilNcfgOperatorInfo(std::unique_ptr<HRilNcfgOperatorInfo> &rilNcfgOperatorInfo, 14311fccf17Sopenharmony_ci const OHOS::HDI::Ril::V1_2::NcfgOperatorInfo &ncfgOperatorInfo); 14411fccf17Sopenharmony_ci bool BuildLockStatusResp(const void *response, size_t responseLen, HDI::Ril::V1_1::LockStatusResp &lockStatus); 14511fccf17Sopenharmony_ci void ResponseLockStatus(HDI::Ril::V1_1::LockStatusResp &lockStatus, 14611fccf17Sopenharmony_ci HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen); 14711fccf17Sopenharmony_ci int32_t BuildSimIOResp(HDI::Ril::V1_1::IccIoResultInfo &result, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 14811fccf17Sopenharmony_ci const void *response, size_t responseLen); 14911fccf17Sopenharmony_ci int32_t CheckCharData(const void *response, size_t responseLen); 15011fccf17Sopenharmony_ci void BuildRadioProtocol(HDI::Ril::V1_1::RadioProtocol &radioProtocol, const void *response); 15111fccf17Sopenharmony_ci int32_t ConvertRadioProtocolTech(int32_t tech); 15211fccf17Sopenharmony_ci 15311fccf17Sopenharmony_ciprivate: 15411fccf17Sopenharmony_ci const HRilSimReq *simFuncs_ = nullptr; 15511fccf17Sopenharmony_ci}; 15611fccf17Sopenharmony_ci} // namespace Telephony 15711fccf17Sopenharmony_ci} // namespace OHOS 15811fccf17Sopenharmony_ci#endif // OHOS_HRIL_SIM_H 159