1 /* 2 * Copyright (C) 2025-2025 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_ESIM_MANAGER_H 17 #define OHOS_ESIM_MANAGER_H 18 19 #include "i_esim_manager.h" 20 #include "i_tel_ril_manager.h" 21 22 #ifdef CORE_SERVICE_SUPPORT_ESIM 23 #include "esim_file.h" 24 #endif 25 26 namespace OHOS { 27 namespace Telephony { 28 const int32_t ESIM_SLOT_ID_ZERO = 0; 29 const int32_t ESIM_MAX_SLOT_COUNT = 3; 30 class EsimManager : public IEsimManager { 31 public: 32 explicit EsimManager(std::shared_ptr<ITelRilManager> telRilManager); 33 virtual ~EsimManager(); 34 // Init 35 bool OnInit(int32_t slotCount) override; 36 int32_t GetEid(int32_t slotId, std::u16string &eId) override; 37 int32_t GetEuiccProfileInfoList(int32_t slotId, GetEuiccProfileInfoListInnerResult &euiccProfileInfoList) override; 38 int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo) override; 39 int32_t DisableProfile( 40 int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, int32_t &enumResult) override; 41 int32_t GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress) override; 42 int32_t GetRulesAuthTable(int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable) override; 43 int32_t GetEuiccChallenge(int32_t slotId, int32_t portIndex, ResponseEsimInnerResult &responseResult) override; 44 int32_t GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress) override; 45 int32_t CancelSession(int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason, 46 ResponseEsimInnerResult &responseResult) override; 47 int32_t GetProfile( 48 int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile) override; 49 int32_t ResetMemory(int32_t slotId, ResetOption resetOption, int32_t &enumResult) override; 50 int32_t SetDefaultSmdpAddress( 51 int32_t slotId, const std::u16string &defaultSmdpAddress, int32_t &enumResult) override; 52 bool IsSupported(int32_t slotId) override; 53 int32_t SendApduData(int32_t slotId, const std::u16string &aid, const EsimApduData &apduData, 54 ResponseEsimInnerResult &responseResult) override; 55 int32_t PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo, 56 ResponseEsimInnerResult &responseResult) override; 57 int32_t LoadBoundProfilePackage(int32_t slotId, int32_t portIndex, const std::u16string &boundProfilePackage, 58 ResponseEsimBppResult &responseResult) override; 59 int32_t ListNotifications(int32_t slotId, int32_t portIndex, EsimEvent events, 60 EuiccNotificationList ¬ificationList) override; 61 int32_t RetrieveNotificationList( 62 int32_t slotId, int32_t portIndex, EsimEvent events, EuiccNotificationList ¬ificationList) override; 63 int32_t RetrieveNotification( 64 int32_t slotId, int32_t portIndex, int32_t seqNumber, EuiccNotification ¬ification) override; 65 int32_t RemoveNotificationFromList( 66 int32_t slotId, int32_t portIndex, int32_t seqNumber, int32_t &enumResult) override; 67 int32_t GetEuiccInfo2(int32_t slotId, int32_t portIndex, EuiccInfo2 &euiccInfo2) override; 68 int32_t AuthenticateServer(int32_t slotId, const AuthenticateConfigInfo &authenticateConfigInfo, 69 ResponseEsimInnerResult &responseResult) override; 70 int32_t DeleteProfile(int32_t slotId, const std::u16string &iccId, int32_t &enumResult) override; 71 int32_t SwitchToProfile(int32_t slotId, int32_t portIndex, const std::u16string &iccId, 72 bool forceDisableProfile, int32_t &enumResult) override; 73 int32_t SetProfileNickname( 74 int32_t slotId, const std::u16string &iccId, const std::u16string &nickname, int32_t &enumResult) override; 75 int32_t GetContractInfo( 76 int32_t slotId, const GetContractInfoRequest &getContractInfoRequest, std::string& response) override; 77 78 private: 79 template<class N> 80 bool IsValidSlotId(int32_t slotId, std::vector<N> vec); 81 private: 82 std::shared_ptr<Telephony::ITelRilManager> telRilManager_ = nullptr; 83 int32_t slotCount_ = ESIM_MAX_SLOT_COUNT; 84 #ifdef CORE_SERVICE_SUPPORT_ESIM 85 std::vector<std::shared_ptr<Telephony::EsimFile>> esimFiles_; 86 std::vector<std::shared_ptr<Telephony::EsimFile>> esimFilesLowPriority_; 87 #endif 88 }; 89 } // namespace Telephony 90 } // namespace OHOS 91 #endif // OHOS_ESIM_MANAGER_H