• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 OHOS_I_SIM_MANAGER_H
17 #define OHOS_I_SIM_MANAGER_H
18 
19 #include "dialling_numbers_info.h"
20 #ifdef CORE_SERVICE_SUPPORT_ESIM
21 #include "download_profile_config_info_parcel.h"
22 #include "download_profile_result_parcel.h"
23 #include "downloadable_profile_parcel.h"
24 #include "esim_state_type.h"
25 #include "euicc_info_parcel.h"
26 #include "get_downloadable_profiles_result_parcel.h"
27 #include "profile_info_list_parcel.h"
28 #include "profile_metadata_result_parcel.h"
29 #include "response_esim_result.h"
30 #endif
31 #include "event_handler.h"
32 #include "operator_config_types.h"
33 #include "sim_account_callback.h"
34 #include "sim_state_type.h"
35 
36 namespace OHOS {
37 namespace Telephony {
38 class ISimManager {
39 public:
40     using HANDLE = const std::shared_ptr<AppExecFwk::EventHandler>;
41     // Init
42     virtual bool OnInit(int32_t slotCount) = 0;
43     virtual int32_t InitTelExtraModule(int32_t slotId) = 0;
44     // SimState
45     virtual int32_t HasSimCard(int32_t slotId, bool &hasSimCard) = 0;
46     virtual int32_t GetSimState(int32_t slotId, SimState &simState) = 0;
47     virtual int32_t GetSimIccStatus(int32_t slotId, IccSimStatus &iccStatus) = 0;
48     virtual int32_t GetCardType(int32_t slotId, CardType &cardType) = 0;
49     virtual int32_t SetModemInit(int32_t slotId, bool state) = 0;
50     virtual int32_t UnlockPin(int32_t slotId, const std::string &pin, LockStatusResponse &response) = 0;
51     virtual int32_t UnlockPuk(
52         int32_t slotId, const std::string &newPin, const std::string &puk, LockStatusResponse &response) = 0;
53     virtual int32_t AlterPin(
54         int32_t slotId, const std::string &newPin, const std::string &oldPin, LockStatusResponse &response) = 0;
55     virtual int32_t SetLockState(int32_t slotId, const LockInfo &options, LockStatusResponse &response) = 0;
56     virtual int32_t GetLockState(int32_t slotId, LockType lockType, LockState &lockState) = 0;
57     virtual int32_t RefreshSimState(int32_t slotId) = 0;
58     virtual int32_t UnlockPin2(int32_t slotId, const std::string &pin2, LockStatusResponse &response) = 0;
59     virtual int32_t UnlockPuk2(
60         int32_t slotId, const std::string &newPin2, const std::string &puk2, LockStatusResponse &response) = 0;
61     virtual int32_t AlterPin2(
62         int32_t slotId, const std::string &newPin2, const std::string &oldPin2, LockStatusResponse &response) = 0;
63     virtual int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response) = 0;
64     // SimAccount
65     virtual bool IsSimActive(int32_t slotId) = 0;
66     virtual int32_t SetActiveSim(int32_t slotId, int32_t enable) = 0;
67     virtual int32_t SetActiveSimSatellite(int32_t slotId, int32_t enable) = 0;
68     virtual int32_t ResetSimLoadAccount(int32_t slotId) = 0;
69     virtual int32_t GetSimAccountInfo(int32_t slotId, bool denied, IccAccountInfo &info) = 0;
70     virtual int32_t SetDefaultVoiceSlotId(int32_t slotId) = 0;
71     virtual int32_t SetDefaultSmsSlotId(int32_t slotId) = 0;
72     virtual int32_t SetDefaultCellularDataSlotId(int32_t slotId) = 0;
73     virtual int32_t SetPrimarySlotId(int32_t slotId) = 0;
74     virtual int32_t SetShowNumber(int32_t slotId, const std::u16string &number) = 0;
75     virtual int32_t SetShowName(int32_t slotId, const std::u16string &name) = 0;
76     virtual int32_t GetDefaultVoiceSlotId() = 0;
77     virtual int32_t GetDefaultVoiceSimId(int32_t &simId) = 0;
78     virtual int32_t GetDefaultSmsSlotId() = 0;
79     virtual int32_t GetDefaultSmsSimId(int32_t &simId) = 0;
80     virtual int32_t GetDefaultCellularDataSlotId() = 0;
81     virtual int32_t GetDefaultCellularDataSimId(int32_t &simId) = 0;
82     virtual int32_t RegisterSimAccountCallback(
83         const int32_t tokenId, const sptr<SimAccountCallback> &callback) = 0;
84     virtual int32_t UnregisterSimAccountCallback(const sptr<SimAccountCallback> &callback) = 0;
85     virtual int32_t GetPrimarySlotId(int32_t &slotId) = 0;
86     virtual int32_t GetShowNumber(int32_t slotId, std::u16string &showNumber) = 0;
87     virtual int32_t GetShowName(int32_t slotId, std::u16string &showName) = 0;
88     virtual int32_t GetActiveSimAccountInfoList(bool denied, std::vector<IccAccountInfo> &iccAccountInfoList) = 0;
89     virtual int32_t GetOperatorConfigs(int slotId, OperatorConfig &poc) = 0;
90     virtual int32_t UpdateOperatorConfigs(int32_t slotId) = 0;
91     virtual int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) = 0;
92     virtual int32_t SimAuthentication(
93         int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) = 0;
94     virtual int32_t GetRadioProtocolTech(int32_t slotId) = 0;
95     virtual void GetRadioProtocol(int32_t slotId) = 0;
96     virtual int32_t GetDsdsMode(int32_t &dsdsMode) = 0;
97     virtual int32_t SetDsdsMode(int32_t dsdsMode) = 0;
98     virtual int32_t SendSimMatchedOperatorInfo(
99         int32_t slotId, int32_t state, const std::string &operName, const std::string &operKey) = 0;
100     // STK
101     virtual int32_t SendEnvelopeCmd(int32_t slotId, const std::string &cmd) = 0;
102     virtual int32_t SendTerminalResponseCmd(int32_t slotId, const std::string &cmd) = 0;
103     virtual int32_t SendCallSetupRequestResult(int32_t slotId, bool accept) = 0;
104     // SimFile
105     virtual int32_t GetSimOperatorNumeric(int32_t slotId, std::u16string &operatorNumeric) = 0;
106     virtual int32_t GetISOCountryCodeForSim(int32_t slotId, std::u16string &countryCode) = 0;
107     virtual int32_t GetSimSpn(int32_t slotId, std::u16string &spn) = 0;
108     virtual int32_t GetSimIccId(int32_t slotId, std::u16string &iccId) = 0;
109     virtual int32_t GetIMSI(int32_t slotId, std::u16string &imsi) = 0;
110     virtual std::u16string GetLocaleFromDefaultSim(int32_t slotId) = 0;
111     virtual int32_t GetSlotId(int32_t simId) = 0;
112     virtual int32_t GetSimId(int32_t slotId) = 0;
113     virtual int32_t GetSimGid1(int32_t slotId, std::u16string &gid1) = 0;
114     virtual std::u16string GetSimGid2(int32_t slotId) = 0;
115     virtual int32_t GetOpName(int32_t slotId, std::u16string &opname) = 0;
116     virtual int32_t GetOpKey(int32_t slotId, std::u16string &opkey) = 0;
117     virtual int32_t GetOpKeyExt(int32_t slotId, std::u16string &opkeyExt) = 0;
118     virtual int32_t GetSimTelephoneNumber(int32_t slotId, std::u16string &telephoneNumber) = 0;
119     virtual std::u16string GetSimTeleNumberIdentifier(const int32_t slotId) = 0;
120     virtual int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier) = 0;
121     virtual int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber) = 0;
122     virtual int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount) = 0;
123     virtual int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount) = 0;
124     virtual int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number) = 0;
125     virtual std::u16string GetSimIst(int32_t slotId) = 0;
126     virtual int ObtainSpnCondition(int32_t slotId, bool roaming, std::string operatorNum) = 0;
127     virtual int32_t SetVoiceMailInfo(
128         int32_t slotId, const std::u16string &mailName, const std::u16string &mailNumber) = 0;
129     virtual std::u16string GetSimEons(int32_t slotId, const std::string &plmn, int32_t lac, bool longNameRequired) = 0;
130     virtual int32_t IsCTSimCard(int32_t slotId, bool &isCTSimCard) = 0;
131     // SimSms
132     virtual int32_t AddSmsToIcc(int32_t slotId, int status, std::string &pdu, std::string &smsc) = 0;
133     virtual int32_t UpdateSmsIcc(int32_t slotId, int index, int status, std::string &pduData, std::string &smsc) = 0;
134     virtual int32_t DelSmsIcc(int32_t slotId, int index) = 0;
135     virtual std::vector<std::string> ObtainAllSmsOfIcc(int32_t slotId) = 0;
136     // IccDiallingNumbers
137     virtual int32_t QueryIccDiallingNumbers(
138         int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result) = 0;
139     virtual int32_t AddIccDiallingNumbers(
140         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) = 0;
141     virtual int32_t DelIccDiallingNumbers(
142         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) = 0;
143     virtual int32_t UpdateIccDiallingNumbers(
144         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) = 0;
145     // Event register
146     virtual void RegisterCoreNotify(int32_t slotId, const HANDLE &handler, int what) = 0;
147     virtual void UnRegisterCoreNotify(int32_t slotId, const HANDLE &observerCallBack, int what) = 0;
148     // Ims Switch
149     virtual int32_t SaveImsSwitch(int32_t slotId, int32_t imsSwitchValue) = 0;
150     virtual int32_t QueryImsSwitch(int32_t slotId, int32_t &imsSwitchValue) = 0;
151 
152     virtual bool IsSetActiveSimInProgress(int32_t slotId) = 0;
153     virtual bool IsSetPrimarySlotIdInProgress() = 0;
154     virtual int32_t GetSimIO(int32_t slotId, int32_t command,
155         int32_t fileId, const std::string &data, const std::string &path, SimAuthenticationResponse &response) = 0;
156     virtual int32_t SavePrimarySlotId(int32_t slotId) = 0;
157     // Get OpkeyDb connect error
158     virtual bool IsDataShareError() = 0;
159     // Reset OpkeyDb connect error
160     virtual void ResetDataShareError() = 0;
161     virtual void UpdateImsCapFromChip(int32_t slotId, const ImsCapFromChip &imsCapFromChip) = 0;
162     virtual int32_t GetDefaultMainSlotByIccId() = 0;
163 #ifdef CORE_SERVICE_SUPPORT_ESIM
164     virtual int32_t GetEid(int32_t slotId, std::u16string &eId) = 0;
165     virtual int32_t GetEuiccProfileInfoList(int32_t slotId,
166         GetEuiccProfileInfoListInnerResult &euiccProfileInfoList) = 0;
167     virtual int32_t GetEuiccInfo(int32_t slotId, EuiccInfo &eUiccInfo) = 0;
168     virtual int32_t DisableProfile(
169         int32_t slotId, int32_t portIndex, const std::u16string &iccId, bool refresh, int32_t &enumResult) = 0;
170     virtual int32_t GetSmdsAddress(int32_t slotId, int32_t portIndex, std::u16string &smdsAddress) = 0;
171     virtual int32_t GetRulesAuthTable(
172         int32_t slotId, int32_t portIndex, EuiccRulesAuthTable &eUiccRulesAuthTable) = 0;
173     virtual int32_t GetEuiccChallenge(
174         int32_t slotId, int32_t portIndex, ResponseEsimInnerResult &responseResult) = 0;
175     virtual int32_t GetDefaultSmdpAddress(int32_t slotId, std::u16string &defaultSmdpAddress) = 0;
176     virtual int32_t CancelSession(int32_t slotId, const std::u16string &transactionId, CancelReason cancelReason,
177         ResponseEsimInnerResult &responseResult) = 0;
178     virtual int32_t GetProfile(
179         int32_t slotId, int32_t portIndex, const std::u16string &iccId, EuiccProfile &eUiccProfile) = 0;
180     virtual int32_t ResetMemory(int32_t slotId, ResetOption resetOption, int32_t &enumResult) = 0;
181     virtual int32_t SetDefaultSmdpAddress(
182         int32_t slotId, const std::u16string &defaultSmdpAddress, int32_t &enumResult) = 0;
183     virtual bool IsSupported(int32_t slotId) = 0;
184     virtual int32_t SendApduData(int32_t slotId, const std::u16string &aid, const EsimApduData &apduData,
185         ResponseEsimInnerResult &responseResult) = 0;
186     virtual int32_t PrepareDownload(int32_t slotId, const DownLoadConfigInfo &downLoadConfigInfo,
187         ResponseEsimInnerResult &responseResult) = 0;
188     virtual int32_t LoadBoundProfilePackage(int32_t slotId, int32_t portIndex,
189         const std::u16string &boundProfilePackage, ResponseEsimBppResult &responseResult) = 0;
190     virtual int32_t ListNotifications(int32_t slotId, int32_t portIndex, Event events,
191         EuiccNotificationList &notificationList) = 0;
192     virtual int32_t RetrieveNotificationList(
193         int32_t slotId, int32_t portIndex, Event events, EuiccNotificationList &notificationList) = 0;
194     virtual int32_t RetrieveNotification(
195         int32_t slotId, int32_t portIndex, int32_t seqNumber, EuiccNotification &notification) = 0;
196     virtual int32_t RemoveNotificationFromList(
197         int32_t slotId, int32_t portIndex, int32_t seqNumber, int32_t &enumResult) = 0;
198     virtual int32_t DeleteProfile(int32_t slotId, const std::u16string &iccId, int32_t &enumResult) = 0;
199     virtual int32_t SwitchToProfile(int32_t slotId, int32_t portIndex,
200         const std::u16string &iccId, bool forceDisableProfile, int32_t &enumResult) = 0;
201     virtual int32_t SetProfileNickname(
202         int32_t slotId, const std::u16string &iccId, const std::u16string &nickname, int32_t &enumResult) = 0;
203     virtual int32_t GetEuiccInfo2(int32_t slotId, int32_t portIndex, EuiccInfo2 &euiccInfo2) = 0;
204     virtual int32_t AuthenticateServer(int32_t slotId, const AuthenticateConfigInfo &authenticateConfigInfo,
205         ResponseEsimInnerResult &responseResult) = 0;
206 #endif
207 };
208 } // namespace Telephony
209 } // namespace OHOS
210 #endif // OHOS_I_SIM_MANAGER_H
211