• 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_STATE_TYPE_H
17 #define OHOS_SIM_STATE_TYPE_H
18 
19 #include <map>
20 #include <parcel.h>
21 #include <string>
22 #include <vector>
23 
24 namespace OHOS {
25 namespace Telephony {
26 enum class CardType {
27     /** Icc card type: Unknow type Card. */
28     UNKNOWN_CARD = -1,
29 
30     /** Icc card type: Single sim card type. */
31     SINGLE_MODE_SIM_CARD = 10,
32 
33     /** Icc card type: Single usim card type. */
34     SINGLE_MODE_USIM_CARD = 20,
35 
36     /** Icc card type: Single ruim card type. */
37     SINGLE_MODE_RUIM_CARD = 30,
38 
39     /** Icc card type: Double card C+G. */
40     DUAL_MODE_CG_CARD = 40,
41 
42     /** Icc card type:  Roaming Card (Dual Mode). */
43     CT_NATIONAL_ROAMING_CARD = 41,
44 
45     /** Icc card type: China Unicom Dual Mode Card. */
46     CU_DUAL_MODE_CARD = 42,
47 
48     /** Icc card type: LTE Card (Dual Mode). */
49     DUAL_MODE_TELECOM_LTE_CARD = 43,
50 
51     /** Icc card type: Double card U+G. */
52     DUAL_MODE_UG_CARD = 50,
53 
54     /** Icc card type: Single isim card type. */
55     SINGLE_MODE_ISIM_CARD = 60,
56 };
57 
58 enum class SimState {
59     /**
60      * Indicates unknown SIM card state, that is, the accurate status cannot be obtained.
61      */
62     SIM_STATE_UNKNOWN,
63 
64     /**
65      * Indicates that the SIM card is in the <b>not present</b> state, that is, no SIM card is inserted
66      * into the card slot.
67      */
68     SIM_STATE_NOT_PRESENT,
69 
70     /**
71      * Indicates that the SIM card is in the <b>locked</b> state, that is, the SIM card is locked by the
72      * personal identification number (PIN)/PIN unblocking key (PUK) or network.
73      */
74     SIM_STATE_LOCKED,
75 
76     /**
77      * Indicates that the SIM card is in the <b>not ready</b> state, that is, the SIM card is in position
78      * but cannot work properly.
79      */
80     SIM_STATE_NOT_READY,
81 
82     /**
83      * Indicates that the SIM card is in the <b>ready</b> state, that is, the SIM card is in position and
84      * is working properly.
85      */
86     SIM_STATE_READY,
87 
88     /**
89      * Indicates that the SIM card is in the <b>loaded</b> state, that is, the SIM card is in position and
90      * is working properly.
91      */
92     SIM_STATE_LOADED
93 };
94 
95 enum class LockReason {
96     SIM_NONE,
97     SIM_PIN,
98     SIM_PUK,
99     SIM_PN_PIN, // Network Personalization (refer 3GPP TS 22.022 [33])
100     SIM_PN_PUK,
101     SIM_PU_PIN, // network sUbset Personalization (refer 3GPP TS 22.022 [33])
102     SIM_PU_PUK,
103     SIM_PP_PIN, // service supplier Personalization (refer 3GPP TS 22.022 [33])
104     SIM_PP_PUK,
105     SIM_PC_PIN, // Corporate Personalization (refer 3GPP TS 22.022 [33])
106     SIM_PC_PUK,
107     SIM_SIM_PIN, // SIM/USIM personalisation (refer 3GPP TS 22.022 [33])
108     SIM_SIM_PUK,
109 };
110 
111 enum class PersoLockType {
112     PN_PIN_LOCK, // Network Personalization (refer 3GPP TS 22.022 [33])
113     PN_PUK_LOCK,
114     PU_PIN_LOCK, // network sUbset Personalization (refer 3GPP TS 22.022 [33])
115     PU_PUK_LOCK,
116     PP_PIN_LOCK, // service supplier Personalization (refer 3GPP TS 22.022 [33])
117     PP_PUK_LOCK,
118     PC_PIN_LOCK, // Corporate Personalization (refer 3GPP TS 22.022 [33])
119     PC_PUK_LOCK,
120     SIM_PIN_LOCK, // SIM/USIM personalisation (refer 3GPP TS 22.022 [33])
121     SIM_PUK_LOCK,
122 };
123 
124 enum class LockType {
125     PIN_LOCK = 1,
126     FDN_LOCK = 2,
127 };
128 
129 enum class LockState {
130     /**Indicates that the lock state card is in the <b>off</b> state. */
131     LOCK_OFF = 0,
132 
133     /**Indicates that the lock state card is in the <b>open</b> state. */
134     LOCK_ON,
135 
136     /**Indicates that the lock state card is in the <b>error</b> state. */
137     LOCK_ERROR,
138 };
139 
140 struct LockInfo {
141     LockType lockType;
142     std::u16string password;
143     LockState lockState;
144 };
145 
146 struct PersoLockInfo {
147     PersoLockType lockType;
148     std::u16string password;
149 };
150 
151 enum UnlockResult {
152     UNLOCK_FAIL = -2, // unlock fail
153     UNLOCK_INCORRECT = -1, // password error
154     UNLOCK_OK = 0, // unlock successful
155 };
156 
157 struct LockStatusResponse {
158     int32_t result;
159     int32_t remain;
160 };
161 
162 struct SimAuthenticationResponse {
163     int32_t sw1;
164     int32_t sw2;
165     std::string response;
166 };
167 
168 enum SimAuthResult {
169     SIM_AUTH_FAIL = -1,
170     SIM_AUTH_SUCCESS = 0,
171 };
172 
173 struct IccAccountInfo : public Parcelable {
174     int32_t simId; // sim Id for card
175     int32_t slotIndex; // slot index for card
176     bool isEsim; // mark card is eSim or not
177     bool isActive; // active status for card
178     std::u16string iccId; // iccId for card
179     std::u16string showName; // show name for card
180     std::u16string showNumber; // show number for card
181     inline static const std::u16string DEFAULT_SHOW_NAME = u"Card";
182     inline static const std::u16string DEFAULT_SHOW_NUMBER = u"";
183     inline static const std::u16string DEFAULT_ICC_ID = u"";
184 
InitIccAccountInfo185     void Init(int32_t simCardId, int32_t slotId)
186     {
187         this->simId = simCardId;
188         this->slotIndex = slotId;
189         this->isEsim = false;
190         this->isActive = true;
191         this->iccId = DEFAULT_ICC_ID;
192         this->showName = DEFAULT_SHOW_NAME;
193         this->showNumber = DEFAULT_SHOW_NUMBER;
194     };
195 
SetIsEsimIccAccountInfo196     void SetIsEsim(bool isEsimType)
197     {
198         this->isEsim = isEsimType;
199     }
200 
SetIsActiveIccAccountInfo201     void SetIsActive(bool activeEnabled)
202     {
203         this->isActive = activeEnabled;
204     }
205 
SetIccIdIccAccountInfo206     void SetIccId(std::u16string id)
207     {
208         this->iccId = id;
209     }
210 
SetShowNameIccAccountInfo211     void SetShowName(std::u16string name)
212     {
213         this->showName = name;
214     }
215 
SetShowNumberIccAccountInfo216     void SetShowNumber(std::u16string number)
217     {
218         this->showNumber = number;
219     }
220 
MarshallingIccAccountInfo221     bool Marshalling(Parcel &parcel) const
222     {
223         if (!parcel.WriteInt32(simId)) {
224             return false;
225         }
226         if (!parcel.WriteInt32(slotIndex)) {
227             return false;
228         }
229         if (!parcel.WriteBool(isEsim)) {
230             return false;
231         }
232         if (!parcel.WriteBool(isActive)) {
233             return false;
234         }
235         if (!parcel.WriteString16(iccId)) {
236             return false;
237         }
238         if (!parcel.WriteString16(showName)) {
239             return false;
240         }
241         if (!parcel.WriteString16(showNumber)) {
242             return false;
243         }
244         return true;
245     };
246 
UnMarshallingIccAccountInfo247     std::shared_ptr<IccAccountInfo> UnMarshalling(Parcel &parcel)
248     {
249         std::shared_ptr<IccAccountInfo> param = std::make_shared<IccAccountInfo>();
250         if (param == nullptr || !param->ReadFromParcel(parcel)) {
251             param = nullptr;
252         }
253         return param;
254     };
255 
ReadFromParcelIccAccountInfo256     bool ReadFromParcel(Parcel &parcel)
257     {
258         parcel.ReadInt32(simId);
259         parcel.ReadInt32(slotIndex);
260         parcel.ReadBool(isEsim);
261         parcel.ReadBool(isActive);
262         parcel.ReadString16(iccId);
263         parcel.ReadString16(showName);
264         parcel.ReadString16(showNumber);
265         return true;
266     };
267 
268     bool operator==(const IccAccountInfo &p)
269     {
270         return (slotIndex == p.slotIndex && simId == p.simId);
271     }
272 };
273 } // namespace Telephony
274 } // namespace OHOS
275 #endif // OHOS_SIM_STATE_TYPE_H
276