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