• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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_SIM_MANAGER_H
17 #define OHOS_SIM_MANAGER_H
18 
19 #include "event_handler.h"
20 #include "i_sim_manager.h"
21 #include "i_tel_ril_manager.h"
22 #include "sim_state_manager.h"
23 #include "sim_file_manager.h"
24 #include "sim_sms_manager.h"
25 #include "sim_account_manager.h"
26 #include "icc_dialling_numbers_manager.h"
27 #include "stk_manager.h"
28 
29 namespace OHOS {
30 namespace Telephony {
31 const int32_t SLOT_ID_ZERO = 0;
32 class SimManager : public ISimManager {
33 public:
34     SimManager(std::shared_ptr<ITelRilManager> telRilManager);
35     virtual ~SimManager();
36     // Init
37     virtual bool OnInit(int32_t slotCount) override;
38     virtual void SetNetworkSearchManager(int32_t slotCount,
39             std::shared_ptr<INetworkSearch> networkSearchManager) override;
40     // SimState
41     virtual bool HasSimCard(int32_t slotId) override;
42     virtual int32_t GetSimState(int32_t slotId) override;
43     virtual int32_t GetCardType(int32_t slotId) override;
44     virtual bool UnlockPin(int32_t slotId, std::string pin, LockStatusResponse &response) override;
45     virtual bool UnlockPuk(
46         int32_t slotId, std::string newPin, std::string puk, LockStatusResponse &response) override;
47     virtual bool AlterPin(
48         int32_t slotId, std::string newPin, std::string oldPin, LockStatusResponse &response) override;
49     virtual bool SetLockState(int32_t slotId, const LockInfo &options, LockStatusResponse &response) override;
50     virtual int32_t GetLockState(int32_t slotId, LockType lockType) override;
51     virtual int32_t RefreshSimState(int32_t slotId) override;
52     virtual bool UnlockPin2(int32_t slotId, std::string pin2, LockStatusResponse &response) override;
53     virtual bool UnlockPuk2(
54         int32_t slotId, std::string newPin2, std::string puk2, LockStatusResponse &response) override;
55     virtual bool AlterPin2(
56         int32_t slotId, std::string newPin2, std::string oldPin2, LockStatusResponse &response) override;
57     virtual bool UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response) override;
58     // SimAccount
59     virtual bool IsSimActive(int32_t slotId) override;
60     virtual bool SetActiveSim(int32_t slotId, int32_t enable) override;
61     virtual bool GetSimAccountInfo(int32_t slotId, IccAccountInfo &info) override;
62     virtual bool SetDefaultVoiceSlotId(int32_t slotId) override;
63     virtual bool SetDefaultSmsSlotId(int32_t slotId) override;
64     virtual bool SetDefaultCellularDataSlotId(int32_t slotId) override;
65     virtual bool SetPrimarySlotId(int32_t slotId) override;
66     virtual bool SetShowNumber(int32_t slotId, const std::u16string number) override;
67     virtual bool SetShowName(int32_t slotId, const std::u16string name) override;
68     virtual int32_t GetDefaultVoiceSlotId() override;
69     virtual int32_t GetDefaultSmsSlotId() override;
70     virtual int32_t GetDefaultCellularDataSlotId() override;
71     virtual int32_t GetPrimarySlotId() override;
72     virtual std::u16string GetShowNumber(int32_t slotId) override;
73     virtual std::u16string GetShowName(int32_t slotId) override;
74     virtual bool GetActiveSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList) override;
75     virtual bool GetOperatorConfigs(int slotId, OperatorConfig &poc) override;
76     virtual bool HasOperatorPrivileges(const int32_t slotId) override;
77     // STK
78     virtual bool SendEnvelopeCmd(int32_t slotId, const std::string &cmd) override;
79     virtual bool SendTerminalResponseCmd(int32_t slotId, const std::string &cmd) override;
80     // SimFile
81     virtual std::u16string GetSimOperatorNumeric(int32_t slotId) override;
82     virtual std::u16string GetISOCountryCodeForSim(int32_t slotId) override;
83     virtual std::u16string GetSimSpn(int32_t slotId) override;
84     virtual std::u16string GetSimIccId(int32_t slotId) override;
85     virtual std::u16string GetIMSI(int32_t slotId) override;
86     virtual std::u16string GetLocaleFromDefaultSim(int32_t slotId) override;
87     virtual std::u16string GetSimGid1(int32_t slotId) override;
88     virtual std::u16string GetSimTelephoneNumber(int32_t slotId) override;
89     virtual std::u16string GetSimTeleNumberIdentifier(const int32_t slotId) override;
90     virtual std::u16string GetVoiceMailIdentifier(int32_t slotId) override;
91     virtual std::u16string GetVoiceMailNumber(int32_t slotId) override;
92     virtual int ObtainSpnCondition(int32_t slotId, bool roaming, std::string operatorNum) override;
93     virtual bool SetVoiceMailInfo(
94         int32_t slotId, const std::u16string &mailName, const std::u16string &mailNumber) override;
95     // SimSms
96     virtual bool AddSmsToIcc(int32_t slotId, int status, std::string &pdu, std::string &smsc) override;
97     virtual bool UpdateSmsIcc(
98         int32_t slotId, int index, int status, std::string &pduData, std::string &smsc) override;
99     virtual bool DelSmsIcc(int32_t slotId, int index) override;
100     virtual std::vector<std::string> ObtainAllSmsOfIcc(int32_t slotId) override;
101     // IccDiallingNumbers
102     virtual std::vector<std::shared_ptr<DiallingNumbersInfo>> QueryIccDiallingNumbers(int slotId, int type) override;
103     virtual bool AddIccDiallingNumbers(
104         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) override;
105     virtual bool DelIccDiallingNumbers(
106         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) override;
107     virtual bool UpdateIccDiallingNumbers(
108         int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber) override;
109     // Event register
110     virtual void RegisterCoreNotify(int32_t slotId, const HANDLE &handler, int what) override;
111     virtual void UnRegisterCoreNotify(int32_t slotId, const HANDLE &observerCallBack, int what) override;
112 private:
113     bool IsValidSlotId(int32_t slotId);
114 private:
115     std::shared_ptr<Telephony::ITelRilManager> telRilManager_ = nullptr;
116     std::vector<std::shared_ptr<Telephony::SimStateManager>> simStateManager_;
117     std::vector<std::shared_ptr<Telephony::SimFileManager>> simFileManager_;
118     std::vector<std::shared_ptr<Telephony::SimSmsManager>> simSmsManager_;
119     std::vector<std::shared_ptr<Telephony::SimAccountManager>> simAccountManager_;
120     std::vector<std::shared_ptr<Telephony::IccDiallingNumbersManager>> iccDiallingNumbersManager_;
121     std::vector<std::shared_ptr<Telephony::StkManager>> stkManager_;
122     int32_t slotCount_ = SLOT_ID_ZERO;
123 };
124 } // namespace Telephony
125 } // namespace OHOS
126 #endif // OHOS_SIM_MANAGER_H
127