• 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 #include "response_esim_result.h"
21 #include <set>
22 #include "event_handler.h"
23 #include "operator_config_types.h"
24 #include "sim_account_callback.h"
25 #include "sim_state_type.h"
26 
27 namespace OHOS {
28 namespace Telephony {
29 class ISimManager {
30 public:
31     using HANDLE = const std::shared_ptr<AppExecFwk::EventHandler>;
32     // Init
33     virtual bool OnInit(int32_t slotCount) = 0;
34     virtual int32_t InitTelExtraModule(int32_t slotId) = 0;
35     // SimState
36     virtual int32_t HasSimCard(int32_t slotId, bool &hasSimCard) = 0;
37     virtual int32_t GetSimState(int32_t slotId, SimState &simState) = 0;
38     virtual int32_t GetSimIccStatus(int32_t slotId, IccSimStatus &iccStatus) = 0;
39     virtual int32_t GetCardType(int32_t slotId, CardType &cardType) = 0;
40     virtual int32_t SetModemInit(int32_t slotId, bool state) = 0;
41     virtual int32_t UnlockPin(int32_t slotId, const std::string &pin, LockStatusResponse &response) = 0;
42     virtual int32_t UnlockPuk(
43         int32_t slotId, const std::string &newPin, const std::string &puk, LockStatusResponse &response) = 0;
44     virtual int32_t AlterPin(
45         int32_t slotId, const std::string &newPin, const std::string &oldPin, LockStatusResponse &response) = 0;
46     virtual int32_t SetLockState(int32_t slotId, const LockInfo &options, LockStatusResponse &response) = 0;
47     virtual int32_t GetLockState(int32_t slotId, LockType lockType, LockState &lockState) = 0;
48     virtual int32_t RefreshSimState(int32_t slotId) = 0;
49     virtual int32_t UnlockPin2(int32_t slotId, const std::string &pin2, LockStatusResponse &response) = 0;
50     virtual int32_t UnlockPuk2(
51         int32_t slotId, const std::string &newPin2, const std::string &puk2, LockStatusResponse &response) = 0;
52     virtual int32_t AlterPin2(
53         int32_t slotId, const std::string &newPin2, const std::string &oldPin2, LockStatusResponse &response) = 0;
54     virtual int32_t UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response) = 0;
55     // SimAccount
56     virtual bool IsSimActive(int32_t slotId) = 0;
57     virtual int32_t SetActiveSim(int32_t slotId, int32_t enable) = 0;
58     virtual int32_t SetActiveSimSatellite(int32_t slotId, int32_t enable) = 0;
59     virtual int32_t ResetSimLoadAccount(int32_t slotId) = 0;
60     virtual int32_t GetSimAccountInfo(int32_t slotId, bool denied, IccAccountInfo &info) = 0;
61     virtual int32_t SetDefaultVoiceSlotId(int32_t slotId) = 0;
62     virtual int32_t SetDefaultSmsSlotId(int32_t slotId) = 0;
63     virtual int32_t SetDefaultCellularDataSlotId(int32_t slotId) = 0;
64     virtual int32_t SetPrimarySlotId(int32_t slotId, bool isUserSet = false) = 0;
65     virtual int32_t SetShowNumber(int32_t slotId, const std::u16string &number) = 0;
66     virtual int32_t SetShowName(int32_t slotId, const std::u16string &name) = 0;
67     virtual int32_t GetDefaultVoiceSlotId() = 0;
68     virtual int32_t GetDefaultVoiceSimId(int32_t &simId) = 0;
69     virtual int32_t GetDefaultSmsSlotId() = 0;
70     virtual int32_t GetDefaultSmsSimId(int32_t &simId) = 0;
71     virtual int32_t GetDefaultCellularDataSlotId() = 0;
72     virtual int32_t GetDefaultCellularDataSimId(int32_t &simId) = 0;
73     virtual int32_t RegisterSimAccountCallback(
74         const int32_t tokenId, const sptr<SimAccountCallback> &callback) = 0;
75     virtual int32_t UnregisterSimAccountCallback(const sptr<SimAccountCallback> &callback) = 0;
76     virtual int32_t GetPrimarySlotId(int32_t &slotId) = 0;
77     virtual int32_t GetShowNumber(int32_t slotId, std::u16string &showNumber) = 0;
78     virtual int32_t GetShowName(int32_t slotId, std::u16string &showName) = 0;
79     virtual int32_t GetActiveSimAccountInfoList(bool denied, std::vector<IccAccountInfo> &iccAccountInfoList) = 0;
80     virtual int32_t GetOperatorConfigs(int slotId, OperatorConfig &poc) = 0;
81     virtual int32_t UpdateOperatorConfigs(int32_t slotId) = 0;
82     virtual int32_t HasOperatorPrivileges(const int32_t slotId, bool &hasOperatorPrivileges) = 0;
83     virtual int32_t SimAuthentication(
84         int32_t slotId, AuthType authType, const std::string &authData, SimAuthenticationResponse &response) = 0;
85     virtual int32_t GetRadioProtocolTech(int32_t slotId) = 0;
86     virtual void GetRadioProtocol(int32_t slotId) = 0;
87     virtual int32_t GetDsdsMode(int32_t &dsdsMode) = 0;
88     virtual int32_t SetDsdsMode(int32_t dsdsMode) = 0;
89     virtual int32_t SendSimMatchedOperatorInfo(
90         int32_t slotId, int32_t state, const std::string &operName, const std::string &operKey) = 0;
91     // STK
92     virtual int32_t SendEnvelopeCmd(int32_t slotId, const std::string &cmd) = 0;
93     virtual int32_t SendTerminalResponseCmd(int32_t slotId, const std::string &cmd) = 0;
94     virtual int32_t SendCallSetupRequestResult(int32_t slotId, bool accept) = 0;
95     // SimFile
96     virtual int32_t GetSimOperatorNumeric(int32_t slotId, std::u16string &operatorNumeric) = 0;
97     virtual int32_t GetISOCountryCodeForSim(int32_t slotId, std::u16string &countryCode) = 0;
98     virtual int32_t GetSimSpn(int32_t slotId, std::u16string &spn) = 0;
99     virtual int32_t GetSimIccId(int32_t slotId, std::u16string &iccId) = 0;
100     virtual int32_t GetIMSI(int32_t slotId, std::u16string &imsi) = 0;
101     virtual int32_t GetSpdiPlmns(int32_t slotId, std::set<std::string> &spdiPlmns) = 0;
102     virtual int32_t GetEhPlmns(int32_t slotId, std::set<std::string> &ehPlmns) = 0;
103     virtual std::u16string GetLocaleFromDefaultSim(int32_t slotId) = 0;
104     virtual int32_t GetSlotId(int32_t simId) = 0;
105     virtual int32_t GetSimId(int32_t slotId) = 0;
106     virtual int32_t GetSimGid1(int32_t slotId, std::u16string &gid1) = 0;
107     virtual std::u16string GetSimGid2(int32_t slotId) = 0;
108     virtual int32_t GetOpName(int32_t slotId, std::u16string &opname) = 0;
109     virtual int32_t GetOpKey(int32_t slotId, std::u16string &opkey) = 0;
110     virtual int32_t GetOpKeyExt(int32_t slotId, std::u16string &opkeyExt) = 0;
111     virtual int32_t GetSimTelephoneNumber(int32_t slotId, std::u16string &telephoneNumber) = 0;
112     virtual std::u16string GetSimTeleNumberIdentifier(const int32_t slotId) = 0;
113     virtual int32_t GetVoiceMailIdentifier(int32_t slotId, std::u16string &voiceMailIdentifier) = 0;
114     virtual int32_t GetVoiceMailNumber(int32_t slotId, std::u16string &voiceMailNumber) = 0;
115     virtual int32_t GetVoiceMailCount(int32_t slotId, int32_t &voiceMailCount) = 0;
116     virtual int32_t SetVoiceMailCount(int32_t slotId, int32_t voiceMailCount) = 0;
117     virtual int32_t SetVoiceCallForwarding(int32_t slotId, bool enable, const std::string &number) = 0;
118     virtual std::u16string GetSimIst(int32_t slotId) = 0;
119     virtual int ObtainSpnCondition(int32_t slotId, bool roaming, std::string operatorNum) = 0;
120     virtual int32_t SetVoiceMailInfo(
121         int32_t slotId, const std::u16string &mailName, const std::u16string &mailNumber) = 0;
122     virtual std::u16string GetSimEons(int32_t slotId, const std::string &plmn, int32_t lac, bool longNameRequired) = 0;
123     virtual int32_t IsCTSimCard(int32_t slotId, bool &isCTSimCard) = 0;
124     // SimSms
125     virtual int32_t AddSmsToIcc(int32_t slotId, int status, std::string &pdu, std::string &smsc) = 0;
126     virtual int32_t UpdateSmsIcc(int32_t slotId, int index, int status, std::string &pduData, std::string &smsc) = 0;
127     virtual int32_t DelSmsIcc(int32_t slotId, int index) = 0;
128     virtual std::vector<std::string> ObtainAllSmsOfIcc(int32_t slotId) = 0;
129     // IccDiallingNumbers
130     virtual int32_t QueryIccDiallingNumbers(
131         int slotId, int type, std::vector<std::shared_ptr<DiallingNumbersInfo>> &result) = 0;
132     virtual int32_t AddIccDiallingNumbers(
133         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) = 0;
134     virtual int32_t DelIccDiallingNumbers(
135         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) = 0;
136     virtual int32_t UpdateIccDiallingNumbers(
137         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) = 0;
138     // Event register
139     virtual void RegisterCoreNotify(int32_t slotId, const HANDLE &handler, int what) = 0;
140     virtual void UnRegisterCoreNotify(int32_t slotId, const HANDLE &observerCallBack, int what) = 0;
141     // Ims Switch
142     virtual int32_t SaveImsSwitch(int32_t slotId, int32_t imsSwitchValue) = 0;
143     virtual int32_t QueryImsSwitch(int32_t slotId, int32_t &imsSwitchValue) = 0;
144 
145     virtual bool IsSetActiveSimInProgress(int32_t slotId) = 0;
146     virtual bool IsSetPrimarySlotIdInProgress() = 0;
147     virtual int32_t GetSimIO(int32_t slotId, int32_t command,
148         int32_t fileId, const std::string &data, const std::string &path, SimAuthenticationResponse &response) = 0;
149     virtual int32_t SavePrimarySlotId(int32_t slotId) = 0;
150     // Get OpkeyDb connect error
151     virtual bool IsDataShareError() = 0;
152     // Reset OpkeyDb connect error
153     virtual void ResetDataShareError() = 0;
154     virtual void UpdateImsCapFromChip(int32_t slotId, const ImsCapFromChip &imsCapFromChip) = 0;
155     virtual int32_t GetDefaultMainSlotByIccId() = 0;
156     virtual int32_t GetAllSimAccountInfoList(bool denied, std::vector<IccAccountInfo> &iccAccountInfoList) = 0;
157     virtual int32_t GetSimLabel(int32_t slotId, SimLabel &simLabel) = 0;
158     virtual int32_t SetSimLabelIndex(const std::string &iccId, int32_t labelIndex) = 0;
159     virtual int32_t NotifySimSlotsMapping(int32_t slotId) = 0;
160     virtual int32_t InsertEsimData(const std::string &iccId, int32_t esimLabel, const std::string &operatorName) = 0;
161 };
162 } // namespace Telephony
163 } // namespace OHOS
164 #endif // OHOS_I_SIM_MANAGER_H
165